// JavaScript Document

<!--
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var alpha = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
var numeric = "1234567890";
var dateMsg = "";
var dtCh= "/";
var minYear=1900;
var maxYear=2100;



/**
// -----------------------------------------------------------------------------------------------------------
//   TEMPLATE FOR VALIDATION FUNCTIONS
// -----------------------------------------------------------------------------------------------------------

function validateFunctionTemplate(normalColour, errorColour) {
	var msg = 'Please correct the following errors:\n';
	msg += '-------------------------------------------\n\n';
	
	var ok = true;
	
	// do this for every form element you are validating
	setBGColor("!!yourElementNameHere!!",normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("!!yourElementNameHere!!")) {
		ok = false;
		msg += "Please enter yourElementNameHere\n";
		setBGColor("!!yourElementNameHere!!",errorColour);
	}


	// if ok submit, it not display the errors
	if (!ok) {
		alert(msg);
	} else {
		document.!!yourFormNameHere!!.submit();
	}		

}
**/

function ResetSwfDivHeight(height){
    //window.alert('Do resize to ' + height);
    if (height != "0" && height != 0)
    {
        var containerHeight = document.getElementById('flashContainer'); 
        containerHeight.style.height = height + 'px'; 
        //window.alert('Flash div resized to ' + height);
    }
}

function GooglePPC(depositAmount, height){
    //window.alert('Do Google PPC tracking');
    //frames['_googlePPC'].location.href = "/templates/column_2/flash_container_google_code.asp?depositAmount=" + depositAmount;
    frames['_googlePPC'].location.href = "/FluorineGateway/paymentprocess/ppc.aspx?amount=" + depositAmount;
    ResetSwfDivHeight(height);
}

function GoToFlashTop(param) {
    //window.alert('Go to flash top');
    //window.location.href = "#flashtop";
    window.scrollTo(0,0);
    //window.alert('Done go to flash top');
}

function openFlashPopupWindow(url) {
    window.open(url, 'flashPopupWin', '');
}


// Deploy a flash movie OR alternative HTML
function DeployFlashWindow(flashMovieURL, requiredFlashVersion, width, height, noFlashHTML) {
	var ShowFlash=false;

	//alert(flashinstalled + '.' + installedFlashversion + '.' + requiredFlashVersion);
	if (flashinstalled == 1){
		if (installedFlashversion>=requiredFlashVersion) {
			ShowFlash=true;
		}
	}
	document.open();
	
	if (ShowFlash==true) {
		document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '"> ');
		document.write(' <param name="movie" value="' + flashMovieURL + '"> ');
		document.write(' <param name="wmode" value="Window"> ');
		document.write(' <param name="quality" value="high"> ');
		document.write(' <embed src="' + flashMovieURL + '" quality="high" wmode="Window" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
		document.write('</object>');
	} else {
		document.write(noFlashHTML);
		document.close();
	}
}


function DeployFlexApp(flashMovieURL, requiredFlashVersion, width, height, noFlashHTML, url, lcid, id) {
	var ShowFlash=false;

	//alert(flashinstalled + '.' + installedFlashversion + '.' + requiredFlashVersion);
	if (flashinstalled == 1){
		if (installedFlashversion>=requiredFlashVersion) {
			ShowFlash=true;
		}
	}
	document.open();
	
	if (ShowFlash==true) {
		document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '"> ');
		document.write(' <param name="movie" value="' + flashMovieURL + '"> ');
		document.write(' <param name="wmode" value="opaque"> ');
		document.write(' <param name="menu" value="false"> ');
		document.write(' <param name="quality" value="high"> ');
		document.write(' <param name="id" value="' + id + '"> ');
		document.write(' <param name="name" value="' + id + '"> ');
		document.write(' <param name="bgcolor" value="#ffffff"> ');
		document.write(' <param name="allowScriptAccess" value="sameDomain"> ');
		document.write(' <param name="flashvars" value="historyUrl=' + url + '%3F&lconid=' + lcid + '"> ');
		document.write(' <embed src="' + flashMovieURL + '" allowScriptAccess="sameDomain" quality="high" wmode="opaque" menu="false" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" id="' + id + '" name="' + id + '" flashvars="historyUrl=' + url + '%3F&lconid=' + lcid + '" bgcolor="#ffffff"></embed>');
		//document.write(' <embed src="' + flashMovieURL + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" id="' + id + '" name="' + id + '" flashvars="historyUrl=' + url + '%3F&lconid=' + lc_id + '" bgcolor="#ffffff"></embed>');
		document.write('</object>');
	} else {
		document.write(noFlashHTML);
		document.close();
	}
}


