function populatePrices(exp,city)
{
		//alert(exp+"**"+city);
	if ( exp != '' ) {
		var http = false;
		var frm = document.case_postfrm2;
			
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http = new XMLHttpRequest();
		}
		var currentTime = new Date().getTime();
		http.abort();
		http.open("GET", "AjaxPriceDetails.php?exp="+exp+"&city="+city+"&timestamp="+currentTime, true);
		var reg=document.case_postfrm2.idPrice;
		
		http.onreadystatechange=function() {
		
		if(http.readyState == 4) { 
				if (http.status == 200) {			
					var xmlobj = http.responseText; 
				
					//document.getElementById("idPrice").innerHTML=xmlobj;
					//commented by stani
					
				}
			} 
		}
	 	http.send(null);
	}
}

function populateCaseDesc(obj)
{
		
	if ( obj != '' ) {
		var http = false;
		var frm = document.case_postfrm2;
			
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http = new XMLHttpRequest();
		}
		var currentTime = new Date().getTime();
		http.abort();
		http.open("GET", "AjaxCaseDesc.php?caseid="+obj+"&timestamp="+currentTime, true);
		var reg=document.case_postfrm2.idPrice;
		
		http.onreadystatechange=function() {
		
		if(http.readyState == 4) { 
				if (http.status == 200) {			
					var xmlobj = http.responseText; 
				
					document.getElementById("txtcaseDes").innerHTML=xmlobj;
					
				}
			} 
		}
	 	http.send(null);
	}
}

function populateSpecIssue(obj)
{
	if ( obj != '' ) {
		var http = false;
		var frm = document.case_postfrm2;
			
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http = new XMLHttpRequest();
		}
		var currentTime = new Date().getTime();
		http.abort();
		http.open("GET", "AjaxSpecIssue.php?lawyertype="+obj+"&timestamp="+currentTime, true);
		var reg=document.case_postfrm2.idPrice;
		
		http.onreadystatechange=function() {
		
		if(http.readyState == 4) { 
				if (http.status == 200) {			
					var xmlobj = http.responseText; 
				
					document.getElementById("txtcaseDes").innerHTML=xmlobj;
					
				}
			} 
		}
	 	http.send(null);
	}
}


function recomment_open()
{
	document.getElementById('recommend').style.display='';
}

if(location.hostname=='nitins'||location.hostname=='localhost'){
	var mysiteurl = 'http://'+location.hostname+'/lawyerupdate_ca/';
}else{
var mysiteurl = 'http://'+location.hostname+'/';	
}

function change_country(){
	document.getElementById('Divcountry').innerHTML='<select name="cont" onchange="chang_cont(this.value)"><option selected >Select Country</option><option value="223">UNITED STATES</option><option value="38">CANADA</option></select>';
	
}
/*****My new function for specific****/
function practice_area1(lawtypeid)
{  
	var pdata = "ID=" + lawtypeid ;
	var temp=mysiteurl+'finalajax_practicearea.php?';
	postdata_practicearea1(temp, pdata);
	
}


