jQuery.fn.extend({	everyTime: function(interval, label, fn, times, belay) {		return this.each(function() {			jQuery.timer.add(this, interval, label, fn, times, belay);		});	},	oneTime: function(interval, label, fn) {		return this.each(function() {			jQuery.timer.add(this, interval, label, fn, 1);		});	},	stopTime: function(label, fn) {		return this.each(function() {			jQuery.timer.remove(this, label, fn);		});	}});jQuery.extend({	timer: {		guid: 1,		global: {},		regex: /^([0-9]+)\s*(.*s)?$/,		powers: {			// Yeah this is major overkill...			'ms': 1,			'cs': 10,			'ds': 100,			's': 1000,			'das': 10000,			'hs': 100000,			'ks': 1000000		},		timeParse: function(value) {			if (value == undefined || value == null)				return null;			var result = this.regex.exec(jQuery.trim(value.toString()));			if (result[2]) {				var num = parseInt(result[1], 10);				var mult = this.powers[result[2]] || 1;				return num * mult;			} else {				return value;			}		},		add: function(element, interval, label, fn, times, belay) {			var counter = 0;						if (jQuery.isFunction(label)) {				if (!times) 					times = fn;				fn = label;				label = interval;			}						interval = jQuery.timer.timeParse(interval);			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)				return;			if (times && times.constructor != Number) {				belay = !!times;				times = 0;			}						times = times || 0;			belay = belay || false;						if (!element.$timers) 				element.$timers = {};						if (!element.$timers[label])				element.$timers[label] = {};						fn.$timerID = fn.$timerID || this.guid++;						var handler = function() {				if (belay && this.inProgress) 					return;				this.inProgress = true;				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)					jQuery.timer.remove(element, label, fn);				this.inProgress = false;			};						handler.$timerID = fn.$timerID;						if (!element.$timers[label][fn.$timerID]) 				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);						if ( !this.global[label] )				this.global[label] = [];			this.global[label].push( element );					},		remove: function(element, label, fn) {			var timers = element.$timers, ret;						if ( timers ) {								if (!label) {					for ( label in timers )						this.remove(element, label, fn);				} else if ( timers[label] ) {					if ( fn ) {						if ( fn.$timerID ) {							window.clearInterval(timers[label][fn.$timerID]);							delete timers[label][fn.$timerID];						}					} else {						for ( var fn in timers[label] ) {							window.clearInterval(timers[label][fn]);							delete timers[label][fn];						}					}										for ( ret in timers[label] ) break;					if ( !ret ) {						ret = null;						delete timers[label];					}				}								for ( ret in timers ) break;				if ( !ret ) 					element.$timers = null;			}		}	}});if (jQuery.browser.msie)	jQuery(window).one("unload", function() {		var global = jQuery.timer.global;		for ( var label in global ) {			var els = global[label], i = els.length;			while ( --i )				jQuery.timer.remove(els[i], label);		}	});	/**	 * jQuery.placeholder - Placeholder plugin for input fields	 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)	 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).	 * Date: 2008/10/14	 *	 * @author Blair Mitchelmore	 * @version 1.0.1	 *	 **/	new function($) {	    $.fn.placeholder = function(settings) {	        settings = settings || {};	        var key = settings.dataKey || "placeholderValue";	        var attr = settings.attr || "placeholder";	        var className = settings.className || "placeholder";	        var values = settings.values || [];	        var block = settings.blockSubmit || false;	        var blank = settings.blankSubmit || false;	        var submit = settings.onSubmit || false;	        var value = settings.value || "";	        var position = settings.cursor_position || 0;	        return this.filter(":input").each(function(index) { 	            $.data(this, key, values[index] || $(this).attr(attr)); 	        }).each(function() {	            if ($.trim($(this).val()) === "")	                $(this).addClass(className).val($.data(this, key));	        }).focus(function() {	            if ($.trim($(this).val()) === $.data(this, key)) 	                $(this).removeClass(className).val(value)	                if ($.fn.setCursorPosition) {	                  $(this).setCursorPosition(position);	                }	        }).blur(function() {	            if ($.trim($(this).val()) === value)	                $(this).addClass(className).val($.data(this, key));	        }).each(function(index, elem) {	            if (block)	                new function(e) {	                    $(e.form).submit(function() {	                        return $.trim($(e).val()) != $.data(e, key)	                    });	                }(elem);	            else if (blank)	                new function(e) {	                    $(e.form).submit(function() {	                        if ($.trim($(e).val()) == $.data(e, key)) 	                            $(e).removeClass(className).val("");	                        return true;	                    });	                }(elem);	            else if (submit)	                new function(e) { $(e.form).submit(submit); }(elem);	        });	    };	}(jQuery);if (document.images) {var preloadImage;preloadImage = new Image();preloadImage.src = "/images/nav/home-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/careers-on.jpg";preloadImage = new Image();preloadImage.src = "/images/nav/press-on.jpg";preloadImage = new Image();preloadImage.src = "/images/nav/contact-on.jpg";preloadImage = new Image();preloadImage.src = "/images/nav/aberdeen-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/glasgow-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/birmingham-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/about-us-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/services-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/faq-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/tariffs-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/subscribe-on.gif";preloadImage = new Image();preloadImage.src = "/images/nav/news-on.gif";}function rollover() {window.status = arguments[0];if (document.images) {var inc, endInc=arguments.length-1;for (inc=1; inc<endInc; inc+=2) {image = new Image();image.src = arguments[inc];swapImage(arguments[inc+1]);}}}function rolloff() {if (document.images) {var inc, endInc=arguments.length;for (inc=0; inc<endInc; inc+=2) {image = new Image();image.src = arguments[inc];swapImage(arguments[inc+1]);}}window.status = '';}function swapImage(whichImage) {document.images[whichImage].src = image.src;}function switchMainImage(new_image_src){	$("#main_image").attr('src', new_image_src).fadeIn();	currentImage = -1;}currentImage = 0;function rotateImages(){	var thumbs = $(".gallery_thumb");			if (currentImage == -1)		return;	if (currentImage == null)		currentImage = 0;	currentImage = currentImage + 1;	if (currentImage == 4)		currentImage = 0;		if (thumbs.size() < currentImage)		currentImage = 0;		if ($("#main_image").length)		$("#main_image").attr('src', thumbs[currentImage].src).fadeIn();		}booking_locale = "en-gb";function openBookingEngine(){	location_val = $("#location").val();	if (location_val == "Glasgow")		hotel_id = 12117; 	else if (location_val == "Aberdeen")		hotel_id = 12118;	else if (location_val == "Birmingham")		hotel_id = 17727;	else	{		alert("Please select a location first.");		return false;	}				check_in_date = $("#checkIn").val();	nights = $("#numberOfNights").val();	adults = $("#numberOfAdults").val();	children = $("#numberOfChildren").val();	rooms = 1;	children = 0;			_gaq.push(['_trackEvent', 'booking_link', 'clicked'])		var booking_url = "https://reservations.synxis.com/gc/rez.aspx?Hotel=" + hotel_id + "&Chain=5445&locale=" + booking_locale + "&start=availresults&arrive=" + check_in_date + "&nights=" + nights + "&rooms=" + rooms + "&adult=" + adults + "&child=" + children + "&promo=&Submit2.x=110&Submit2.y=8"		window.location = booking_url;		}function parseDate(str) {   var mdy = str.split('/')  return new Date(mdy[2], mdy[1]-1, mdy[0]);}function bookmarkPage(url, title){ 	if (window.sidebar)	{		window.sidebar.addPanel(title, url,"");	} 	else if( window.external ) 	{		window.external.AddFavorite( url, title); 	}	else if(window.opera && window.print) 	{		return true; 	}		 	}function daydiff(first, second) {    return (second-first)/(1000*60*60*24)}$(document).ready(function() {	$(".fade").hide();	$(".feature_list").each(function() { 		$(".feature_list").find("li").each(function() { 				if ($(this)[0].innerHTML == "")					$(this).remove();			});	});	$("body").everyTime(7000, 'images', function() { rotateImages(); });		if ($("#checkIn").size() > 0)	{		$("#checkIn").datepicker();		$("#checkIn").datepicker('option', { dateFormat: 'dd/mm/yy' });		$("#checkIn")[0].value = $.datepicker.formatDate("dd/mm/yy", new Date());			$("#checkIn").change(function() {			book_form_touched = true;			var tomorrow = parseDate($("#checkIn")[0].value);			tomorrow.setTime(tomorrow.getTime() + (1000*3600*24));			var month = tomorrow.getMonth() + 1 + "";			var date = tomorrow.getDate() + "";			if (month.length == 1)				month = "0" + month;			if (date.length == 1)				date = "0" + date;		});			}	// 		// $(".bookButton").click(function() {	// 	$("#bookForm").submit();	// });		$("#search_field").bind('keypress', function(e){		var code = (e.keyCode ? e.keyCode : e.which);		 if(code == 13) { //Enter keycode			window.location = "/search?q=" + $("#search_field").val();		 }	});		$("#search_field").placeholder();	$("#search_button").click(function() {		window.location = "/search?q=" + $("#search_field").val();			});		$(".faq_answer").hide();	$(".faq_question").css('cursor', 'pointer');	$(".faq_question").click(function() { $(this).next().fadeIn(); });		$(".more_info_button, .features_button, .photos_button").bind("click", function(e) {		e.preventDefault();				if ($(this).hasClass("more_info_button"))		{			$(this).parent().parent().parent().find(".fade").fadeOut('fast', function() { 					$(this).parent().parent().parent().find(".fade:eq(200)").fadeIn();				} );		}			else if ($(this).hasClass("features_button"))		{			$(this).parent().parent().parent().find(".fade").fadeOut('fast', function() { 					$(this).parent().parent().parent().find(".fade:eq(0)").show();									} );					}		else if ($(this).hasClass("photos_button"))		{			$(this).parent().parent().parent().find(".fade").fadeOut('fast', function() { 					$(this).parent().parent().parent().find(".fade:eq(1)").fadeIn();				} );					}		e.stopPropagation();	});	});var tweetUsers = ['TheSpiresSuites'];var buildString = "";$(document).ready(function(){	// After the page is loaded	$('#twitter-ticker').slideDown('slow');	// Show the ticker	for(var i=0;i<tweetUsers.length;i++)	{		// Build the search api parameters		if(i!=0) buildString+='+OR+';		buildString+='from:'+tweetUsers[i];	}	var fileref = document.createElement('script');	// Creating a new script element	fileref.setAttribute("type","text/javascript");	fileref.setAttribute("src", "http://search.twitter.com/search.json?q="+buildString+"&callback=TweetTick&rpp=50");	// Setting its src to the search API URL; We provide TweetTick as a callback	document.getElementsByTagName("head")[0].appendChild(fileref);	// Appending it to the head of the page and thus executing it});function TweetTick(ob){	// This is the callback function	var container=$('#tweet-container');	container.html('');	// Removing the loading gif animation	$(ob.results).each(function(el){		// ob contains all the tweets		var str = '	<div class="tweet">\		<div class="avatar"><a href="http://twitter.com/'+this.from_user+'" target="_blank"><img src="'+this.profile_image_url+'" alt="'+this.from_user+'" /></a></div>\		<div class="user"><a href="http://twitter.com/'+this.from_user+'" target="_blank">'+this.from_user+'</a></div>\		<div class="time">'+relativeTime(this.created_at)+'</div>\		<div class="txt">'+formatTwitString(this.text)+'</div>\		</div>';		var str = '	<div class="tweet">\		<div class="time">'+relativeTime(this.created_at)+'</div>\		<div class="txt">'+formatTwitString(this.text)+'</div>\		</div>';		container.append(str);		// Adding the tweet to the container	});	container.jScrollPane();	// After all the tweets have been added, create the slidebar}function formatTwitString(str){	// This function formats the tweet body text	str=' '+str;	str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'<a href="$1" target="_blank">$1</a>');	// The tweets arrive as plain text, so we replace all the textual URLs with hyperlinks	str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@<a href="http://twitter.com/$2" target="_blank">$2</a>');	// Replace the mentions	str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1<a href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');	// Replace the hashtags	return str;}function relativeTime(pastTime){	// Generate a JavaScript relative time for the tweets	var origStamp = Date.parse(pastTime);	var curDate = new Date();	var currentStamp = curDate.getTime();	var difference = parseInt((currentStamp - origStamp)/1000);	if(difference < 0) return false;	if(difference <= 5)			return "Just now";	if(difference <= 20)			return "Seconds ago";	if(difference <= 60)			return "A minute ago";	if(difference < 3600)		return parseInt(difference/60)+" minutes ago";	if(difference <= 1.5*3600) 	return "One hour ago";	if(difference < 23.5*3600)	return Math.round(difference/3600)+" hours ago";	if(difference < 1.5*24*3600)	return "One day ago";	// If the tweet is older than a day, show an absolute date/time value;	var dateArr = pastTime.split(' ');	return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+	(dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');}
