function addBookmark(title,url)
{
	if( document.all )
	{
		window.external.AddFavorite( url, title);
	} 
	else if (window.sidebar) 
	{ 
		window.sidebar.addPanel(title, url,""); 
	} 
}
function swapImgRestore() { //v3.0
	var i;
	var x;
	var a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++){
		x.src=x.oSrc;
	}
}
function preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p){
			d.MM_p=new Array();
		}
		var i
		var j=d.MM_p.length
		var a=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 findObj(n, d) { //v4.0
	var p;
	var i;
	var 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=findObj(n,d.layers[i].document);
	}
	if(!x && document.getElementById){
	x=document.getElementById(n);
	}
	return x;
}
function swapImage() { //v3.0
	var i;
	var j=0;
	var x;
	var a=swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3){
		if ((x=findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
			if(!x.oSrc){
				//if (x.src.indexOf("/menu_")>-1){
				//x.src=x.src.replace(/.gif/,'Off.gif');//replace original static image with animated image that restores initial state
				//}
				x.oSrc=x.src;
			}
			x.src=a[i+2];
		}
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function signIn(isIntranetLogin){
	//alert("***dev note - make sure to add client services: access to:\n- Database and Automated Certificate Production\n- Absolute Hire link for background checks");
	var myMsg = "";
	var usernameObj = document.getElementById("username");
	var passwordObj = document.getElementById("password");
	var submitWhatObj = document.getElementById("submitWhat");
	if (usernameObj && passwordObj && submitWhatObj){
		if((usernameObj.value=="")){
			myMsg = "Please supply your username and password to sign in.\n\nThank you."
		}else{
			if(usernameObj.value==""){
				myMsg = "Please supply your username to sign in.\n\nThank you."
			}
			//if(passwordObj.value==""){
				//myMsg = "Please supply your password to sign in.\n\nThank you."
			//}
		}
		if (myMsg==""){
			if (isIntranetLogin){
			submitWhatObj.value="loginIntranet";
			}else{
			submitWhatObj.value="login";
			}
			document.myForm.submit();
		}else{
			alert(myMsg);
		}
	}
}
function onKeyPress() {
var keycode;
var submitWhatObj = document.getElementById("submitWhat");
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13){
	if (submitWhatObj){
		if (submitWhatObj.value=="login"){
		signIn();
		return false;
		}/*else if(submitWhatObj.value=="email"){
			if (sendEmail){
			//send email function is on the page itself
			//confirm it first, because user may be trying to put a break in the email
			//instead of submitting it
			var confirmIt = confirm("Send the email?")
			if(confirmIt){sendEmail();return false;}
			}
		}*/
	}
}
return true
}
document.onkeypress = onKeyPress;
function submitWhatForm(formType){
	//this function must be called by each form field's onfocus to set the flag for what type
	//of action is being taken if multiple forms are on being displayed
	//and the enter key was pressed to submit one of them
	var submitWhatObj = document.getElementById("submitWhat");
	if (submitWhatObj){
		submitWhatObj.value=formType;
	}
}
function emailValidator(myEmail) {
	// Note: The next expression must be all on one line...
	var goodEmail = myEmail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\.cc)|(\.to)|(\..{2,2}))$)\b/gi);
	if (goodEmail){
	   return true
	} else {
	   return false;
	}
}
var newWindow;
function myWindow(windowName, desiredWidth, desiredHeight, URL) {
var totalscreenwidth = screen.width;
var totalscreenheight = screen.height;
var calculatedwidth = parseInt((totalscreenwidth - desiredWidth) / 2);
var calculatedheight = parseInt((totalscreenheight - desiredHeight) / 2);
newWindow = window.open(URL, windowName,'scrollbars=yes,status=yes,resizable=yes,width=' + desiredWidth + ',height=' + desiredHeight + ',screenX=' + calculatedwidth + ',screenY=' + calculatedheight + ',left=' + calculatedwidth +',top=' + (calculatedheight - 20) + '');
try{
    newWindow.focus();
}catch(err){
    alert('Error. Could not open new browser window.\nPlease disable any popup-blockers.');
}   
}

////////////////////////////
//image ready functions
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
