var popupWin;
var casestudyWin;

function PopupWindow(loc, width, height, scrollbars) {
	var parms = "";
  
  var sb = "yes";
  if (scrollbars) sb = scrollbars;
  
	if (width && height) parms = "width=" + width + ",height=" + height + ",scrollbars=" + sb + ",resizable,status=no";
	popupWin = window.open(loc, "popupWindow", parms);
	if (!popupWin.opener) popupWin.opener = window;
	popupWin.focus();
}

function PopupCaseStudy(loc, width, height)
{
	var parms = "";
	if (width && height) parms = "width=" + width + ",height=" + height + ",scrollbars=yes,resizable,status=no";
	casestudyWin = window.open(loc, "casestudyWindow", parms);
	if (!casestudyWin.opener) casestudyWin.opener = window;
	casestudyWin.focus();
}

function CloseCaseStudyWindow()
{
   window.opener.focus();
   self.close();
}

function ValidateSearchParameters(form) {
	with (form) {
		var blankSpace = /\w/;
		if (!txtSearch.value || txtSearch.value.search(blankSpace) == -1) {
			alert("Please enter a search term.");
			txtSearch.focus();
			return false;
		}
	}
	return true;
}

function sessionCountDown()
{  
   sessionCountDownTimer -= 1;
   
   if( sessionCountDownTimer == sessionTimeoutWarning )
   {
      var href = window.location.href;
      window.location.href = "/sessiontoexpire.asp?" + href;
   }
   else if( sessionCountDownTimer == 1 )
   {
      window.location.href = "/sessionexpired.asp?";
   }
   else
   {
      setTimeout( "sessionCountDown()", 1000);
   }
}

function onLoadHandler()
{
   // Start session expiration timer if feature is enabled.
   if( sessionEnableTimeout )
   {
      sessionCountDown();
   }
}

function textCounter(field, maxlength) 
{
  if (field.value.length > maxlength)
  {
    field.value = field.value.substring(0, maxlength);
  }
}