var $jg = jQuery.noConflict();
function loadProgressaCountry(element){
$jg(element).html("<select class='textareacountry'><option value=''>Loading....</option></select>");
}

function loadProgressa(element){
$jg(element).html("<select class='textarearegion'><option value=''>Loading....</option></select>");
}

function ajax_pull_country(CID){ 
	loadProgressaCountry("#ajaxCountryBox");
  $jg("#ajaxCountryBox").show(); 
  $jg.post("http://www.rentpropertyanywhere.com/ajax/ajax-get-country.php", {countryIds : CID}, function(data){
     $jg("#ajaxCountryBox").html(data);
  }) 
} 

function ajax_pull_region(CID){ 
	loadProgressa("#ajaxRegionBox");
	$jg("#ajaxRegionBox").show();  
	$jg.post("http://www.rentpropertyanywhere.com/ajax/ajax-get-region.php", {countryIds : CID}, function(data){
    $jg("#ajaxRegionBox").html(data);
  }) 
} 

function ajax_pull_city(cityIds){ 
loadProgressa("#ajaxCityBox");
  $jg("#ajaxCityBox").show(); 
  $jg.post("http://www.rentpropertyanywhere.com/ajax/ajax-get-city.php", {regionIds : cityIds}, function(data){
     $jg("#ajaxCityBox").html(data);
  }) 
}

function getAjaxPropType(Cid){ 
loadProgressa("#ajaxSubType");
  $jg("#ajaxSubType").show(); 
  $jg.post("http://www.rentpropertyanywhere.com/ajax/ajax_proptype.php", {CID : Cid}, function(data){
     $jg("#ajaxSubType").html(data);
  }) 
}

function loadProgressaPrice(element){
$jg(element).html("<select class='textareaprice'><option value=''>Loading...</option></select>");
}
function getToPrice(fromPriceIds, toPriceId){ 
loadProgressaPrice("#PriceTableAjax");
  $jg("#PriceTableAjax").show(); 
  $jg.post("http://www.rentpropertyanywhere.com/ajax/fromprice.php", {fromPriceIds : fromPriceIds, toPriceId : toPriceId}, function(data){
     $jg("#PriceTableAjax").html(data);
  }) 
} 

function sort_function(val){
	if(val!=""){
	  document.myform.submit();

	}
}

$jg(function() {

	$jg( "#available_from,#available_to" ).datepicker({
			changeMonth: true,
			changeYear: true,
			showButtonPanel: true
	});
	
	$jg("#arrival_date,#available_to").datepicker({		
			changeMonth: true,
			changeYear: true,
			showButtonPanel: true
	});
	
	$jg("#departure_date").datepicker({
			changeMonth: true,
			changeYear: true,
			showButtonPanel: true
	});

	$jg("#contact-adate,#contact-ddate").datepicker({
		changeMonth: true,
		changeYear: true,
		showButtonPanel: true
	});	

	$jg("#fromrate,#torate").datepicker({		
		changeMonth: true,
		changeYear: true,
		showButtonPanel: true
	});	

});

function mapProgress(){
	document.getElementById("map_canvas").innerHTML = "<div align=center><img src='{{http_path}}images/loading_m.gif' border='0' ></div>";	
}

var map = null;
var geocoder = null;

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

function showDetailMap(myObj){ 	
  $jg.post("http://www.rentpropertyanywhere.com/mapInfo1.php", {pId : myObj}, function(data){
	  initialize();
		var spliRes = data.split("###");
		var len = spliRes.length;
		//alert(data);
		for(i=0; i<(len-1); i++){
			var args = spliRes[0].split("@@@");
			showAddressDetail(args[0], args[1], args[2], args[3], args[4], 11);

		}
     
  }) 
}

function popup(url,wi,hi){
	
	newWindow = window.open(url,'daughter','menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=no,width='+wi+',height='+hi+',screenX=100,screenY=100,top=250,left=50');
	if (newWindow.opener == null) newWindow.opener = self;
	newWindow.focus();
}

function valid(){
	var c = document.getPrice;
	if(c.arrival_date.value == "")
	{
		alert("Please Select From Date....");
		c.arrival_date.focus();
		return false;
	}
	if(c.departure_date.value == "")
	{
		alert("Please Select To Date....");
		c.departure_date.focus();
		return false;
	}
	
return true;
}

function caloff(obj){
	if(obj == 1)
	document.getElementById('deptBox').style.display="block";
	else
	document.getElementById('deptBox').style.display="none";
}

function vali(){
	var c = document.getPrice;
	
	if(c.adults.value == "" || c.adults.value == "0")
	{
		alert("Please enter No.of Adults....");
		c.adults.focus();
		return false;
	}
	if(c.firstName.value == "")
	{
		alert("Please enter first name....");
		c.firstName.focus();
		return false;
	}
	if(c.lastName.value == "")
	{
		alert("Please enter last name....");
		c.lastName.focus();
		return false;
	}

	if(c.address1.value == "")
	{
		alert("Please enter your address....");
		c.address1.focus();
		return false;
	}
	if(c.country.value == "")
	{
		alert("Please select your country....");
		c.country.focus();
		return false;
	}
	if(c.state.value == "")
	{
		alert("Please enter your state/county....");
		c.state.focus();
		return false;
	}
	if(c.city.value == "")
	{
		alert("Please enter your city/town....");
		c.city.focus();
		return false;
	}
	if(c.zip.value == "")
	{
		alert("Please enter your postcode....");
		c.zip.focus();
		return false;
	}
return true;
}

function hidedivpass()
{
	if(document.getElementById("fdiv").style.display == "block")
	{
		document.getElementById("fdiv").style.display = "none";
		document.getElementById("Forgoterrordiv").style.display = "none";
	}
	else {
		document.getElementById("fdiv").style.display = "block";
		//document.getElementById("confmessage").style.display = "none";
		document.getElementById("femail").value="";
		document.getElementById("Forgoterrordiv").style.display = "none";
	}
}

function lerrdiv()
{
	document.getElementById("Loginerrordiv").style.display = "none";
}

function ferrdiv()
{
	document.getElementById("Forgoterrordiv").style.display = "none";
}

function rerrdiv()
{
	document.getElementById("errordiv").style.display = "none";
}

function perrdiv()
{
	document.getElementById("propErrordiv").style.display = "none";
}

function fileerrdiv()
{
	document.getElementById("propFileErrordiv").style.display = "none";
}

function verrdiv()
{
	document.getElementById("VendorErrordiv").style.display = "none";
}
function memdiv()
{
	document.getElementById("memerrordiv").style.display = "none";
}

