function getById(elementname)
{
	if(document.all)
	{
		element=document.all[elementname];	
	}
	else
	{
		element=document.getElementById(elementname);	
	}
	return element;
}
function dayJobs(dayStamp,half)
{
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
					getById('jobsDiv').innerHTML=xmlHttp.responseText;
					getById('jobsDiv').style.display="block";
					expandJobs(dayStamp,half,1);
			}//end if status==200
			else 
			{ 
				
			}
		}//end if readystate==4
	}; //end state change function 

	xmlHttp.open('GET', "ajax.getJobs.php?dS="+dayStamp+"&half="+half, true); 
	xmlHttp.send(null);
}

function expandJobs(dayStamp,half,currHeight)
{
	if(currHeight<=430)
	{
		newHeight=parseInt(currHeight)+10;
		getById('jobsDiv').style.height=newHeight+"px";
		setTimeout("expandJobs("+dayStamp+",'"+half+"',"+newHeight+")",15);
	}
}
function closeJobs(currHeight)
{
	newHeight=parseInt(currHeight)-10;
	getById('jobsDiv').style.height=newHeight+"px";
	if(newHeight>=10)
		setTimeout("closeJobs("+newHeight+")",15);
	else
	{
		getById('jobsDiv').innerHTML="";
		getById('jobsDiv').style.display="none";
	}
}
function editJob(jobid,dayStamp,half)
{
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				getById('jobList').innerHTML=xmlHttp.responseText;
			}//end if status==200
			else 
			{ 
				
			}
		}//end if readystate==4
	}; //end state change function 

	xmlHttp.open('GET', "ajax.editJob.php?dS="+dayStamp+"&half="+half+"&jobid="+jobid, true); 
	xmlHttp.send(null);
}
function validateJob(theForm)
{
	var returnVal=true;
	if(theForm.Job_Title.value=='')
	{
		theForm.Job_Title.style.backgroundColor="#FFD5D5";	
		returnVal=false;
	}
	else
	{
		theForm.Job_Title.style.backgroundColor="#FFFFFF";	
	}
	return returnVal;
}

function moveToDay(job,dateTime,fullMonth,year)
{
	var xmlHttp;
	if (window.XMLHttpRequest)     // Object of the current windows
	{ 
		xmlHttp = new XMLHttpRequest();     // Firefox, Safari, ...
	} 
	else if (window.ActiveXObject)   // ActiveX version
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	} 
	xmlHttp.onreadystatechange  = function()
	{ 
		if(xmlHttp.readyState  == 4)
		{
			if(xmlHttp.status  == 200) 
			{
				//alert(xmlHttp.responseText);
				window.location.href="calendar.php?fullMonth="+fullMonth+"&year="+year;
			}//end if status==200
			else 
			{ 
				
			}
		}//end if readystate==4
	}; //end state change function 

	xmlHttp.open('GET', "ajax.moveToDay.php?job="+job+"&dateTime="+dateTime+"&fullMonth="+fullMonth+"&year="+year, true); 
	xmlHttp.send(null);
}
