var agt=navigator.userAgent.toLowerCase();
var nonPrintingObjectsArray = new Array(1) ;
function printWindow(hideList) {// first optional arg is a list of objects to hide before printing
	printBtn="";
	backBtn="";
	closeBtn="";
	if (window.print) {
		if (navigator.appName=='Microsoft Internet Explorer') {
			if (window.document.BackPrintForm) {
				if (window.document.BackPrintForm.printBtn)
					printBtn=window.document.BackPrintForm.printBtn.visibility = "hidden"; ;
				if (window.document.BackPrintForm.backBtn)
					backBtn=window.document.BackPrintForm.backBtn.visibility = "hidden"; ;
				if (window.document.BackPrintForm.closeBtn)
					closeBtn=window.document.BackPrintForm.closeBtn.visibility = "hidden"; ;
			}
		}
		window.print();
		if (navigator.appName=='Microsoft Internet Explorer') {
			if (window.document.BackPrintForm) {
				if (window.document.BackPrintForm.printBtn)
					printBtn=window.document.BackPrintForm.printBtn.visibility = "visible"; ;
				if (window.document.BackPrintForm.backBtn)
					backBtn=window.document.BackPrintForm.backBtn.visibility = "visible"; ;
				if (window.document.BackPrintForm.closeBtn)
					closeBtn=window.document.BackPrintForm.closeBtn.visibility = "visible"; ;
			}
		}
	}
		else if (agt.indexOf("mac") != -1) {
			alert("Press 'Cmd+p' on your keyboard to print.");
		}
		else {
			alert("Press 'Ctrl+p' on your keyboard to print.");
		}
	return false;
}

function validEmail(email) {
	invalidChars = " /:,;"
	if ((email=="") || (email==null)) {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length) {
		return false;
	}
	return true;
}

function validPhone(p)	{ // Supports area codes, leading ones, dashes and parentheses - anything after the phone is considered an extension
	var newp="" ;
	phoneRE=/(1?)[\s\.-]*\(?(\d{3})\)?[-\.\s]*(\d{3})[\s\.-]?(\d{4})\s*(.*)|(\d{3})[\s\.-]?(\d{4})\s*(.*)/i ;
	parsedPhone = phoneRE.exec(p) ;
	if (!parsedPhone) {
		return false ;
	} else {
		return true ;
	}
}


function openWin(theURL, theWidth, theHeight, menubar) {
	if(menubar) mb='yes' ; else mb='no' ;
	OpenWindow=window.open(theURL,'OpenWindow','toolbar=no,location=no,status=no,menubar='+mb+',scrollbars=yes,resizable=yes,width='+theWidth+',height='+theHeight+',top=100,left=100,screenX=100,screenY=100');
	OpenWindow.focus();
}

function exitWin(theURL) {// Close this window. Send browser to theURL in the opener, if avail. otherwise, in a new window.
   if (!window.opener || window.opener.closed) {
      window.open(theURL);
	  top.close();
   } else {        
      top.opener.top.location.href = theURL;
	  top.opener.focus();
      top.close();
   }
}

function rewriteSelectControl(controlObj,newValuesArray,newLabelsArray) {
	var selectedValueString="" ; // handles multiple select groups too
	var isSelected=false ;
	for (m=controlObj.options.length-1;m>0;m--) { // empty old array, saving current selection in case there is a match in the new array
		if (controlObj.options[m].selected) {
			selectedValueString+='"'+controlObj.options[m].value.toLowerCase()+'"' ;
		}
		controlObj.options[m]=null ;
	}
	for (m=0; m<newValuesArray.length; m++) {
		isSelected=(selectedValueString.indexOf('"'+newValuesArray[m].toLowerCase()+'"') != -1) ;
		controlObj.options[m]=new Option(newLabelsArray[m],newValuesArray[m],false,isSelected) ;
	}
	if (controlObj.options.selectedIndex == -1) {// select first if none selected
			controlObj.options.selectedIndex = 0 ;
	}
}	

function ajaxLoadXMLDoc(url) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		xmlhttp.open("GET",url,false);
		xmlhttp.send(null);
	} else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("GET",url,false);
		// Do not send null for ActiveX
		xmlhttp.send();
	}
	return xmlhttp.responseText;
}

