	function LoadSchedule(strReqLink) {
		var strLink;

		//document.getElementById('site_title').innerHTML = document.getElementById('sitename').value;
				
		//strLink = "http://booking.omniplex.ie/new/newschedule.asp";
		//strLink = "getschedule.php";
		strLink = "http://www.swancinemas.ie/booking/cache_getschedule.php";
				
		if (strReqLink.length > 0) {
			strLink = strLink + strReqLink;
		} else {
			strLink = strLink + "?site=" + document.getElementById('sitename').value;
		} 	
 	
 		//alert(strLink);

		try {
			LoadDates(strReqLink)
		} 
		catch (err)
		{
			//alert(err);
		}

		//alert (strLink);
		//alert(strReqLink);
	
		//Get the next page contents
		xmlHttpNew = GetXmlHttpObject();
		if (xmlHttpNew == null) {
			alert("Your browser does not support AJAX.");
			return;
		}

		document.getElementById('schedule_content').innerHTML = "<br/><br/><p><img id='WaitingImage' src='http://www.omniplex.ie/imgs/UI/icons/loading.gif' /></p>";

		xmlHttpNew.onreadystatechange = SchedulePageGot;
		try {
			xmlHttpNew.open("GET",strLink,true);
		}
		catch (err)
		{
			alert(err.description);
		}

		xmlHttpNew.send(null);
	}

	function SchedulePageGot()
	{
		if (xmlHttpNew.readyState==4) 
		{
			if (xmlHttpNew.status==200) 
			{
				strReturn = xmlHttpNew.responseText
				//alert (strReturn);
				document.getElementById('schedule_content').innerHTML = "";
				if (strReturn.indexOf("SUCCESSTIMES") == -1) 
				{	
					//Error Occurred
					//If there is an error in the return then display error message
					//document.getElementById("schedule_content").innerHTML = strReturn;
					document.getElementById("schedule_content").innerHTML = "<div id='bk-error'>Cinema times are not available at the moment, please try again later</div>";
				}
				else 
				{
					//Success getting times
					strReturn = strReturn.replace("SUCCESSTIMES","");
					document.getElementById("schedule_content").innerHTML = strReturn;
					GetToggleCode();					
				}
			} else {
				var strRespStatus
       			if (xmlHttpNew.status == 404) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 1.";
       			} else if (xmlHttpNew.status == 403) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 2.";
       			} else if (xmlHttpNew.status == 500) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 3.";
       			} else {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 4.";
         		}			
				document.getElementById("schedule_content").innerHTML = "<div id='bk-error'>" + strRespStatus + "</div>";
			}
		}
	}
	
	
	function LoadDates(strReqLink)
	{
		var strLink;

		document.getElementById("days-menu").style.display = "block";

		//strLink = "http://booking.omniplex.ie/new/getdates.asp";
		//strLink = "getdates.php";
		strLink = "http://www.swancinemas.ie/booking/cache_getdates.php";
						
		if (strReqLink.length > 0) {
			strLink = strLink + strReqLink;
		} else {
			strLink = strLink + "?site=" + document.getElementById('sitename').value;
		}

		//alert ("Load Dates 1: " + strLink);
		//alert(strReqLink);
	
		//Get the next page contents
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp == null) {
			alert("Your browser does not support AJAX.");
			return;
		}

		//document.getElementById('schedule_date_content').innerHTML = "<br/><br/><p><img id='WaitingImage' src='http://www.omniplex.ie/imgs/UI/icons/loading.gif' /></p>";
		//alert ("Load Dates 2: " + strLink);

		xmlHttp.onreadystatechange = DatePageGot;
		
		//alert ("Load Dates: 3 " + strLink);
		
		try {
			xmlHttp.open("GET",strLink,true);
		}
		catch (err)
		{
			alert(err.description);
		}
		
		//alert ("Load Dates: 4 " + strLink);
		xmlHttp.send(null);	
	}

	function DatePageGot()
	{
		if (xmlHttp.readyState==4) 
		{
			if (xmlHttp.status==200) 
			{
				strReturn = xmlHttp.responseText
				//alert ("Load Return: " + strReturn);
				document.getElementById('schedule_date_content').innerHTML = "";
				if (strReturn.indexOf("Error") == -1) 
				{	
					//No error						
					document.getElementById("schedule_date_content").innerHTML = strReturn;
				}
				else 
				{
					//If there is an error in the return then display error message
					document.getElementById("schedule_date_content").innerHTML = "<div id='bk-error'>Cinema dates are not available at the moment, please try again later</div>";
				}
			} else {
				var strRespStatus
				
       			if (xmlHttp.status == 404) {
         				strRespStatus = "Cinema dates are not available at the moment, please try again later. 1.";
       			} else if (xmlHttp.status == 403) {
         				strRespStatus = "Cinema dates are not available at the moment, please try again later. 2.";
       			} else if (xmlHttp.status == 500) {
         				strRespStatus = "Cinema dates are not available at the moment, please try again later. 3.";
       			} else {
         				strRespStatus = "Cinema dates are not available at the moment, please try again later. 4.";
         		}
				document.getElementById("schedule_date_content").innerHTML = "<div id='bk-error'>Cinema dates are not available at the moment, please try again later</div>";
			} //200 Check
		}
	}


	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 DisplayTimes(strDivName)
	{
		var PrevTimesDivId;
		PrevTimesDivId = document.getElementById("PrevTimesDivId").value;
 		
 		if (PrevTimesDivId == strDivName) {
 			if (document.getElementById("times_" + PrevTimesDivId).style.display == "block") {
	 			document.getElementById("times_" + PrevTimesDivId).style.display="none";
		 		document.getElementById("div_" + PrevTimesDivId).className = "bkmov-box";
		 		document.getElementById("span_film_cert_" + PrevTimesDivId).className = "bkmov-film-cert";
		 		document.getElementById("img_" + PrevTimesDivId).src = "http://www.swancinemas.ie/imgs/booking/times.jpg";
	 			exit;
	 		}
 		}
 		if (PrevTimesDivId.length > 0) {
	 		document.getElementById("times_" + PrevTimesDivId).style.display="none";
		 	document.getElementById("div_" + PrevTimesDivId).className = "bkmov-box";
		 	document.getElementById("span_film_cert_" + PrevTimesDivId).className = "bkmov-film-cert";
		 	document.getElementById("img_" + PrevTimesDivId).src = "http://www.swancinemas.ie/imgs/booking/times.jpg";		 		
	 	}

 		document.getElementById("times_" + strDivName).style.display="block";
	 	document.getElementById("PrevTimesDivId").value = strDivName;
		document.getElementById("img_" + strDivName).src = "http://www.swancinemas.ie/imgs/booking/close.jpg";
	 	document.getElementById("div_" + strDivName).className = "bkmov-box_selected";
		document.getElementById("span_film_cert_" + strDivName).className = "bkmov-film-cert-selected";
 	}
	
	function LoadAllSchedule() {
		var strLink;

		//document.getElementById('site_title').innerHTML = document.getElementById('sitename').value;
		//strLink = "http://booking.omniplex.ie/new/newschedule.asp";
		//strLink = "cache_getscheduleall.php";
		//strLink = "./GetSchedule.asp";
		//strLink = "../GetScheduleAll.asp";
		strLink = "http://www.swancinemas.ie/booking/cache_getscheduleall.php";

		strLink = strLink + "?site=" + document.getElementById('sitename').value;
		document.getElementById("days-menu").style.display = "none";
 	
		//Get the next page contents
		xmlHttpNew = GetXmlHttpObject();
		if (xmlHttpNew == null) {
			alert("Your browser does not support AJAX.");
			return;
		}

		document.getElementById('schedule_content').innerHTML = "<br/><br/><p><img id='WaitingImage' src='http://www.omniplex.ie/imgs/UI/icons/loading.gif' /></p>";

		xmlHttpNew.onreadystatechange = AllSchedulePageGot;
		try {
			xmlHttpNew.open("GET",strLink,true);
		}
		catch (err)
		{
			alert(err.description);
		}

		xmlHttpNew.send(null);
	}

	function AllSchedulePageGot()
	{
		if (xmlHttpNew.readyState==4) 
		{
			if (xmlHttpNew.status==200) 
			{
				strReturn = xmlHttpNew.responseText
				//alert (strReturn);
				document.getElementById('schedule_content').innerHTML = "";
				if (strReturn.indexOf("SUCCESSTIMES") == -1) 
				{	
					//Error Occurred
					//If there is an error in the return then display error message
					//document.getElementById("schedule_content").innerHTML = strReturn;
					document.getElementById("schedule_content").innerHTML = "<div id='bk-error'>Cinema times are not available at the moment, please try again later</div>";
				}
				else 
				{
					//Success getting times
					strReturn = strReturn.replace("SUCCESSTIMES","");
					document.getElementById("schedule_content").innerHTML = strReturn;
					document.getElementById("schedule_date_content").innerHTML = "";
					document.getElementById("days-menu").style.display = "none";
					document.getElementById("all_link").innerHTML = "";
				}
			} else {
				var strRespStatus
       			if (xmlHttpNew.status == 404) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 1.";
       			} else if (xmlHttpNew.status == 403) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 2.";
       			} else if (xmlHttpNew.status == 500) {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 3.";
       			} else {
         				strRespStatus = "Cinema times are not available at the moment, please try again later. 4.";
         		}			
				document.getElementById("schedule_content").innerHTML = "<div id='bk-error'>" + strRespStatus + "</div>";
			}
		}
	}

$(document).ready( function(){ 
	$(".cb-enable").click(function(){
		var parent = $(this).parents('.switch');
		$('.cb-disable',parent).removeClass('selected');
		$(this).addClass('selected');
		$('.checkbox',parent).attr('checked', true);
		//alert($(this).text());
		LoadSchedule('');
	});
	$(".cb-disable").click(function(){
		var parent = $(this).parents('.switch');
		$('.cb-enable',parent).removeClass('selected');
		$(this).addClass('selected');
		$('.checkbox',parent).attr('checked', false);
		//alert($(this).text());
		LoadAllSchedule();
	});
});