// JavaScript Document
function forsale()
{
	submitOK="true";
	var category1=document.getElementById("category_residential").value;
	var category2=document.getElementById("category_commercial").value;
	var location=document.getElementById("location").value;
	var description=document.getElementById("description").value;
	var min_price=document.getElementById("minprice").value;
	var max_price=document.getElementById("maxprice").value;
	var image=document.getElementById("image").value;
		
	 	if (category1==0 || category2==0 ) 
		{
	  	alert("Select category");
	 	document.getElementById("category_residential").focus();
 	 	submitOK="false";
 		}
		
		else if(location==0)
				{
				alert("Select location");
	 			document.getElementById("location").focus();
 	 			submitOK="false";
				}
		
		else if(description=="")
				{
				alert("Fill description aboout your property");
	 			document.getElementById("description").focus();
 	 			submitOK="false";
				}
					
		else if(min_price==0)
				{
				alert("Select minimum budget");
	 			document.getElementById("minprice").focus();
 	 			submitOK="false";
				}
				
		else if(max_price==0)
				{
				alert("select maximum budget");
	 			document.getElementById("maxprice").focus();
 	 			submitOK="false";
				}
		else if(image!="")
				{
				var file =image;
						var mime = file.substr(file.lastIndexOf('.'));
						if (mime!= '.gif' && mime!= '.jpg' && mime!= '.bmp' && mime!= '.png' && mime!= '.jpeg')
						{
						alert("wrong file extension,Select image file");
						document.getElementById("image").focus();
						submitOK="false";
						}
				}		
				
			
	////////////////////////
		if (submitOK=="false")
 		{
 		return false;
 		}
	//////////////////////////		
	
}

//function for property lease..........


function forlease()
{
	submitOK="true";
	var category1=document.getElementById("cat_lease_residential").value;
	var category2=document.getElementById("cat_lease_commercial").value;
	var location=document.getElementById("location_lease").value;
	var description=document.getElementById("description_lease").value;
	var min_price=document.getElementById("minprice_lease").value;
	var max_price=document.getElementById("maxprice_lease").value;
	var image=document.getElementById("image_lease").value;
		
	 	if (category1==0 ) 
		{
	  	alert("Select category");
	 	document.getElementById("cat_lease_residential").focus();
 	 	submitOK="false";
 		}
		
		else if(location==0)
				{
				alert("Select location");
	 			document.getElementById("location_lease").focus();
 	 			submitOK="false";
				}
		
		else if(description=="")
				{
				alert("Fill description aboout your property");
	 			document.getElementById("description_lease").focus();
 	 			submitOK="false";
				}
					
		else if(min_price==0)
				{
				alert("Select minimum budget");
	 			document.getElementById("minprice_lease").focus();
 	 			submitOK="false";
				}
				
		else if(max_price==0)
				{
				alert("select maximum budget");
	 			document.getElementById("maxprice_lease").focus();
 	 			submitOK="false";
				}
		else if(image!="")
				{
				var file =image;
						var mime = file.substr(file.lastIndexOf('.'));
						if (mime!= '.gif' && mime!= '.jpg' && mime!= '.bmp' && mime!= '.png' && mime!= '.jpeg')
						{
						alert("wrong file extension,Select image file");
						document.getElementById("image_lease").focus();
						submitOK="false";
						}
				}		
				
			
	////////////////////////
		if (submitOK=="false")
 		{
 		return false;
 		}
	//////////////////////////		
	
}



//function for property freehold..........


