

var $js = jQuery.noConflict();


function loadProgressCountry(element){
	$js(element).html("<select class='text_area_1'><option value='' style='width:190px'>Country Loading....</option></select>");
}
function loadProgressCountryRight(element){
	$js(element).html("<select class='text_area_2' style='width:170px'><option value=''>Country Loading....</option></select>");
}
function loadProgressLocation(element){
	$js(element).html("<select class='text_area_1'><option value='' style='width:180px'>Country Loading....</option></select>");
}

function loadProgressSubType(element){
	$js(element).html("<select class='text_area_1'><option value='' style='width:180px'> Loading....</option></select>");
}

function loadProgressPrice(element){
	$js(element).html("<select id='SliderMaxPrice' name='SliderMaxPrice'  class='text_area_1' style='width:100px'><option value=''>Loading...</option></select>");
}

function mapProgress(element){
	$js(element).html("<div align=center><img src='http://www.buypropertyanywhere.ru/images/loading.gif' border='0' ></div>");
}

function getAjaxCountry(){ 
	loadProgressCountry("#ajaxCountryBox");
	$js("#ajaxCountryBox").show(); 
	$js.post("http://www.buypropertyanywhere.ru/ajaxcountrylist.php", { }, function(data){
    $js("#ajaxCountryBox").html(data);
  }) 
} 

function getAjaxCountryRight(countryId){ 
	loadProgressCountryRight("#ajaxFilterSearchCountry");
	$js("#ajaxFilterSearchCountry").show(); 
	$js.post("http://www.buypropertyanywhere.ru/ajaxcountrysearchpage.php", {selcountryId : countryId}, function(data){
    $js("#ajaxFilterSearchCountry").html(data);
  }) 
} 

function getRegions(countryIds,pTypeOpt){ 
	//$js('#location').removeAttr('disabled');
	//$js('#location').addClass('autosearch1 inpt');
	loadProgressLocation("#regionTableAjax1");
	$js("#regionTableAjax1").show(); 
	$js.post("http://www.buypropertyanywhere.ru/frameregion.php", {countryIds : countryIds}, function(data){
    $js("#regionTableAjax1").html(data);
	})
}

function getRegionsLeft(countryIds,locationid) {
	loadProgressLocation("#ajaxFilterLocation");
	$js("#ajaxFilterLocation").show(); 
	$js.post("http://www.buypropertyanywhere.ru/leftregion.php", {countryIds : countryIds,locationid : locationid}, function(data){
    $js("#ajaxFilterLocation").html(data);
	})
}

function getAjaxPropType(countryID,locationarea)
{
	loadProgressSubType("#ajaxSubType");
	$js("#ajaxSubType").show(); 
	$js.post("http://www.buypropertyanywhere.ru/ajax_proptype.php", {countryID : countryID,locationarea : locationarea}, function(data){
    $js("#ajaxSubType").html(data);
	})
}

function getToPrice(frompriceIds, dVal)
{
	loadProgressPrice("#PriceTableAjax");
	$js("#PriceTableAjax").show(); 
	$js.post("http://www.buypropertyanywhere.ru/fromprice.php", {frompriceIds : frompriceIds,dVal : dVal}, function(data){
    $js("#PriceTableAjax").html(data);
	})
}

function sendValueReg(myObj)
{
	$js("#map_canvas").show(); 
	var myObj1 = $js("#searchCountry").val();
	$js.post("http://www.buypropertyanywhere.ru/mapInfo.php", {countryId : myObj1,regionId : myObj}, function(data){
	initialize();
    var spliRes = data.split("###");
	var len = spliRes.length
	for(i=0; i< (len-1); i++){
		var args = spliRes[i].split("@@@");
		showAddressListForRegion(args[0], args[1], args[2], args[3], args[4], 9, args[5], args[6], args[7]);
	}
	})
}

function sendValueCity(myObj, regID)
{
	var New = $js('select.searchCountry option:selected').val();
	var myObj1 = $js("#searchCountry").val();
	$js("#map_canvas").show(); 
	$js.post("http://www.buypropertyanywhere.ru/mapInfo.php", {countryId : myObj1,regionId : regID,cityId : myObj}, function(data){
	initialize();
	var spliRes = data.split("###");
	var len = spliRes.length
	for(i=0; i< (len-1); i++){
		var args = spliRes[i].split("@@@");
		showAddress(args[0], args[1], args[2], args[3], args[4], 11);
	}
	})
}

function sendValue(myObj,langs)
{
	mapProgress("#map_canvas");
	$js("#map_canvas").show(); 
	$js.post("http://www.buypropertyanywhere.ru/mapInfo.php", {countryId : myObj , langs : langs }, function(data){
	initialize();
	var spliRes = data.split("###");
	var len = spliRes.length
	for(i=0; i< (len-1); i++){
		var args = spliRes[i].split("@@@");
		showAddressList(args[0], args[1], args[2], args[3], args[4], 6, args[5], args[6]);
	}
    })
}

function sendLocation(locationvalues)
{
	explocation = locationvalues.split(",");
	loctype = explocation[0];
	locreg = explocation[1];
	loccity = explocation[2];
	loccount = explocation[3];
	if(loctype == "1")
		sendValueReg(locreg);	
	if(loctype == "0")
		sendValueCity(loccity,locreg);
}

function initialize() {
	if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	geocoder = new GClientGeocoder();
	}
}

function searchvalid()
{
	var countryId = $js("#searchCountry").val();
	if(countryId == "")
	{	
		alert("Please Select Country ");
		$js("#searchCountry").focus();
		return false ;
	}
}

function countryalert()
{
	var countryId = $js("#searchCountry").val();
	if(countryId == "")
	{	
		alert("Please Select Country ");
		document.getElementById('location').value = "";
	}
}