function getObj(n, d) { 
  var p,i,x;  
  if(!d) {
		d=document; 
	}
	if((p=n.indexOf("?")) > 0 && parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n]) && d.all) {
		x=d.all[n]; 
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
  for(i=0; !x&&d.layers && i<d.layers.length; i++) {
		x=getObj(n,d.layers[i].document);
	}
  if(!x && d.getElementById) {
		x=d.getElementById(n); 
	}
	return x;
}


function confirmation(guid) {
	var answer = confirm("Are you sure you want to delete this booking?")
	if (answer){
		//window.location = "http://www.google.com/";
		//alert(guid);
		document.location.href="bookingDelete.htm?bguid="+ guid;
	}
	else{
		
	}
}

function validate_login_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical

	var msg = ''	
	var ok = true;

	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';
	
	// do this for every form element you are validating
	setBGColor("txt_email", normalColour);
	setBGColor("txt_password", normalColour);
	
	// use the functions listed below to check your form elements
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}

	if (!isThere("txt_password")) {
		ok = false;
		msg += "Please enter your Password\n";
		setBGColor("txt_password",errorColour);
	}

	// if ok submit, if not display the errors
	if (!ok)
	{
		alert(msg);
		return false;
	}
	else
	{
		document.fm_login.submit();
	}
}

function fnBookingReminderOnClick()
{
	var msg = ''	
	var ok = true;

	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';
	
	// do this for every form element you are validating
	setBGColor("txt_email", normalColour);
	
	// use the functions listed below to check your form elements
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address and click the link again\n";
		setBGColor("txt_email",errorColour);
	}

	// if ok submit, if not display the errors
	if (!ok)
	{
		alert(msg);
		//return false;
	}
	else
	{
		document.fm_login.action = "login-3.htm"
		document.fm_login.submit();
	}	
}


function validate_contact_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;

	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';
	
	// do this for every form element you are validating
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	//setBGColor("address_1", normalColour);
	//setBGColor("town_city", normalColour);
	//setBGColor("county", normalColour);
	//setBGColor("postcode", normalColour);
	//setBGColor("txt_email", normalColour);
	//setBGColor("txt_confirm_email", normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}


	var address_1 = document.getElementById('address_1');	
	setBGColour(address_1,normalColour);
	if (address_1.value == '') {
		setBGColour(address_1,errorColour); 
		ok = false; 
		msg += "Please complete the 'Address 1' box\n";
	}	

	var town_city = document.getElementById('town_city');	
	setBGColour(town_city,normalColour);
	if (town_city.value == '') {
		setBGColour(town_city,errorColour); 
		ok = false; 
		msg += "Please complete the 'Town/City' box\n";
	}	
	
	//var county = document.getElementById('county');	
	//setBGColour(county,normalColour);
	//if (county.value == '') {
		//setBGColour(county,errorColour); 
		///ok = false; 
		//msg += "Please complete the 'County' box\n";
	//}		

	var postcode = document.getElementById('postcode');	
	setBGColour(postcode,normalColour);
	if (postcode.value == '') {
		setBGColour(postcode,errorColour); 
		ok = false; 
		msg += "Please complete the 'Postcode' box\n";
	}		
		
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
	}

	var tel_day = document.getElementById('tel_day');	
	var tel_eve = document.getElementById('tel_eve');	
	var tel_mob = document.getElementById('tel_mobile');	
	setBGColour(tel_day,normalColour);
	setBGColour(tel_eve,normalColour);
	setBGColour(tel_mob,normalColour);
	if (tel_day.value == '' && tel_eve.value == '' && tel_mob.value == '') {
		setBGColour(tel_day,errorColour); 
		setBGColour(tel_eve,errorColour); 
		setBGColour(tel_mob,errorColour); 
		ok = false; 
		msg += "Please provide at least 1 telephone number\n";
	}	
	
	
	// if ok submit, if not display the errors
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_contact.submit();
	}
}

