function sen_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=sen_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 sen_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 sen_FindObj(n, d) { //v3.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=sen_FindObj(n,d.layers[i].document); return x;
}

function sen_SwapImage() { //v3.0
  var i,j=0,x,a=sen_SwapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=sen_FindObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sen_DisplayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.sen_ReturnValue = true;
}

function sen_SubmitForm(formName){ //v3.0
	if (sen_ValidateGenericForm(formName)){
		document.forms[formName].submit();
	}
}

function sen_ValidateGenericForm(formName, allFieldsReq){ //v3.0
	for (j=0; j < document.forms[formName].elements.length; j++) 
	{
		if (document.forms[formName].elements[j].type=="text")
		{
			if(document.forms[formName].elements[j].name != "email")		//text fields
			{
				var textValue = document.forms[formName].elements[j].value;
				if(document.forms[formName].elements[j].id == "req"){
					if ((textValue.length<=0) || (textValue==null) || (textValue=="") || (textValue==" ")) {
						document.forms[formName].elements[j].value = "";
						document.forms[formName].elements[j].focus();
						alert("Please fill out all required fields.");
						return (false);
					}
				}
				if (textValue.length >= 255) {
						document.forms[formName].elements[j].focus();
						alert("Fields must not contain more than 255 characters.");
						return (false);
				}
			}
			else {															//email fields
				var strEmail = document.forms[formName].elements[j].value
				var emailMessage = "Please enter a valid email address.";
				
				if ((strEmail.length<=0) || (strEmail==null) || (strEmail=="") || (strEmail==" ")) {
					document.forms[formName].elements[j].value = "";
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}
				if (document.forms[formName].elements[j].value.length >= 255) {
					document.forms[formName].elements[j].focus();
					alert("Fields must not contain more than 255 characters.");
					return (false);
				}				
				
				var at="@"
				var dot="."
				var lat=strEmail.indexOf(at)
				var lstr=strEmail.length
				var ldot=strEmail.indexOf(dot)
				
				if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//@ does not exist

				if (strEmail.indexOf(dot)==-1 || strEmail.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//. does not exist

				if (strEmail.indexOf(at,(lat+1))!=-1){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//two consecutive @@s

				if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//postion before and after @ is .

				if (strEmail.indexOf(dot,(lat+2))==-1){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//dot occurs after @
				
				if (strEmail.indexOf(" ")!=-1){
					document.forms[formName].elements[j].focus();
					alert(emailMessage);
					return (false);
				}	//contains space
			}
		}
	}	
	return (true);
}

var win=null;
function sen_NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*(screen.height-h)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?((screen.height-h)-20)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=50;TopPosition=50}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}}

function sen_LaunchFullScreen(mypage,myname){
	win=window.open(mypage,myname,"scrollbars=no,fullscreen=yes");
if(win.focus){win.focus();}}
