/**
Author: Sanjesh Verma
Date: 21-05-2009

Discription: This js is used to get the reponse of jsps using ajax

*/



//function to get div object
function getDivObj(name)
 {
	if (document.getElementById)
	 {
		this.obj = document.getElementById(name); 
	 }
	else if (document.all)
	 {
	    this.obj = document.all[name];
	 }
	else if (document.layers)
	 {
	    this.obj = document.layers[name];	
	 }
}// function over


//function to get request object
function createRequestObject()
 {
   	var xmlhttp;
	if (window.XMLHttpRequest)
	 { 
	    xmlhttp = new XMLHttpRequest();
	 }
	else if (window.ActiveXObject)
	 {
	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	 } 
	return  xmlhttp;
 }// function over



// this function will populate the div in htm pages
function populateDiv(form,type,occup)
{
   //alert("hiiiiiii");
   xmlHttpObj1=createRequestObject();
   
   if (xmlHttpObj1==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    } 
  
   if(type == 'region')
	{
      var url1="/registration/cd/seminar/getCdCal.jsp?state="+form+"&occup="+occup;
    }
   else
	{
  var url1="/registration/cd/seminar/cdSeminarForm.jsp?form="+form;
	}
   //alert("inside function & url is  is----"+url1); 
   //var url1="templt_grph_lnk_"+symbol+".htm";
   xmlHttpObj1.onreadystatechange=function()
   {
      if(xmlHttpObj1.readyState == 4 || xmlHttpObj1.readyState == "complete") 
	   {  
	     if (xmlHttpObj1.status == 200 ) 
	      {
		    var s=xmlHttpObj1.responseText;
		    //alert("rrererrer"+s);
			if(type == 'region')
	           divBoxObj = new getDivObj('regionDiv');
			else
				divBoxObj = new getDivObj('formDiv');

//alert(xmlHttpObj1.responseText);

            divBoxObj.obj.innerHTML=xmlHttpObj1.responseText;
	      }
      } 
	  else
	   {
		  if(type == 'region')
	           divBoxObj = new getDivObj('regionDiv');
		  else
			   divBoxObj = new getDivObj('formDiv');
        

		divBoxObj.obj.innerHTML = "<img src ='/images/load111.gif' width='30' height='30'>";
	  
	  
	  }
   }
 //alert("inside function & symbol is----");
 xmlHttpObj1.open("GET",url1,true);
 xmlHttpObj1.send(null);

}// fun populateDiv over


