// JavaScript Document
var xmlHttp;
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 addtoShortlist(property_id)
{
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval	=	SITE_URL+'ajax/ajax-page.php?action=addToShortlist&property_id='+property_id;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('rm_list'+property_id).innerHTML	=	"<a href='JavaScript:void(0);' class='blu_bld itlc no_underline' onclick='removefromShortlist(\""+property_id+"\");'>Remove From Shortlist</a>";//xmlHttp.responseText;
		}
		else
		{
			document.getElementById('rm_list'+property_id).innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
		}
	}
	params="";
	xmlHttp.open("POST",urlval,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);		
}
function removefromShortlist(property_id)
{
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval	=	SITE_URL+'ajax/ajax-page.php?action=removeFromShortlist&property_id='+property_id;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('rm_list'+property_id).innerHTML	=	"<a href='JavaScript:void(0);' class='blu_bld itlc no_underline' onclick='addtoShortlist(\""+property_id+"\");'>Add to My Shortlist</a>";
		}
		else
		{
			document.getElementById('rm_list'+property_id).innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
		}
	}
	params="";
	xmlHttp.open("POST",urlval,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}
function ajaxGetTown(obj)
{
	area_id	=	obj.value;
	if(area_id!='')
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?area_id='+area_id+'&action=GetAreaTown';
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				document.getElementById('sel_town').innerHTML	=	xmlHttp.responseText;
			}
			else
			{
				document.getElementById('sel_town').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' style='height:20px;' />";
				/*document.getElementById('sel_town').innerHTML	=	'<select style="width:80%" name="select_town" id="select_town" 							disabled="disabled" class="transparent"><option value=""></option></select>';*/
			}
		}
		params="";
		xmlHttp.open("POST",urlval,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	}
}
function ajaxGetArea(obj)
{
	town_id	=	obj.value;
	if(town_id!='')
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?town_id='+town_id+'&action=GetAreaArea';
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				document.getElementById('sel_town').innerHTML	=	xmlHttp.responseText;
			}
			else
			{
				document.getElementById('sel_town').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' style='height:20px;' />";
				/*document.getElementById('sel_town').innerHTML	=	'<select style="width:80%" name="select_town" id="select_town" 							disabled="disabled" class="transparent"><option value=""></option></select>';*/
			}
		}
		params="";
		xmlHttp.open("POST",urlval,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	}
}
function ajaxGetDistrict(obj)
{
	town_id	=	obj.value;
	if(town_id!='')
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?town_id='+town_id+'&action=GetDistrict';
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				document.getElementById('sel_town').innerHTML	=	xmlHttp.responseText;
			}
			else
			{
				document.getElementById('sel_town').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' style='height:20px;' />";
				/*document.getElementById('sel_town').innerHTML	=	'<select style="width:80%" name="select_town" id="select_town" 							disabled="disabled" class="transparent"><option value=""></option></select>';*/
			}
		}
		params="";
		xmlHttp.open("POST",urlval,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	}
}
/*** Google map ***/
var map = null;
var geocoder = null;
function searchAddress(address,container)
{
	geocoder = new GClientGeocoder();
	if (geocoder) 
	{
    	geocoder.getLatLng(address,function(point){
		if(point){loadGMap(point,container);}else{document.getElementById(container).style.display="none";}});
    }
}
function loadGMap(point,container)
{
	map = new GMap2(document.getElementById(container));
	map.setCenter(point, 8);
	var marker = new GMarker(point);
	map.addOverlay(marker);
	map.setUIToDefault();
}
/*** END: Google map ***/
function doResearch()
{
	frm	=	document.getElementById('research_form');
	frm.submit();
}
function doResearch2()
{
	frm	=	document.getElementById('research_form2');
	frm.submit();
}
