// JavaScript Document
function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}




function MakeRequest()
{
  var xmlHttp = getXMLHttp();
 
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "test4.php?qs=3", true);
  xmlHttp.send(null);
}
//---------------------Functions-------------------
function getBatchDates(strname)
{
 // alert(strname);
  var xmlHttp = getXMLHttp();
 
  xmlHttp.onreadystatechange = function()
  {
	  //alert(strname);
    if(xmlHttp.readyState == 4)
	
    {
		//alert(xmlHttp.responseText);
      fillBatchDates(xmlHttp.responseText);
    }
  }
  xmlHttp.open("GET", "dosql.php?qs=cnm&cname="+strname, true);
  xmlHttp.send(null);
}


function getBatchTiming(bdate,cname)
{
	//alert(cname);
  var xmlHttp = getXMLHttp();
 //document.write(cname+"---------------"+bname);
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      fillBatchTiming(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "dosql.php?qs=bnm&cname="+cname+"&bdate="+bdate, true);
  xmlHttp.send(null);
}




function getaddress(strname)
{
  var xmlHttp = getXMLHttp();
 
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      filladdress(xmlHttp.responseText);
    }
  }

  xmlHttp.open("GET", "test4.php?qs=4&ctr="+strname, true);
  xmlHttp.send(null);
}

//---------Sub Functions--------------------

function fillBatchDates(response)
{
		var stropt=response;
		//statecombo=document.form1.state;
		statecombo=document.getElementById('datofjoining')
		var listArray=response.split("|*|");
		for(i=0;i<listArray.length-1;i++)
		{
		statecombo.options[i]=new Option(listArray[i],listArray[i]);	
		}
//		for(i=0;i<listArray.length/2-1;i++)
//		{
//		statecombo.options[i]=new Option(listArray[i*2+1],listArray[i*2]);	
//		}		
// document.getElementById('datofjoining').innerHTML = response;
 
}

function fillBatchTiming(response)
{
	var stropt=response;
		//statecombo=document.form1.state;
		statecombo=document.getElementById('batchtiming')
		var listArray=response.split("|*|");
		for(i=0;i<listArray.length-1;i++)
		{
		statecombo.options[i]=new Option(listArray[i],listArray[i]);	
		}
	//document.getElementById('batchtiming').innerHTML = response;

}

function filladdress(response)
{
 document.getElementById('s2').innerHTML = response;
}

function HandleResponse(response)
{
  document.getElementById('ResponseDiv').innerHTML = response;
  document.getElementById('s1').innerHTML = response;
}
