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 popup(lPage){
var iMyWidth;
var iMyHeight;
var lPage;
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;
var sid;

switch(lPage){
	case 'photoUpload':
		strPage = ("/admin/getSession.asp")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "425"
		break
	case 'fpUpload':
		strPage = ("/admin/getSession.asp?page=fp")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "425"
		break
	case 'teUpload':
		strPage = ("/admin/getSession.asp?page=no")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "425"
		break
	case 'rtUpload':
		strPage = ("/admin/getSession.asp?page=rt")	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "425"
		break
	case 'content_images':
		strPage = ("/admin/content_images.asp?src=tiny")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "500"
		strWidth = "425"
		break
	case 'print':
		strPage = ("/print.asp")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "100"
		strWidth = "100"
		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,"ASLC","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}
function doPopup(lid){
	var theState = formName.State.value;
	var theURL = "http://new.newbergreport.com/playAudio.asp?id=";
	theURL += lid;
	window.open(theURL);
} 

function popup2(lPage,lId){
var iMyWidth;
var iMyHeight;
var lPage;
lId
var strPage;
var strResize;
var strScroll;
var strHeight;
var strWidth;

switch(lPage){
	case 'audio':
		strPage = ("/playAudio.asp?id=" + lId)	
		strResize = "no"
		strScroll = "no"
		strHeight = "200"
		strWidth = "425"
		break
	case 'password':
		strPage = ("/password.asp?em=" + lId)	
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "625"
		break
	case 'exclude':
		strPage = ("/admin/excludeCalendar.asp?m=" + lId)	
		strResize = "no"
		strScroll = "no"
		strHeight = "250"
		strWidth = "215"
		break
	case 'upload':
		strPage = ("/admin/Upload-Progress.asp?id=" + lId + "&a=affiliates")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "200"
		strWidth = "425"
		break
	case 'futures':
		strPage = ("/admin/Upload-Progress.asp?id=" + lId + "&a=futures")	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "200"
		strWidth = "425"
		break
	case 'showImage':
		strPage = ("/admin/showImage.asp?id=" + lId)	
		strResize = "yes"
		strScroll = "yes"
		strHeight = "600"
		strWidth = "900"
		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.com","status,height=" + strHeight + ",width=" + strWidth + ",resizable=" + strResize + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=" + strScroll + "")
}

function validateEmail() {
	  var valid = true, output = '';
	  var valid;
	if (window.document.frmEMail.to_address.value.length != 0) {
		//EMail validation
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,4}$/;
	
		if(((window.document.frmEMail.to_address.value.search(exclude) != -1)||(window.document.frmEMail.to_address.value.search(check)) == -1)||(window.document.frmEMail.to_address.value.search(checkend) == -1)){
			valid = false;
        	output += 'Please select a recipient\n';
		}
		}
		 if (!valid){
		  alert(output);
		  return false;
		  }  
	  
  }

function validateNavBar() {
	    var valid = true, output = '';
	  var valid;
	  if (window.document.imageForm.pn.value.length == 0) {
		  valid = false;
		 output += 'Please enter a Navbar name for this page\n';
	  }
	  if (window.document.imageForm.pr.value.length == 0) {
		  valid = false;
		 output += 'Please enter a redirect name for this page\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 == 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;
		  }  
	  
  }
  
