//Imzee Ajax Tabs
var this_domain = document.domain;
if (this_domain.indexOf("192.") > -1) this_domain = this_domain + "/zameen";
if (typeof loadstatustext=='undefined') 
{	
	var loadstatustext="<img src='http://" + this_domain + "/javascript/ajax/loading.gif' />";
}

////NO NEED TO EDIT BELOW////////////////////////
var bustcacheparameter=""

function ajaxpage(url, containerid)
{      
	var page_request = false;
	try
    {
         
    // Firefox, Opera 8.0+, Safari
   		 page_request = new XMLHttpRequest();
    }
  	catch (e)
    {
    // Internet Explorer
    	try
      	{
      		page_request = new ActiveXObject("Msxml2.XMLHTTP");
      	}
    	catch (e)
      	{
      		try
        	{
        		page_request = new ActiveXObject("Microsoft.XMLHTTP");
        	}
      		catch (e)
        	{
        		alert("Your browser does not support AJAX!");
        		return false;
        	}
      	}
    }
	//Change inner html to loading message
	
	document.getElementById(containerid).innerHTML=loadstatustext;
	
	page_request.onreadystatechange=function()
	{
		
		loadpage(page_request, containerid)
	}
	if (typeof bustcachevar == 'undefined')
    {
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();	
	}	
	/*if (bustcachevar == undefined) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()*/
	
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

function ajaxpage_sub(url, containerid)
{
    var page_request = false;
    try
    {
    // Firefox, Opera 8.0+, Safari
            page_request = new XMLHttpRequest();
    }
      catch (e)
    {
    // Internet Explorer
        try
          {
              page_request = new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
              try
            {
                page_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
              catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
          }
    }
    //Change inner html to loading message
    
    document.getElementById(containerid).innerHTML=loadstatustext;
    
    page_request.onreadystatechange=function()
    {
        loadpage(page_request, containerid)
    }
    if (typeof bustcachevar == 'undefined')
    {
        bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();    
    }    
    /*if (bustcachevar == undefined) //if bust caching of external page
        bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()*/
    
    page_request.open('GET', url+bustcacheparameter, true)
    page_request.send(null)
}


function loadpage(page_request, containerid)
{
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{                                                  
		res = trim(page_request.responseText);
		if(containerid == "location" || containerid == "area" || containerid == "last")
		{
			j_obj = eval(res);
			lbl_count =  "lbl_" + containerid;
			sp_del =  "sp_" + containerid;
			document.getElementById(containerid).innerHTML = j_obj[0]["combo"];
			document.getElementById(lbl_count).innerHTML = "Total Listing: " + j_obj[0]["listing_count"];
			document.getElementById(sp_del).innerHTML = j_obj[0]["del_button"];
		}
		else if(containerid == "load_area")
		{
			j_obj = eval(res);
			document.getElementById("td_area1").innerHTML = j_obj[0]["area1"];
			document.getElementById("td_area2").innerHTML = j_obj[0]["area2"];
			document.getElementById("json_object").innerHTML = j_obj[0]["area_txt"];
			document.getElementById("load_area").innerHTML = "";
		}
		else if(res == "reload")
		{
			//window.location.href=window.location.href;
			document.small_search.submit();
		}
		else if(res.indexOf("add_fav") > -1)
		{
			add_fav = res.split(":");
			ajaxfav_listing(add_fav[1]);
			popUp();backgroundFilter();
			setTimeout(window.location.href=window.location.href,5000)
		}
		else
		{
			document.getElementById(containerid).innerHTML=page_request.responseText
		}
	}
}




////////////////////////////////////////////////////////////
function getMain(area)
{
	var mainValue=document.getElementsByTagName("select");
	var tempMain;

	for(var k=0; k < mainValue.length; k++)
	{
		if(mainValue[k].getAttribute('name') == "main")
		
				tempMain=mainValue[k];
	}
              
	city = tempMain.value;
	url = "http://"+this_domain+"/areadata.php?pid=";
	url += city;
	if(area != "")
	{
		url += "&area="+area;
	}
	          
	var mainDiv=document.getElementsByTagName("div");
	var tempDiv = "";
	for(var k=0;k<mainDiv.length;k++)
	{
		if(mainDiv[k].getAttribute('id') == "locationarea")
		
				tempDiv=mainDiv[k];

	
	}            
	if(tempDiv != "")
	{
       
		ajaxpage(url,tempDiv.id);
         
	}
}//End of Function

function getAgentListing(div_id,type,number_records,purpose,page,userid)
{
	_domain = this_domain;
	_domain = _domain + "/getAgentListing.php?";
	_domain = "http://"+_domain;
	_domain += "type="+type;
	_domain += "&number_records="+number_records;
	_domain += "&purpose="+purpose;
	_domain += "&page="+page;
	_domain += "&div_id="+div_id;
	_domain += "&userid="+userid;	
	var mainDiv=document.getElementsByTagName("div");
	var tempDiv = "";
	if(number_records == 10)
	{
		divheight = 260;
	}
	else if(number_records == 15)
	{
		divheight = 350;	
	}
	else if(number_records > 15)
	{
		divheight = 22 * number_records;	
	}
	else
	{
		divheight = 0;
	}
	for(var k=0;k<mainDiv.length;k++)
	{
		if(mainDiv[k].getAttribute('id') == div_id)
		{
			tempDiv=mainDiv[k];
			if(divheight != 0 && div_id != "recent_listings")
				document.getElementById(div_id).style.height = divheight;			
		}
	}
	if(tempDiv != "")
	{
		
		ajaxpage(_domain,div_id);
	}
}//End of Function

function getAjaxListings(div_id,type,subtype,list_order,number_records,purpose,page,userid,cat_id,view_order)
{    
     _domain = this_domain;
     if(type == 5)
     {
        
        _domain = _domain + "/includes/subwanted.php?";
     }    
     else
     {
        _domain = _domain + "/includes/sub.php?"; 
     } 
    _domain = "http://"+_domain;
    _domain += "type="+type;
    _domain += "&subtype="+subtype;
    _domain += "&list_order="+list_order;
    _domain += "&number_records="+number_records;
    _domain += "&p="+purpose;
    _domain += "&page="+page;
    _domain += "&div_id="+div_id;
    _domain += "&userid="+userid;
    _domain += "&cat="+cat_id;
	_domain += "&view_filter="+view_order;
    
      
    
    var mainDiv=document.getElementsByTagName("div");
    var tempDiv = "";
    if(number_records == 10)
    {
        divheight = 260;
    }
    else if(number_records == 15)
    {
        divheight = 350;    
    }
    else if(number_records > 15)
    {
        divheight = 22 * number_records;    
    }
    else
    {
        divheight = 0;
    }
     
    for(var k=0;k<mainDiv.length;k++)
    {
        if(mainDiv[k].getAttribute('id') == div_id)
        {
            tempDiv=mainDiv[k];
           /* if(divheight != 0 && div_id != "recent_listings")
                document.getElementById(div_id).style.height = divheight;     */       
        }
    }  
    /*alert(_domain);         */
    if(tempDiv != "")
    { 
        /*alert(_domain);*/
        ajaxpage_sub(_domain,div_id);
    }
    return false;

}//End of Function


function getListing(div_id,type,number_records,purpose,page,showtype,showdeleted)
{       
	_domain = this_domain;
	_domain = _domain + "/myzameen/includes/sub.php?";
	_domain = "http://"+_domain;
	_domain += "type="+type;
	_domain += "&number_records="+number_records;
	_domain += "&purpose="+purpose;
	_domain += "&page="+page;
	_domain += "&div_id="+div_id;
	_domain += "&showtype="+showtype;	
	_domain += "&showdeleted="+showdeleted;	
	
	var mainDiv=document.getElementsByTagName("div");
	var tempDiv = "";
	if(number_records == 10)
	{
		divheight = 260;
	}
	else if(number_records == 15)
	{
		divheight = 350;	
	}
	else if(number_records > 15)
	{
		divheight = 22 * number_records;	
	}
	else
	{
		divheight = 0;
	}
	for(var k=0;k<mainDiv.length;k++)
	{
		if(mainDiv[k].getAttribute('id') == div_id)
		{
			tempDiv=mainDiv[k];
			if(divheight != 0 && div_id != "recent_listings")
				document.getElementById(div_id).style.height = divheight;			
		}
	}
	if(tempDiv != "")
	{
		
		ajaxpage(_domain,div_id);
	}
}//End of Function

function getsubType(selectedsubtype)
{	
	//loadstatustext="<option value=1 selected>Loading ...</option>";
	type = document.getElementById("type").value;
	_domain = this_domain;
	_domain = _domain + "/myzameen/includes/subtype.php?";
	_domain = "http://"+_domain;
	_domain += "type="+type;
	if(selectedsubtype !== "undefined" && selectedsubtype != "")
	{
		_domain += "&selectedsubtype="+selectedsubtype;		
	}
	if(type != "")
		ajaxpage(_domain,'subtype_area');
	else
		document.getElementById("subtype_area").innerHTML = "";
} ////End of Function

function getcpsubType(selectedsubtype)
{	
	//loadstatustext="<option value=1 selected>Loading ...</option>";
	type = document.getElementById("type").value;
	_domain = this_domain;
	_domain = _domain + "/cp/ajax_subtype.php?";
	_domain = "http://"+_domain;
	_domain += "type="+type;
	if(selectedsubtype !== "undefined" && selectedsubtype != "")
	{
		_domain += "&selectedsubtype="+selectedsubtype;		
	}
	if(type != "")
		ajaxpage(_domain,'subtype_area');
	else
		document.getElementById("subtype_area").innerHTML = "";
} ////End of Function


function getsearchsubType(selectedsubtype)
{	
	//loadstatustext="<option value=1 selected>Loading ...</option>";
	type = document.getElementById("type").value;
	_domain = this_domain;
	_domain = _domain + "/includes/subtype.php?";
	_domain = "http://"+_domain;
	_domain += "type="+type;
	if(selectedsubtype !== "undefined" && selectedsubtype != "")
	{
		_domain += "&selectedsubtype="+selectedsubtype;		
	}
	if(type != "")
		ajaxpage(_domain,'subtype_area');
	else
		document.getElementById("subtype_area").innerHTML = "";
		
	if(type==1)
	{
		document.getElementById('showbed').style.display='block'
	}
	else
	{
		document.getElementById('showbed').style.display='none'
	}	
} ////End of Function

function deleteselected(status)
{
	chk = document.getElementsByTagName("input");
	chklength = chk.length;
	var thread_id = "";
	for(var i=0;i < chklength; i++)
	{
		if(chk[i].getAttribute('type') == "checkbox")
		{
			chk[i].getAttribute('name');
			if(chk[i].checked)
			{
				thread_id += "," + chk[i].getAttribute("name");
			}
		}
	}
	if(thread_id != "")
	{
		return overlib('<form name=frmDel action=http://'+this_domain+'/myzameen/mailbox/change_status.php method=post>Are you sure you want to delete these Conversation?<br />This will remove the associated messages.<input type=hidden name=thread_id value='+thread_id+'  /><input type=hidden name=status value='+status+'  /><br/><br/>	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=subDel value=Delete class=button_class />&nbsp;&nbsp;&nbsp;<input type=button name=btncancel value=Cancel class=button_class onclick=cClick(); />	<br /><br /></form>', STICKY, CAPTION, 'Delete Conversation', CLOSECLICK, WIDTH, 300,HEIGHT, 50, CLOSECOLOR, 'white', CENTER);
	}
	else
	{
		return overlib('Please select a Conversation<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button name=btncancel value=Close class=button_class onclick=cClick(); />', STICKY, CAPTION, 'Delete Conversation', CLOSECLICK, WIDTH, 180,HEIGHT, 50, CLOSECOLOR, 'white', CENTER)
	}
} ////End of Function

function change_status(status)
{
	chk = document.getElementsByTagName("input");
	chklength = chk.length;
	var thread_id = "";
	for(var i=0;i < chklength; i++)
	{
		if(chk[i].getAttribute('type') == "checkbox")
		{
			if(chk[i].checked)
			{
				thread_id += "," + chk[i].getAttribute("name");
			}
		}
	}
	if(thread_id == "")
	{
		return overlib('Please select a Conversation<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button name=btncancel value=Close class=button_class onclick=cClick(); />', STICKY, CAPTION, 'Delete Conversation', CLOSECLICK, WIDTH, 180,HEIGHT, 50, CLOSECOLOR, 'white', CENTER)
	}
	else
	{
		document.frm.thread_id.value = thread_id;
		document.frm.status.value = status;
		setTimeout("document.frm.submit()",50);
	}
} ////End of Function

function deletedmsg()
{
	var mainDiv = document.getElementsByTagName("div");
	var tempDiv = "";
	a = mainDiv.length;
	if(document.getElementById("changetxt").innerHTML == "Show Deleted Message")
	{
		for(var k=0;k < a;k++)
		{
			if(mainDiv[k].getAttribute('id') == "del_msg")
			{
				tempDiv = mainDiv[k];
				tempDiv.style.visibility = "visible";
				tempDiv.style.position = "relative";
			}
		}
		document.getElementById("changetxt").innerHTML = "Hide Deleted Message";
	}
	else
	{
		for(var k=0;k < a;k++)
		{
			if(mainDiv[k].getAttribute('id') == "del_msg")
			{
				tempDiv = mainDiv[k];
				tempDiv.style.visibility = "hidden";
				tempDiv.style.position = "absolute";
			}
		}
		document.getElementById("changetxt").innerHTML = "Show Deleted Message";
	}
} ////End of Function

function change_checkbox()
{
	change_value = document.frm.select_msg.value;
	chk = document.getElementsByTagName("input");
	chklength = chk.length;
	
	switch(change_value)
	{
		case "none":	
			for(var i=0;i < chklength; i++)
			{
				if(chk[i].getAttribute('type') == "checkbox")
				{
					chk[i].checked = false;
				}				
			}		
		break;
		
		case "read":	
			for(var i=0;i < chklength; i++)
			{
				if(chk[i].getAttribute('type') == "checkbox")
				{
					if(chk[i].id == "")
					{
						chk[i].checked = true;
					}
					else
					{
						chk[i].checked = false;
					}
				}				
			}				
		break;
			
		case "unread":	
			for(var i=0;i < chklength; i++)
			{
				if(chk[i].getAttribute('type') == "checkbox")
				{
					if(chk[i].id == "unread")
					{
						chk[i].checked = true;
					}
					else
					{
						chk[i].checked = false;
					}
				}				
			}	
		break;
		
		case "replied":	
			for(var i=0;i < chklength; i++)
			{
				if(chk[i].getAttribute('type') == "checkbox")
				{
					if(chk[i].id == "replied")
					{
						chk[i].checked = true;
					}
					else
					{
						chk[i].checked = false;
					}
				}				
			}	
		break;
		
		case "all":	
			for(var i=0;i < chklength; i++)
			{
				if(chk[i].getAttribute('type') == "checkbox")
				{
					chk[i].checked = true;
				}				
			}		
		break;
	}
} ////End of Function

function showmoreoption()
{
	if(document.getElementById("a_moresearch").innerHTML == "See more search options")
	{
		document.getElementById('moresearch').style.display='block';
		document.getElementById("a_moresearch").innerHTML = "Hide the options below";
		document.getElementById('image').style.display='none';
	}
	else
	{
		document.getElementById('moresearch').style.display='none';
		document.getElementById("a_moresearch").innerHTML = "See more search options";
		document.getElementById('image').style.display='block';
	}
} ////End of Function

function submit_paginate(formname,frmaction,page)
{
	
    document.forms[formname].action= frmaction+"&page="+page;
	document.forms[formname].submit();
} ////End of Function

function lbchange(lb)
{	
	if(lb=="lbtype")
	{
		document.getElementById(lb).innerHTML = document.getElementById('type').options[document.getElementById('type').selectedIndex].text;
		 self.setTimeout('lbchange("lbsubtype")', 500)  
		//document.getElementById("lbsubtype").innerHTML = "";
	}
	else if(lb=="lbsubtype")
	{
		document.getElementById(lb).innerHTML = document.getElementById('subtype').options[document.getElementById('subtype').selectedIndex].text;	
	}
	else if(lb=="lbpurpose")
	{
		document.getElementById(lb).innerHTML = document.getElementById('purpose').options[document.getElementById('purpose').selectedIndex].text;	
	}
}  ////End of Function

function changecase(str,word_case)
{
	if(word_case == "T")
	{
		str_value = document.getElementById(str).value;
		
		newValue = '';
		value = str_value.split(' ');
		for(var i = 0; i < value.length; i++) 
		{
			newValue += value[i].substring(0,1).toUpperCase() +
			value[i].substring(1,value[i].length).toLowerCase() + ' ';
		}		
		document.getElementById(str).value = newValue;
	}
	else
	{
		 val = document.getElementById(str).value;
		 result = new Array();
		 result2 = '';
		 count = 0;
		 endSentence = new Array();
		 for (var i = 1; i < val.length; i++)
		 {
		 	if(val.charAt(i) == '.' || val.charAt(i) == '!' || val.charAt(i) == '?')
		 	{
		   		endSentence[count] = val.charAt(i);
		   		count++
		 	}
		 }
		
		var val2 = val.split(/[.|?|!]/);
		
		if(val2[val2.length-1] == '')val2.length = val2.length-1;
		
		for (var j = 0; j < val2.length; j++)
		{
		 	val3 = val2[j];
			val4 = val2[j-1];
			last_word = "";
			if(typeof(val4) != "undefined")
			{
				temp4 = val4.split(" ");
				last_word = temp4[temp4.length-1];
			}
			if(val3.substring(0,1)!=' ')val2[j]=' '+val2[j];
			
			var temp=val2[j].split(' ');
			var incr=0;
		
			if(temp[0]=='')
			{
		 		incr=1;
			}
			
			temp2=temp[incr].substring(0,1);
			temp3=temp[incr].substring(1,temp[incr].length);
			if(last_word != "no" && last_word != "NO" && last_word != "sq" && last_word != "SQ" && last_word != "ft" && last_word != "FT")
			{
				temp2=temp2.toUpperCase();
			}
			else
			{
				temp2=temp2.toLowerCase();
			}
			temp3=temp3.toLowerCase();
			temp[incr]=temp2+temp3;
		
			for (var i=incr+1;i<temp.length;i++)
			{
		 		temp2=temp[i].substring(0,1);
			 	temp2=temp2.toLowerCase();
				temp3=temp[i].substring(1,temp[i].length);
				temp3=temp3.toLowerCase();
				temp[i]=temp2+temp3;
			}
		
			if(endSentence[j]==undefined)endSentence[j]='';
		 	result2+=temp.join(' ')+endSentence[j];
		}
		
		if(result2.substring(0,1)==' ')result2=result2.substring(1,result2.length);
		 document.getElementById(str).value=result2;

	}	
}  ////End of Function


function ajaxfav_listing(listing_id)
{
	div_id = "fav_"+listing_id;
	msgdiv_id = "msg_"+listing_id;
	url = "http://"+this_domain+"/custom/makeFavourite.php?id="+listing_id;
	document.getElementById(msgdiv_id).style.display="block";
	div_width = document.getElementById(msgdiv_id).style.width;
	/*if(typeof open_popup!== "undefined" && open_popup)
	{
		popUp();backgroundFilter();	
	}*/
	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		document.getElementById(msgdiv_id).style.left = posx+"px";
		//document.getElementById(msgdiv_id).style.top = posy+10+"px";
	}
	else
	{
		
		document.getElementById(msgdiv_id).style.left = posx+"px";
		document.getElementById(msgdiv_id).style.width = "35%";
		//document.getElementById(msgdiv_id).style.top = posy-1350+"px";
	}
	ajaxpage(url,msgdiv_id);
	document.getElementById(div_id).innerHTML = "<img src='http://"+this_domain+"/images/favourite.gif' />&nbsp;My Favourite Property";
}  ////End of Function

function chkfields()
{
	error = "";
	if(document.frmenq.realname.value == "")
	{
		error += "Please enter name.<br />";
	}
	if(document.frmenq.email.value == "")
	{
		error += "Please enter email.<br />";
	}
	if(document.frmenq.number.value == "")
	{
		error += "Please enter number.<br />";
	}
	if(document.frmenq.message.value == "")
	{
		error += "Please enter message.<br />";
	}
	if(document.frmenq.txt_code.value == "" || document.frmenq.hcode.value != document.frmenq.txt_code.value)
	{
		error += "Please enter correct security code.<br />";
	}
	
	if(error != "")
	{
		document.getElementById("chk_msg").innerHTML = error;
	}
	else
	{
		url = "http://"+this_domain+"/send_mortgage.php";
		/*url += "?realname="+document.frmenq.realname.value;
		url += "&email="+document.frmenq.email.value;
		url += "&number="+document.frmenq.number.value;
		url += "&message="+document.frmenq.message.value;
		url += "&country="+document.frmenq.country.value;*/
		//url += "&realname="+document.frmenq.realname.value;
		document.getElementById("chk_msg").innerHTML = "";
		ajaxpostpage(url,"af","frmenq");
		//document.frmenq.submit();
	}
	
}

function loadmortgagepage()
{
	overlib("<div id=\"mort\">",STICKY, CAPTION, 'Home Finance Contact Form', CLOSECLICK, WIDTH,350,HEIGHT, 300,CLOSECOLOR, 'white',ABOVE);
	ajaxpage("http://"+this_domain+"/loadmortgage.php","mort");
}

function submit_contactform()
{
	url = document.getElementById("frmcontact").getAttribute("action");
	ajaxpostpage(url,"div_contact","frmcontact");
	/*document.getElementById("div_contact").style.display = "block";*/
}

function ajaxpostpage(url, containerid,formid)
{
	var page_request = false;
	try
    {
    // Firefox, Opera 8.0+, Safari
   		 page_request = new XMLHttpRequest();
    }
  	catch (e)
    {
    // Internet Explorer
    	try
      	{
      		page_request = new ActiveXObject("Msxml2.XMLHTTP");
      	}
    	catch (e)
      	{
      		try
        	{
        		page_request = new ActiveXObject("Microsoft.XMLHTTP");
        	}
      		catch (e)
        	{
        		alert("Your browser does not support AJAX!");
        		return false;
        	}
      	}
    }
	//Change inner html to loading message
	var loadstatusimage="<table border=\"0\" height=\"300px\" width=\"100%\"><tr><td height=\"300px\" width=\"100%\" valign=\"middle\" align=\"center\">Processing <img src='http://" + this_domain + "/images/loading1.gif' /></td></tr></table>";
	if(formid == "popup_reg" || formid == "frmlogin")
	{
		var loadstatusimage="<table border=\"0\" height=\"10px\" width=\"100%\"><tr><td height=\"10px\" width=\"100%\" valign=\"middle\" align=\"center\">Processing <img src='http://" + this_domain + "/images/loading1.gif' /></td></tr></table>";	
	}
	var form_var = document.getElementById(formid).elements;
	f_value = "";
	for(var fl = 0;fl < form_var.length; fl++)
	{//alert(form_var[fl].name + "=" + form_var[fl].value);
		c_value = form_var[fl].value;
		c_array = c_value.split("&");
		c_len = c_array.length;
		new_value = "";
		if(c_len > 1)
		{
			for(var i = 0; i < c_len; i++)
				new_value += c_array[i] + "**";
		}
		else
		{
			new_value = form_var[fl].value;
		}
		f_value += form_var[fl].name + "=" + new_value+"&";
	}
	document.getElementById(containerid).style.display = "block";
	document.getElementById(containerid).innerHTML = loadstatustext;
	
	page_request.onreadystatechange=function()
	{
		loadpage(page_request, containerid)
	}
	if (typeof bustcachevar == 'undefined')
    {
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();	
	}	
	/*if (bustcachevar == undefined) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()*/
	
	page_request.open('POST', url, true);
	page_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	page_request.setRequestHeader("Content-length",f_value.length);
	page_request.send(f_value);
	
	
}

function commentmsg(com_txt)
{
	return overlib(com_txt,STICKY, CAPTION, 'Inquiry Text', CLOSECLICK, CLOSECOLOR,'white');
}

function lasthfcomment(hf_id)
{
	$url = "http://"+this_domain+"/cp/ajax_hflcomments.php?hf="+hf_id;
	overlib("<div id=\"lastmsg\"></div>",STICKY, CAPTION, 'Inquiry Comment', CLOSECLICK, CLOSECOLOR,'white',WIDTH,200);
	ajaxpage($url,"lastmsg");
}

function hfstatus(hf_id)
{
	action_url = "http://"+this_domain+"/cp/enquiry_update.php?hf="+hf_id;
	txt = "";
	txt += "<form name=\"frmst\" id=\"frmst\" method=\"post\" action=\""+action_url+"\"";
	txt += "<table width=\"100%\" align=\"center\"><tr><td>";
	txt += "<input type=\"radio\" name=\"rd_status\" value=\"new\"> New<br /><br />";
	txt += "<input type=\"radio\" name=\"rd_status\" value=\"verified\"> Verified<br /><br />";
	/*txt += "<input type=\"radio\" name=\"rd_status\" value=\"allocated\"> Allocated<br /><br />";
	txt += "<input type=\"radio\" name=\"rd_status\" value=\"sent\"> Sent<br /><br />";*/
	txt += "<input type=\"radio\" name=\"rd_status\" value=\"closed\"> Closed<br /><br />";
	txt += "<input type=\"radio\" name=\"rd_status\" value=\"deleted\"> Deleted<br /><br />";
	txt += "<input type=\"submit\" name=\"update_status\" />";
	txt += "</td></tr></table>";
	txt += "</form>";
	overlib(txt,STICKY, CAPTION, 'Inquiry Comment', CLOSECLICK, CLOSECOLOR,'white',WIDTH,200);
}

function trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

function hide_admin_message()
{
	var mdiv=document.getElementById("messages");
	var chk = document.getElementById("msg_read");
	var agn = document.getElementById("agn");
	add_link = "?1=1";
	if(chk.checked)
	{
		add_link += "&read=read";
	}
	if(agn.value == 1)
	{
		add_link += "&agn=1";
	}
	action_url = "http://"+this_domain+"/myzameen/admin_messages_status.php"+add_link;
	if(mdiv.style.display="block")
		mdiv.style.display="none";
	ajaxpage(action_url, "messages");
}

function change_area_combo(val)
{
	action_url = "http://"+this_domain+"/custom/search_sqft.php?new_val="+val;
	this_image = "<img src=\"http://"+this_domain+"/images/loading1.gif\" border=\"0\" />";
	document.getElementById("td_area1").innerHTML = "&nbsp;";
	document.getElementById("td_area2").innerHTML = "&nbsp;";
	ajaxpage(action_url, "load_area");
}


function toggle_page(page)
{
	if(page == "login")
	{
		this_link = "http://"+this_domain+"/custom/pop_div/login_content.php";
		selector = document.popup_reg.hvalue.value;
		frm = "frmlogin";
		cross = "logincross";
		document.getElementById("login_ajax").style.display = "block";
		document.getElementById("reg_main").style.display = "none";
	}
	else
	{
		this_link = "http://"+this_domain+"/custom/pop_div/registration_content.php?ajax_call=1";
		selector = document.frmlogin.hvalue.value;
		frm = "popup_reg";
		cross = "regcross";
		document.getElementById("login_ajax").style.display = "none";
		document.getElementById("reg_main").style.display = "block";
	}
	//ajaxpage(this_link, "popupBody");
	document.forms[frm].hvalue.value = selector;
	if(imgcross == 1)
		document.getElementById(cross).style.display = "inline";
}

function submit_popup(page)
{
	if(page == "login")
	{
		this_link = "http://"+this_domain+"/custom/pop_div/login_submit.php";
		div_id = "login_error";
		form_id = "frmlogin";
	}
	else
	{
		this_link = "http://"+this_domain+"/custom/pop_div/registration_submit.php";
		div_id = "reg_error";
		form_id = "popup_reg";
	}
	ajaxpostpage(this_link, div_id,form_id);
	
}

function load_chid_category(sl,level,selected_id)
{
	dropdownIndex = document.getElementById(sl).selectedIndex;
	dropdownValue = document.getElementById(sl)[dropdownIndex].value;
	if(typeof selected_id === "undefined")
		selected_id = "";
	newurl = "http://" + this_domain + "/myzameen/includes/newlisting/childlocation.php?cat_id=" + dropdownValue + "&cat_level=" + level + "&selected_id=" + selected_id;
	if(level == 1)
	{	
		div_name = "load_location";
		document.getElementById("load_myzameenarea").innerHTML = "";
	}	
	else if(level == 2)
		div_name = "load_myzameenarea";	
	
	ajaxpage(newurl,div_name);
}

function fav_pop(selector)
{
	popUp(1);
	backgroundFilter();	
	document.popup_reg.hvalue.value = selector;
	if(imgcross == 1)
		document.getElementById("regcross").style.display = "inline";
}

var posx;var posy;
function getMouse(e)
{
	posx=0;posy=0;
	var ev=(!e)?window.event:e;//IE:Moz
	if (ev.pageX)
	{//Moz
		posx=ev.pageX+window.pageXOffset;
		posy=ev.pageY+window.pageYOffset;
	}
	else if(ev.clientX)
	{//IE
		posx=ev.clientX+document.body.scrollLeft;
		posy=ev.clientY+document.body.scrollTop;
	}
	else
	{
		return false
	}//old browsers
	//document.getElementById('myspan').firstChild.data='X='+posx+' Y='+posy;
	
}
document.onclick=getMouse
