// unhides extra fields
function display_extras()	{
		if (document.Entry.night_phone_suffix.value.length >= 4) {
				document.getElementById('extra_questions').style.display='block';
				//Effect.Appear('extra_questions');
				//Effect.SlideDown('extra_questions');
			} else {
				document.getElementById('extra_questions').style.display='none';
				//Effect.SlideUp('extra_questions');
			}
	}

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(); }
	}

//Controls tabbing for phone fields etc.
function TabOut(field,tabtofield,maxlength)
{
	if(field.value.length==maxlength)
	{
		tabtofield.focus();
		tabtofield.select();
	}
}

function invalidcheck() {
	var boolReturn = true;

	if (document.Entry.country.options[document.Entry.country.selectedIndex].value=="NON-US")
	{
		invalidPop('us_leads');
		return false;
	}
	
	if (document.Entry.level_of_education.options[document.Entry.level_of_education.selectedIndex].value=="High School")
	{
		invalidPop('need_associates');
		return false;
	}

	return boolReturn;
		
}
	
	
function invalidPop(error){
	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;
	
	var url='dsp_pop_invalid.cfm?error='+escape(error)+'&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');
}
	

function checkForm()
{

	//Program checker			
	if ((document.Entry.program.options[document.Entry.program.selectedIndex].value==""))
		{
		alert("\nYou must select a program.");
		document.Entry.program.focus();
		return false;
		} 
	
	//zip code check
	if (document.Entry.zip.value == null || document.Entry.zip.value.length == 0) 
		{
			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;
 		}
	
	//check the basic info
	var state = CheckBasicInfo();
	if(state == false){
		return false;
	}

	//level of education		
	if ((document.Entry.level_of_education.options[document.Entry.level_of_education.selectedIndex].value==""))
	{
		alert("\nYou must select your level of education.");
		document.Entry.level_of_education.focus();
		return false;
	} 	

	if ( invalidcheck() == false ) { return false; } 
	
	//consent
	if (document.Entry.consent.checked == false)
	{
		alert("\nYou must agree to have a representative from New England Culinary Institute contact you.");
		document.Entry.consent.focus();
		return false;
	}
	
function e(s) {
	r1 = new RegExp("^[A-Za-z0-9]([A-Za-z0-9_-]|(\.[A-Za-z0-9]))+@[A-Za-z0-9](([A-Za-z0-9]|(-[A-Za-z0-9]))+)\.([A-Za-z]{2,10})(\.([A-Za-z]{2,6}))?$") 
	if (!s.match(r1)) {
		return false;
	}
	return true;
}

setBool();

// Pressnall Dupe Stopper
if ( typeof ( formSubmission ) == "number" ){
      return false;
	}
formSubmission = 1;
}


