function getXMLHTTP() 

{ 

//fuction to return the xml http object

		var xmlhttp=false;	

		try{

			xmlhttp=new XMLHttpRequest();

		}

		catch(e)	{		

			try{			

				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");

			}

			catch(e){

				try{

				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

				}

				catch(e1)

				{

					xmlhttp=false;

				}

			}

		}

		 	

		return xmlhttp;

    }

	

	function check_email(txt)

	    {

			//

		document.getElementById('em').innerHTML = '<img src="loading.gif" />';

		

		var strURL="email_check.php?val="+txt;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) 

					{		

					  

					     if(req.responseText=='This Email Id Already Exists !')

						  {

							document.getElementById('f15').value='';			  

						  }

					  

						document.getElementById('em').innerHTML=req.responseText;						

					} else 

					{

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

		

		}

	

	function show_child(siz,ad)

	  {
       
		var strURL="populate_child.php?val="+siz+'&adl=' + ad;
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) 

					{						

						document.getElementById('main').innerHTML=req.responseText;						

					} else 

					{

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

				

	}

	function save() 
	{
		document.getElementById('select_date').innerHTML = '<img src="loading.gif" />';

		 for (var i=0; i < document.form1.r1.length; i++)

			   {

			   if (document.form1.r1[i].checked)

				  {

				     var  var_r1 = document.form1.r1[i].value;

				  }

			   }

			

			if(document.form1.sub_leb.length > 1)

			{

				for (var i=0; i < document.form1.sub_leb.length; i++)

				   {

				   if (document.form1.sub_leb[i].checked)

					  {

						 var  sub_leb = document.form1.sub_leb[i].value;

					  }

				   }

			}

			else

			{
			   var sub_leb=document.getElementById("sub_leb").value;

			}

		var txt_country=document.getElementById("txt_country").value;
		var txt_year=document.getElementById("txt_year").value;

		var name=document.getElementById("name").value;

		var strURL="post.php?var_r1="+ var_r1+'&txt_country=' + txt_country +'&name='+name+'&txt_year='+txt_year+'&sub_leb='+sub_leb;

		var req = getXMLHTTP();

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('select_date').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}		

	}

	 function get_size(siz)

	  {

		var strURL="populate_size.php?val="+siz;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {	

					      //alert(req.responseText);

						  if(req.responseText==1)

						   {

							var msg="Filesize is greater than 100 Kb";   

						   }

						    else

						   {

							   var msg="";   

						  }

						document.getElementById('siz').innerHTML=msg;

						 if(req.responseText==1)

						   {

							   document.getElementById("field16").value="";

						    }

						

					} else 

					{

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

	  }
	function get_corporatecenter(val,stateId) 
	  {
		var strURL="populate_corporate_center.php?val="+val+"&state="+stateId;
		var req = getXMLHTTP();
		if (req) {
			
			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('citydiv').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

				

	}

	

	function get_corporatdate(val,corp,level) 
	{
		var exam_type_val=level;
		var strURL="corporate_date_populate.php?val="+val+"&id="+corp+"&exam_type="+exam_type_val;
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {	

					//alert(req.responseText);

						document.getElementById('select_date').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}		

	}

	function getcompany(val) 

	{	

	   document.getElementById('company').innerHTML = '<img src="loading.gif" />';

	   var strURL="other.php?val="+val;

		var req = getXMLHTTP();

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('company').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		   }		

	  }

	

	function getdate(val,level) 
	  {	
	
			if(level=='')
			 {
			   var exam_type_val=document.getElementById('rd_leveltype').value;		
			  }else
			  {
                var exam_type_val=level;
	          }
		
	    var strURL="date_populate.php?val="+val+"&exam_type="+exam_type_val;
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() 

			{
				if (req.readyState == 4)

				{


					if (req.status == 200) 

					{	

						document.getElementById('select_date').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}		

	}

	function getcenter(val,stateId,level) 
	{
		var exam_type_val=level;
		var strURL="populate_center.php?val="+val+"&state="+stateId+"&exam_type="+exam_type_val;
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						

					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

				

	}

	

	

	var cityname='txt_city';

	function getState(countryId, sid )

	{

		//alert("get state");

		//alert(sid);

	if(typeof(sid)=='undefined')

	      {

	        var statename='txt_state';

				cityname='txt_city';

		  }

		  else

		  {

			var statename=sid; 

			cityname='p_city';

		  }

		  //alert(statename);

		var strURL="findState.php?country="+countryId;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

						

					 var option_string=req.responseText;

					// alert(req.responseText);

					 document.getElementById(statename).options.length=0;

					 

					 var option_list = option_string.split(",");

					 for(var i=0; i<option_list.length; i++)

					 {

						 var each_option_list =option_list[i].split("=>");

						 var objoption = document.createElement("option");

						 objoption.text=each_option_list[1];

						 objoption.value=each_option_list[0];

						 document.getElementById(statename).options.add(objoption);

					 }

						//document.getElementById(statename).innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}	

			

			req.open("GET", strURL, true);

			req.send(null);

		}	

	}

	

	function getcity(val,stateId,sid) 

	{

		//alert("get city");

		var strURL="populate_enroll_city.php?val="+val+"&state="+stateId;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() 

			{

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {		

					

						 var option_string=req.responseText;

						 //alert(document.getElementById(cityname).options.length);

						 //alert(option_string);

					 //alert(document.getElementById(cityname).length);

					 document.getElementById(cityname).options.length=1;

					 

					  	/*var objoption = document.createElement("option");

						 objoption.text=".1111111....Select State.....";

						 objoption.value="";*/

					//alert("ok");

					//document.getElementById(cityname).options.add(objoption);

						 //alert("okkkkkkkkkkkk");

						 

					 var option_list = option_string.split(",");

					

					 if(option_list.length >0)

						  {

							 for(var i=0; i<option_list.length; i++)

					 		  {

								 var each_option_list =option_list[i].split("=>");

								 var objoption = document.createElement("option");

											objoption.text=each_option_list[1];

								 objoption.value=each_option_list[0];

								 document.getElementById(cityname).options.add(objoption);

							 } 

							  

						  }

					 

					 

					} 

					else 

					{

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

				

	}

	

	function getform1(select_frm) {	

			var strURL="en_form1.php?fm="+select_frm;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('s_frm').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}		

	}

	

	

	

	

	function get_new(val) 

	{

		

	

	

	var strURL="populate_new_old.php?val="+val;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('new').innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

		

	}

	

	function get_appear(val, regid) 

	{


	var strURL="populate_appear.php?val="+val+'&regid='+regid+'&extype='+cal_fun;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

						

						document.getElementById('w').innerHTML=req.responseText;

						parrentchild(document.getElementById('rd_leveltype').value);

						

						var selected_exam_type = document.getElementById('selected_examt').value;

						if(cal_fun=="corp") get_corporate_form_detail(selected_exam_type);

						else  				 get_form_detail(selected_exam_type);

						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

		

	}

function get_corporate_form_detail(val, regid) 

	{

		

	var cid = document.getElementById("cor_type").value;	

	var strURL="corporate_form_detail.php?val="+val+'&id='+cid+'&regid='+regid;

	

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

		

					 var option_string=req.responseText;

					 

					 var cityname = 'f1';

					 document.getElementById(cityname).options.length=1;

					 if(option_string.length > 2)

					 {

					 	var option_list = option_string.split(",");

						var string_length = option_list.length;

					 }

					 else

					 {

						 var string_length = 0;

					 }

					//alert(string_length);

					 if(string_length >0)

						  {

							 for(var i=0; i<string_length; i++)

					 		  {

								 var each_option_list =option_list[i].split("=>");

								 var objoption = document.createElement("option");

											objoption.text=each_option_list[1];

								 objoption.value=each_option_list[0];

								 document.getElementById(cityname).options.add(objoption);

							 } 

							  

						  }

					 

					 

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

		

	}

	

	

	

	

	function get_form_detail(val, regid) 

	{

		

//alert(val);

	var strURL="form_detail.php?val="+val+'&regid='+regid;

		var req = getXMLHTTP();

		

		if (req) {

			

			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

		

					 var option_string=req.responseText;

					 

					 var cityname = 'f1';

					 document.getElementById(cityname).options.length=1;

					 if(option_string.length > 2)

					 {

					 	var option_list = option_string.split(",");

						var string_length = option_list.length;

					 }

					 else

					 {

						 var string_length = 0;

					 }

					//alert(string_length);

					 if(string_length >0)

						  {

							 for(var i=0; i<string_length; i++)

					 		  {

								 var each_option_list =option_list[i].split("=>");

								 var objoption = document.createElement("option");

											objoption.text=each_option_list[1];

								 objoption.value=each_option_list[0];

								 document.getElementById(cityname).options.add(objoption);

							 } 

							  

						  }

					 

					 

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}			

			req.open("GET", strURL, true);

			req.send(null);

		}

		

	}

	

	

	

function setPaymentInfo(isChecked)

{

	

	with (window.document.form1)

	{

		

			getState(txt_country.value,'p_state');

		    getcity(txt_country.value,txt_state.value);



		

		

		if (isChecked) 

		{

			if(confirm("Your Postal Address will be same as Permanent Address."))

			{			

				

				p_Address.value= txt_Address1.value;

				p_country.value= txt_country.value;

				p_state.value   = txt_state.value;

				p_city.value   = txt_city.value;

				p_pincode.value = txt_pincode.value;

			}

			else

			{	

			

			   document.form1.chkSame.checked=false;

				p_Address.value ="";

			    p_country.value="";

				p_state.value   ="";

				p_city.value   = "";

				p_pincode.value  = "";

			

			

			}

		} 

		else 

		{

			

			p_Address.value ="";

			p_country.value="";

		    p_state.value   ="";

			p_city.value   = "";

			p_pincode.value  = "";

			

			

		}

	}

}

var xmlHttp
function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 
var url="foundation_exam_date.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function setnul()
{
	document.form1.chkSame.checked=false;
}

	

function stateChanged() 

{ 

if (xmlHttp.readyState==4)

{ 

document.getElementById("txtHint").innerHTML=xmlHttp.responseText;

}

}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();

  }

catch (e)

  {

  // Internet Explorer

  try

    {

    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

  catch (e)

    {

    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

  }

return xmlHttp; 

}


