//STYLE SWITCH FUNCTIONS

function setActiveStylesheet(title) {
	linksFound = document.getElementsByTagName("link");
	for (i=0; i<linksFound.length; i++) {
		thisLink = linksFound[i];
   	if (thisLink.getAttribute("rel").indexOf("style") > -1 && thisLink.getAttribute("title")) {
			thisLink.disabled = true;
			if (thisLink.getAttribute("title") == title) {
				thisLink.disabled = false;
			}
		}
	}
}

//CALL SEARCH FORM WITH RESET
addLoadEvent(function () {
	if($('Srchelp')) {
		$('tktsearch').form.reset();
	}
});

//SET STYLE BUTTON FUNCTION
addLoadEvent(function () {
	if(document.getElementById('zoombut')) {
		document.getElementById('zoombut').getElementsByTagName('a').item(0).onclick = function() {
			if (this.getElementsByTagName('span').item(0).innerHTML != 'zoom') {
				this.getElementsByTagName('span').item(0).innerHTML = 'zoom';
				setActiveStylesheet('Default');
			} else {
				this.getElementsByTagName('span').item(0).innerHTML = 'Graphic version';
				setActiveStylesheet('Zoom');
			}
			//kill the href link
			return false;
		}
		//setActiveStylesheet('Default');
	}
});

//SET HELP BUTTONS
addLoadEvent(function() {
	if($('Srchelp')) {
		var srcHelpBtn = document.getElementById('Srchelp').getElementsByTagName('a').item(0);
		var srcHelpBox = DIV({"id":"srcHelpBox"},H3(null,"Help"),UL(null,LI(null,"Choose the date you would like to see the show"),LI(null,"Choose the show you would like to see"),LI(null,"Select the number of tickets you require"),LI(null,"Click GO")));
		appendChildNodes($('Wrapper'),srcHelpBox);
		hideElement($('srcHelpBox'));
		srcHelpBtn.onclick = function() { return false; }
		srcHelpBtn.onmouseover = function() {
			showElement($('srcHelpBox'));
		}
		srcHelpBtn.onmouseout = function() {
			hideElement($('srcHelpBox'));
		}
		//set GO button states
		$('tktsearch').onmouseover = function() {
			this.src = "g/gohv_btn.gif";
		}
		$('tktsearch').onmouseout = function() {
			this.src = "g/goup_btn.gif";
		}
		$('tktsearch').onclick = function() {
			this.src = "g/godn_btn.gif";
		}
		//disable GO button on form submit
		$('tktsearch').form.onsubmit = function() {
			$('tktsearch').disabled = "disabled";
		}
	}
	if($('Mailhelp')) {
		var mailHelpBtn = document.getElementById('Mailhelp').getElementsByTagName('a').item(0);
		var mailHelpBox = DIV({"id":"mailHelpBox"},H3(null,"Help"),P(null,"To join our mailing list and recieve advanced notification of special offers and improvements to the website."),UL(null,LI(null,"Type in your email address"),LI(null,"Click OK")));
		appendChildNodes($('Wrapper'),mailHelpBox);
		hideElement($('mailHelpBox'));
		mailHelpBtn.onclick = function() { return false; }
		mailHelpBtn.onmouseover = function() {
			showElement($('mailHelpBox'));
		}
		mailHelpBtn.onmouseout = function() {
			hideElement($('mailHelpBox'));
		}
		//set OK button states
		$('mailistok').onmouseover = function() {
			this.src = "g/okhv_btn.gif";
		}
		$('mailistok').onmouseout = function() {
			this.src = "g/okup_btn.gif";
		}
		$('mailistok').onclick = function() {
			this.src = "g/okdn_btn.gif";
		}
		//disable OK button on form and do ajax
//		$('mailistok').form.onsubmit = function() {
//			$('mailAlert').innerHTML = '<p><img src="g/waitani.gif" alt="" width="16" height="16" style="border:none;margin-right:7px;vertical-align:middle;" />Please wait...<\/p>';
//			$('mailistok').disabled = "disabled";
//			var d = doSimpleXMLHttpRequest("xmlmailist.php",{email: this.email.value});
//			var gotListData = function(lrslt) {
//				$('mailAlert').innerHTML = lrslt.responseText;
//				$('mailistok').disabled = "";
//			}
//			d.addCallback(gotListData);
//			return false;
//		}
	}
}); 

function showConfirmDialog(show,date,tickets,performance,venue,area,surcharge,total) {
	return confirm("You are about to book the following show.\nPlease note all tickets are non-refundable and non-transferable so please check details carefully.\n\n"+
		"\tShow : "+show+"\n"+
		"\tDate : "+date+"\n"+
		"\tTickets : "+tickets+"\n"+
		"\tArea : "+area+"\n"+
		"\tPerformance : "+performance+"\n"+
		"\tVenue : "+venue+"\n"+
		"\tSurcharge : £"+surcharge+"\n"+
		"\tTotal : £"+total+"\n\n"+
		"Press the OK button below to make your booking.");
}
