
	function NewWindow(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
		win = window.open(mypage, myname, winprops)
		
		if (parseInt(navigator.appVersion) >=4) { win.window.focus(); }
	}
	
	
function invalidcheck() {
			var df_fname=document.Entry.first_name.value;
			var df_lname=document.Entry.last_name.value;
			var df_email=document.Entry.email.value;
			var df_address=document.Entry.address.value;
			var df_city=document.Entry.city.value;
			var df_state=document.Entry.state.options[document.Entry.state.selectedIndex].value;
			var df_country=document.Entry.country.options[document.Entry.country.selectedIndex].value;
			var df_zip=document.Entry.zip.value;
			var df_day_phone_area=document.Entry.day_phone_area.value;
			var df_day_phone_prefix=document.Entry.day_phone_prefix.value;
			var df_day_phone_suffix=document.Entry.day_phone_suffix.value;
			var df_sid=document.Entry.sid.value;

	if ((document.Entry.age.options[document.Entry.age.selectedIndex].value=="Under 23 years old" ||document.Entry.bachelors.options[document.Entry.bachelors.selectedIndex].value=="No"))
		{
			var url='dsp_pop_invalid.cfm?df_fname='+escape(df_fname)+'&df_lname='+escape(df_lname)+'&df_address='+escape(df_address)+'&df_city='+escape(df_city)+'&df_state='+escape(df_state)+'&df_country='+escape(df_country)+'&df_zip='+escape(df_zip)+'&df_city='+escape(df_city)+'&df_day_phone_area='+escape(df_day_phone_area)+'&df_day_phone_prefix='+escape(df_day_phone_prefix)+'&df_day_phone_suffix='+escape(df_day_phone_suffix)+'&df_email='+escape(df_email)+'&sid='+escape(df_sid);
			NewWindow(url,'name','600','500','yes');
            return false;
		} 
	if (document.Entry.state.options[document.Entry.state.selectedIndex].value=="AR")
		{
			var url='dsp_pop_invalid.cfm?error=no_arkansas&df_fname='+escape(df_fname)+'&df_lname='+escape(df_lname)+'&df_address='+escape(df_address)+'&df_city='+escape(df_city)+'&df_state='+escape(df_state)+'&df_country='+escape(df_country)+'&df_zip='+escape(df_zip)+'&df_city='+escape(df_city)+'&df_day_phone_area='+escape(df_day_phone_area)+'&df_day_phone_prefix='+escape(df_day_phone_prefix)+'&df_day_phone_suffix='+escape(df_day_phone_suffix)+'&df_email='+escape(df_email)+'&sid='+escape(df_sid);
			NewWindow(url,'name','600','500','yes');
            return false;
		} 		
    return true;
	}

//Controls tabbing for phone fields etc.
function TabOut(field,tabtofield,maxlength){
	if(field.value.length==maxlength){
		tabtofield.focus();
		tabtofield.select();
	}
	}
//Area code checker
function  AreaCheck(area){
 PhoneArea = new Array('000','111','123','222','333','444','555','666','777','999','911');
		for (var i=0; i<this.PhoneArea.length; i++)
		{
			if (area == this.PhoneArea[i]) return true;
		}
}

//Prefix Checker
function  PrefixCheck(prefix){
 PhonePrefix = new Array('000','911','555');
		for (var i=0; i<this.PhonePrefix.length; i++)
		{
			if (prefix == this.PhonePrefix[i]) return true;
		}
}

//Phone7 Checker
function  Phone7(phone){
 PhoneInvalid = new Array('1111111','2222222','3333333','4444444','5555555','6666666','7777777','8888888','9999999','0000000');
		for (var i=0; i<this.PhoneInvalid.length; i++)
		{
			if (phone == this.PhoneInvalid[i]) return true;
		}
}

//Phone10 Checker
function  Phone10(phone){
 PhoneInvalid = new Array('1111111111','2222222222','3333333333','4444444444','5555555555','6666666666','7777777777','8888888888','9999999999','0000000000','1234567890');
		for (var i=0; i<this.PhoneInvalid.length; i++)
		{
			if (phone == this.PhoneInvalid[i]) return true;
		}
}



function checknum(numfieldArray,numfieldDisplayArray,form){
	var i = 0; 
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;

for(i=0; i<numfieldArray.length; i++){
strString = eval("form." + numfieldArray[i] + ".value")

//  test strString consists of valid characters listed above
   for (a = 0; a < strString.length  && blnResult == true; a++)
      {
      strChar = strString.charAt(a);
      if (strValidChars.indexOf(strChar) == -1)
         {
		 alert("The field " + numfieldDisplayArray[i] + " must be a numeric.");
         blnResult = false;
         }
      }
   return blnResult;
   }

}
	
function checkForm()
{

	if (!invalidcheck()) {return false;}	

	//Program checker			
	if ((document.Entry.program.options[document.Entry.program.selectedIndex].value==""))
		{
		alert("\nYou must select a program.");
		document.Entry.program.focus();
		return false;
		} 
	
	// implies no night phone passed in from another form
	// and this form has no night phone field, therefore set night phone = day phone before the MP basic info check.
	if (document.Entry.night_phone_area.value == "") {
			document.Entry.night_phone_area.value = document.Entry.day_phone_area.value;
			document.Entry.night_phone_prefix.value = document.Entry.day_phone_prefix.value;
			document.Entry.night_phone_suffix.value = document.Entry.day_phone_suffix.value;
	}
	
	//check the basic info
	var state = CheckBasicInfo();
	if(state == false){
		return false;
	}
		
	//Bachelors degree check
	if ((document.Entry.bachelors.options[document.Entry.bachelors.selectedIndex].value=="No"))
		{
		invalidcheck();
		return false;
		} 
	
	//bachelors check
	if (document.Entry.bachelors.value == null || document.Entry.bachelors.value.length == 0) 
	{
		alert("\nPlease select whether or not you have a Bachelors degree.");
		document.Entry.bachelors.focus();
		return false;
	}
	
	//age
	if ((document.Entry.age.options[document.Entry.age.selectedIndex].value==""))
		{
		alert("\nYou must select your age.");
		document.Entry.age.focus();
		return false;
		} 
		
	if ((document.Entry.age.options[document.Entry.age.selectedIndex].value=="Under 23 years old"))
		{
		invalidcheck();
		return false;
		} 
		
	


	//zip code check
	if (document.Entry.zip.value == null || document.Entry.zip.value.length == 0) 
	{
		document.getElementById('basic_info').style.display = 'block';
		alert("\nPlease Fill in your ZIP Code.");
		document.Entry.zip.focus();
		return false;
	}
	
	var numfieldDisplayArray = new Array("Zip Code");
	var numfieldArray = new Array("zip");

 	if (!checknum(numfieldArray,numfieldDisplayArray,document.Entry)) {
		return false;
	}
	
	
	function e(s) {
	
		rex=true;
	
		if (window.RegExp) 
		{st="a";ex=new RegExp(st);
			if (st.match(ex)) {
			r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			b=(!r1.test(s)&&r2.test(s));
			}
			else 
			{rex=false;
			}
		} 
		else
		{	rex=false;
		}
		if(!rex) b=(s.indexOf("@")>0 && s.indexOf(".")>0 && s!="" && s!="enter e-mail");
		return (b);
	}
	
	// Pressnall Dupe Stopper
	if ( typeof ( formSubmission ) == "number" )
	{
		return false;
	}
	formSubmission = 1;
}

