var xmlHttp
function showCity(str,city)
{
	
	document.getElementById("txtCity").innerHTML="<select name='city'><option>Loading...</option></select>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="getcity.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	if(city !='')
	{
	url=url+"&city="+city;	
	}
	//url=url+"&city="+
    
    //alert(url);
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}



function showSpeciality(str)
{
	
    if(str == '')
	{
		document.getElementById("txtProfessionID").innerHTML="<select name='subCatId' style='width:220px;' class='textfield'><option value=''>--Select One--</option></select>";	
	}
	else
	{
		document.getElementById("txtProfessionID").innerHTML="<select name='subCatId' class='text_box'><option>Loading...</option></select>";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
	 	  alert ("Browser does not support HTTP Request")
	 	  return
	 	}
		var url="getSpeciality.php";
		url=url+"?catID="+str;
		xmlHttp.onreadystatechange=stateChanged2;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function showSpeciality1(str)
{
		if(str == '')
		{
			document.getElementById("txtProfessionID").innerHTML="<select name='subCatId' style='width:220px;' class='textfield'><option value=''>--Select One--</option></select>";	
		}
		else
		{
			document.getElementById("txtProfessionID").innerHTML="<select name='subCatId'><option>Loading...</option></select>";
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			  alert ("Browser does not support HTTP Request")
			  return
			}
			var url="getSpeciality1.php";
			url=url+"?catID="+str;
			xmlHttp.onreadystatechange=stateChanged2;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
}

function showSpeciality2(str, subcateg)
{
		document.getElementById("txtProfessionID").innerHTML="<select name='subCatId' class='text_box'><option>Loading...</option></select>";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
	 	   alert ("Browser does not support HTTP Request");
	 	   return
	 	}
		var url="getSpeciality2.php";
		url=url+"?catID="+str+"&subcat="+subcateg;
		xmlHttp.onreadystatechange=stateChanged2;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

function showSpeciality3(str)
{

		document.getElementById("txtProfessionID").innerHTML="<select name='subCatId' class='text_box'><option>Loading...</option></select>";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
	 	  alert ("Browser does not support HTTP Request")
	 	  return
	 	}
		var url="../getSpeciality.php";
		url=url+"?catID="+str;
		xmlHttp.onreadystatechange=stateChanged2;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}



function subFeild(str)
{
//		alert("viuney");
//		return false;

		document.getElementById("txtProfessionID").innerHTML="<select name='subFieldID' class='text_box'><option>Loading...</option></select>";
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
	 	  alert ("Browser does not support HTTP Request")
	 	  return
	 	}
		var url="getSubField.php";
		url=url+"?fieldID="+str;
		xmlHttp.onreadystatechange=stateChanged2;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

function subFeild1(str)
{
//        alert("viuney");
//        return false;

        document.getElementById("txtProfessionID").innerHTML="<select name='subFieldID' class='text_box' id='subCatId'><option>Loading...</option></select>";
        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
         {
           alert ("Browser does not support HTTP Request")
           return
         }
        var url="../getSubField.php";
        url=url+"?fieldID="+str;
        xmlHttp.onreadystatechange=stateChanged2;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
}









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;
}

function stateChanged2() 
{ 
//alert(xmlHttp.responseText);
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
   // alert(xmlHttp.responseText);
    document.getElementById('txtProfessionID').innerHTML=xmlHttp.responseText 
 } 
}


function stateChanged3() 
{ 
     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
     { 
        //alert(xmlHttp.responseText);
        var str =  xmlHttp.responseText;
        if(str != "")
         {
            var arrStr = str.split("&");
            document.getElementById('title').value = arrStr[0];
            document.getElementById('desc').value = arrStr[1];
            document.getElementById('keyword').value = arrStr[2];     
         }
         else
         {
            var arrStr = str.split("&");
            document.getElementById('title').value = "";
            document.getElementById('desc').value = "";
            document.getElementById('keyword').value = "";         
         }
     } 
}

function showCityAdmin(str,city)
{
    //document.getElementById("txtCity").innerHTML="<select name='city' id='city' class='text_box'><option>Loading...</option></select>"
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
     {
     alert ("Browser does not support HTTP Request")
     return
     }
    var appNav = navigator.appName;
	if(appNav == "Microsoft Internet Explorer")
	{
		var url="getadmincity.php"
	    url=url+"?q="+str+"&op=ie"
	    xmlHttp.onreadystatechange=stateIEChanged 
	    xmlHttp.open("GET",url,true)
	    xmlHttp.send(null)
    }
	else
    {
		var url="getadmincity.php"
		url=url+"?q="+str
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}		

}



