var xmlHttp;
var mignore = 0;
function addfavourite(mFav)
{ 
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null)
 	{
 		alert ("Browser does not support HTTP Request");
 		return;
 	}

	mignore=1;
	url="includes/addfavourite.php?pid="+mFav;
	//alert(url);
	xmlHttp2.onreadystatechange=stateChanged;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);
	document.getElementById("favid").innerHTML="ADDED TO FAVOURITES";
}
function prevmonth()
{
	var mlength = document.getElementById("calenderid").length;
	var mpos = document.getElementById("calenderid").selectedIndex;
	if(mpos>0)
	{
		
		document.getElementById("calenderid").selectedIndex = document.getElementById("calenderid").selectedIndex - 1;
		//document.calform.users.selectedIndex = document.calform.users.selectedIndex - 1;
		showUser();
	}
	return;
}
function nextmonth()
{
	var mlength = document.getElementById("calenderid").length;
	var mpos = document.getElementById("calenderid").selectedIndex;
	mpos=mpos+1;
	if(mpos<mlength)
	{
		document.getElementById("calenderid").selectedIndex = document.getElementById("calenderid").selectedIndex + 1;
		showUser();
	}
	return;
}
function showUser()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="includes/availability_ajax.php";
var str=document.getElementById('calenderid').value;
if(document.getElementById('occupancyid') != null)
{
	var str2=document.getElementById('occupancyid').value;
}
else
{
	var str2="price";
}
url=url+"?q="+str+"&s="+str2;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (mignore == 1)
{
	return;
}
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("content_calendar").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;
}