
var cityid=0;
var cityname;	
var subcatid=0;
var subcatename;
var url = "http://estate99.net/StateCity.asmx";

var ctrl1;
var idcity;
var idsubcate;

 function Redirect()
   {
   //navigate("http://www.estate99.net/");
   window.location.href="http://www.estate99.net/";
   }
function showLoading(ctrl)
{
while (document.getElementById(ctrl).options.length) 
            {
				 document.getElementById(ctrl).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl).options[document.getElementById(ctrl).options.length]=opt; 
}

function fillcityid(aid,ctrl)
{
   ctrl1=ctrl; 
   if(aid > 0)
      {
   while (document.getElementById(ctrl1).options.length) 
            {
				 document.getElementById(ctrl1).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
	    var pl = new SOAPClientParameters();
	    pl.add("ContryID",aid);
    
	    SOAPClient.invoke(url, "GetCityByCountry", pl, true, HandleGetRequest);
   }
   else
    {  while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}		
     opt=new Option("Select City",0);        // add select city to the dropdown
    document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
  }
}


function getcityid(aid,ctrl)
{
    if(aid > 0)
    document.getElementById(ctrl).value=aid;   
  }
function HandleGetRequest(ms)
{
	 while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}
			opt=new Option("Select City",0);
			document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
    for(var i=0; i< ms.length; i++)
	{
		cityid=ms[i].CityId;		
		cityname = ms[i].CityName;
		opt=new Option(cityname,cityid);
		document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
	}
}
/* --------------------------------function for fill city name only-----------------*/
function fillcityname(aid,ctrl)
{
   ctrl1=ctrl; 
   if(aid > 0)
      {
   while (document.getElementById(ctrl1).options.length) 
            {
				 document.getElementById(ctrl1).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
	    var pl = new SOAPClientParameters();
	    pl.add("ContryID",aid);
    
	    SOAPClient.invoke(url, "GetCityByCountry", pl, true, HandleGetRequestname);
   }
   else
    {  while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}		
     opt=new Option("Select City",0);        // add select city to the dropdown
    document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
  }
}


function getcityname(aid,ctrl)
{
    
    if(aid > 0)
   
    document.getElementById(ctrl).value=aid;   
  }
function HandleGetRequestname(ms)
{
	 while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}
			opt=new Option("Select City",0);
			document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
    for(var i=0; i< ms.length; i++)
	{
		cityid=ms[i].CityName;		
		cityname = ms[i].CityName;
		opt=new Option(cityname,cityid);
		document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
	}
}
/*---------------------------------- end fill city name only ------------------------*/

function fillbudget(aid,ctrl)
{
   ctrl1=ctrl; 
   if(aid > 0)
      {
   while (document.getElementById(ctrl1).options.length) 
            {
				 document.getElementById(ctrl1).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
	    var pl = new SOAPClientParameters();
	    pl.add("ContryID",aid);
    
	    SOAPClient.invoke(url, "GetBudgetbyCountry", pl, true, HandleGetRequest1);
   }
   else
    {  while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}		
     opt=new Option("Select Budget",0);        // add select city to the dropdown
    document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
  }
}

var Budid=0;
var Budname;
function HandleGetRequest1(ms)
{
	 while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}
			opt=new Option("Select Budget",0);
			document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
    for(var i=0; i<ms.length; i++)
	{
		Budid=ms[i].CityId;		
		Budname = ms[i].CityName;
		opt=new Option(Budname,Budid);
		document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
	}
}
/*-----------------------------------section start for property typeid Nature fill-------------------------------*/
function fillType(aid,ctrl)
{
   ctrl1=ctrl; 
   if(aid > 0)
      {
      		
        while (document.getElementById(ctrl1).options.length) 
            {
				 document.getElementById(ctrl1).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
	    var pl = new SOAPClientParameters();
	    pl.add("NatureID",aid);
    
	    SOAPClient.invoke(url, "GetPropTypeNature", pl, true, HandleGetRequest2);
   }
   else
    {  while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
	}
	
     opt=new Option("Select Type",0);        // add select city to the dropdown
    document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
  }
}
function gettype(aid,ctrl)
{
    if(aid > 0)
    document.getElementById(ctrl).value=aid;   
  }
var Typeid=0;
var Typename;
function HandleGetRequest2(ms)
{
	 while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}
			opt=new Option("Select Type",0);
			document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
    for(var i=0; i<ms.length; i++)
	{
		Typeid=ms[i].CityId;		
		Typename = ms[i].CityName;
		opt=new Option(Typename,Typeid);
		document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
	}
}
/*-----------------------------------section end for property type Nature fill-------------------------------*/
/*-----------------------------------section start for property typename Nature fill-------------------------------*/
function fillTypename(aid,ctrl)
{
   ctrl1=ctrl; 
   if(aid > 0)
      {
      		
        while (document.getElementById(ctrl1).options.length) 
            {
				 document.getElementById(ctrl1).options[0] = null;
			}	
        opt=new Option("Loading...",0);
        document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
	    var pl = new SOAPClientParameters();
	    pl.add("NatureID",aid);
    
	    SOAPClient.invoke(url, "GetPropTypeNature", pl, true, HandleGetRequest_2);
   }
   else
    {  while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
	}
	
     opt=new Option("Select Type",0);        // add select city to the dropdown
    document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
  }
}
function gettypename(aid,ctrl)
{
    if(aid != "Select Type")
    {
    //alert(aid.options[aid.selectedIndex].text);
    document.getElementById(ctrl).value=aid.options[aid.selectedIndex].value;   
    }
    else {alert("inside else : condition is not working - " + aid);}
  }
//function gettypename(aid,ctrl)
//{
//    if(aid != "Select Type")
//    document.getElementById(ctrl).value=aid;
//else alert("Please Select Type");   
//  }
var Typeid=0;
var Typename;
function HandleGetRequest_2(ms)
{
	 while (document.getElementById(ctrl1).options.length) {
				 document.getElementById(ctrl1).options[0] = null;
			}
			opt=new Option("Select Type",0);
			document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 	
    for(var i=0; i<ms.length; i++)
	{
		Typeid=ms[i].CityName;
		Typename = ms[i].CityName;
		opt=new Option(Typename,Typeid);
		document.getElementById(ctrl1).options[document.getElementById(ctrl1).options.length]=opt; 
	}
}
/*-----------------------------------section end for property type Nature fill-------------------------------*/