function stateIEChanged() 
{ 
  //alert('Vineet');
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    //alert(xmlHttp.responseText)
     document.getElementById("txtCitys").innerHTML=xmlHttp.responseText 
  } 
}





function showSpecialities(thisValue)
{
    if(document.getElementById('professionId').value != '')
    {
        showSpeciality4(thisValue); 
    } 
}
function showSpeciality4(str)
{
        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
         {
           alert ("Browser does not support HTTP Request")
           return
         }
        var url="getSpeciality.php";
        url=url+"?catID="+str;
        xmlHttp.onreadystatechange=stateChangedMetaData;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
}
//CODE ADDED BY VINEET
function showAdminSpecialities(thisValue)
{
    if(document.getElementById('professionId').value != '')
    {
        showAdminSpeciality4(thisValue); 
    } 
}
function showAdminSpeciality4(str)
{
        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
         {
           alert ("Browser does not support HTTP Request")
           return
         }
        
		var appNav = navigator.appName;
	    if(appNav == "Microsoft Internet Explorer")
	    {
			var url="getAdminSpeciality.php";
	        url=url+"?catID="+str+"&op=ie";
	        xmlHttp.onreadystatechange=stateChangedIEMetaData;
	        xmlHttp.open("GET",url,true);
	        xmlHttp.send(null);
        }
		else
		{
			var url="getAdminSpeciality.php";
	        url=url+"?catID="+str;
	        xmlHttp.onreadystatechange=stateChangedMetaData;
	        xmlHttp.open("GET",url,true);
	        xmlHttp.send(null);
		}
}


function stateChangedIEMetaData() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
    document.getElementById('txtProfessionIDs').innerHTML=xmlHttp.responseText;
    showContent(); 
 } 
}

//END
function showContent()
{
    if(document.getElementById('state').value != '' && document.getElementById('txtCity').value != '' && document.getElementById('professionId').value != '')
    {
        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
         {
         alert ("Browser does not support HTTP Request")
         return false;
         }
        var url="getContent.php"
        url=url+"?state_seo="+document.getElementById('state').value
        url=url+"&city_seo="+document.getElementById('txtCity').value
        url=url+"&category_seo="+document.getElementById('professionId').value
        url=url+"&service_seo="+document.getElementById('txtProfessionID').value
        xmlHttp.onreadystatechange=stateChanged3 
        xmlHttp.open("GET",url,true)
        xmlHttp.send(null)    
    }
}


function stateChangedMetaData() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
    document.getElementById('txtProfessionID').innerHTML=xmlHttp.responseText;
    showContent(); 
 } 
}

function showCitySeo(str,city)
{
   //alert(str+'--'+city); return false;
    document.getElementById("txtCity").innerHTML="<select name='city'><option>Loading...</option></select>"
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
         alert ("Browser does not support HTTP Request")
         return
    }
    var url="getcity_new.php"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    if(city !='')
    {
        url=url+"&city="+city;    
    }
    //url=url+"&city="+
    
    //alert(url);
    xmlHttp.onreadystatechange=stateChanged 
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function stateChanged() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    document.getElementById("txtCity").innerHTML=xmlHttp.responseText 
  } 
} 
function privewDetails(frm)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
    {
    	 alert ("Browser does not support HTTP Request");
     	 return;
     }
	
	var pars       =  Form.serialize( frm );
    var url        = 'preview_upgrade_data.php';
	var url        =  url+'?type=preview&rand='+Math.random();
    /*xmlHttp.onreadystatechange=textSearchResponseUpgrade 
    xmlHttp.open("post",url,true)
    xmlHttp.send(null)*/
	var myAjax     =  new Ajax.Request( url, {method: 'post', parameters: pars, onComplete: textSearchResponseUpgrade} );
}
function textSearchResponseUpgrade (originalRequest) 
{
    //window.open('preview_popup.php','popupWindow');
   if (originalRequest)
  {
    //alert(originalRequest.responseText);
	//$varPost = originalRequest.responseText; 
    window.open('preview_upgrade.php','popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=950,height=700,screenX=50,screenY=50,top=50,left=50');
  }
    
}

