

function I(el)
{
	return document.getElementById(el);
}


$("#see_more_div").livequery(function()
{
	$(this).click(function()
	{ 
		var status = I("hideShow_div").style.display;
		if(status == "none")
		{
			I("hideShow_div").style.display = "block";
			I("top_search_btn").style.display = "none";
			I("bottom_search_btn").style.display = "block";
	
			I("search_label_t").innerHTML = "<img src="+this_domain+"/images/common/m.gif>&nbsp;Hide more search options";

		}
		else
		{
			I("hideShow_div").style.display = "none";
			I("top_search_btn").style.display = "block";
			I("bottom_search_btn").style.display = "none";
			I("search_label_t").innerHTML = "<img src="+this_domain+"/images/common/p.gif>&nbsp;See more search options";
		}
	});
});	


function getImgWidth(imgSrc)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	//var height = newImg.height;
	var width = newImg.width;
	return width;
}

	
/*$('#main_cat_tabs').click(function()
{	
	var cat_id = $("#cat_id").val();
	alert(cat_id);
	$.get(this_domain + '/body/ajax_cat.php', {selector:selector,ptype:"ajax"}, 
	
		function(str) 
		{
			
		$("#secondTabContent").html(str);});

});*/


function newCat(val,p, el)
{
		$("#cat_tabs span").removeClass();
		$(el).parents("span").addClass("current");
		
		var load_image = "<img style='margin:80px 0 20px 48%;' src='" + this_domain + "/images/common/loading1.gif' />";
        I("cat_div_1").innerHTML = load_image;
		
	 	cat_id = val;
		$.get(this_domain + '/body/main/ajax_cat.php', {cat_id:cat_id,purpose:p},
		function(str)
		{
			$("#cat_div_1").html(str);
		});
}


function showPriceText(a){var b=document.getElementsByTagName("input");var c;if(a){c=a}else{for(k=0;k<b.length;k++){if(b[k].getAttribute("name")=="prices")c=b[k]}}if(isNaN(c.value)){showprice="<font color=\"red\">Price must contain numbers only</font>"}else{showprice=getPriceText(c.value)}document.getElementById("stext").innerHTML=showprice}
function getPriceText(a){retText="";a=a+"";price_array=a.split(",");price_length=price_array.length;a="";for(i=0;i<price_length;i++){a+=price_array[i]}a=number_format(a,0,"","");lprice=a.length;if(a==0){retText+="Price should be greater than '0'"}else{if(lprice>=12){retText+="Price is too big. Please contact us"}else if(lprice==11){retText+=a.substr(0,2);retText+=" Billion ";if(a.substr(2,1)!="0")retText+=a.substr(2,3)+" Million ";if(a.substr(2,1)=="0"&&a.substr(3,1)!="0")retText+=a.substr(3,2)+" Million ";if(a.substr(2,1)=="0"&&a.substr(3,1)=="0"&&a.substr(4,1)!="0")retText+=a.substr(4,1)+" Million "}else if(lprice==10){retText+=a.substr(0,1);retText+=" Billion ";if(a.substr(1,1)!="0")retText+=a.substr(1,3)+" Million ";if(a.substr(1,1)=="0"&&a.substr(2,1)!="0")retText+=a.substr(2,2)+" Million ";if(a.substr(1,1)=="0"&&a.substr(2,1)=="0"&&a.substr(3,1)!="0")retText+=a.substr(3,1)+" Million "}else if(lprice==9){retText+=a.substr(0,3)+" Million ";if(a.substr(3,1)!="0")retText+=a.substr(3,3)+" Thousand";if(a.substr(3,1)=="0"&&a.substr(4,1)!="0")retText+=a.substr(4,2)+" Thousand";if(a.substr(3,1)=="0"&&a.substr(4,1)=="0"&&a.substr(5,1)!="0")retText+=a.substr(5,1)+" Thousand"}else if(lprice==8){retText+=a.substr(0,2);if(a.substr(2,3)=="00")retText+=" Million ";if(a.substr(2,3)!="00")retText+=" Million ";if(a.substr(2,2)!="00"&&a.substr(2,1)=="0")retText+=a.substr(3,2)+" Thousand";if(a.substr(2,2)!="00"&&a.substr(2,1)!="0")retText+=a.substr(2,3)+" Thousand"}else if(lprice==7){retText+=a.substr(0,1);retText+=" Million ";if(a.substr(1,1)!="0")retText+=a.substr(1,3)+" Thousand";if(a.substr(1,1)=="0"&&a.substr(2,1)!="0")retText+=a.substr(2,2)+" Thousand";if(a.substr(1,1)=="0"&&a.substr(2,1)=="0"&&a.substr(3,1)!="0")retText+=a.substr(3,1)+" Thousand"}else if(lprice==6){retText+=a.substr(0,1)+" Hundred";if(a.substr(1,2)=="00")retText+=" Thousand";if(a.substr(1,2)!="00"&&a.substr(1,1)!="0")retText+=" "+a.substr(1,2)+" Thousand";if(a.substr(1,2)!="00"&&a.substr(1,1)=="0")retText+=" "+a.substr(2,1)+" Thousand"}else if(lprice==5){if(a.substr(0,2)!="00"&&a.substr(0,1)!="0")retText+=a.substr(0,2)+" Thousand";if(a.substr(0,1)=="0"&&a.substr(1,1)!="0")retText+=a.substr(1,1)+" Thousand"}else if(lprice==4){if(a.substr(0,1)!="0"&&a.substr(0,2)!="00")retText+=a.substr(0,1)+" Thousand"}else if(lprice<=3){retText+=a}if(lprice<12)retText+=""}return retText}
function number_format(a,b,c,d){a=Math.round(a*Math.pow(10,b))/Math.pow(10,b);e=a+'';f=e.split('.');if(!f[0])f[0]='0';if(!f[1])f[1]='';if(f[1].length<b){g=f[1];for(i=f[1].length+1;i<=b;i++){g+='0'}f[1]=g}if(d!=''&&f[0].length>3){h=f[0];f[0]='';for(j=3;j<h.length;j+=3){i=h.slice(h.length-j,h.length-j+3);f[0]=d+i+f[0]+''}j=h.substr(0,(h.length%3==0)?3:(h.length%3));f[0]=j+f[0]}c=(b<=0)?'':c;return f[0]+c+f[1]}










function getsearchsubType(selectedsubtype)
{	
	type = document.getElementById("type").value;
	//_domain = this_domain;
	//_domain = _domain + "/includes/subtype.php?";
	//_domain += "type="+type;
	
	$.get(this_domain + '/body/landlord/subtype.php', {type:type},
	function(str)
	{
		$("#subtype_area").html(str);
	});
} ////End of Function


function getsubType(selectedsubtype,selected)
{	
	type = selectedsubtype;
	subtype = selected;
	//_domain = this_domain;
	//_domain = _domain + "/includes/subtype.php?";
	//_domain += "type="+type;

	$.get(this_domain + '/body/landlord/subtype.php', {type:type,subtype:subtype},
	function(str)
	{
		
		$("#subtype_area").html(str);
	});
} ////End of Function