function postdata_practicearea1(path , parameters)
{	
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			// http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_practicearea1;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_practicearea1() 
{		
      if (http_request.readyState == 4) 
      {	
         if (http_request.status == 200) 
         {   
		
            result = http_request.responseText;	
			
			stateobj 	=	result.split("+++++");
			
			descobj		=	result.split("^^^^");
			
			if(descobj.length>1)
			{
				//document.getElementById('txtcaseDes').innerHTML="";
				//document.getElementById('txtcaseDes').innerHTML='<div class=\"box_100\"><h1>'+descobj[1] + '</h1></div><br/>' + descobj[2]; 
			}
			
			if(stateobj.length>1)
		   	{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML ="<select name='specific' id='specific'   style='width:250px;'  onchange='populateSpecIssue(this.value);'>";
				removeAllOptions(document.getElementById('specific'));
				//addOption(document.getElementById('specific'), "", "Select Specific");
				for (var i=0; i<stateobj.length-1;i++)
				{
					
					statesubobj=stateobj[i].split("***");
					
						addOption(document.getElementById('specific'), statesubobj[0],statesubobj[1]);
					
				}
				//addOption(document.getElementById('specific'), "Other", "Other");
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML="<select name='specific' id='specific'   style='width:250px;'  >";			
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}		   
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
	  else
	  {
		  	document.getElementById('specificdiv').innerHTML="";
			document.getElementById('specificdiv').innerHTML ="<select name='specific'   id='specific'   style='width:250px;' >";
			removeAllOptions(document.getElementById('specific'));
			addOption(document.getElementById('specific'), '','Loading...');
			document.getElementById('specificdiv').innerHTML += "</select>";
	  }
}


/*****My end function here  for specific****/



//Function to trim the space in the left side of the string
function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}
//Function to trim the space in the right side of the string
function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}
//Function to trim the space in the  string
function trim(s)
{
	var temp = s;
   	return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

//function chkdetail(postcode,city,province){
//function chkdetail(city,province){
function chkdetail(tem){
	//alert('hi');
	var form_id=document.getElementById('case_postfrm2');
	var city=form_id.city_search.value;
	//alert(city);
	document.getElementById('DivZipcode').innerHTML='<img src="images/indicator.gif" >Searching';	
	//document.getElementById('state_name').value=province;
	//document.getElementById('city').value=city;
	//document.getElementById('postcode').value=postcode;
	
	var rand=Math.random();
	//new Ajax.Updater('DivZipcode', mysiteurl+"chk_detail.php?zip="+postcode+"&city="+city+"&un_time="+rand, {asynchronous:true, evalScripts:true });
	new Ajax.Updater('DivZipcode', mysiteurl+"chk_detail.php?city="+city+"&un_time="+rand, {asynchronous:true, evalScripts:true });
	//alert( mysiteurl+"chk_detail.php?zip="+postcode+"&city="+city+"&un_time="+rand);
}
 function set_count(){
	 document.getElementById('set_cont').style.display='inline';
	 document.getElementById('country_name').value=38;
	 }
	  function unset_count(){
	 document.getElementById('set_cont').style.display='none';
	  document.getElementById('country_name').value=223;
	 }

function checkzip(){
	var country=document.regfrm.country_lawyer.value;
	var state=document.regfrm.state_lawyer.value;
	var city=document.regfrm.txtCity_lawyer.value;
	var zip=document.regfrm.zip.value;
	var rand=Math.random();
	document.getElementById('Zip_error').innerHTML='<br><img src="images/indicator.gif" >Checking';
	//document.getElementById('city_here').innerHTML='<img src="images/indicator.gif" >Checking';
	new Ajax.Updater('Zip_error', mysiteurl+"zip_check.php?zip="+zip+"&city="+city+"&state="+state+"&country="+country+"&un_time="+rand, {asynchronous:true, evalScripts:true });
	
}

function change_c(){
	document.getElementById('country_nm').innerHTML='<select name="cont" onchange=chang_cont("'+mysiteurl+'viewcase.php?country="this.value)><option selected >Select Country</option><option value="223">UNITED STATES</option><option value="38">CANADA</option></select>';
	
}

function chang_cont(country){
document.getElementById('Divcountry').innerHTML='Change Country  <a onclick="change_country()">Change</a>';
if(country==38){

set_count();	
}
if(country==223){
unset_count();	
}
}

function search_city_code(tem){

//	var country=document.case_postfrm2.country.value;
	//var state=document.case_postfrm2.state.value;
	var city=document.case_postfrm2.city_search.value;
	var temp =city.length;
	if(temp>=3){
	var rand=Math.random();
	//alert(country+" "+state+" "+city);
document.getElementById('DivZipcode').innerHTML='<img src="images/indicator.gif" >Searching';
	 new Ajax.Updater('DivZipcode', mysiteurl+"search_city_code.php?city="+city+"&un_time="+rand, {asynchronous:true, evalScripts:true });
	 //alert(mysiteurl+"search_city_code.php?city="+city+"&un_time="+rand);
	}else{
	document.getElementById('DivZipcode').innerHTML='<span style="color:#FF0000">Please enter at least 3 charachter for search</span>';	
	}
	}



function removeAllOptions(selectbox)
{
    var i;
    for(i=selectbox.options.length-1;i>=0;i--)
    {
        //selectbox.options.remove(i);
        selectbox.remove(i);
    }
}

var month_array= new Array(12);
month_array[0]="January";
month_array[1]="February";
month_array[2]="March";
month_array[3]="April";
month_array[4]="May";
month_array[5]="June";
month_array[6]="July";
month_array[7]="August";
month_array[8]="September";
month_array[9]="October";
month_array[10]="November";
month_array[11]="December";	

function addOption(selectbox, value, text )
{

    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}

function addOption_selected(selectbox, value, text )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    optn.selected=true;
    selectbox.options.add(optn);
}

function check_availability(email,loadarea)
{		

  var myemail =	document.getElementById(email)
  var address_string = mysiteurl+"check_name.php?email="+myemail.value;
  //alert(address_string);
  ajaxpage(address_string, loadarea)
}	
function check_nameavailability(objid,loadarea)
{		
  var myobj=document.getElementById(objid)
  var address_string = mysiteurl+"chk_name.php?name="+ myobj.value;
  //alert(address_string);
  ajaxpage(address_string, loadarea)
}
 
function ajaxpage(url, c_id)
{
  var page_request = false
 
  if (window.XMLHttpRequest)     // if Mozilla, Safari etc
  {
    page_request = new XMLHttpRequest()
  }
  else if (window.ActiveXObject) // if IE
  {
    try
    {
      page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e)
    {
      try
      {
        page_request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch (e){}
    }
  }
  else
    return false
 
  page_request.onreadystatechange=function()
  {
    loadpage(page_request, c_id)
  }
 
  anticache=(url.indexOf("?")!=-1) ?
            "&"+new Date().getTime() :
            "?"+new Date().getTime()
 
  page_request.open('GET', url+anticache, true)
  page_request.send(null)
}
 
function loadpage(page_request, c_id)
{
  if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  {
	document.getElementById(c_id).innerHTML=page_request.responseText
  }
}


function finalajax(con)
{
	document.getElementById('statediv').innerHTML='<img src="images/indicator.gif" >'
	var pdata = "ID=" + con ;
	postdata(mysiteurl+'finalajax.php?', pdata);	
}

function postdata(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;			
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				//document.getElementById('statediv').innerHTML="";
				document.getElementById('statediv').innerHTML ="<select name='state' id='state' class='text'>";
				removeAllOptions(document.getElementById('state'));
				addOption(document.getElementById('state'), "", "Select State");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
				
					addOption(document.getElementById('state'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('state'), "Other", "Other");
				document.getElementById('statediv').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('statediv').innerHTML="";
				document.getElementById('statediv').innerHTML=result;			
			}			
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}


function finalajax_lawyer(con)
{
	document.getElementById('statediv_lawyer').innerHTML='<img src="images/indicator.gif" >'
	var pdata = "ID=" + con ;
	postdata_lawyer(mysiteurl+'finalajax_lawyer.php?', pdata);	
}

function postdata_lawyer(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_lawyer;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_lawyer() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;			
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				//document.getElementById('statediv_lawyer').innerHTML="";
				document.getElementById('statediv_lawyer').innerHTML ="<select name='state_lawyer' id='state_lawyer' class='text'>";
				removeAllOptions(document.getElementById('state_lawyer'));
				addOption(document.getElementById('state_lawyer'), "", "Select State");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('state_lawyer'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('state_lawyer'), "Other", "Other");
				document.getElementById('statediv_lawyer').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('statediv_lawyer').innerHTML="";
				document.getElementById('statediv_lawyer').innerHTML=result;			
			}			
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}



function finalajax_contact(con)
{
	var pdata = "ID=" + con ;
	postdata_contact(mysiteurl+'finalajax_contact.php?', pdata);	
}

function postdata_contact(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{			
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_contact;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_contact() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;			
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				document.getElementById('statediv_contact').innerHTML="";
				document.getElementById('statediv_contact').innerHTML ="<select name='state_contact' id='state_contact' class='text'>";
				removeAllOptions(document.getElementById('state_contact'));
				addOption(document.getElementById('state_contact'), "", "Select State");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('state_contact'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('state'), "Other", "Other");
				document.getElementById('statediv_contact').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('statediv_contact').innerHTML="";
				document.getElementById('statediv_contact').innerHTML=result;			
			}			
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}

function finalajax_work(con)
{	
	var pdata = "ID=" + con ;
	postdata_work(mysiteurl+'finalajax_work.php?', pdata);	
}

function postdata_work(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_work;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_work() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;			
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				document.getElementById('statework_div').innerHTML="";
				document.getElementById('statework_div').innerHTML ="<select name='state_work' id='state_work' class='text'>";
				removeAllOptions(document.getElementById('state_work'));
				addOption(document.getElementById('state_work'), "", "Select State");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('state_work'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('state'), "Other", "Other");
				document.getElementById('statework_div').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('statework_div').innerHTML="";
				document.getElementById('statework_div').innerHTML=result;			
			}			
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}

