// JavaScript Document
var xmlHttp;
var xmlHttp3;
var xmlHttp4;
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 ajaxGetSubRegions(obj)
{
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?region='+obj.value+'&action=GetSubRegions';
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('sub_regions').innerHTML	=	xmlHttp.responseText;
		}
		else
		{
			document.getElementById('sub_regions').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 ajaxGetSubRegions2(obj)
{ 
	ajaxGetTown2(obj);
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?region='+obj.value+'&action=GetSubRegions2';
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('sub_regions').innerHTML	=	xmlHttp.responseText;
		}
		else
		{
			document.getElementById('sub_regions').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 ajaxGetSubregions3(obj)
{ 
	ajaxGetTown2(obj);
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?region='+obj.value+'&action=GetSubRegions3';
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('prop_type_sub_regions').innerHTML	=	xmlHttp.responseText;
			document.getElementById('prop_type_town_village_cntnr').innerHTML	=	'<select name="prop_type_town_village" id="prop_type_town_village" disabled="disabled"><option value="">--Select--</option></select>';
		}
		else
		{
			document.getElementById('prop_type_sub_regions').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
			document.getElementById('prop_type_town_village_cntnr').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 ajaxGetTown2(obj)
{
	xmlHttp3	=	GetXmlHttpObject();
	if (xmlHttp3==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?region='+obj.value+'&action=GetTown2';
	xmlHttp3.onreadystatechange=function()
	{
		if(xmlHttp3.readyState==4)
		{
			document.getElementById('town_village_cntnr').innerHTML	=	xmlHttp3.responseText;
		}
		else
		{
			document.getElementById('town_village_cntnr').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
		}
	}
	params="";
	xmlHttp3.open("POST",urlval,true);
	xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp3.setRequestHeader("Content-length", params.length);
	xmlHttp3.setRequestHeader("Connection", "close");
	xmlHttp3.send(params);
}
function ajaxGetTown3(obj)
{
	xmlHttp3	=	GetXmlHttpObject();
	if (xmlHttp3==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?subregion_id='+obj.value+'&action=GetTown2';
	xmlHttp3.onreadystatechange=function()
	{
		if(xmlHttp3.readyState==4)
		{
			document.getElementById('town_village_cntnr').innerHTML	=	xmlHttp3.responseText;
		}
		else
		{
			document.getElementById('town_village_cntnr').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
		}
	}
	params="";
	xmlHttp3.open("POST",urlval,true);
	xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp3.setRequestHeader("Content-length", params.length);
	xmlHttp3.setRequestHeader("Connection", "close");
	xmlHttp3.send(params);
}
function ajaxGetTown4(obj)
{
	xmlHttp3	=	GetXmlHttpObject();
	if (xmlHttp3==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?subregion_id='+obj.value+'&action=GetTown3';
	xmlHttp3.onreadystatechange=function()
	{
		if(xmlHttp3.readyState==4)
		{
			document.getElementById('prop_type_town_village_cntnr').innerHTML	=	xmlHttp3.responseText;
		}
		else
		{
			document.getElementById('prop_type_town_village_cntnr').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
		}
	}
	params="";
	xmlHttp3.open("POST",urlval,true);
	xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp3.setRequestHeader("Content-length", params.length);
	xmlHttp3.setRequestHeader("Connection", "close");
	xmlHttp3.send(params);
}
/** calendar JS ***/
function selectMonth(calendar)
{
	mnth_selected	=	parseInt(document.getElementById('cal'+calendar+'mnth_selected').value);
	total_day	=	parseInt(document.getElementById('cal'+calendar+'total_day').value);
	if(mnth_selected ==0)
	{
		for(var_day=1;var_day<=total_day;var_day++)
		{
			selectDay(var_day,calendar);
			removeAvailDay(var_day,calendar);
		}
		document.getElementById('cal'+calendar+'mnth_selected').value	=	1;
		for(i=1;i<7;i++)
		{
			if(document.getElementById('cal'+calendar+'week_selected'+i))
			{
				document.getElementById('cal'+calendar+'week_selected'+i).value	=	1;
			}
		}
	}
	else
	{
		for(var_day=1;var_day<=total_day;var_day++)
		{
			selectAvailDay(var_day,calendar);
			removeDay(var_day,calendar);
		}
		document.getElementById('cal'+calendar+'mnth_selected').value	=	0;
		for(i=1;i<7;i++)
		{
			if(document.getElementById('cal'+calendar+'week_selected'+i))
			{
				document.getElementById('cal'+calendar+'week_selected'+i).value	=	0;
			}
		}
	}
}
function selectWeek(row,calendar)
{
	week_selected	=	parseInt(document.getElementById('cal'+calendar+'week_selected'+row).value);
	
	if(row==1)
	{
		first_day	=	parseInt(document.getElementById('cal'+calendar+'first_day').value);
		days_left	=	8-first_day;	
		if(week_selected ==0)
		{
			for(var_day=1;var_day<=days_left;var_day++)
			{	
				avail_selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
				avail_selected_daysArr	=	avail_selected_days.split(',');
				selectDay(var_day,calendar);
				for(i=0;i<avail_selected_daysArr.length;i++)
				{
					if(parseInt(avail_selected_daysArr[i])==var_day)
					{
						removeAvailDay(var_day,calendar);
					}
				}
			}
			document.getElementById('cal'+calendar+'week_selected'+row).value	=	1;
		}
		else
		{
			for(var_day=1;var_day<=days_left;var_day++)
			{
				removeDay(var_day,calendar);
				selectAvailDay(var_day,calendar);
			}
			document.getElementById('cal'+calendar+'week_selected'+row).value	=	0;
		}
	}
	else
	{
		first_day	=	parseInt(document.getElementById('cal'+calendar+'week'+row).value);
		this_day	=	first_day;
		total_day	=	parseInt(document.getElementById('cal'+calendar+'total_day').value);
		if(week_selected ==0)
		{
			
			for(var_day=1;var_day<8&&this_day<=total_day;var_day++)
			{	
				avail_selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
				avail_selected_daysArr	=	avail_selected_days.split(',');
				loop_till	=	avail_selected_daysArr.length;
				selectDay(this_day,calendar);
				
				for(i=0;i<loop_till;i++)
				{
					if(parseInt(avail_selected_daysArr[i])==this_day)
					{
						//alert('remove '+this_day);
						removeAvailDay(this_day,calendar);
					}
				}
				this_day++;
			}
			document.getElementById('cal'+calendar+'week_selected'+row).value	=	1;
		}
		else
		{
			for(var_day=1;var_day<8&&this_day<=total_day;var_day++)
			{
				removeDay(this_day,calendar);
				selectAvailDay(this_day,calendar);
				//markDay(this_day,calendar);
				//removeAvailDay(this_day,calendar);
				this_day++;
			}
			document.getElementById('cal'+calendar+'week_selected'+row).value	=	0;
		}
	}
}
function markDay(var_day,calendar)
{
	selected_days	=	document.getElementById('cal'+calendar+'selected').value;
	avail_selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
	
	selected_daysArr	=	selected_days.split(',');
	avail_selected_daysArr	=	avail_selected_days.split(',');
	
	new_selected_days	=	'';
	found	=	false;
	for(i=0;i<selected_daysArr.length;i++)
	{
		if(parseInt(selected_daysArr[i])==var_day)
		{
			found	=	true;
		}
	}
	in_avail	=	false;
	for(i=0;i<avail_selected_daysArr.length;i++)
	{
		if(parseInt(avail_selected_daysArr[i])==var_day)
		{
			in_avail	=	true;
		}
	}
	if(found)
	{
		removeDay(var_day,calendar);
		selectAvailDay(var_day,calendar);
	}
	else if(in_avail)
	{
		selectDay(var_day,calendar);
		removeAvailDay(var_day,calendar);
	}
	else
	{
		selectDay(var_day,calendar);
	}
	/*if(found)
	{
		removeDay(var_day,calendar);
	}
	else
	{
		selectDay(var_day,calendar);
	}*/
}
function addClass(objId,className)
{
	obj	=	document.getElementById(objId);
	classNames	=	obj.className;
	nameArr	=	classNames.split(' ');
	totalClass	=	nameArr.length;
	newClass	=	'';
	for(i=0;i<totalClass;i++)
	{
		if(nameArr[i]!=className)
		{
			if(newClass=='')
				newClass	=	nameArr[i];
			else
				newClass	=	newClass+' '+nameArr[i];
		}
	}
	newClass	=	newClass+' '+className;
	obj.className	=	newClass;
}
function removeClass(objId,className)
{
	obj	=	document.getElementById(objId);
	classNames	=	obj.className;
	nameArr	=	classNames.split(' ');
	totalClass	=	nameArr.length;
	newClass	=	'';
	for(i=0;i<totalClass;i++)
	{
		if(nameArr[i]!=className)
		{
			if(newClass=='')
				newClass	=	nameArr[i];
			else
				newClass	=	newClass+' '+nameArr[i];
		}
	}
	obj.className	=	newClass;
}
function selectDay(var_day,calendar)
{
	selected_days	=	document.getElementById('cal'+calendar+'selected').value;
	selected_daysArr	=	selected_days.split(',');
	new_selected_days	=	'';
	for(i=0;i<selected_daysArr.length;i++)
	{
		if(parseInt(selected_daysArr[i])!=var_day)
		{
			new_selected_days	=	(new_selected_days=='')?selected_daysArr[i]:new_selected_days+','+selected_daysArr[i];
		}
	}
	new_selected_days	=	(new_selected_days=='')?var_day:new_selected_days+','+var_day;
	div_id	=	'col_'+calendar+'_'+var_day;
	removeClass(div_id,'cal-day_unkn');
	addClass(div_id,'cal-day_sel');
	document.getElementById('cal'+calendar+'selected').value	=	new_selected_days;
}
function removeDay(var_day,calendar)
{
	selected_days	=	document.getElementById('cal'+calendar+'selected').value;
	selected_daysArr	=	selected_days.split(',');
	new_selected_days	=	'';
	for(i=0;i<selected_daysArr.length;i++)
	{
		if(parseInt(selected_daysArr[i])!=var_day)
		{
			new_selected_days	=	(new_selected_days=='')?selected_daysArr[i]:new_selected_days+','+selected_daysArr[i];
		}
	}
	div_id	=	'col_'+calendar+'_'+var_day;
	removeClass(div_id,'cal-day_sel');
	document.getElementById('cal'+calendar+'selected').value	=	new_selected_days;
}

function selectAvailDay(var_day,calendar)
{
	selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
	selected_daysArr	=	selected_days.split(',');
	new_selected_days	=	'';
	for(i=0;i<selected_daysArr.length;i++)
	{
		if(parseInt(selected_daysArr[i])!=var_day)
		{
			new_selected_days	=	(new_selected_days=='')?selected_daysArr[i]:new_selected_days+','+selected_daysArr[i];
		}
	}
	new_selected_days	=	(new_selected_days=='')?var_day:new_selected_days+','+var_day;
	/*div_id	=	'col_'+calendar+'_'+var_day;
	removeClass(div_id,'cal-day_unkn');
	addClass(div_id,'cal-day_sel');*/
	document.getElementById('cal'+calendar+'avail_selected').value	=	new_selected_days;
}
function removeAvailDay(var_day,calendar)
{
	selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
	selected_daysArr	=	selected_days.split(',');
	new_selected_days	=	'';
	
	for(i=0;i<selected_daysArr.length;i++)
	{
		if(parseInt(selected_daysArr[i])!=var_day)
		{
			new_selected_days	=	(new_selected_days=='')?selected_daysArr[i]:new_selected_days+','+selected_daysArr[i];
		}
	}
	/*div_id	=	'col_'+calendar+'_'+var_day;
	removeClass(div_id,'cal-day_sel');*/
	document.getElementById('cal'+calendar+'avail_selected').value	=	new_selected_days;
}

/** END:calendar JS ***/
function ajaxUpdateAvailability(product_id,calendar,var_year,var_month)
{
	selected_days	=	document.getElementById('cal'+calendar+'selected').value;
	avail_selected_days	=	document.getElementById('cal'+calendar+'avail_selected').value;
	update	=	'update'+calendar;
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?product_id='+product_id+'&action=UpdateAvailability&selected_days='+selected_days+'&year='+var_year+'&month='+var_month+'&avail_selected_days='+avail_selected_days;
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(update).innerHTML	=	xmlHttp.responseText;//'saved';
		}
		else
		{
			document.getElementById(update).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 ajaxGetArea(obj)
{
	region_id	=	obj.value;
	if(region_id!='')
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?region_id='+region_id+'&action=GetArea';
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				document.getElementById('sel_area').innerHTML	=	xmlHttp.responseText;
			}
			else
			{
				document.getElementById('sel_area').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' />";
				document.getElementById('sel_town').innerHTML	=	'<select style="width:100%" 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 ajaxGetAreaHome(obj)
{
	region_id	=	obj.value;
	if(region_id!='')
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval='ajax/ajax-page.php?region_id='+region_id+'&action=GetAreaHome';
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				
				document.getElementById('sel_area').innerHTML	=	xmlHttp.responseText;
			}
			else
			{
				document.getElementById('sel_area').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 ajaxGetTown(obj)
{
	subregion_id	=	obj.value;
	if(subregion_id)
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?subregion_id='+subregion_id+'&action=GetTown';
		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' />";
			}
		}
		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 ajaxGetTownHome(obj)
{
	subregion_id	=	obj.value;
	if(subregion_id)
	{
		xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?subregion_id='+subregion_id+'&action=GetTownHome';
		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;' />";
			}
		}
		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 isEmailAddr(email)
{
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
	}
	return result;
}
function addReview()
{
	var name		=	document.getElementById('rev_name').value;
	var email		=	document.getElementById('rev_email').value;
	var review		=	document.getElementById('review').value;
	var property_id	=	document.getElementById('property_id').value;
	var captcha		=	document.getElementById('txtCaptcha').value;
	
	
	if (review=='') 
	{
		alert ("Review field cannot be empty");
		return;
	}
	if (name=='') 
	{
		alert ("invalid Name");
		return;
	}
	
	if (email=='') 
	{
		alert ("invalid Email address");
		return;
	}

	if (isEmailAddr(email) == false)
	{
		alert("Please enter a valid email address.");  
		return false; 
	}


	
	xmlHttp	=	GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	
	var urlval	=	SITE_URL+'ajax/ajax-page.php?name='+name+'&email='+email+'&review='+review+'&captcha='+captcha+'&action=addreview&property_id='+property_id;

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('review_approv_mesg').innerHTML	=	xmlHttp.responseText;
		}
		else
		{
			document.getElementById('review_approv_mesg').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 submitForm(next_link,form_id)
{
	frm	=	document.getElementById(form_id);
	frm.action	=	next_link;
	frm.submit();
}
function fn_loadSubregion(subregion)
{
	ajaxLoadFlashRegion(subregion);
	ajaxLoadFlashSubRegion(subregion);
	obj	=	document.getElementById('temp');
	obj.value	=	subregion;
	ajaxGetTownHome(obj);
}
function ajaxLoadFlashRegion(subregion)
{
	xmlHttp4	=	GetXmlHttpObject();
		if (xmlHttp4==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?subregion='+subregion+'&action=LoadFlashRegion';
		xmlHttp4.onreadystatechange=function()
		{
			if(xmlHttp4.readyState==4)
			{
				document.getElementById('my_region').innerHTML	=	xmlHttp4.responseText;
			}
			else
			{
				document.getElementById('my_region').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' style='height:20px;' />";
			}
		}
		params="";
		xmlHttp4.open("POST",urlval,true);
		xmlHttp4.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp4.setRequestHeader("Content-length", params.length);
		xmlHttp4.setRequestHeader("Connection", "close");
		xmlHttp4.send(params);
}
function ajaxLoadFlashSubRegion(subregion)
{
	xmlHttp3	=	GetXmlHttpObject();
		if (xmlHttp3==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?subregion='+subregion+'&action=LoadFlashSubRegion';
		xmlHttp3.onreadystatechange=function()
		{
			if(xmlHttp3.readyState==4)
			{
				document.getElementById('sel_area').innerHTML	=	xmlHttp3.responseText;
			}
			else
			{
				document.getElementById('sel_area').innerHTML	=	"<img src='"+SITE_URL+"images/ajax-loader.gif' style='height:20px;' />";
			}
		}
		params="";
		xmlHttp3.open("POST",urlval,true);
		xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp3.setRequestHeader("Content-length", params.length);
		xmlHttp3.setRequestHeader("Connection", "close");
		xmlHttp3.send(params);
}
function ajaxGetCalender(product_id,next_month)
{

	xmlHttp3	=	GetXmlHttpObject();
		if (xmlHttp3==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?product_id='+product_id+'&action=GetCalender&next_month='+next_month;
		xmlHttp3.onreadystatechange=function()
		{
			if(xmlHttp3.readyState==4)
			{
				document.getElementById('fcal').innerHTML	=	xmlHttp3.responseText;
			}
			else
			{
				document.getElementById('fcal').innerHTML	=	"<div class='ajaxloader'><img src='"+SITE_URL+"images/ajax-loader.gif' height:100px;' /></div><br />";
			}
		}
		params="";
		xmlHttp3.open("POST",urlval,true);
		xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp3.setRequestHeader("Content-length", params.length);
		xmlHttp3.setRequestHeader("Connection", "close");
		xmlHttp3.send(params);

}
function ajaxGetCalenderAdmin(product_id,next_month)
{

	xmlHttp3	=	GetXmlHttpObject();
		if (xmlHttp3==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?product_id='+product_id+'&action=GetCalenderAdmin&next_month='+next_month;
		xmlHttp3.onreadystatechange=function()
		{
			if(xmlHttp3.readyState==4)
			{
				document.getElementById('form_content').innerHTML	=	xmlHttp3.responseText;
			}
			else
			{
				document.getElementById('form_content').innerHTML	=	"<div class='ajaxloader'><img src='"+SITE_URL+"images/ajax-loader_org.gif' height:100px;' /></div>";
			}
		}
		params="";
		xmlHttp3.open("POST",urlval,true);
		xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp3.setRequestHeader("Content-length", params.length);
		xmlHttp3.setRequestHeader("Connection", "close");
		xmlHttp3.send(params);
}
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);' onclick='removefromShortlist("+property_id+");'><img src='"+SITE_URL+"gfx/remove_shortlist.jpg' /></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);' onclick='addtoShortlist("+property_id+");'><img src='"+SITE_URL+"gfx/add_to_shortlist.png' /></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 removeItemfromShortlist(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_lista'+property_id)).slideUp();
		}
		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 loadImages()
	{
	
	var product_id		=	document.getElementById('product_id').value;
	xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		
	var urlval	=	SITE_URL+'ajax/ajax-page.php?action=getimages&product_id='+product_id;

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('image_display').innerHTML	=	xmlHttp.responseText;
		}
		else
		{
			document.getElementById('image_display').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 loadImagesAdmin()
	{
	
	var product_id		=	document.getElementById('property_id').value;
	xmlHttp	=	GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		
	var urlval	=	SITE_URL+'ajax/ajax-page.php?action=getImagesAdmin&product_id='+product_id;

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('show_images').innerHTML	=	xmlHttp.responseText;
		}
		else
		{
			document.getElementById('show_images').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 checkNull()
{
	if(document.getElementById('from').value=='')
	{
		//alert('Please enter the start date');
		document.getElementById('from').focus();
		return false;
	}
	if(document.getElementById('to').value=='')
	{
		//alert('Please enter the end date');
		document.getElementById('to').focus();
		return false;
	}
	if(document.getElementById('rental_amount').value=='')
	{
		alert('Please enter the rate amount');
		document.getElementById('rental_amount').focus();
		return false;
	}
	return true;	
}


/*** Google map ***/
var map = null;
var geocoder = null;
function searchAddress(town,sub_region,region,country,container)
{
	geocoder = new GClientGeocoder();
	
	address	=	town+','+sub_region+','+region+','+country;
	if (geocoder) 
	{
    	geocoder.getLatLng(address,function(point){
		if(point){loadGMap(point,container);}
		else
		{
			address	=	town+','+region+','+country;
			geocoder.getLatLng(address,function(point){
			if(point){loadGMap(point,container);}
			else
			{
				address	=	town+','+sub_region+','+country;
				geocoder.getLatLng(address,function(point){
				if(point){loadGMap(point,container);}
				else
				{
					address	=	sub_region+','+region+','+country;
					geocoder.getLatLng(address,function(point){
					if(point){loadGMap(point,container);}
					else
					{
						address	=	region+','+country;
						geocoder.getLatLng(address,function(point){if(point){loadGMap(point,container);}});
					}
					});
				}
				});
			}
			});
		}
		});
    }
}
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 load_loc(obj)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?loccat='+obj.value+'&action=GetLocationType';
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('select_loc').innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById('select_loc').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 ajaxgetSubRegionsLoc(obj)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return;
	}
	var urlval=SITE_URL+'ajax/ajax-page.php?region='+obj.value+'&action=getSubRegionsLoc';
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('sub_regions').innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById('sub_regions').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 ajaxGetTownLoc(obj)
{
	subregion_id = obj.value;
	if(subregion_id)
	{
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return;
		}
		var urlval=SITE_URL+'ajax/ajax-page.php?subregion_id='+subregion_id+'&action=getTownLoc';
		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' />";
			}
		}
		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);
	}
}
