	var xmlHttp
	
	function GetXmlHttpObject(handler)
	{ 
		var objXmlHttp=null
		
		if (navigator.userAgent.indexOf("Opera")>=0)
		{
			alert("This example doesn't work in Opera") 
			return 
		}
		if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			} 
			try
			{ 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler 
				return objXmlHttp
			} 
			catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
		} 
		if (navigator.userAgent.indexOf("Mozilla")>=0)
		{
			objXmlHttp=new XMLHttpRequest()
			objXmlHttp.onload=handler
			objXmlHttp.onerror=handler 
			return objXmlHttp
		}
	}  /*-- Function GetXmlHttpObject() Ends Here --*/	
	
	function school_display1(str)
	{    
	    var url="ajax_school_display.php?sid=" + Math.random() + "&c=" + str
		xmlHttp=GetXmlHttpObject(schoolChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}  /*-- Function show_city_state(str) Ends Here --*/
	
	function schoolChanged1() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("school_locations").innerHTML=xmlHttp.responseText 		
		} 
	}  /*-- Function city_stateChanged() Ends Here --*/	
	
	/* popup window start */
	   function addSchool()
	    {
	        var ht="400";
		    var wd="530";
		    var t=(screen.height-ht)/2;
		    var l=(screen.width-wd)/2;
		    var url="popup_school.php";
		    open(url,"result_customer","resizable=yes,scrollbars=yes,height="+ht+",width="+wd+",left="+l+",top="+t);
	    }
	/* popup window end */
	
	function popup_sel_country(str)
	{    
	     var str = document.getElementById('country').value;
	     var arr = str.split("_");
	     str = arr[0];
	     if(str == "1"){	              
		         document.getElementById('other_country').style.display="none";
			     document.getElementById('usa_zip').style.display="block";			     
			     document.getElementById('other_zip').style.display="none";
			     document.getElementById('canada_zip').style.display="none";
			     document.getElementById('usatxtstate').style.display="block";
		         document.getElementById('usatxtcity').style.display="block";
			     document.getElementById('txtstate').style.display="none";
			     document.getElementById('txtcity').style.display="none";
			     document.getElementById('othertxtcity').style.display="none";
			     document.getElementById('othertxtstate').style.display="none";
		  }  
		 else if(str == "26")
		 {
		 	     document.getElementById('other_country').style.display="none";
			     document.getElementById('canada_zip').style.display="block";
			     document.getElementById('usa_zip').style.display="none";
			     document.getElementById('other_zip').style.display="none";
			     document.getElementById('usatxtstate').style.display="block";
		         document.getElementById('usatxtcity').style.display="block";
			     document.getElementById('txtstate').style.display="none";
			     document.getElementById('txtcity').style.display="none";
			     document.getElementById('othertxtcity').style.display="none";
			     document.getElementById('othertxtstate').style.display="none";
		 }
		 else if(str == "Other")
		  {
		        document.getElementById('other_country').style.display="block";
		        document.getElementById('othertxtcity').innerHTML = "<input type='text' name='other_citys' size='33'>";
		        document.getElementById('othertxtcity').style.display="block";
			    document.getElementById('othertxtstate').innerHTML = "<input type='text' name='other_state' size='33'>";
			    document.getElementById('othertxtstate').style.display="block";
			    document.getElementById('other_zip').style.display="block";
			    document.getElementById('canada_zip').style.display="none";
		        document.getElementById('usa_zip').style.display="none";		        	        
		        document.getElementById('usatxtstate').style.display="none";
		        document.getElementById('usatxtcity').style.display="none";
		        document.getElementById('txtstate').style.display="none";
		        document.getElementById('txtcity').style.display="none";		        
		        //document.getElementById('state_other').style.display="none";alert("spp");
		        document.getElementById('city_other_selected').style.display="none";			   
		  }
		 else
		  {      
		        document.getElementById('other_country').style.display="none";
		        document.getElementById('usa_zip').style.display="none";
		        document.getElementById('canada_zip').style.display="none";
		        document.getElementById('other_zip').style.display="block";
		        document.getElementById('usatxtstate').style.display="none";
		        document.getElementById('usatxtcity').style.display="none";  
		        document.getElementById('txtstate').style.display="block";
		        document.getElementById('txtcity').style.display="block"; 
		        document.getElementById('othertxtcity').style.display="none";  
			    document.getElementById('othertxtstate').style.display="none";	 
		        document.add_school_form.usa_zipcode.value = "";  
			    otherUsa_sel_country(str); 
		  } 
		  
	  }
	 //other state city selected when country is selected
	 
	  function otherUsa_sel_country(str)
		{ 
		    var url="ajax_select_userstate.php?sid=" + Math.random() + "&c="+ str
			xmlHttp=GetXmlHttpObject(popup_stat_stateChanged)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		}  
		
	  function popup_stat_stateChanged() 
		{ 
		   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
				document.getElementById("txtstate_cityhidden").innerHTML=xmlHttp.responseText 		
			 } 
		     else {
			     document.getElementById("txtstate_cityhidden").innerHTML = '<table><tr><td align="center"><img src="indicator.gif" width="16" height="16"></td><td>Loading...</td></tr></table>';
			} 		    
		}  
	 
	 //end of state city selected
	 function other_city_select(str2)
	 {  
	 	if(str2 == "Other")
	 	{   
	 		document.getElementById('city_other_selected').style.display = "block";
	 	}
	 	else
	 	{
	 		document.getElementById('city_other_selected').style.display = "none";
	 	}
	 }
	 //other city selected when state is select
	   function sel_city(str1)
		{ 
		   if(str1 == 'Other') {  
		   		document.getElementById('usatxtcity').style.display = "none";  
		   		document.getElementById('txtcity').style.display = "none"; 
		   		document.getElementById('city_other_selected').style.display="none";
		   		document.getElementById('txtstate').style.display = "block"; 
		   		document.getElementById('state_other').style.display = "block";  
		   		document.getElementById('othertxtcity').style.display = "block";  
		   		return false;
		   }
		   else {
		   		document.getElementById('txtcity').style.display = "block";
		   		document.getElementById('state_other').style.display = "none";
		   		document.getElementById('othertxtcity').style.display = "none";
		   }
		   if(document.getElementById('state').value == "Other"){
		        document.getElementById('other_state').style.display = "block";
		       // document.getElementById('city').disabled = false;
		      }
		   
		    var url="ajax_select_usercity.php?sid=" + Math.random() + "&cval=" + str1
			xmlHttp=GetXmlHttpObject(city_stateChanged)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		} 
		
		function city_stateChanged() 
		{ 
		   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
				document.getElementById("txtcity").innerHTML=xmlHttp.responseText 		
			 }
	       else
			 {
			     document.getElementById("txtcity").innerHTML =  '<table><tr><td align="center"><img src="indicator.gif" width="16" height="16"></td><td>Loading...</td></tr></table>';
			 } 
		}  
	 //end of the other city selected
	 
	 //usa state city selected when zipcode is entered
	 
	  function popup_show_city_state(str,val)
	  {
		var country = document.getElementById('country').value;
	    var arr = country.split("_");
	    country = arr[0];
	    if(country == "1"){	     
	         document.getElementById('other_country').style.display="none";
		     document.getElementById('usa_zip').style.display="block";
		     document.getElementById('canada_zip').style.display="none";
		     document.getElementById('other_zip').style.display="none";
		     var url="ajax_state_city.php?c="+str+"&country="+country+"&act=usa";		    
		} 
	    else if(country == "26") {
	    	 document.getElementById('other_country').style.display="none";
		     document.getElementById('canada_zip').style.display="block";
		     document.getElementById('usa_zip').style.display="none";
		     document.getElementById('other_zip').style.display="none";
	    	 var url="ajax_state_city.php?c="+str+"&country="+country+"&act=canada";
	    }
	    if(str!='') {			    	  
		    xmlHttp=GetXmlHttpObject(country_city_state)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		}
	} 
	
	function country_city_state() 
	{ 
	   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
		   document.getElementById("txtstate_cityhidden").innerHTML=xmlHttp.responseText 		
		 }
	    else
	     {
	        document.getElementById("txtstate_cityhidden").innerHTML = '<table><tr><td align="center"><img src="indicator.gif" width="16" height="16"></td><td>Loading...</td></tr></table>';
	     } 
	}
	 //zip code process end 
	 
	  function lschool(n,m,state_name,city_name,zip_code)
	  {   
 		    var schoo_arr = document.add_school_form.school_opt_val.value;
 		   
 		    var x = '';
 		    x += '<select name="school" id="school" onChange="school_display(this.value);">';
			x += '<option value="">Select School</option>';
 		   
 		      school_name_arr = schoo_arr.split("#"); 
		      
		      for(j=0;j<school_name_arr.length-1;j++) {
		         if(school_name_arr[j] != ''){
		         	school_val_arr = school_name_arr[j].split("@"); 
		         	sid   = school_val_arr[0];
		         	sname = school_val_arr[1];
		         	if(sid != '' && sname !== '')		         	
		         	   x += '<option value="'+sid+'">'+sname+'</option>';
		         } 
		   }
		   
		   x += '<option value="'+m+'" selected>'+n+'</option>';
		   
		   x += '</select>'; 
 		   
 		   var ODOC = window.opener.document;
           var OFORM = ODOC.user_add_frm;
          
		   //ODOC.getElementById("schooldis").innerHTML = x;  
		   	              
           window.close();
           return;  
	  }
	 
	 function add_school_validate()
	   {
		     if(document.add_school_form.country.value == "")
		     {
		     	 alert("Country Field is Empty/Invalid");
				 document.add_school_form.country.focus();
				 return false; 
		     }
		     var country = document.add_school_form.country.value;
		     var arr = country.split("_");
		     country = arr[0];
		     if(country == "Other")
			   {
					if(IsBlank('add_school_form','other_country')) 
					{
					  alert("Other Country Field is empty/Invalid");
					  document.add_school_form.other_country.focus();
					  return false;
				    }
				    var country = document.add_school_form.other_country.value;
			   }
	
			 if(country == "1") 
			 {
				if(IsBlank('add_school_form','usa_zipcode'))
				{
					alert("USA zipcode is Empty");
					return false;
				}
				if(isNaN(document.add_school_form.usa_zipcode.value))
				{
					alert("USA Zipcode Must be numeric");
					document.add_school_form.usa_zipcode.select();
					return false;
				}
				var zip=document.add_school_form.usa_zipcode.value;				
				if(document.add_school_form.usa_state.value == '0' && document.add_school_form.usa_city.value == '0')
			    {
			 		alert("Please select the Correct zipcode");
				    document.add_school_form.usa_zipcode.select();
				    return false;
			    }
			    var state = document.add_school_form.usa_state.value;
			    var city = document.add_school_form.usa_city.value;
			}
			else if(country == "26") 
			 {
				if(IsBlank('add_school_form','canada_zipcode'))
				{
					alert("Canada zipcode is Empty");
					return false;
				}				
				var zip=document.add_school_form.canada_zipcode.value;				
				if(document.add_school_form.canada_state.value == '0' && document.add_school_form.canada_city.value == '0')
			    {
			 		alert("Please select the Correct zipcode");
				    document.add_school_form.canada_zipcode.select();
				    return false;
			    }
			    var state = document.add_school_form.canada_state.value;
			    var city = document.add_school_form.canada_city.value;
			}
			if(country != "1" && country != "26")
			{
				if(IsBlank('add_school_form','other_zipcode'))
				{
					alert("Zipcode is Empty");
					return false;
				}				
				var zip=document.add_school_form.other_zipcode.value;
			}
			 
			 if(document.add_school_form.country.value == "Other") 
			 {
				  if(IsBlank('add_school_form','other_country')) 
				  {
					 alert("Other Country Field is empty/Invalid");
					 document.add_school_form.other_country.focus();
					 return false;
				  }
			 
				  if(IsBlank('add_school_form','other_state')) 
				  {
					 alert("Other State Field is empty/Invalid");
					 document.add_school_form.other_state.focus();
					 return false;
				  }
				  var state = document.add_school_form.other_state.value;
				  if(IsBlank('add_school_form','other_citys')) 
				  {
					 alert("Other City Field is empty/Invalid");
					 document.add_school_form.other_citys.focus();
					 return false;					
				  }
				  var city = document.add_school_form.other_citys.value;
			 }		 
			  
			 else if(country != "1" && country != "26" && country != "Other") 
			 {
				 if(document.add_school_form.hidden_state.value == "not")
				 {
					if(IsBlank('add_school_form','other_state1')) 
					{
						alert("Other State Field is empty/Invalid");
						document.add_school_form.other_state1.focus();
						return false;
					}
					var state = document.add_school_form.other_state1.value;
					
					if(IsBlank('add_school_form','other_city1')) 
					{
						alert("Other City Field is empty/Invalid");
						document.add_school_form.other_city1.focus();
						return false;
					}
					var city = document.add_school_form.other_city1.value;
				}
				
				 if(document.add_school_form.hidden_state.value == "found")
				 {   
					if(document.add_school_form.state.value == "") 
					{  
						alert("State Field is empty/Invalid");
						document.add_school_form.state.focus();
						return false;
					}
					var state = document.add_school_form.state.value;
					if(document.add_school_form.state.value=="Other")
					{
						if(IsBlank('add_school_form','other_state2')) 
						{
							alert("Other State Field is empty/Invalid");
							document.add_school_form.other_state2.focus();
							return false;
						}
						var state = document.add_school_form.other_state2.value;
						if(IsBlank('add_school_form','other_city')) 
						{
							alert("Other City Field is empty/Invalid");
							document.add_school_form.other_city.focus();
							return false;
						}
						var city = document.add_school_form.other_city.value;
					}
					if(document.add_school_form.state.value != "Other")
					{
						if(IsBlank('add_school_form','city')) 
						{
							alert("City Field is empty/Invalid");
							document.add_school_form.city.focus();
							return false;
						}
						var city = document.add_school_form.city.value;
						if(document.add_school_form.city.value == "Other")
						{
							if(IsBlank('add_school_form','other_city2')) 
							{
								alert("Other City Field is empty/Invalid");
								document.add_school_form.other_city2.focus();
								return false;
							}
							var city = document.add_school_form.other_city2.value;
						}
					}
				 }
			 } 
			 
			 if(IsBlank('add_school_form','school_name')) 
			 {
				alert("School Field is empty/Invalid");
				document.add_school_form.school_name.focus();
				return false;
			 }
			 var school = document.add_school_form.school_name.value;
			 
			 document.getElementById("schooldis").style.display = "block";
			 var url = "ajax_add_school.php?country="+country+"&state="+state+"&city="+city+"&zip="+zip+"&school="+school;
			 if(document.add_school_form.country.value == 'Other')
			 	url = url + "&cntry=new";
			 
			 xmlHttp=GetXmlHttpObject(popup_school_results)
			 xmlHttp.open("GET", url,true)
			 xmlHttp.send(null)
	   }
	   
	   function popup_school_results() 
	   { 
		   if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			   document.getElementById("schooldis").innerHTML = "";
			   document.getElementById("schooldis").innerHTML = xmlHttp.responseText;			   
			   Modalbox.hide();
			   return false;		
			 }
		    else
		     {
		        document.getElementById("schooldis").innerHTML = '<table><tr><td align="center"><img src="indicator.gif" width="16" height="16"></td><td>Loading...</td></tr></table>';
		     }
	   }
	
	   function checkSchool()
	   {
	   	    document.getElementById("schooldis").innerHTML = '<select name="sss"><option value="e">ddd</option></select>';
	   }