function practice_area(lawtypeid)
{
	//alert( lawtypeid );
	var pdata = "ID=" + lawtypeid ;
	var temp=mysiteurl+'finalajax_practicearea.php?';
	postdata_practicearea(temp, pdata);
	
}


function postdata_practicearea(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_practicearea;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_practicearea() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {   
		
            result = http_request.responseText;	
			
			stateobj 	=	result.split("+++++");
			
			descobj		=	result.split("^^^^");
			//alert(descobj);
			if(descobj.length>1)
			{
				document.getElementById('txtcaseDes').innerHTML="";
				document.getElementById('txtcaseDes').innerHTML='<div class=\"box_100\"><h1>'+descobj[1] + '</h1></div><br/>' + descobj[2]; 
			}
			
			if(stateobj.length>1)
		   	{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML ="<select name='specific' id='specific'   style='width:250px;' multiple='multiple'>";
				removeAllOptions(document.getElementById('specific'));
				//addOption(document.getElementById('specific'), "", "Select Specific");
				for (var i=0; i<stateobj.length-1;i++)
				{
					
					statesubobj=stateobj[i].split("***");
					
						addOption(document.getElementById('specific'), statesubobj[0],statesubobj[1]);
					
				}
				//addOption(document.getElementById('specific'), "Other", "Other");
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML="<select name='specific' id='specific'   style='width:250px;' multiple='multiple'  >";			
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}		   
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
	  else
	  {
		  	document.getElementById('specificdiv').innerHTML="";
			document.getElementById('specificdiv').innerHTML ="<select name='specific' multiple='multiple'  id='specific'   style='width:250px;' onchange=showCaseDes(this.value);>";
			removeAllOptions(document.getElementById('specific'));
			addOption(document.getElementById('specific'), '','Loading...');
			document.getElementById('specificdiv').innerHTML += "</select>";
	  }
}

function set_plan_tn(typ){
	document.getElementById('plan_type_tn').value=typ;
if(typ=='leads'){
	document.getElementById('chosen').innerHTML='';
	}	
}


function practice_area_reg(lawtypeid,typ)
{	
	var pdata = "ID=" + lawtypeid ;
	var typ = document.getElementById('plan_type_tn').value
	
	postdata_practicearea_reg(mysiteurl+'finalajax_practicearea.php?', pdata,typ);	
}

function postdata_practicearea_reg(path , parameters,typ)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_practicearea_reg;
	if(typ=='leads'){
	document.getElementById('chosen').innerHTML='';
	}
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_practicearea_reg() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;				
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML ="<select name='specific' multiple='multiple' id='specific'class='select_type_3' size=10>";
				removeAllOptions(document.getElementById('specific'));
				//addOption(document.getElementById('specific'), "", "Select Specific");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('specific'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('specific'), "Other", "Other");
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML ="<select name='specific' multiple='multiple' id='specific' class='select_type_3' size='10' >";			
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}		   
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}


