function showRegions(id)
{
	if (id!="des_0")
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			//alert ("Browser does not support HTTP Request")
		return
		} 
		var url="include/regions-ajax.asp"
		url=url+"?id="+id
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=regionsChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function regionsChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var responseText=xmlHttp.responseText;
		if (responseText == '')
		{
			document.getElementById("region_insert").value='';
		}
		else
		{
			document.getElementById("region_insert").innerHTML=responseText;
		}
	} 
} 


function showPrice(day,month,year,contract,formnumber)
{
	if (isDate(day, month, year) == true)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			//alert ("Browser does not support HTTP Request")
		return
		} 
		var url="include/landing-sql.asp"
		url=url+"?day="+day+"&month="+month+"&year="+year+"&contract="+contract+"&formnumber="+formnumber
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	    var responseArray = xmlHttp.responseText.split("X");



	    document.getElementById("allocLeft" + responseArray[3]).value = responseArray[4];
		
		document.getElementById("adultAjax"+responseArray[3]).innerHTML=responseArray[0];
		document.getElementById("childAjax"+responseArray[3]).innerHTML=responseArray[1];
		document.getElementById("ageAjax"+responseArray[3]).innerHTML=responseArray[2];
		if (responseArray[0] == 'N/A')
		{
			document.getElementById("cont"+responseArray[3]).value='N';
		}
		else
		{
			document.getElementById("cont"+responseArray[3]).value='';
		}
	} 
} 

function showPriceCalendar(contract,dropdtls,form)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		//alert ("Browser does not support HTTP Request")
	return
	} 
	var url="include/allocation-popup-ajax.asp"
	url=url+"?contract="+contract+"&dropdtls="+dropdtls+"&form="+form
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedCalendar
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	function stateChangedCalendar() 
	{ 	
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("Allocation"+form).innerHTML=xmlHttp.responseText
			toggleLayer("CalendarForm"+form);
		} 
	} 
}

function showPriceP(month,year,id,contractname,navigation,form)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		//alert ("Browser does not support HTTP Request")
	return
	} 
	var url="include/package-calendar.asp"
	url=url+"?selyear="+year+"&selmonth="+month+"&id="+id+"&contractnames="+contractname+"&Navigation="+navigation+"&form="+form
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedDC
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showPriceDC(month,year,contracts,contractname,services,navigation,formnumber,noTicketInfo)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		//alert ("Browser does not support HTTP Request")
	return
	} 
	var url="include/allocation.asp"
	url=url+"?seldate="+year+" "+month+"&contracts="+contracts+"&contractnames="+contractname+"&services="+services+"&Navigation="+navigation+"&formnumber="+formnumber+"&noticketinfo="+noTicketInfo
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedDC
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedDC() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var responseArray=xmlHttp.responseText.split("XX");
		document.getElementById("Allocation"+responseArray[0]).innerHTML=responseArray[1];
	} 
} 

function grabReviews(suppliers,review)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		//alert ("Browser does not support HTTP Request")
	return
	} 
	var url="include/landing-page-reviews.asp"
	url=url+"?suppliers="+suppliers+"&getrecs="+review
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedR
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedR() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("Review").innerHTML=xmlHttp.responseText;
	} 
} 

function isDate (day,month,year) 
	{
	// checks if date passed is valid
	// will accept dates in following format:
	// isDate(dd,mm,ccyy), or
	// isDate(dd,mm) - which defaults to the current year, or
	// isDate(dd) - which defaults to the current month and year.
	// Note, if passed the month must be between 1 and 12, and the
	// year in ccyy format.
	
		var today = new Date();
		year = ((!year) ? y2k(today.getYear()):year);
		month = ((!month) ? today.getMonth():month-1);
		if (!day) return false
		var test = new Date(year,month,day);
		if ( (y2k(test.getYear()) == year) && (month == test.getMonth()) && (day == test.getDate()) )
			return true;
		else
			return false
	}
	
