/*
$(document).ready(function(){
	
	//slide out geotargeted schools
	var timerShow = setTimeout(showFoundSchools,2000);

	function showFoundSchools(){
		$('#foundSchools').show("slide",{direction: "right"},2000);	
	}
	
	//hide geotargetd schools
	var timerHide = setTimeout(hideFoundSchools,20000);
	
	function hideFoundSchools(){
		$('#foundSchools').hide("slide",{direction: "right"},2000);
	}
	
	function validateForm(formid){
	
		var datastring=$('form#'+formid).serialize();
		var x;
		valid=false;
		$.ajax({
			type: "POST",
			url: "/com/assets/templates/Filter.cfm",
			data: datastring,
			async:false,
			success: function(response){
				var resp = jQuery.trim(response);
				
				if (resp != "") {
					//show error message in sliding div
					$('#errorDisplayText').html(response);
					$("#errorDisplayText").slideDown("slow");
				}else{
					//submit form
					$('#errorDisplayText').hide();
					document.forms[0].submit();
				}
			}
		});
	}

	//add click handler to submit button	
	$("#imageSubmit").click(function(e){
		var formName = document.forms[0].name;
		validateForm(formName)
	});

	$("#submitButton").click(function(e){
		e.preventDefault();
		
		//Hijack the form action
		document.GetDetail.action = "School_Multi_Process.cfm";
		//document.GetDetail.submit();
			
		validateThisForm();
		
		//Validate the long form for 3 schools form
		function validateThisForm(){
			var errors="";
			
			if($('[name=FirstName]').val() == ''){
				var errors = errors + "Please enter your first name." + "\n";
			}
			if($('[name=LastName]').val() == ''){
				var errors = errors + "Please enter your last name." + "\n";
			}
			if($('[name=Address1]').val() == ''){
				var errors = errors + "Please enter your address." + "\n";
			}
			if($('[name=Zip]').val() == ''){
				var errors = errors + "Please enter your zip code." + "\n";
			}
			if($('[name=City]').val() == ''){
				var errors = errors + "Please enter your city." + "\n";
			}
			if($('input[name=State]').val() == ''){
				var errors = errors + "Please enter your state." + "\n";
			}
			if($('[name=EveArea]').val() == ''){
				var errors = errors + "Please enter your area code." + "\n";
			}
			if($('[name=EvePhone]').val() == ''){
				var errors = errors + "Please enter your phone number." + "\n";
			}
			if($('input[name=EmailAddress]').val() == ''){
				var errors = errors + "Please enter your email address." + "\n";
			}
			if($('[name=level_of_education_school]').val() == 0){
				var errors = errors + "Please enter your level of education." + "\n";
			}
			if($('[name=time_zone]').val() == 0){
				var errors = errors + "Please enter your time zone." + "\n";
			}
			if($('[name=military]').val() == 0){
				var errors = errors + "Please enter your miliatry affiliation." + "\n";
			}
			if($('[name=HSGradYear]').val() == 0){
				var errors = errors + "Please enter your high school graduation year." + "\n";
			}
			if($('[name=us_citizen]:checked').val() == null){
				var errors = errors + "Please enter your US citizenship." + "\n";
			}
			if($('[name=7767_program]').val() == "0"){
				var errors = errors + "Please choose a program for University of Phoenix." + "\n";
			}
			if($('[name=9379_program]').val() == "0"){
				var errors = errors + "Please choose a program for DeVry University." + "\n";
			}
			if($('[name=5684_program]').val() == "0"){
				var errors = errors + "Please choose a program for Colorado Technical University." + "\n";
			}
			if (! $('[name=acknowledge]').attr('checked')){
				var errors = errors + "Please acknowledge that you will be contacted." + "\n";
			}
				
			if (errors != ""){
				alert(errors);
				return false;
			}else{
				document.forms[0].submit();
			}
		
		}
		
	})
	
	// tab content on edu index page.
	$('.tab').click(function(e) {
		
		e.stopPropagation();
		//$("#thecontent").fadeOut("fast");
		
                $("li.tab").removeClass("on");
	        $(this).addClass("on");
		
                var page = $(this).attr("rel");	
		$.ajax({
			method: "get",url: page+".txt",
			success: function(html){ $("#boxed").html(html); }
		}); //close $.ajax(
            	e.stopPropagation();
					e.preventDefault();
					return false;
	}); //close click(
	
	//footer links open in new window
	$('#foot a[href^=""]').click(function(){
		window.open( $(this).attr("href"), "newWindow");
	return false;
	});
	
	
	
	
});	
*/
	var req;

	function loadXMLDoc(url) 
	{
	    // branch for native XMLHttpRequest object
	    if (window.XMLHttpRequest) {
	        req = new XMLHttpRequest();
	        req.open("GET", url, true);
	        req.onreadystatechange = processReqChange;
	        req.send(null);
	    // branch for IE/Windows ActiveX version
	    } else if (window.ActiveXObject) {
	        req = new ActiveXObject("Microsoft.XMLHTTP");
	        if (req) {
	            req.open("GET", url, true);
	            req.onreadystatechange = processReqChange;
	            req.send();
	        }
	    }
	}

	function processReqChange() 
	{ 
	    // only if req shows "complete"
	    if (req.readyState == 4)
		  {
	        // only if "OK"
	        if (req.status == 200) 
			  {
				document.getElementById('VerifyZip').style.display = 'none';
		      	response  = req.responseXML.documentElement;
				resultfound = response.getElementsByTagName('nofound')[0].firstChild.data;
			    result1 = 'Invalid';
				result2 = 'Invalid';
				for (i = 0; i < resultfound; i++)
				   {
				    result1 = response.getElementsByTagName('city')[i].firstChild.data;
					result2 = response.getElementsByTagName('state')[i].firstChild.data;
					}
				DisplayResult(result1,result2);
	          } 
			else 
			  {
	            alert("There was a problem retrieving the XML data:\n" + req.statusText);
	          }
	      }
	}

	var ns=(document.layers);
	var ie=(document.all);
	var w3=(document.getElementById && !ie);
	var calunit=ns? "" : "px"

	function checkZip(input)
	{
		input = trimVar(input);
		if (trimVar(input) == '') return;
		if (!ValidZip(input))
			DisplayResult('Invalid', 'Invalid')
		else
		  {
			document.getElementById('VerifyZip').style.display = 'inline';
			framename = 'ItemBody';
			scrname = Zip_scrname+'?FrameCall=Yes&ZipCode='+input;
			document.getElementById(framename).src           = scrname;
		  }
	}

	function DisplayResult(data1, data2, data3)
	{
		data = document.GetDetail;
		if (data1 == 'Invalid' || data2 == 'Invalid')
		  {
			data.City.value = '';
			data.State.value = '';
			data.EveArea.value = '';
			alert('Invalid Zip Code: '+data.Zip.value);
			data.Zip.value = '';
			data.Zip.focus();
		  }
		else
		  {
			data.City.value = data1;
			data.State.value = data2;
			data.EveArea.value = data3;
		  }
		document.getElementById('VerifyZip').style.display = 'none';
	}
	
	function trimVar(txt)
	{
		// trim leading spaces
		while(''+txt.charAt(0)==' ')
			txt=txt.substring(1,txt.length);		
			
		// trim trailing spaces
		while(''+txt.charAt(txt.length-1)==' ')
			txt=txt.substring(0,txt.length-1);
				
		return 	txt;
	}

	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

	function ValidateEMail(emailID){
	
		if ((emailID.value==null)||(emailID.value=="")){
	//		alert("Please Enter your Email ID")
	//		emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
		return true
	 }

	function CheckPhone(nn){
		data = document.GetDetail;
		if (nn == 1)
		  {
			if (trimVar(data.EveArea.value) == '' && trimVar(data.EvePhone.value) == '') return;
			tmpphone = trimVar(data.EveArea.value) + ' ' + trimVar(data.EvePhone.value);
			tmpno1 = trimVar(data.EveArea.value);
			tmpno2 = trimVar(data.EvePhone.value);
			if (tmpno1 == '000' || tmpno2 == '0000000' || tmpno2 == '000-0000' || tmpno2 == '000 0000' || !ValidPhoneNumber(tmpphone))
			  {
				alert('Invalid Contact Number!');
				data.EveArea.focus();
				return false;
			  }
		  }
		if (nn == 2)
		  {
			if (trimVar(data.DayArea.value) == '' && trimVar(data.DayPhone.value) == '') return;
			tmpphone = trimVar(data.DayArea.value) + ' ' + trimVar(data.DayPhone.value);
			tmpno1 = trimVar(data.DayArea.value);
			tmpno2 = trimVar(data.DayPhone.value);
			if (tmpno1 == '000' || tmpno2 == '0000000' || tmpno2 == '000-0000' || tmpno2 == '000 0000' || !ValidPhoneNumber(tmpphone))
			  {
				alert('Invalid Alternate Number!');
				data.DayArea.focus();
				return false;
			  }
		  }
		return true;
	}

	function ValidZip(Zip){
		//Your zip code must contain 5 or 9 digits.  9 digit zip codes should contain no spaces and a hyphen before the last 4 digits.
		var stringValue = new String(Zip);
		var stringLength = stringValue.length;
		if ((stringLength!=5)&&(stringLength!=9)&&(stringLength!=10))
			return false;
		if(stringLength==5)
		{
			for (var i = 0; i < stringLength; i++)
			{
				value = stringValue.charAt(i)
				if (!((value >= 0) && (value <=9)))
					return false;
			}
		}
		if(stringLength==9)
		{
			for (var i = 0; i < stringLength; i++)
			{
				value = stringValue.charAt(i)
				if (!((value >= 0) && (value <=9)))
					return false;
			}
		}
		if(stringLength==10)
		{
			var zip=stringValue.substring(0,5)
			var symbol=stringValue.substring(5,6)
			var plus4=stringValue.substring(6,10)
			if(symbol!="-")
				return false;
			for (var i = 0; i < zip.length; i++)
			{
				value = zip.charAt(i)
				if (!((value >= 0) && (value <=9)))
					return false;
			}
			for (var i = 0; i < plus4.length; i++)
			{
				value = plus4.charAt(i)
				if (!((value >= 0) && (value <=9)))
					return false;
			}
		}
		return true;
	}

	function ValidPhoneNumber(PhoneNumber)
	{
		var PNum = new String(PhoneNumber);
		
		//	555-555-5555
		//	(555)555-5555
		//	(555) 555-5555
		//	555-5555
	//	var regex = /^[0-9]{3,3}\ [0-9]{7,7}$|^[0-9]{3,3}\-[0-9]{3,3}\-[0-9]{4,4}$|^\([0-9]{3,3}\) [0-9]{3,3}\-[0-9]{4,4}$|^\([0-9]{3,3}\)[0-9]{3,3}\-[0-9]{4,4}$|^[0-9]{3,3}\-[0-9]{4,4}$/;
		//	555 5555555
		//	555 555-5555
		//	555 555 5555
		var regex = /^[0-9]{3,3}\ [0-9]{7,7}$|^[0-9]{3,3}\ [0-9]{3,3}\-[0-9]{4,4}$|^[0-9]{3,3}\ [0-9]{3,3}\ [0-9]{4,4}$/;
		return regex.test(PNum);
	}

	function MartinPopup( strURL, intWidth, intHeight, blnNewWindow ) { 
		var openPopup = window.open( strURL,'popup','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + intWidth + ',height=' + intHeight );
			openPopup.focus();	
	}

	//OpenItem is for rollovers at bottom of page on index.cfm
	function OpenItem(RowNo)
	{
		for (i = 1; i <= 3; i++)
		  {
			document.getElementById('row'+i).style.color='FFFFFF';
			document.getElementById('rowtext'+i).style.display='none';
		  }
		document.getElementById('row'+RowNo).style.color=selectedColor;
		selectedColor = document.getElementById('row'+RowNo).style.color;
		document.getElementById('rowtext'+RowNo).style.display='inline';
		
	}
	
	function OverMe(RowNo,c1,c2)
	{
		if (document.getElementById(RowNo).style.backgroundColor != selectedColor)
			document.getElementById(RowNo).style.backgroundColor=c2;
	}
	
	function OverMeOut(RowNo,c1,c2)
	{
		if (document.getElementById(RowNo).style.backgroundColor != selectedColor)
			document.getElementById(RowNo).style.backgroundColor=c2;
	}

	selectedColor = '#FF0000'; 

	function ShowThankYouPage()
	{
		w = 350;
		if (ie){
			documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
			documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;}	
		else if (ns){
			documentWidth=window.innerWidth/2+window.pageXOffset-20;
			documentHeight=window.innerHeight/2+window.pageYOffset-20;} 
		else if (w3){
			documentWidth=self.innerWidth/2+window.pageXOffset-20;
			documentHeight=self.innerHeight/2+window.pageYOffset-20;} 
	
			document.getElementById('ThankYouPage').style.left    = documentWidth-w+calunit;
			document.getElementById('ThankYouPage').style.top     = '150'+calunit;
	
			document.getElementById('BlurMe').style.display = 'inline';
			document.getElementById('ThankYouPage').style.display = 'inline';
			
	}

	function truebody(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	



//OpenItem is for rollovers at bottom of page on index.cfm
	function OpenItem(RowNo)
	{
		for (i = 1; i <= 3; i++)
		  {
			document.getElementById('row'+i).style.color='FFFFFF';
			document.getElementById('rowtext'+i).style.display='none';
		  }
		document.getElementById('row'+RowNo).style.color=selectedColor;
		selectedColor = document.getElementById('row'+RowNo).style.color;
		document.getElementById('rowtext'+RowNo).style.display='inline';
		
	}
	
	function OverMe(RowNo,c1,c2)
	{
		if (document.getElementById(RowNo).style.backgroundColor != selectedColor)
			document.getElementById(RowNo).style.backgroundColor=c2;
	}
	
	function OverMeOut(RowNo,c1,c2)
	{
		if (document.getElementById(RowNo).style.backgroundColor != selectedColor)
			document.getElementById(RowNo).style.backgroundColor=c2;
	}
	