function practice_area_home(lawtypeid)
{	
	var pdata = "ID=" + lawtypeid ;
	//alert( lawtypeid);
	var temp=mysiteurl+'finalajax_practicearea.php?';
	postdata_practicearea_home(temp, pdata);	
}

function postdata_practicearea_home(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_practicearea_home;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_practicearea_home() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;	
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				document.getElementById('specificdiv').innerHTML="";
				document.getElementById('specificdiv').innerHTML ="<select name='specific' id='specific' style='width:190px' class='right_gotalegal_form_dropdown' >";
				removeAllOptions(document.getElementById('specific'));
				//addOption(document.getElementById('specific'), "", "Select Specific");
				//alert(document.getElementById('specificdiv').innerHTML);
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('specific'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('specific'), "Other", "Other");
				document.getElementById('specificdiv').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('specificdiv').innerHTML="<select name='specific' id='specific' style='width:190px' class='right_gotalegal_form_dropdown'><option> Select specific issue</select>";
				//document.getElementById('specificdiv').innerHTML=result;			
			}		   
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
	  else
	  {
			document.getElementById('specificdiv').innerHTML="";
			document.getElementById('specificdiv').innerHTML ="<select name='specific' id='specific' style='width:190px' class='right_gotalegal_form_dropdown'>";
			removeAllOptions(document.getElementById('specific'));
			addOption(document.getElementById('specific'),'','Loading...');
			document.getElementById('specificdiv').innerHTML += "</select>";
	  }
}


