// JavaScript Document

function loadCalender(variables, new_date)
{
	var xmlHttp;
	try
	  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
		  // Internet Explorer
		  try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
				try
				  {
					  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				  }
				catch (e)
				  {
					  alert("Your browser does not support AJAX!");
					  return false;
				  }
			}
	  }
	 
	
	// each time the readystate changes...
	xmlHttp.onreadystatechange=function()
	{
		var changeDiv = document.getElementById("cal");
		
		if(xmlHttp.readyState==4)
		{
			changeDiv.innerHTML=xmlHttp.responseText;
			
			if(new_date) 
			{
				document.getElementById("change_date_field").value = new_date;
			}
		}
		
		if(xmlHttp.readyState>0 && xmlHttp.readyState<4)
		{
			changeDiv.innerHTML = 'Fetching Images...';
		}
	}
	 
	// Random number because shitty explorer caches the result if its already pulled that link and doesnt bring new content so this creates
	// a unique url every time.
	var randomnumber=Math.floor(Math.random()*100010);

	
	xmlHttp.open("GET","ajax/calender.php"+variables,true);
	xmlHttp.send(null);
	
}
