function trackConv() {
        var google_conversion_id = 1037481668;
        var google_conversion_label = "9TtXCLi41AEQxO3a7gM";
        image = new Image(1,1);
        image.src = "http://www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?label="+google_conversion_label+"&script=0";
} 

$(document).ready(function(){

// /* ------------------------------------------ Drop down menu ------------------------------------------ */ //

function rooms_down(){ $('#nav_rooms_dd').slideDown(400); }
function rooms_up(){ $('#nav_rooms_dd').slideUp(200); }
function dining_down(){ $('#nav_dining_dd').slideDown(400); }
function dining_up(){ $('#nav_dining_dd').slideUp(200); }
function events_down(){ $('#nav_events_dd').slideDown(400); }
function events_up(){ $('#nav_events_dd').slideUp(200); }


$('#li_nav_rooms').hoverIntent(rooms_down,rooms_up);
$('#li_nav_dining').hoverIntent(dining_down,dining_up);
$('#li_nav_events').hoverIntent(events_down,events_up);


/* ------------------------------------------ Footer Twitter ------------------------------------------ */

	$.getJSON('http://api.twitter.com/1/statuses/user_timeline/stanwellhotel.json?count=1&callback=?',function(tweet){
		var tweetTemp = tweet[0].text;
		
		if (tweetTemp) {
			tweetTemp = tweetTemp.trim().substring(0, 50)
			.split(" ").slice(0, -1).join(" ") + "&hellip;";
			$("#footer_twitter").html('"' + tweetTemp +'"');
		}
 
	});


// /* ------------------------------------------ Datepickers ------------------------------------------ */ //

$(function() {
		$("#checkin").datepicker({
			showButtonPanel: true,
			currentText: '',
			closeText: 'Close',
			minDate: 0,
			dateFormat: 'mm/dd/yy',
			onClose: function(date) { 
				$("#bookbar").validate().element( "#checkin" ) 
			}
	    });

		$("#checkout").datepicker({
			showButtonPanel: true,
			currentText: '',
			closeText: 'Close',
			minDate: 0,
			dateFormat: 'mm/dd/yy',
			onClose: function(date) { 
				$("#bookbar").validate().element( "#checkout" ) 
			}
	    });

		$("#bistro_date").datepicker({
			showButtonPanel: true,
			currentText: '',
			closeText: 'Close',
			minDate: 0,
			dateFormat: 'dd/mm/yy',
			onClose: function(date) { 
				$("#bistro_reservation").validate().element( "#bistro_date" ) 
			}
	    });

		$("#seafood_date").datepicker({
			showButtonPanel: true,
			currentText: '',
			closeText: 'Close',
			minDate: 0,
			dateFormat: 'dd/mm/yy',
			onClose: function(date) { 
				$("#seafood_reservation").validate().element( "#seafood_date" ) 
			}
			
	    });

		
		$("#bookbar_NEW").datepicker({
			showButtonPanel: true,
			currentText: '',
			closeText: 'Close',
			minDate: 0,
			dateFormat: 'dd/mm/yy',
			/*
			onClose: function(date) { 
				$("#bookbar").validate().element( "#bookbar_NEW" ) 
			},*/
			onSelect: function(dateText,picker) {
                                                 $('#bookDay').val( dateText.split(/\//)[0] );
                                                 $('#bookMonth').val( dateText.split(/\//)[1] );
                                                 $('#bookYear').val( dateText.split(/\//)[2] );
            }   
	    });



});

// /* ------------------------------------------ Bookbar Input clearing on focus ------------------------------------------ */ //

$('#no_adults').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});
	
$('#no_adults').blur(function() {
	if($(this).val() == "")
	 $(this).val(this.defaultValue);
});

$('#no_children').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});
	
$('#no_children').blur(function() {
	if($(this).val() == "")
	 $(this).val(this.defaultValue);
});

/* ------------------------------------------ Get directions postcode input clearing ------------------------------------------ */

$('#saddr').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});

$('#saddr').blur(function() {
	if($(this).val() == "")
	 $(this).val(this.defaultValue);
});


/* ------------------------------------------ Bookbar Validation ------------------------------------------ */

	/*
	$("#bookbar").validate({
		rules: {
		
		DateIn: {
		required: true,
		date: true
		},
		no_of_nights: {
		required: true,
		number: true
		}
		
		},
		
		messages: {
		DateIn: "",
		no_of_nights: ""
		}
	});

	$('#bookstay_button').click(function(){		
	
		if ($("#bookbar").valid() == false) {	
		return false;
		}
		
	});
	*/


// /* ------------------------------------------ TABS ------------------------------------------ */ //

$(function() { 
    $("ul#tabs").tabs("div.panes > div", {
		initialIndex:3
	}); 
});

var totaltabs = 5

<!-- Remove special offers tab if no offers currently active -->
if ( $(".offer_overview_link").length == 0 ) {
$('li#offers_tab').hide();
totaltabs = totaltabs - 1;
}

<!-- Remove festive offers tab if no offers currently active -->
if ( $(".festive_offer_overview_link").length == 0 ) {
$('li#festive_offers_tab').hide();
totaltabs = totaltabs - 1;
}


<!-- Generate random number to use to select a tab -->
/*taborder = Math.ceil(Math.random()*totaltabs);

taborder = taborder - 1

var api = $(".body_home ul#tabs").data("tabs");

if (typeof api != 'undefined') {
api.click(taborder);
}*/




<!-- Adjust spacer width to take up remaining space -->
var tabs_width = 0;
var a_width = 0;
var spacer_width = 940;

$('ul#tabs a').each(function(){
a_width = ($(this).width());
$(this).width(a_width + 5);
tabs_width = tabs_width + ($(this).outerWidth(true));
});

spacer_width = spacer_width - tabs_width;

$('li.end_spacer').css('width',spacer_width);


// /* ------------------------------------------ BISTRO Reservation ------------------------------------------ */ //

$("#bistro_reservation").validate({
	rules: {
	
	name: {
	required: true,
	minlength: 2
	},
	phone: {
	required: true
	},
	bistrodate: {
	required: true
	},
	diners: {
	required: true,
	maxlength: 2,
	number: true
	}
	
	},
	
	messages: {
	name: "",
	phone: "",
	bistrodate: "",
	diners: ""
	}
});

$('#bistro_submit').click(function(){		

	if ($("#bistro_reservation").valid() == false) {	
	return false;
	}

	if ($("#bistro_sms_subscribe").is(':checked')) {
	var subscriber = true;
	}

	var name = $("#bistro_name").val();
	var phone = $("#bistro_phone").val();
	var date = $("#bistro_date").val();
	var diners = $("#bistro_diners").val();
	var time = $("#bistro_time").val();


	var message = "A visitor to the Stanwell House website has made a reservation enquiry for the Bistro:"+"\n"+"\n"+"\n"+"Their name is: "+name+"\n"+"\n"+"Their phone number is: "+phone+"\n"+"\n"+"Their enquiry is for "+diners+" people on "+date+" at "+time+".";
	
	if (subscriber == true) {
	var message = message+"\n"+"\n"+"\n"+"They have also asked to receive future Bistro offers via mobile."
	}
	
	$.post("http://www.stanwellhousehotel.co.uk/sh_mail.php",	{ emailTo: 'enquiries@stanwellhouse.com', emailFrom: 'enquiries@stanwellhouse.com', subject: 'New Bistro reservation received from the Stanwell House website', message: message },	function(data){ 
			$("#bistro_reservation fieldset").fadeOut();											
			$('#dining_book h2').text("Thank you");
			$('#form_intro').text("We have received your request and will respond shortly with confirmation of your booking.");
			$("#contact_success").fadeIn();											
			
			if (subscriber == true) {
			$("#dining_book p#subscriber").html("You have also signed up to receive future offers about the Bistro by mobile.");
			};
			
			trackConv();
			
			});
	
	return false;
		
});						   

// /* ------------------------------------------ SEAFOOD Reservation ------------------------------------------ */ //

$("#seafood_reservation").validate({
	rules: {
	
	name: {
	required: true,
	minlength: 2
	},
	phone: {
	required: true
	},
	seafooddate: {
	required: true
	},
	diners: {
	required: true,
	maxlength: 2,
	number: true
	}
	
	},
	
	messages: {
	name: "",
	phone: "",
	seafooddate: "",
	diners: ""
	}
});

$('#seafood_submit').click(function(){		

	if ($("#seafood_reservation").valid() == false) {	
	return false;
	}

	if ($("#seafood_sms_subscribe").is(':checked')) {
	var subscriber = true;
	}

	var name = $("#seafood_name").val();
	var phone = $("#seafood_phone").val();
	var date = $("#seafood_date").val();
	var diners = $("#seafood_diners").val();
	var time = $("#seafood_time").val();


	var message = "A visitor to the Stanwell House website has made a reservation enquiry for the Seafood restaurant:"+"\n"+"\n"+"\n"+"Their name is: "+name+"\n"+"\n"+"Their phone number is: "+phone+"\n"+"\n"+"Their enquiry is for "+diners+" people on "+date+" at "+time+".";
	
	if (subscriber == true) {
	var message = message+"\n"+"\n"+"\n"+"They have also asked to receive future Seafood offers via mobile."
	}
	
	$.post("http://www.stanwellhousehotel.co.uk/sh_mail.php",	{ emailTo: 'enquiries@stanwellhouse.com', emailFrom: 'enquiries@stanwellhouse.com', subject: 'New Seafood reservation received from the Stanwell House website', message: message },	function(data){ 
			$("#seafood_reservation fieldset").fadeOut();											
			$('#dining_book h2').text("Thank you");
			$('#form_intro').text("We have received your request and will respond shortly with confirmation of your booking.");
			$("#contact_success").fadeIn();											
			
			if (subscriber == true) {
			$("#dining_book p#subscriber").html("You have also signed up to receive future offers about the Seafood restaurant by mobile.");
			};
			
			trackConv();
			
			});
	
	return false;
		
});						   


/* ------------------------------------------ CONTACT FORM ------------------------------------------ */

$("#contact_form2").validate({
	rules: {
	
	name: {
	required: true,
	minlength: 2
	},
	email: {
	required: true,
	email: true
	},
	phone: {
	required: true,
	minlength: 7
	},
	enquiry: {
	required: true,
	minlength: 2
	}
	
	},
	
	messages: {
	name: "",
	email: "",
	phone: "",
	enquiry: ""
	}
});

$("#directions_go").click(function(){

	var postcode = $("#saddr").val();

	if (postcode == 'Enter your postcode') {
		
	return false

	}

});


$('#contact_subscribe').click(function(){
	if ( $('#contact_subscribe').attr('checked') ) {
		$('#contact_sub_options').slideDown();	
	} else {
		$('#contact_sub_options').slideUp();	
	}
});


/* ------------------------------------------ COLORBOX ------------------------------------------ */

$(function(){
	
	$("#menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#menu_button2").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#menu_button3").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#menu_button4").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#menu_button5").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});

	$("#menu_link").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#wine_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#breakfast_menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#morning_menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#lunch_menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#tea_menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#cocktail_menu_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});
	$("#tariff_button").colorbox({transition:"none",iframe:true,height:600,width:770,scrolling:false,opacity:0.6});


});

/* ------------------------------------------ SCROLLABLE ------------------------------------------ */

$(function() { 
 
    $(".scroll_wrapper").scrollable({
	vertical: true,
	size: 1,
	clickable: false	
	}); 
 
}); 

/* ------------------------------------------ Newsletter signup ------------------------------------------ */

$("#newsletter_form_email").validate();

$("#newsletter_form_text").validate();

/* ------------------------------------------ Voucher order ------------------------------------------ */

$('#delivery_address1').click(function() {
	$('#recipient_address_row').slideUp();
});

$('#delivery_address2').click(function() {
	$('#recipient_address_row').slideDown();
});

$("#voucher_form").validate({
	rules: {
	
	contact_name: {
	required: true,
	minlength: 2
	},
	contact_phone: {
	required: true
	}
	
	},
	
	messages: {
	contact_name: "",
	contact_phone: ""
	}
	
	});

$('#voucher_form_submit').click(function(){		

	if ($("#voucher_form").valid() == false) {	
	return false;
	}

	var name = $("#contact_name").val();
	var phone = $("#contact_phone").val();
	var address = $("#contact_address").val();
	var email = $("#contact_email").val();
	var voucher_type = $('input[name=voucher_type]:checked').val();
	var voucher_value = $("#voucher_value").val();
	var voucher_msg = $("#voucher_msg").val();
	
	var delivery_address = $('input[name=delivery_address]:checked').val();

	if (delivery_address == 2) {
		
		var recip_address = $("#recipient_address").val();
		
	}

	var message = "A visitor to the Stanwell House website has made a request for a gift voucher. Their contact details are:\n\n"+name;
	
	if (address != "") {
		
		message = message + "\n"+address;
		
	}
	
	message = message + "\n"+phone;
	
	if (email != "") {
		
		message = message + "\n"+email;
		
	}
	
	message = message + "\n\nThey have requested a voucher for "+voucher_type;
	
	if (voucher_value != "") {
		
		message = message + " to the sum of "+voucher_value;
		
	}
	
	if (voucher_msg != "") {
	
		message = message + "\nThey would like the following message printed on their voucher:\n\n"+voucher_msg+"\n";
	
	}
	
	if (delivery_address == 2) {
		
		message = message + "\nThe voucher is to be sent to the following address:\n\n"+recip_address;
		
	} else if (delivery_address == 1 && address != "") {
		
		message = message + "\nThe voucher is to be sent to the above address"
		
	}
	
	$.post("http://www.stanwellhousehotel.co.uk/sh_mail.php",	{ emailTo: 'enquiries@stanwellhouse.com', emailFrom: 'enquiries@stanwellhouse.com', subject: 'New Voucher request from the Stanwell House website', message: message },	function(data){ 
																																																											 			$('#voucher_form').slideUp();
			$('#gift_heading h2').text("Thank You");	
			$('#gift_heading p').text("We have received your request for a gift voucher and will contact you shortly.");	

			});
	
	return false;
		
});			

/* ------------------------------------------ YACHT CHARTER ------------------------------------------ */

var yacht_contact_valid = false
var yacht_sender_valid = false
var yacht_message_valid = false

$('#yacht_form #sender').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});

