



function loadPageExtras()
{


}

function showViaLoadingPage(url,xWidth,xHeight)
{
	popupMainWindow1('loading.asp',xWidth,xHeight);
	setTimeout("mainWindow1.location.href='"+url+"';",550);

}

function showFormProcessing()
{	

	if (document.getElementById('formSubmitButtons'))
	{
		
		document.getElementById('formSubmitButtons').style.display = 'none';

		if (document.getElementById('formSubmitProcessing'))
		{
		document.getElementById('formSubmitProcessing').style.display = 'inline';
		}
	}
}


function getElementLeft(Elem) {

		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;

}


function getElementTop(Elem) {
		
		if(document.getElementById) {	
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}

		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;

		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;

  		}
		return yPos;

}


//======================================================
//	popup DHTML searchbox
//======================================================

function showPopUpSearchBox(Elem,xOffset,yOffset,whatBox)
{
	var whatBox = document.getElementById(whatBox).style
	
	var searchBoxWidth = whatBox.width;
	searchBoxWidth = searchBoxWidth.replace('px','')
	var x = getElementLeft(Elem)
	var y = getElementTop(Elem)
	x = x - Number(searchBoxWidth) + Number(xOffset);
	y = y + Number(yOffset)

	if((x!='') && (y!=''))
	{
		whatBox.left = x;
		whatBox.top = y;
	}


	if ((document.all.cSearch) && (cSearch.searchterm))
		cSearch.searchterm.value='';
	
	if(whatBox.visibility=='visible'){
		whatBox.visibility='hidden';
		whatBox.left = 0;
		whatBox.top = 0;
	}
	else {
		whatBox.visibility='visible';
	}
}

function checkKeyInputForPopUpSearchBox(Elem,xOffset,yOffset,whatBox)
{
	if ((event.keyCode == 13) && (document.all.cSearch))
	{
		cSearch.submit();
		showPopUpSearchBox(Elem,xOffset,yOffset,whatBox)
	}
}