function y2k(number) 
	{ 
		return (number < 1000) ? number + 1900 : number;
	}
	
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        //alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        if (navigator.appVersion.indexOf("MSIE 7.0")>=1)
		{
			try
        	{
            	objXmlHttp=new XMLHttpRequest()
            	//objXmlHttp.onreadystatechange=handler
            	return objXmlHttp
        	}
        	catch(e)
        	{
            	//alert("Error. Scripting for XML might be disabled")
            	return
        	}
		}
		else
		{
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			}
			try
			{
				objXmlHttp=new ActiveXObject(strName)
				//objXmlHttp.onreadystatechange=handler
				return objXmlHttp
			}
			catch(e)
			{
				//alert("Error. Scripting for ActiveX might be disabled")
				return
			}
		}
    }
	
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
}

function checkForm(thisForm) {


    var ticketsBooked = parseInt(thisForm.ticketbookA_0.value) + parseInt(thisForm.ticketbookC_0.value);



    if (ticketsBooked > thisForm.allocLeft.value) {
        alert("We only have " + thisForm.allocLeft.value + " tickets left for sale on the website for the date you selected. If you require more tickets please call us.");
        return false;
    }

		
			if	(thisForm.ticketbookA_0.value==0 && thisForm.ticketbookC_0.value==0)
			{
				alert("You did not enter the number of tickets you require");
				return false;
			}
			if (thisForm.cont.value=='N')
			{
				alert("The date you are trying to book is not available for this attraction");
				return false;
			}
				
			if (isDate(thisForm.day.value, thisForm.month.value, thisForm.year.value) == false)
			{
				alert ("The date entered ("+thisForm.day.value+"/"+thisForm.month.value+"/"+thisForm.year.value+") is invalid. Please select a new date and press the 'Search' button.");
				
				return false;
			}
			
			var chosenDate = thisForm.day.value+" "+literalMonth(thisForm.month.value)+" "+thisForm.year.value;
			var date = new Date(chosenDate);
			var now = new Date();
			var diff = date.getTime() - now.getTime();
			var days = Math.floor(diff / (1000 * 60 * 60 * 24));
			if (days < 0) {
				alert("Please choose a date in the future");
				return false;
			}
			
			{
		   
			
			}  
			return true;
		}
		
function CreateBookmarkLink(url)
 {
	title = "AttractionTix - Pay, Print, Present"; 	

	if (window.sidebar)
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}
	else if( window.external)
	{ // IE Favorite
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print)
	{ // Opera Hotlist
		return true;
	}
 }
 
 function SetCalendarValue(thisForm, FormDay, FormMonth, FormYear, contract)
{
	document.getElementById("tick"+thisForm).day.value=FormDay;
	document.getElementById("tick"+thisForm).month.value=FormMonth;
	document.getElementById("tick"+thisForm).year.value=FormYear;
	showPrice(FormDay,FormMonth,FormYear,contract,thisForm)
}

function literalMonth(month, form)
		{
			var shortMonth = new String();
			var numericMonth = new Number();
		
			numericMonth = month;
		
			if (numericMonth == 1) {shortMonth = "Jan"}
			if (numericMonth == 2) {shortMonth = "Feb"}
			if (numericMonth == 3) {shortMonth = "Mar"}
			if (numericMonth == 4) {shortMonth = "Apr"}
			if (numericMonth == 5) {shortMonth = "May"}
			if (numericMonth == 6) {shortMonth = "Jun"}
			if (numericMonth == 7) {shortMonth = "Jul"}
			if (numericMonth == 8) {shortMonth = "Aug"}
			if (numericMonth == 9) {shortMonth = "Sep"}
			if (numericMonth == 10) {shortMonth = "Oct"}
			if (numericMonth == 11) {shortMonth = "Nov"}
			if (numericMonth == 12) {shortMonth = "Dec"}
		
			return shortMonth;
		}
		
function setDate(dayDate, monthDate, yearDate, FormName)
		{
			var form = eval("document." + FormName);
			form.bdate.value=dayDate + "-" + literalMonth(monthDate, form) + "-" + yearDate;
		}