function finalajax_admitted(con)
{	
	var pdata = "ID=" + con ;
	postdata_admitted(mysiteurl+'finalajax_admitted.php?', pdata);	
}

function postdata_admitted(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_admitted;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	//alert(parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
	//alert(parameters);
}

function alertContents_admitted() 
{		
      if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;			
			stateobj =result.split("+++++");			
			if(stateobj.length>1)
		   	{
				document.getElementById('statediv_admitted').innerHTML="";
				document.getElementById('statediv_admitted').innerHTML ="<select name='state_admitted' id='state_admitted' class='text'>";
				removeAllOptions(document.getElementById('state_admitted'));
				addOption(document.getElementById('state_admitted'), "", "Select State");
				for (var i=0; i<stateobj.length-1;i++)
				{
					statesubobj=stateobj[i].split("***");
					addOption(document.getElementById('state_admitted'), statesubobj[0],statesubobj[1]);
				}
				//addOption(document.getElementById('state'), "Other", "Other");
				document.getElementById('statediv_admitted').innerHTML +=	"</select>";
			}
			else
			{
				document.getElementById('statediv_admitted').innerHTML="";
				document.getElementById('statediv_admitted').innerHTML=result;					
			}			
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
}




function showCaseDes(id)
{	
	var cdata = "ID=" + id ;
	postdata_showCaseDes(mysiteurl+'finalajax_casedes.php?', cdata);	
	
}

function postdata_showCaseDes(path,parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	//alert(path);
	http_request.onreadystatechange = alertContents_showCaseDes;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);

}

function alertContents_showCaseDes() 
{		
    
	  if (http_request.readyState == 4) 
      {
         if (http_request.status == 200) 
         {            
            result = http_request.responseText;	
			stateobj 	=  result.split("+++++");
			descobj		=   result.split("^^^^^");	
			//document.getElementById('casetypeDIV').innerHTML="";	
			//document.getElementById('casetypeDIV').innerHTML=descobj[1];	
			document.getElementById('txtcaseDes').innerHTML="";
			document.getElementById('txtcaseDes').innerHTML=descobj[0];						
	 	 }
		 else 
		 {
				alert('There was a problem with the request.');
		 }
      }
	  else
	  {
		  document.getElementById('txtcaseDes').innerHTML   =   "<img src=\"images/img_loding.gif\" border=\"0\">";
	  }
}