function popupemailprompt(url) {
muppetswin = window.open(url,"muppets",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=152');
}

function popupComment(url) {
commentwin = window.open(url,"comment",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=300');
}

function popupFundedHead(url) {
FundedHeadwin = window.open(url,"FundedHead",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=300');
}

function popupPrint(url) {
printwin = window.open(url,"print",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=500');
}

function popupShowCase(url) {
showCasewin = window.open(url,"showCase",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=500');
}

function centerScreen(xWidth,xHeight)
{
	
	var uAgent = navigator.userAgent;
	if(uAgent.indexOf("Windows NT 5.1")!=-1)
	{
		xHeight = Number(xHeight) + Number(30);
	}

	var wHeight = Number(screen.height)-Number(xHeight);
	var wWidth = Number(screen.width)-Number(xWidth);
	window.moveTo(Number(wWidth)/2,Number(wHeight)/2);	
	window.resizeTo(xWidth,xHeight);
	window.moveTo(Number(wWidth)/2,Number(wHeight)/2);
	
}

function popupMainWindow(url,height,width) {
var wHeight = screen.height;
var wWidth = screen.width;
	var isHeight=Number(height);
	var isWidth=Number(width);
	var wTop = (wHeight - isHeight) / Number(2);
	var wLeft = (wWidth - isWidth) / Number(2);
	//  mainWindow  =   window.open(url,"mainWindow",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+isWidth+',height='+isHeight+',top='+wTop+',left='+wLeft);
	mainWindow  =   window.open(url,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+isWidth+',height='+isHeight+',top='+wTop+',left='+wLeft);
	mainWindow.focus();
}

function popupMainWindow1(url,height,width) {
	var wHeight = screen.height;
var wWidth = screen.width;
  var isHeight=Number(height);
  var isWidth=Number(width);
  var wTop = (wHeight - isHeight) / 2
  var wLeft = (wWidth - isWidth) / 2
  mainWindow1  =   window.open(url,"mainWindow1",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+isWidth+',height='+isHeight+',top='+wTop+',left='+wLeft);
  mainWindow1.focus();
}


function popupPrintWindow(url,height,width) {
	var wHeight = screen.height;
var wWidth = screen.width;
  var isHeight=Number(height);
  var isWidth=Number(width);
  var wTop = (wHeight - isHeight) / 2
  var wLeft = (wWidth - isWidth) / 2
  printWindow1  =   window.open(url,"printWindow1",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+isWidth+',height='+isHeight+',top='+wTop+',left='+wLeft);
  printWindow1.focus();
}

function popupExcelWindow(url,height,width) {
	var wHeight = screen.height;
var wWidth = screen.width;
  var isHeight=Number(height);
  var isWidth=Number(width);
  var wTop = (wHeight - isHeight) / 2
  var wLeft = (wWidth - isWidth) / 2
  excelWindow  =   window.open(url,"excelWindow",'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+isWidth+',height='+isHeight+',top='+wTop+',left='+wLeft);
  excelWindow.focus();
}



function isDigits(str) {
	var i
	for (i = 0; i < str.length; i++) {
		mychar = str.charAt(i)
		
		if ((i==0) && (mychar =="-"))
		 {}
		else if ((mychar < "0" || mychar > "9") && mychar !=".")
			return false;
		
	}
	return true;
}

function isDigitsNotNegative(str) {
	var i
	for (i = 0; i < str.length; i++) {
		mychar = str.charAt(i)
		
		if ((mychar < "0" || mychar > "9") && mychar !=".")
			return false;
		
	}
	return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
 
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function isDate(sDate) {
  var aiDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var iDay;
  var iMonth;
  var iYear;


  if (sDate.substring(1, 2) == '/') {
    iDay = parseInt(sDate.substring(0, 1), 10);
    if (sDate.substring(3, 4) == '/') {
      iMonth = parseInt(sDate.substring(2, 3), 10);
      iYear = parseInt(sDate.substring(4, 8), 10);
    }
    else {
      iMonth = parseInt(sDate.substring(2, 4), 10);
      iYear = parseInt(sDate.substring(5, 9), 10);
    }
  }
  else {
    iDay = parseInt(sDate.substring(0, 2), 10);
    if (sDate.substring(4, 5) == '/') {
      iMonth = parseInt(sDate.substring(3, 4), 10);
      iYear = parseInt(sDate.substring(5, 9), 10);
    }
    else {
      iMonth = parseInt(sDate.substring(3, 5), 10);
      iYear = parseInt(sDate.substring(6, 10), 10);
    }
  }
  
  if (iDay < 1 || iMonth < 1 || iYear < 0)
    return false;
    
  if (iMonth > 12)
    return false;
    
  iYear += iYear < 100 ? iYear > 10 ? 1900 : 2000 : false;
  aiDays[1] += (iYear % 4 ? false : iYear % 100 ? true : iYear % 400 ?
    iYear == 200 ? true : false : true);

  return (iDay <= aiDays[iMonth - 1]);
}

function checkemail(s)
{
    var str = s;
    var filter=/^([a-zA-Z0-9_\.\-\'])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
    if (filter.test(str))
        testresults=true
    else
    {
        alert("Please input a valid email address!")
        testresults=false
    }
    return (testresults)
}


     function checkPassword(txtField) 
     {

		var error = 0;
		var errorChar = 1;
		var errorNum = 1;
		var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWQYZ1234567890";
		var reNum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWQYZ"
		var reAlph = "1234567890"

		var password = txtField.value;

		// iterate through string and check against allowed character list
		for (x=0; x<password.length; x++)
		{
			c = password.charAt(x);
			if (validChars.indexOf(c) == -1)
			{
				error = 1;
				break;
			}
		}
		
		// check to make sure contains numbers and characters
		for (x=0; x<password.length; x++)
		{
			c = password.charAt(x);
			if (reNum.indexOf(c) != -1)
			{
				errorChar = 0;
				break;
			}
		}
		// check to make sure contains numbers and characters
		for (x=0; x<password.length; x++)
		{
			c = password.charAt(x);
			if (reAlph.indexOf(c) != -1)
			{
				errorNum = 0;
				break;
			}
		}

		// display appropriate message
		if ((error == 1) || (password.length < 6) || (errorChar == 1) || (errorNum == 1))
		{
			alert("The PASSWORD must be a minimum of 6 characters and contain a mixture of letters and numbers")
			txtField.focus();
			return false;
		}
		else
		{
			return true;
		}
	}

function leftTrim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function rightTrim(sString) 
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function trim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function closeAndFocusOpener()
{
	
	if ( window.opener && !window.opener.closed )
	{
		window.opener.focus();
	}
	window.close();
}
