function clearBox(f) {
	if(f.defaultValue==f.value) {
		f.value = '';	
	}
}

function restoreBox(f) {
	if(f.value=='') {
		f.value = f.defaultValue;	
	}
}

function s(id) {
	document.getElementById(id).style.display = 'block';
}

function h(id) {
	document.getElementById(id).style.display = 'none';
}

function runSlideShow() {
	if (document.all){
		document.images.PictureBox.style.filter="blendTrans(duration=2)";
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans.Apply();
	}
	document.images.PictureBox.src = preLoad[jss].src;
	if (document.getElementById) document.getElementById("link-url").href = Caption[jss];
	if (document.all) document.images.PictureBox.filters.blendTrans.Play();
	jss = jss + 1;
	if (jss > (pss)) jss=1;
	tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function loadMap() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		var point = new GLatLng(51.521687,-0.145244);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(point, 15);
		
		function createMarker(point, icon, html) {
			var marker = new GMarker(point, icon);
			GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
			});
			return marker;
		}
		
		/* add 76 Portland Place details */
		var addresses = Array();
		addresses[0] = Array(51.521687,-0.145244,'logo-small.png',"<div class='title'><strong>76 Portland Place</strong></div><div class='detail'>London<br>W1B 1NT</div>");
		
		var icon = new GIcon();
		icon.shadow = "/images/logo-small-shadow.png";
		icon.iconSize = new GSize(60, 71);
		icon.shadowSize = new GSize(97, 71);
		icon.iconAnchor = new GPoint(48, 70);
		icon.infoWindowAnchor = new GPoint(12, 0);
		icon.image = "/images/"+addresses[0][2];		
		var point = new GLatLng(addresses[0][0], addresses[0][1]);
		map.addOverlay(createMarker(point, icon, addresses[0][3]));		
		
		
		/* other locations */
		addresses[1] = Array(51.52216241009077,-0.14209270477294922,'green.png',"<div class='title'><strong>Holiday Inn London Regents Park</strong></div><div class='detail'>Carburton Street<br />London<br />W1W 5EE<br /><br /><div class='telephone' title='Telephone'>0870 400 9111</div><div class='website' title='Website'><a href=\"http://www.holidayinn.co.uk\" target=\"_blank\">www.holidayinn.co.uk</a></div></div>");
		addresses[2] = Array(51.522309273255594,-0.14277935028076172,'green.png',"<div class='title'><strong>Grange Fitzrovia Hotel</strong></div><div class='detail'>20-28 Bolsover Street<br />London<br />W1W 5NB<br /><br /><div class='telephone' title='Telephone'>+44 (0) 20 7467 7000</div><div class='fax' title='Fax'>+44 (0) 20 7636 5085</div><div class='email' title='Email'><a href=\"mailto:reservations@grangehotels.com\">reservations@grangehotels.com</a></div><div class='website' title='Website'><a href=\"http://www.grangehotels.com\" target=\"_blank\">www.grangehotels.com</a></div></div>");
		addresses[3] = Array(51.51915828688337, -0.14127731323242187,'green.png',"<div class='title'><strong>Grange Langham Court Hotel</strong></div><div class='detail'>31-35 Langham Street<br />London<br />W1W 6BU<br /><br /><div class='telephone' title='Telephone'>+44 (0) 20 7436 6622</div><div class='fax' title='Fax'>+44 (0) 20 7436 2303</div><div class='email' title='Email'><a href=\"mailto:langhamcourt@grangehotels.com\">langhamcourt@grangehotels.com</a></div><div class='website' title='Website'><a href=\"http://www.grangehotels.com\" target=\"_blank\">www.grangehotels.com</a></div></div>");
		addresses[4] = Array(51.5231103367263, -0.14463543891906738,'yellow.png',"<div class='title'><strong>Devonshire Row Mews Carpark</strong></div><div class='detail'>London<br />W1N 5FU<br /><br /><div class='telephone' title='Telephone'>0800 074 3974</div></div>");
		addresses[5] = Array(51.52289672117861, -0.14243602752685547,'yellow.png',"<div class='title'><strong>National Car Park</strong></div><div class='detail'>Holiday Inn<br />Carburton Street<br />London<br />W1W 5AJ<br /><br /><div class='telephone' title='Telephone'>0870 606 7050</div></div>");
	
		var icon = new GIcon();
		icon.shadow = "/images/msmarker_shadow.png";
		icon.iconSize = new GSize(12, 20);  // sets the size of the icon
		icon.shadowSize = new GSize(22, 20);  // sets the size of the shadow
		icon.iconAnchor = new GPoint(6, 20);  // sets the bottom position of the anchor - (half the width of the iconSize, full height of iconSize)
		icon.infoWindowAnchor = new GPoint(12, 0);  // sets the offset of the information speach bubble
	
		for(i=1;i<addresses.length;i++) {
			icon.image = "/images/"+addresses[i][2];		
			var point = new GLatLng(addresses[i][0], addresses[i][1]);
			map.addOverlay(createMarker(point, icon, addresses[i][3]));
		}
	}
}
/* if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false); */

function toggle(id) {
	if(document.getElementById) {
		if(document.getElementById(id).style.display=='block') {
			document.getElementById(id).style.display = 'none';
		}
		else {
			document.getElementById(id).style.display = 'block';
		}
		return false;
	}
	else {
		return true;	
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function Validate() {

	/* Items that require a text input */
	var myVars = new Array("frm_name",
												 "frm_postcode",
												 "frm_contact",
												 "frm_telephone",
												 "frm_fax"
													);
	
	for(i=0;i<myVars.length;i++){
		var id = myVars[i];
		if(document.getElementById(id).value == ""){
			document.getElementById(id).style.borderColor = "#f67f7f";
			
			var errors = 'yes';
		}
		else {
			document.getElementById(id).style.borderColor = "#cccccc";
		}
	}
	
	var email = document.getElementById("frm_email").value;

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){
			document.getElementById("frm_email").style.borderColor = "#f67f7f";
	
			var errors = 'yes';
		}
		else {
			document.getElementById("frm_email").style.borderColor = "#cccccc";
		}


	if(errors == 'yes'){
		alert("Your booking submission failed.\n\n Please correct the errors highlighted in red.\n");
		self.scrollTo(0, 0);
		return false;
	}
	else {
		if(document.getElementById("frm_verify").checked == true){
			return true;
		}
		else {
			alert("Please confirm that you have read and accepted the\n Terms and Conditions by checking the box provided");
			return false;
		}
	}
}