function validateSplashPageEmailForm(normalColour, errorColour)
{
	var msg = ''	
	var ok = true;
	
	// do this for every form element you are validating
	setBGColor("txt_email", normalColour);
	
	// use the functions listed below to check your form elements
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}

	// if ok submit, if not display the errors
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_email.submit();
	}		
}





// -----------------------------------------------------------------------------------------------------------
// form validation functions
// -----------------------------------------------------------------------------------------------------------


// -----------------------------------------------------------------------------------------------------------
// checkes that a value has been entered
// -----------------------------------------------------------------------------------------------------------
function isThere(elementName) {
	var element = getObj(elementName);
	if (element.value == "") {
		return false;
	} else {
		return true;
	}
}

// -----------------------------------------------------------------------------------------------------------
// sets the background colour of an element
// -----------------------------------------------------------------------------------------------------------

function setBGColor(elementName, colour) {
	element = getObj(elementName);
	try {
		element.style.backgroundColor = colour;
	} catch (e) {
		alert(e);
	}
}

// -----------------------------------------------------------------------------------------------------------
// check a form elements length agains the entered value
// -----------------------------------------------------------------------------------------------------------
function checkLength(elementName, length) {
	var element = getObj(elementName);
	if (element.value.length < length) {
		return false;
	} else {
		return true;
	}
}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a select drop box matches a particular value
// -----------------------------------------------------------------------------------------------------------
function selectMatches(elementName, value) {
	var element = getObj(elementName);
	var elementValue = element.options[element.selectedIndex].value;
	if (elementValue == value) {
		return true;
	} else {
		return false;
	}
}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it is numeric
// -----------------------------------------------------------------------------------------------------------
function isNumeric(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789.";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it matches a credit card (can include spaces)
// -----------------------------------------------------------------------------------------------------------
function isCC(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789 ";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it matches a phone number
// does not do format checking, only checks that the characters entered are
// valid for a phone number
// -----------------------------------------------------------------------------------------------------------
function isPhoneNumber(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789 ()+";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checks if two elements values match
// -----------------------------------------------------------------------------------------------------------
function valuesMatch(element1, element2) {
	var e1 = getObj(element1);
	var e2 = getObj(element2);
	if (e1.value == e2.value) {
		return true;
	} else {
		return false;
	}
}

// -----------------------------------------------------------------------------------------------------------
// checks that a value has been entered and that it follows an email format.
// -----------------------------------------------------------------------------------------------------------
function emailCheck(elementName) 
{
	var email = getObj(elementName).value;
	invalidChars = " /:,;"

	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length)	{
		return false;
	}
	return true;
}

// -----------------------------------------------------------------------------------------------------------
// checks that a value has been entered and that it is a valid date
// -----------------------------------------------------------------------------------------------------------

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		dateMsg = "The date format should be : mm/dd/yyyy";
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		dateMsg = "Please enter a valid month";
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		dateMsg = "Please enter a valid day";
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		dateMsg = "Please enter a valid 4 digit year between "+minYear+" and "+maxYear;
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		dateMsg = "Please enter a valid date"
		return false;
	}
	return true;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this
}

// -----------------------------------------------------------------------------------------------------------
// Other functions
// -----------------------------------------------------------------------------------------------------------


