function formFocus(){
	var bFound = false;
	// for each form
	for (f=0; f < document.forms.length; f++){
	// for each element in each form
	for(i=0; i < document.forms[f].length; i++){
	  // if it's not a hidden element
	  if (document.forms[f][i].type != "hidden"){
		// and it's not disabled
		if (document.forms[f][i].disabled != true){
			// set the focus to it
			document.forms[f][i].focus();
			var bFound = true;
		}
	  }
	  // if found in this element, stop looking
	  if (bFound == true)
		break;
	}
	// if found in this form, stop looking
	if (bFound == true)
	  break;
	}
}

function printPopup(lPage,ldb,lId){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var lId;
var ldb;

switch(lPage){
	case 'print':
		strPage = ("/echoPrint.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "650"
		break
	case 'pdf':
		strPage = ("/pdf.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "650"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage + "db=" + ldb + "&id=" + lId,"Intranet","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}


function popup(lPage,lId){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var lId;

switch(lPage){
	case 'scheduleUpload':
		strPage = ("/ASPUploads/scheduleUpload.asp?")	
		strResize = "no"
		strScroll = "no"
		strHeight = "400"
		strWidth = "600"
		break
	case 'left':
		strPage = ("/admin/align.asp?a=left&")	
		strResize = "no"
		strScroll = "no"
		strHeight = "100"
		strWidth = "100"
		break
	case 'right':
		strPage = ("/admin/align.asp?a=right&")	
		strResize = "no"
		strScroll = "no"
		strHeight = "100"
		strWidth = "100"
		break
	case 'imageCode':
		strPage = ("/admin/imageCode.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'password':
		strPage = ("/password.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "160"
		strWidth = "500"
		break
	case 'email':
		strPage = ("/email.asp?em=yes&")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "400"
		strWidth = "550"
		break
	case 'email1':
		strPage = ("/email.asp?em=y&")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "400"
		strWidth = "550"
		break
	case 'rosters':
		strPage = ("/admin/managerosters.asp?")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "400"
		strWidth = "750"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage + "id=" + lId,"Intranet","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}

function calPopup(lPage,dstart,dstop){
var iMyWidth;
var iMyHeight;
var lPage;
var dstart;
var dstop;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;

switch(lPage){
	case 'tdates':
		strPage = ("/admin/start.asp?t=yes&s=" + dstart + "&f=" + dstop)		
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "400"
		break
	case 'start':
		strPage = ("/admin/start.asp?s=" + dstart + "&f=" + dstop)		
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "400"
		break
	case 'stop':
		strPage = ("/admin/start.asp?st=" + dstart + "&f=" + dstop)		
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "400"
		break
	case 'image':
		strPage = ("/admin/imageInsert.asp?st=" + dstart + "&f=" + dstop)		
		strResize = "no"
		strScroll = "yes"
		strHeight = "300"
		strWidth = "500"
		break
	case 'newimage':
		strPage = ("/ASPUploads/Upload-Progress.asp?close=yes")		
		strResize = "no"
		strScroll = "no"
		strHeight = "225"
		strWidth = "500"
		break
	case 'hotelimage':
		strPage = ("/ASPUploads/Upload-Progress.asp?logo=yes&close=yes")		
		strResize = "no"
		strScroll = "no"
		strHeight = "225"
		strWidth = "500"
		break
}

//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - ((strWidth/2) + 10)//half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - ((strHeight/2) + 50)//half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open(strPage,"NewbergReport","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}

function validatehpnews() {
	  var valid = true, output = '';
	  var valid;
	  if (window.document.frmNews.title.value.length == 0) {
		  valid = false;
		  output += 'Please enter an article title\n';
	  }
	  if (window.document.frmNews.text.value.length == 0) {
		  valid = false;
		  output += 'Please enter some text\n';
	  }
	  if (window.document.frmNews.start.value.length == 0) {
		  valid = false;
		  output += 'Please enter a start date\n';
	  }
	  if (window.document.frmNews.stop.value.length == 0) {
		  valid = false;
		  output += 'Please enter a stop date\n';
	  }
		 if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }

function validateregistration() {
	  var valid = true, output = '';
	  var valid;
	  if (window.document.frmReg.fn.value.length == 0) {
		  valid = false;
		  output += 'Please enter your first name\n';
	  }
	  if (window.document.frmReg.ln.value.length == 0) {
		  valid = false;
		  output += 'Please enter your last name\n';	  
	  }
	if (window.document.frmReg.em.value.length == 0) {
        valid = false;
        output += 'Please enter your E-mail address\n';
	}else{
		//EMail validation
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
	
		if(((window.document.frmReg.em.value.search(exclude) != -1)||(window.document.frmReg.em.value.search(check)) == -1)||(window.document.frmReg.em.value.search(checkend) == -1)){
			valid = false;
        	output += 'That does not appear to be a valid E-mail address! Please enter your E-mail address again\n';
		}
		}
		if ((window.document.frmReg.pw.value.length < 6) || (window.document.frmReg.pw.value.length > 24)) {
		  	valid = false;
       		output += 'Your password must be between 6 and 24 characters in length.\n';
    		} 
	  if (window.document.frmReg.pw.value.length == 0) {
        valid = false;
        output += 'Please enter a password\n';
	}
	if (window.document.frmReg.pw.value != window.document.frmReg.pw2.value) {
        valid = false;
        output += 'Your passwords do not match\n';
	}
		 if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }
