window.onload = WindowLoad;

	function WindowLoad()
	{
		var objDateChooserEx1 = new DateChooser();
		
		
		if (!objDateChooserEx1.display)
		{
			return false;
		}
		
		var objStartDateEx1 = new Date();
		var objEarliestDateEx1 = new Date();
		var objLatestDateEx1 = new Date();
		
		objDateChooserEx1.setAllowedDays(['4']);
			
		//objStartDateEx1.setMonth(2);
		//objStartDateEx1.setDate(19);
		//objStartDateEx1.setFullYear(2008);
		
		objLatestDateEx1.setMonth(9);
		objLatestDateEx1.setDate(31);
		objLatestDateEx1.setFullYear(2008);
			
		objDateChooserEx1.setStartDate(objStartDateEx1);
		objDateChooserEx1.setEarliestDate(objStartDateEx1);
		objDateChooserEx1.setLatestDate(objLatestDateEx1);
		objDateChooserEx1.setUpdateFunction(FunctionEx1);
		document.getElementById('datelinkex1').onclick = objDateChooserEx1.display;
		
	
	}
	
	
	
	function FunctionEx1(objDate)
		{
			// objDate is a plain old Date object, with the getPHPDate() property added on.
			document.getElementById('dateinputex1').value = objDate.getPHPDate('d/m/Y');
			var date = document.getElementById('dateinputex1').value;
			//do blocked date checking
			blockedfield = document.getElementById('blocked').value;
			blockedarray= blockedfield.split("\r");
			
			for (i=0;i<blockedarray.length;i++) {

			if (date == trim(blockedarray[i])) { 
			alert("There are no further seats available on "+date+". Please try another date.");
			document.getElementById('dateinputex1').value = "";
			} 
			}
			return true;
			
		}



function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
	
//-->