// -----------------------------------------------------------------------------------------------------------
// formats a number to a particular number of decimals
// -----------------------------------------------------------------------------------------------------------
function formatNumber(expr, decplaces) {
	var str = "" + Math.round(eval(expr) * Math.pow(10, decplaces));
	while (str.length <= decplaces)
	{
		str += "0";
	}

	var decpoint = str.length - decplaces;

	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function showhide(qid) {
	for (var x=1; x <= 50; x++) {
	
		if (getObj('answer-' + x) != null) {
			getObj('answer-' + x).style.display = 'none';
		}
	}
	getObj('answer-' + qid).style.display = 'block';
}





function typeit(){
	getObj('typing').insertAdjacentText("beforeEnd",". ")
	setTimeout("typeit()",100)
}

function golink() {
	var sel = getObj('quicklinks').options[getObj('quicklinks').selectedIndex].value;
	window.document.location = sel;
}

function displaydatetime() {
	dateVar = new Date();
	thisday = dateVar.getDate();
	thismonth = getCalendarMonth(dateVar.getMonth());
	thisyear = dateVar.getFullYear();
	thishrs = dateVar.getHours();
	thismins = String(dateVar.getMinutes());
	
	if (thismins.length < 2) {
		thismins = '0' + thismins;
	}
	
	document.write(thisday + ' ' + thismonth + ' ' + thisyear + ' ' + thishrs + ':' + thismins);
	
	function getCalendarMonth(monthNum) {
			
		var moy = new Array(12)
		moy[0] = "January" 
		moy[1] = "February" 
		moy[2] = "March" 
		moy[3] = "April" 
		moy[4] = "May" 
		moy[5] = "June" 
		moy[6] = "July" 
		moy[7] = "August" 
		moy[8] = "September" 
		moy[9] = "October" 
		moy[10] = "November" 
		moy[11] = "December" 
		return moy[monthNum] 
	}
}

function openWindow(theURL, winName, features) {
	newWin=window.open(theURL, winName, features);
	newWin.originalWindow=window; // keep a reference to this window
}

function openTokenWindow(theURL, winName) {
	var w = 500;
	var h = 500;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	newWin=window.open(theURL, winName, "status=0,toolbar=0,scrolllbars=0,resizable=0,width=500,height=500,top="+top+",left="+left);
	newWin.originalWindow=window; // keep a reference to this window
	if (window.focus) {
	    newWin.focus();
	}
}

function setBGColour(element, colour){
	
	element.style.backgroundColor = colour;

}


function ConfirmMemberName()
{
	var Confirmed=false;
	Confirmed=confirm('Check name....\n\nFirstname: ' + document.frmStep1.first_name.value() + '\n!');
	if (Confirmed == true) {
		alert('ok!');//ValidateBookingStep1();
	}
}


function ValidateStep1SaveOrNext(strAction)
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
			
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	

	var booker_email = document.getElementById('txt_booker_email');	
	setBGColour(booker_email,strOKColour);
	if(!emailCheck("txt_booker_email"))
	{
		setBGColour(booker_email,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += "Please provide a valid email address for this booking\n";
	}

	var confirm_booker_email = document.getElementById('txt_confirm_booker_email');
	setBGColour(confirm_booker_email,strOKColour);
	if(!emailCheck("txt_confirm_booker_email") || confirm_booker_email.value != booker_email.value)
	{
		setBGColour(confirm_booker_email,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += "Please ensure the confirmation booking email address is valid and identical\n";
	}		

	if(blnCanSubmit == false){
		alert(strMsg);
	}
	else
	{
		if(strAction == "save")
		{
			document.frmStep1SaveOrNext.action = "booking_step_1-5.htm";
		}
		else
		{
			document.frmStep1SaveOrNext.action = "booking_step_1-6.htm";
		}
		document.frmStep1SaveOrNext.submit();
	}		
}


function ValidateBookingStep1()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
			
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	

	var booker_email = document.getElementById('txt_booker_email');	
	setBGColour(booker_email,strOKColour);
	if(!emailCheck("txt_booker_email"))
	{
		setBGColour(booker_email,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += "Please provide a valid email address for this booking\n";
	}
	else
	{
		document.frmStep1.booker_email.value = booker_email.value
	}



	var confirm_booker_email = document.getElementById('txt_confirm_booker_email');
	setBGColour(confirm_booker_email,strOKColour);
	if(!emailCheck("txt_confirm_booker_email") || confirm_booker_email.value != booker_email.value)
	{
		setBGColour(confirm_booker_email,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += "Please ensure the confirmation booking email address is valid and identical\n";
	}
	
	var member_title = document.getElementById('title');	
	setBGColour(member_title,strOKColour);
	if (member_title.selectedIndex == 0) {
		setBGColour(member_title,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please select Title \n";
	}
	
	var first_name = document.getElementById('first_name');	
	setBGColour(first_name,strOKColour);
	if (first_name.value == '') {
		setBGColour(first_name,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please specify First Name\n";
	}	
	
	var last_name = document.getElementById('last_name');	
	setBGColour(last_name,strOKColour);
	if (last_name.value == '') {
		setBGColour(last_name,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please specify Last Name\n";
	}	

	// Travel insurance **************************************************************************//
	var travel_insurance_required = document.frmStep1.travel_insurance_required;	
	// Set all radio buttons to OK colour
	for(i=0; i<travel_insurance_required.length; i++) {
			setBGColour(travel_insurance_required[i],strOKColour);
		}		
	
	// check if a radio button has been checked
	var blnTravelInsuranceSelected = false;
	for(i=0; i<travel_insurance_required.length; i++) {
			if (travel_insurance_required[i].checked == true)	{
				blnTravelInsuranceSelected = true;
				break
			}
		}
	// if radio button not checked, append to error message
  if (blnTravelInsuranceSelected == false) {
		for(i=0; i<travel_insurance_required.length; i++) {
			setBGColour(travel_insurance_required[i],strPleaseCorrectColour);
		}
		var blnCanSubmit = false;
		strMsg += "Please select whether or not Travel Insurance is required \n";	
	}	
	//alert(blnTravelInsuranceSelected);
	// END Travel insurance **************************************************************************//
	
	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 1 form');
		document.frmStep1.submit();
	}		

}


function ConfirmDelBookingMember(memberid, firstname, lastname, action)
{
	var Confirmed=false;
	Confirmed=confirm('Are you sure you want to delete the following party member?\n\n'+firstname+' '+lastname+'');
	if (Confirmed == true) {
		var gotoURL = '/booking_step_1('+memberid+')-'+action+'.htm';
		document.location.href=gotoURL;
	}
}

function BookingStep2SaveButtonOnClick(intNumberOfMembers)
{
	document.frmStep2.SaveButtonHasBeenClicked.value = "true";
	ValidateBookingStep2(intNumberOfMembers);
}

function ValidateBookingStep2(intNumberOfMembers)
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	
	
	// Loop through select boxes
	for(var i=0; i < document.frmStep2.elements.length; i++) {
		if (document.frmStep2.elements[i].name.indexOf('room_type_') > -1) {
			// increment total number of rooms selected
			//window.alert('increment by ' + document.frmStep2.elements[i].value);
			intTotalRoomsSelected = intTotalRoomsSelected + (document.frmStep2.elements[i].value -0);
		}
	}		

	//window.alert(intTotalRoomsSelected);

	if (intTotalRoomsSelected == 0)
	{
		var blnCanSubmit = false;
		strMsg += "Please select at least 1 room \n";	
	}	

	if (intTotalRoomsSelected > intNumberOfMembers)
	{
		var blnCanSubmit = false;
		strMsg += "You cannot select more than "+intNumberOfMembers+" room(s) for your booking \n";	
	}	


	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 2 form');
		document.frmStep2.submit();
	}		

}

function BookingStep3SaveButtonOnClick()
{
	document.frmStep3.SaveButtonHasBeenClicked.value = "true";
	ValidateBookingStep3();
}

function ValidateBookingStep3()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	

	// Loop through select boxes
	var blnEmptyBed = false;
	for(var i=0; i < document.frmStep3.elements.length; i++) {
		if (document.frmStep3.elements[i].name.indexOf('requested_occupants_') > -1) {
			//window.alert(document.frmStep3.elements[i].name + '=' + document.frmStep3.elements[i].value);
			if (document.frmStep3.elements[i].value == 0)	{
				blnEmptyBed = true;
				break
			}				
		}
	}		

	if (blnEmptyBed == true)
	{
		var blnCanSubmit = false;
		strMsg += "Please ensure that: \n\nSingle Rooms have 1 person allocated \nDouble/Twin rooms have 2 persons allocated";	
		strMsg += "\n\nIf you need to change your room selection, please click the 'Previous' button";
	}	
	

	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 3 form');
		document.frmStep3.submit();
	}		

}

function BookingStep4SaveButtonOnClick()
{
	document.frmStep4.SaveButtonHasBeenClicked.value = "true";
	ValidateBookingStep4();
}

function ValidateBookingStep4()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	
/*
	var frmEmailAddress = document.getElementById('email');
	setBGColour(frmEmailAddress,strOKColour);
	//if(frmEmailAddress.value == ''){
	if(!emailCheck("email")) {
		setBGColour(frmEmailAddress,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += 'Please enter a valid email address.\n';
	}		

	var frmConfirmEmailAddress = document.getElementById('confirm_email');
	setBGColour(frmConfirmEmailAddress,strOKColour);
	//if(frmEmailAddress.value != frmConfirmEmailAddress.value){
	if(!emailCheck("email") || frmEmailAddress.value != frmConfirmEmailAddress.value) {
		setBGColour(frmConfirmEmailAddress,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += "Please ensure the confirmation email address is valid and identical\n";
	}		
*/	
	var tel_day = document.getElementById('tel_day');	
	setBGColour(tel_day,strOKColour);
	if (tel_day.value == '') {
		setBGColour(tel_day,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please provide a daytime telephone number\n";
	}	

	var address_1 = document.getElementById('address_1');	
	setBGColour(address_1,strOKColour);
	if (address_1.value == '') {
		setBGColour(address_1,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please complete the 'Address 1' box\n";
	}	

	var town_city = document.getElementById('town_city');	
	setBGColour(town_city,strOKColour);
	if (town_city.value == '') {
		setBGColour(town_city,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please complete the 'Town/City' box\n";
	}	

	var country = document.getElementById('country');	
	setBGColour(country,strOKColour);
	if (country.value == -1) {
		setBGColour(country,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please select your country of residence\n";
	}	
	
	var terms = document.getElementById('terms');	
	setBGColour(terms,strOKColour);
	//if (optin.checked == false) {
	if (!terms.checked) {
		setBGColour(terms,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please confirm you have read & accepted the Terms & Conditions\n";
	}	
	


	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 4 form');
		document.frmStep4.submit();
	}		

}

function fnDisplayPackageOptionPopUp(packageOptionId)
{
	var url = "popup_package_option-" + packageOptionId + ".htm";
	var name = "Package Option Details";
	var args = "height=500,width=520,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no";
	window.open(url, null, args);
}


function css() {
	if( !window.ScriptEngine && navigator.__ice_version ) { return document.styleSheets; }
	if( document.getElementsByTagName ) { var Lt = document.getElementsByTagName('link'), St = document.getElementsByTagName('style');
	} else if( document.styleSheets && document.all ) { var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
	} else { return []; } for( var x = 0, os = []; Lt[x]; x++ ) {
		var rel = Lt[x].rel ? Lt[x].rel : Lt[x].getAttribute ? Lt[x].getAttribute('rel') : '';
		if( typeof( rel ) == 'string' && rel.toLowerCase().indexOf('style') + 1 ) { os[os.length] = Lt[x]; }
	} for( var x = 0; St[x]; x++ ) { os[os.length] = St[x]; } return os;
}


function openPopup()
{
	var url = "legal.htm";
	var name = "Legal Stuff";
	var args = "height=470,width=520,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no";
	window.open(url, null, args);
}


function validate_club_section_enquiry()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;

	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';
	
	// do this for every form element you are validating
	setBGColor("txt_club_name", normalColour);
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("tournament_id", normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_club_name")) {
		ok = false;
		msg += "Please enter your club name\n";
		setBGColor("txt_club_name",errorColour);
	}
	
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}

	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
	}
	
	if (!isThere("txt_tel")) {
		ok = false;
		msg += "Please enter a contact telephone number\n";
		setBGColor("txt_tel",errorColour);
	}

	if (document.fm_contact.tournament_id.selectedIndex == 0) {
		ok = false;
		msg += "Please choose a tournament\n";
		setBGColor("tournament_id",errorColour);
	}

	
	// if ok submit, if not display the errors
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_contact.hid_submitted.value='1';
		document.fm_contact.submit();
	}
}