$('#yacht_form #sender').blur(function() {
	if($(this).val() == "") {
	 $(this).val(this.defaultValue);
	 yacht_sender_valid = false
	} else {
	 yacht_sender_valid = true
	 $(this).css('color','#000000');
	}
});


$('#yacht_form #contact').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});

$('#yacht_form #contact').blur(function() {
	if($(this).val() == "") {
	 $(this).val(this.defaultValue);
	 yacht_contact_valid = false
	} else {
	 yacht_contact_valid = true
	 $(this).css('color','#000000');
	}
});

$('#yacht_form #message').focus(function() {
	if($(this).val() == this.defaultValue)
	$(this).val("");
});

$('#yacht_form #message').blur(function() {
	if($(this).val() == "") {
	 $(this).val(this.defaultValue);
	 yacht_message_valid = false
	} else {
	 yacht_message_valid = true
	 $(this).css('color','#000000');
	}
});

$('#yacht_form_submit').click(function() {
	
	if (yacht_sender_valid == false) {
		$('#yacht_form #sender').css('color','#ba0000');
		return false
	}

	if (yacht_contact_valid == false) {
		$('#yacht_form #contact').css('color','#ba0000');
		return false
	}
	
	if (yacht_message_valid == false) {
		$('#yacht_form #message').css('color','#ba0000');
		return false
	}

var sender = $('#sender').val();
var contact = $('#contact').val();
var message = $('#message').val();

var message = "New Yacht Charter enquiry received from the Stanwell House website.\n\nFrom: " + sender + "\nContact: " + contact + "\n\nEnquiry: " + message;

	$.post("http://www.stanwellhousehotel.co.uk/sh_mail.php",	{ emailTo: 'enquiries@stanwellhouse.com', emailFrom: 'enquiries@stanwellhouse.com', subject: 'New Yacht Charter enquiry from the Stanwell House website', message: message }, function(data){																																				 
	$('#yacht_form').slideUp();																																																											
	
	$('#yacht_form_success').fadeIn('slow');
	
	});
	
	return false

});

<!-- /doc_ready -->

});