function law_type(con)
{
	
	var pdata = "ID=" + con ;
	lawpostdata(mysiteurl+'ajax_lawtype.php?', pdata);	
}

function lawpostdata(path , parameters)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) 
			{}
		}
	}
   
	http_request.onreadystatechange = lawTypeContents;
	http_request.open('POST', path , true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

function lawTypeContents() 
{		
	 if (http_request.readyState == 4) 
      {
            result = http_request.responseText;	
			document.getElementById('casetypeDIV').innerHTML		=	"";
			document.getElementById('casetypeDIV').innerHTML		=	result;
      }
	  else
	  {
			document.getElementById('casetypeDIV').innerHTML		=	"";
			document.getElementById('casetypeDIV').innerHTML		= "<select class=\"text\" style=\"width:120px;\"><option>Loading...</option></select>";  
	  }
}


// ######################### COMMON AJAX FUNCTIONS STARTS HERE ##########################
function createXMLHttpRequest() 
{
	var ua;
	
	if(window.XMLHttpRequest) {
	try {
	ua = new XMLHttpRequest();
	} catch(e) {
	ua = false;
	}
	} else if(window.ActiveXObject) {
	try {
	ua = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
	ua = false;
	}
	}
	return ua;
}

var req = createXMLHttpRequest();
var sres = '';

function sendRequest(frmMain, element, url) 
{	
	//alert(frmMain);
	sres = element;		
	var str = DisplayFormValues(frmMain);
	req.open('POST', url, true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	req.onreadystatechange = handleResponse;
	req.send(str);
	return false;
}

function handleResponse() 
{
	element = sres;
	if(req.readyState == 4)
	{
		//alert(trim(req.responseText));
		switch(trim(req.responseText))
		{
			case '1':
				window.location.href="mymail.php?sm=1&show=1";
				break;
			case '2':
				window.location.href="mymail.php?sm=2&show=2";
				break;
			case '3':
				window.location.href="mymail.php?sm=3&show=3";
				break;
			case '4':
				window.location.href="mymail.php?sm=4&show=4";
				break;
			case '5':
				window.location.href="mymail.php?sm=5&show=5";
				break;
			case '6':
				window.location.href="mymail.php?dm=1&show=1";
				break;
			case '7':
				//alert("sss");
				window.location.href="mymail.php?dm=2&show=2";
				break;
			case '8':
			//alert("sss");
				window.location.href="mymail.php?dm=3&show=3";
				break;
			case '9':
				window.location.href="mymail.php?dm=4&show=4";
				break;
			case '10':
				window.location.href="mymail.php?dm=5&show=5";
				break;
			default:
				window.location.href="mymail.php";
				break;
		}
		/*if(req.responseText==1)
		{	
			window.location.href="mymail.php?sm=1&show=1";			
			//document.getElementById(element).innerHTML = req.responseText;
		}*/
	}
	else{
	//alert("loading " + req.element); // used for debugging only!
	}
}

function DisplayFormValues(frmMain)
{	
	var str = '';
	var elem = document.getElementById(frmMain).elements;
	//var elem = frmMain.elements;
	for(var i = 0; i < elem.length; i++)
	{
		if((elem[i].type == 'checkbox') && (elem[i].checked == true))
		{
			str += encodeURIComponent(elem[i].name) + "=";
			str += encodeURIComponent(elem[i].value) + "&";
		}
		if((elem[i].type != 'checkbox'))
		{
			str += encodeURIComponent(elem[i].name) + "=";
			str += encodeURIComponent(elem[i].value) + "&";
		}
	}
	str += "form=" + frmMain;
	return str;
}
<!-- onsubmit="return sendRequest('exampleForm', 'server_thickbox_response', 'get.php');" -->
// ######################### COMMON AJAX FUNCTIONS ENDS HERE ##############################