// LionsTour 2009 Pre booking functions
function ValidatePreBookingStep1()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	

	var member_title = document.getElementById('title');	
	setBGColour(member_title,strOKColour);
	if (member_title.selectedIndex == 0) {
		setBGColour(member_title,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please select Title \n";
	}

	var first_name = document.getElementById('first_name');	
	setBGColour(first_name,strOKColour);
	if (first_name.value == '') {
		setBGColour(first_name,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please specify First Name\n";
	}	
	
	var last_name = document.getElementById('last_name');	
	setBGColour(last_name,strOKColour);
	if (last_name.value == '') {
		setBGColour(last_name,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please specify Last Name\n";
	}	

	var address_1 = document.getElementById('address_1');	
	setBGColour(address_1,strOKColour);
	if (address_1.value == '') {
		setBGColour(address_1,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please complete the 'Address 1' box\n";
	}	

	var town_city = document.getElementById('town_city');	
	setBGColour(town_city,strOKColour);
	if (town_city.value == '') {
		setBGColour(town_city,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please complete the 'Town/City' box\n";
	}	

	var postcode = document.getElementById('postcode');	
	setBGColour(postcode,strOKColour);
	if (postcode.value == '') {
		setBGColour(postcode,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please complete the 'Postcode' box\n";
	}		
	
	var country = document.getElementById('country');	
	setBGColour(country,strOKColour);
	if (country.value == -1) {
		setBGColour(country,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please select your country of residence\n";
	}		

	var frmEmailAddress = document.getElementById('email');
	setBGColour(frmEmailAddress,strOKColour);
	//if(frmEmailAddress.value == ''){
	if(!emailCheck("email")) {
		setBGColour(frmEmailAddress,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += 'Please enter a valid email address.\n';
	}		

	var frmConfirmEmailAddress = document.getElementById('confirm_email');
	setBGColour(frmConfirmEmailAddress,strOKColour);
	//if(frmEmailAddress.value != frmConfirmEmailAddress.value){
	if(!emailCheck("email") || frmEmailAddress.value != frmConfirmEmailAddress.value) {
		setBGColour(frmConfirmEmailAddress,strPleaseCorrectColour); 
		blnCanSubmit = false;
		strMsg += "Please ensure the confirmation email address is valid and identical\n";
	}		
	
	var tel_day = document.getElementById('tel_day');	
	var tel_eve = document.getElementById('tel_eve');	
	var tel_mob = document.getElementById('tel_mobile');	
	setBGColour(tel_day,strOKColour);
	setBGColour(tel_eve,strOKColour);
	setBGColour(tel_mob,strOKColour);
	if (tel_day.value == '' && tel_eve.value == '' && tel_mob.value == '') {
		setBGColour(tel_day,strPleaseCorrectColour); 
		setBGColour(tel_eve,strPleaseCorrectColour); 
		setBGColour(tel_mob,strPleaseCorrectColour); 
		blnCanSubmit = false; 
		strMsg += "Please provide at least 1 telephone number\n";
	}	


	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 1 form');
		document.frmStep1.submit();
	}		

}


// LionsTour 2009 Pre booking functions
function ValidatePreBookingStep2()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	


	// Pulldown validation
	/*
	var fixture = document.getElementById('fixture');	
	setBGColour(fixture,strOKColour);
	if (fixture.selectedIndex == 0) {
		setBGColour(fixture,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please select how many fixtures you are interested in\n";
	}
	var day = document.getElementById('day');	
	setBGColour(day,strOKColour);
	if (day.selectedIndex == 0) {
		setBGColour(day,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please select how many days you are interested in travelling for\n";
	}
	var hotel = document.getElementById('hotel');	
	setBGColour(hotel,strOKColour);
	if (hotel.selectedIndex == 0) {
		setBGColour(hotel,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please select what level of accomodation you are interested in\n";
	}	
	*/

	// Fixture **************************************************************************//
	var fixture = document.frmStep2.fixture;	
	// Set all radio buttons to OK colour
	for(i=0; i<fixture.length; i++) {
			setBGColour(fixture[i],strOKColour);
		}		
	
	// check if a radio button has been checked
	var blnFixtureSelected = false;
	for(i=0; i<fixture.length; i++) {
			if (fixture[i].checked == true)	{
				blnFixtureSelected = true;
				break
			}
		}
	// if radio button not checked, append to error message
	if (blnFixtureSelected == false) {
		for(i=0; i<fixture.length; i++) {
			setBGColour(fixture[i],strPleaseCorrectColour);
		}
		var blnCanSubmit = false;
		strMsg += "Please select how many fixtures you are interested in \n";	
	}	
	//alert(blnTravelInsuranceSelected);
	// END Fixture **************************************************************************//

	// Day **************************************************************************//
	var day = document.frmStep2.day;	
	// Set all radio buttons to OK colour
	for(i=0; i<day.length; i++) {
			setBGColour(day[i],strOKColour);
		}		
	
	// check if a radio button has been checked
	var blnDaySelected = false;
	for(i=0; i<day.length; i++) {
			if (day[i].checked == true)	{
				blnDaySelected = true;
				break
			}
		}
	// if radio button not checked, append to error message
	if (blnDaySelected == false) {
		for(i=0; i<day.length; i++) {
			setBGColour(day[i],strPleaseCorrectColour);
		}
		var blnCanSubmit = false;
		strMsg += "Please select how many days you are interested in travelling for \n";	
	}	
	//alert(blnTravelInsuranceSelected);
	// END Day **************************************************************************//
	
	// Hotel **************************************************************************//
	var hotel = document.frmStep2.hotel;	
	// Set all radio buttons to OK colour
	for(i=0; i<hotel.length; i++) {
			setBGColour(hotel[i],strOKColour);
		}		
	
	// check if a radio button has been checked
	var blnHotelSelected = false;
	for(i=0; i<hotel.length; i++) {
			if (hotel[i].checked == true)	{
				blnHotelSelected = true;
				break
			}
		}
	// if radio button not checked, append to error message
	if (blnHotelSelected == false) {
		for(i=0; i<hotel.length; i++) {
			setBGColour(hotel[i],strPleaseCorrectColour);
		}
		var blnCanSubmit = false;
		strMsg += "Please select what level of accomodation you are interested in \n";	
	}	
	//alert(blnTravelInsuranceSelected);
	// END Hotel **************************************************************************//		
	
	
	
	var places = document.getElementById('number_places');	
	setBGColour(places,strOKColour);
	if (places.selectedIndex == 0) {
		setBGColour(places,strPleaseCorrectColour); 
		blnCanSubmit = false; strMsg += "Please confirm how many places you would like to book\n";
	}		
	


	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 2 form');
		document.frmStep2.submit();
	}		

}


function ValidatePreBookingStep3()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	
	var strPleaseCorrectColour;
	var strOKColour;
	var intTotalRoomsSelected = 0;
		
	strPleaseCorrectColour = '#C7E0EF';
	strOKColour = '#FFFFFF';	

	var terms = document.getElementById('terms');	
	setBGColour(terms,strOKColour);
	if (!terms.checked) {
		setBGColour(terms,strPleaseCorrectColour); blnCanSubmit = false; strMsg += "Please confirm you have read and accepted the Terms & Conditions\n";
	}	

	if(blnCanSubmit == false){
		alert(strMsg);
	}else{
		//alert('Post Step 3 form');
		document.frmStep3.submit();
	}	
}


function validate_subscribe()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;

	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';
	
	// do this for every form element you are validating
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_confirm_email", normalColour);

	var tournamentsOk = false;
	for (i = 0; i < checkbox.length; i++) {
		if (checkbox[i].checked == true)
		{
			tournamentsOk = true;
			break;
		}
	}
	if (tournamentsOk == false) {
		ok = false;
		msg += "Please tick at least one tournament box in order to receive information\n";
	}

	
	// use the functions listed below to check your form elements
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}


	var address_1 = document.getElementById('address_1');	
	setBGColour(address_1,normalColour);
	if (address_1.value == '') {
		setBGColour(address_1,errorColour); 
		ok = false; 
		msg += "Please complete the 'Address 1' box\n";
	}	

	var town_city = document.getElementById('town_city');	
	setBGColour(town_city,normalColour);
	if (town_city.value == '') {
		setBGColour(town_city,errorColour); 
		ok = false; 
		msg += "Please complete the 'Town/City' box\n";
	}	
	
	var county = document.getElementById('county');	
	setBGColour(county,normalColour);
	if (county.value == '') {
		setBGColour(county,errorColour); 
		ok = false; 
		msg += "Please complete the 'County' box\n";
	}		

	var postcode = document.getElementById('postcode');	
	setBGColour(postcode,normalColour);
	if (postcode.value == '') {
		setBGColour(postcode,errorColour); 
		ok = false; 
		msg += "Please complete the 'Postcode' box\n";
	}		
	
	var country = document.getElementById('country');	
	setBGColour(country,normalColour);
	if (country.value == -1) {
		setBGColour(country,errorColour); 
		ok = false; 
		msg += "Please select your country of residence\n";
	}		

	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
	}

	/*
	var tel_mob = document.getElementById('tel_mobile');	
	setBGColour(tel_mob,normalColour);
	if (tel_mob.value == '') {
		setBGColour(tel_mob,errorColour); 
		ok = false; 
		msg += "Please enter your mobile telephone number\n";
	}
	*/
	
	// if ok submit, if not display the errors
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_email_updates.submit();
	}
}