function forfreehold()
{
	submitOK="true";
	var category1=document.getElementById("cat_freehold_residential").value;
	var category2=document.getElementById("cat_freehold_commercial").value;
	var location=document.getElementById("location_freehold").value;
	var description=document.getElementById("description_freehold").value;
	var min_price=document.getElementById("minprice_freehold").value;
	var max_price=document.getElementById("maxprice_freehold").value;
	var image=document.getElementById("image_freehold").value;
		
	 	if (category1==0 ) 
		{
	  	alert("Select category");
	 	document.getElementById("cat_freehold_residential").focus();
 	 	submitOK="false";
 		}
		
		else if(location==0)
				{
				alert("Select location");
	 			document.getElementById("location_freehold").focus();
 	 			submitOK="false";
				}
		
		else if(description=="")
				{
				alert("Fill description aboout your property");
	 			document.getElementById("description_freehold").focus();
 	 			submitOK="false";
				}
					
		else if(min_price==0)
				{
				alert("Select minimum budget");
	 			document.getElementById("minprice_freehold").focus();
 	 			submitOK="false";
				}
				
		else if(max_price==0)
				{
				alert("select maximum budget");
	 			document.getElementById("maxprice_freehold").focus();
 	 			submitOK="false";
				}
		else if(image!="")
				{
				var file =image;
						var mime = file.substr(file.lastIndexOf('.'));
						if (mime!= '.gif' && mime!= '.jpg' && mime!= '.bmp' && mime!= '.png' && mime!= '.jpeg')
						{
						alert("wrong file extension,Select image file");
						document.getElementById("image_freehold").focus();
						submitOK="false";
						}
				}		
				
			
	////////////////////////
		if (submitOK=="false")
 		{
 		return false;
 		}
	//////////////////////////		
	
}













function search_property()
{
	document.searchform.action="search.php";
  document.searchform.submit();
}

//large image
function show_it(){
document.all.box1.style.visibility = "visible";
}

function hide_it(){
document.all.box1.style.visibility = "hidden"

}
//.......................

//image large size...........................

var horizontal_offset="6px" //horizontal offset of hint box from anchor link

var vertical_offset="-10px" //horizontal offset of hint box from anchor link. No need to change.

var ie=document.all

var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype)
{
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;

while (parentEl!=null)
{
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;}
return totaloffset;
}

function iecompattest()
	{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	

function clearbrowseredge(obj, whichedge)
{
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge")
	{
	var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.		innerWidth-40
	
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
//alert(dropmenuobj.contentmeasure);

if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else
	{
	var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}




function showhint(menucontents, obj, e, tipwidth)
{
if ((ie||ns6) && document.getElementById("hintbox"))
{
dropmenuobj=document.getElementById("hintbox")
menucontents="<div id=new_>"+ menucontents +"</div>"

dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500

if (tipwidth!="")
	{
	dropmenuobj.widthobj=dropmenuobj.style
	dropmenuobj.widthobj.width=tipwidth
	}
	
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")

dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"

dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"

dropmenuobj.style.visibility="visible"
obj.onblur=hidetip
}
}

function hidetip()
{
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function onloadEvents()
	{
	createhintbox();
	//document.getElementById("seekername").focus();
	}
	
	function createhintbox()
	{
	var divblock=document.createElement("div")
	divblock.setAttribute("id", "hintbox")
	document.body.appendChild(divblock)
	}
	
	
	
	
	//ajax....................................................
	
	
var xmlHttp

function getCommunity(str)
{ 


if(str==4)
{
var temp3=document.doublecombo.currency;
temp3.options[0]=new Option("Qatar Riyal","1")
temp3.options[1]=new Option("AED","2")
}
else
	{
	var temp3=document.doublecombo.currency;
	temp3.options[0]=new Option("AED","2")
	temp3.options[1]=new Option("Qatar Riyal","1")
	
	}


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var table=document.getElementById("rent").value; 
var url="getcommunity2.php"
url=url+"?q="+str+"&t="+table
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET","./manager/"+url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 
 
 } 
}
	
	
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 changeCurrency(locationID)
{
var temp3=document.form1.currency;
temp3.options[0]=new Option("Qatar Riyal","1")
temp3.options[1]=new Option("AED","2")
}









//remove imahge
var xmlHttp

function remove_image(str,to,type)
{ 

i=new Array("txtHint",to);

i=i.join(".");


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="remove_image.php"
url=url+"?q="+str+"&to="+to+"&type="+type
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 

	var ch;
	ch=window.confirm("Do you want to remove this image ?");
	if(ch==true)
	{
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}


function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(i).innerHTML=xmlHttp.responseText 
 
 
 } 
}
	
	
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;
}		


///////////////////////////////////////////////

//////////////////////////////change image....................

function change_image(str,to,type)
{
var url="change_image.php"
url=url+"?q="+str+"&to="+to+"&type="+type	
location=url;	
}

function add_image(str,to,type)
{
var url="change_image.php"
url=url+"?q="+str+"&to="+to+"&type="+type	
location=url;	
}








