

// a basic function to open a basic window with user specified url, width and heights.

function openwindow(url, width, height, scrollbars) {

	featurestr = "directories=0,height=" + height + ",location=0,menubar=0,resizable=0,status=0,toolbar=0,width=" + width + ", scrollbars=" + scrollbars;

	open(url, "_blank", featurestr);

}



// this one is a function that makes sure that a field (this) is an integer.

function make_int(field) {

	if(isNaN(field.value) || (field.value == "") || (field.value < 0)) {

		field.value = "0";

	}

	else {

		field.value = Math.round(field.value);

	}

}



// this is used on the tickets page, makes sure they're not booking more tickets than be available

function check_avail(quantity) {

	f = quantity.form;

	available = f.available;

	make_int(quantity);

	

	i = 0;

	total_quantity = 0;

	while(this_quantity = f["quantity_" + i]) {

		total_quantity += parseInt(this_quantity.value);

		i++;

	}

	if(total_quantity > available.value) {

		quantity.value = 0;

	}

}



// this function validates their details info

function good_details(f) {

	f = f.form;

	errors = "";

	

	// check required fields

	if(f.first_name.value == '') { errors += "\n   First Name"; }

	if(f.surname.value == '') { errors += "\n   Surname"; }
	
	if(f.address.value == '') { errors += "\n   Address"; }
	
	if(f.postcode.value == '') { errors += "\n   Post/Zip Code"; }
	
	if(f.phone.value == '') { errors += "\n   Phone Number"; }

	if(f.email.value == '') { errors += "\n   Email"; }

	if(f.hotel.value == '') { errors += "\n   Contact in London (use 'N/A' for none)"; }

	if(f.card_number.value == '') { errors += "\n   Credit Card Number"; }

	if(f.card_expires.value == '') { errors += "\n   Credit Card Expiry"; }

	if(f.card_cvn.value == '') { errors += "\n   Card Verification Number"; }

	

	// if from uganda, bitch

	if(f.country.value.toLowerCase() == "uganda") {

		alert("Sorry, but we cannot accept credit card bookings from Uganda, please call +44 207 233 7030 and place your booking manually.");

	}

	// if error, complain, else not

	else if(errors != "") {

		errors = "The following field(s) cannot be blank:\n" + errors + "\n\nPlease amend and try again.";

		alert(errors);

	}

	// make sure to read terms etc.

	else if(!f.confirm.checked) {

		alert("Please make sure you have read the Terms and Conditions.");

	}

	// or send the form

	else {

		f.submit();

	}

}



// this function validates their details info

function good_details2(f) {

	f = f.form;

	errors = "";

	

	// check required fields
	
	if(f.first_name.value == '') { errors += "\n   First Name"; }

	if(f.surname.value == '') { errors += "\n   Surname"; }
	
	if(f.address1.value == '') { errors += "\n   Address1"; }
	
	if(f.town.value == '') { errors += "\n   Town/City"; }

	if(f.county.value == '') { errors += "\n   County"; }
	
	if(f.postcode.value == '') { errors += "\n   Post/Zip Code"; }
	
	if(f.phone.value == '') { errors += "\n   Phone Number"; }
	
	if(f.mobile.value == '') { errors += "\n   Mobile Number"; }

	if(f.email.value == '') { errors += "\n   Email"; }
	
	if(f.email2.value == '') { errors += "\n   Email Again"; }
	

	// if error, complain, else not

	if(errors != "") {

		errors = "The following field(s) cannot be blank:\n" + errors + "\n\nPlease amend and try again.";

		alert(errors);

	}
	
	
	//check email address against second email
	
	else if(f.email.value != f.email2.value) {
		
		alert("Your email addresses do not match, please check you have entered them correctly"); 
			
	} 
	

	// make sure to read terms etc.

	else if(!f.confirm.checked) {

		alert("Please make sure you have read the Terms and Conditions.");

	}

	// or send the form

	else {

		f.submit();

	}

}


// this function validates their details info

function comp_closed(f) {


		alert("This free prize draw is now closed.");

	}


//hide links in status window

function hidestatus(){
	window.status=''
	return true
		}

		if (document.layers)
		document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

	document.onmouseover=hidestatus
	document.onmouseout=hidestatus

//bookmark page

var url = "http://www.GoldenTours.co.uk/"; 
var title = "GoldenTours.co.uk - London's Leading Sightseeing Company"; 
function bookmark(){ 
if(document.all) 
window.external.AddFavorite(url,title) 
} 


//function to print window
function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
