function hideBookingForm() {
	$("div#holdingPage").css({ 'display' : 'none'});//hide the opacity container
	$('div#enginePlacer').css({ 'display' : 'none'}); //'hide the place holder
	$("div#bookingform").css({ 'display' : 'none'}); //hide the booking form	
}

$(function() {
	// navigation ie6 fix for select element bug (add iframe)
	if ($.browser.msie && $.browser.version == 6){ 
	$('#navigation .secondary-level').each(function(){
		var width = $(this).outerWidth();
		var height = $(this).outerHeight();
		var cssWidth = $(this).css('width');
		var innerHeight = $(this).innerHeight();
		var bgColor = $(this).css('background-color');
		
		// add new wrapper
		$('ul',$(this)).wrapAll('<div class="nav_ul_wrapper"></div>');
		$('.nav_ul_wrapper',$(this)).css({
			'position':'absolute',
			'left': 0,
			'top': 0,
			'background-color': bgColor,
			'z-index': 2
		});
		
		// add iframe
		var iframe = '<iframe frameborder="0"></iframe>';
		$(this).append(iframe);
		var iframeElm = $('iframe',$(this));
		iframeElm.css({
				'position' : 'absolute',
				'left': 0,
				'top': 0,
				'z-index': 1,
				'width' : width,
				'height' : height
			});
	});
	}
	
	// navigation hover	
	$('#navigation>ul>li').hover(
		function(){
					$('a:first',$(this)).addClass('hover');
					$('.secondary-level',$(this)).show();
				},
		function(){
					$('a:first',$(this)).removeClass('hover');
					$('.secondary-level',$(this)).hide();
		}
	);
		/*
	$('#navigation>ul>li')
		.mouseover(function(){
					$('a:first',$(this)).addClass('hover');
					$('.secondary-level',$(this)).show();
				})
		.mouseout(function(){
					$('a:first',$(this)).removeClass('hover');
					$('.secondary-level',$(this)).hide();
				});*/
	
	
	$('ul.product-listing-b li').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	
	);
	
	// gallery
	if($('.gallery').length > 0){
		Gallery.init('.gallery');
	}
	
	// Cufon
	//Cufon.replace('h1.sifr,h2');
	
	//display a booking form in a lightbox 
	$("a.bookingform").click(function() {
		$('div#holdingPage').show();
		$('div#enginePlacer').show();
		$('#bookingform').css({ 'display' : 'block'}); 
	});
	//add closeBox function
	$("a.closeBox").click(function() {
		hideBookingForm();
		return false;
	});
	//add closeBox function
	$("div#holdingPage").click(function() {
		hideBookingForm();
	});
	
	$('#sendmailSubmit').click(function() {
		var errors = '';
		var surname = $('input#surname').val();
		var emailAddr = $('input#email').val();
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if( (surname == '') || (surname == 'Type your surname') ) {
			errors += 'Please enter your surname \n';
		}
		if( $("input:checked").length < 1 ) {
			if(reg.test(emailAddr) == false) {
				testresults = false;
			} else {
				testresults = true;
			}
			if( (emailAddr == '' ) || (emailAddr == 'Type your email address') || (testresults == false) ) {
				errors += 'Please enter your email address \n';
			}
		}
		if(errors != '') {
			alert(errors);
			return false;
		} else {
			if($('#brochureRequest').is(':checked')){
				$( "#q487" ).val( "1729" );
				$( "#signupredirect" ).val( "http://www.show-and-stay.co.uk/brochure-request.html?brochure=true" );
			}
			$('#sendmail').submit();
		}
	});
	
	var default_values = new Array();
	$("input.default").focus(function() {  
		if (!default_values[this.id]) {
			default_values[this.id] = this.value;
		}
		if (this.value == default_values[this.id]) {
			this.value = '';
		}
		$(this).blur(function() {
			if (this.value == '') {
				this.value = default_values[this.id];
			}
		}); 
	});
	
});
