$(document).ready( function(){
	$(function(){
	  $("a[rel*='external']").click(function(){
	   this.target = "_blank";
	  });
	});
	
	//map tooltip
	$.tools.addTipEffect("slidedown",  
		function() { 
			var opacity = this.getConf().opacity;
			this.getTip().css({opacity:0}).animate({top: '+=90', opacity:opacity}, 300).show();
		}, 
		function() {
			this.getTip().animate({top: '+=90', opacity:0}, 300, function() { 
					$(this).hide().animate({top: '+=30'}, 0);
			});
		}
	);
	$("#trigger").tooltip({effect: 'slidedown'});

});

// adding nav li:hover support for ie6
if($.browser.msie && $.browser.version=="6.0") {
	$(document).ready(function() {
		$('#nav ul li').hover(function() {
			$(this).addClass('jshover');
		}, function() {
			$(this).removeClass('jshover');
		});
	});
};

//form validation
function contactUs(){
	// Make quick references to our fields
	var name = document.getElementById('name');
	var subject = document.getElementById('subject');
	var email = document.getElementById('email');
	var message = document.getElementById('message');
		if(notEmpty(name, "Please enter your name")){
			if(emailValidator(email, "Please enter a valid email address")){
				if(madeSelection(subject, "Please choose a subject")){
					if(notEmpty(message, "Please enter a message")){
						return true;
					}
				}
			}
		}
	return false;
};

function haveYourSay(){
	// Make quick references to our fields
	var booking = document.getElementById('booking');
	var name = document.getElementById('name');
	var subject = document.getElementById('subject');
	var email = document.getElementById('email');
	var message = document.getElementById('message');
	var rating = ratingValue;
	
	if(notEmpty(booking, "Please enter your booking/invoice #")){
		if(notEmpty(name, "Please enter Name")){
			if(notEmpty(subject, "Please enter subject")){
				if(notEmpty(email, "Please enter your email")){
					if(notEmpty(message, "Please enter a message")){
						sendMail();
						return false;
					}
				}
			}
		}
	}
	return false;
};

function subscribe(){
	// Make quick references to our fields
	var name = document.getElementById('name');
	var email = document.getElementById('email');
		if(notEmpty(name, "Please enter your name")){
			if(emailValidator(email, "Please enter a valid email address")){
				return true;
			}
		}
	return false;
};

function sendMail(){
	$.post('sendmail.php', {
		name: $('#name').val(),
		email: $('#email').val(),
		booking: $('#booking').val(),
		subject: $('#subject').val(),
		message: $('#message').val(),
		rating: ratingValue,
		save: 'true'
	},
	function(r){
		$('#have-your-say .standard-form').hide();
		$('.thank-for-email').show();
	});
	return false;
};

function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
};

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose a Subject"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
};

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
};

/* ================================================================ 
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
slideshow = function() {
	var current = 1;
	var total = $('.entry').length;
	$('.entry').hide();
	$('#photo1').fadeIn('slow');
	$('#imagenumber').html('1/' + total );
	setHeight(1);
	setInterval(function(){
		nextPicture()
	},5000);
	
	$('a.previous').click(function(){
		prevPicture();
		return false;
	});
	
	$('a.next').click(function(){
		nextPicture();
		return false;
	});
	
	function setHeight(current) {
	var entryHeight = $('#photo' + current).outerHeight() + 20;
	$('#slideshow-content').animate({ height: entryHeight + 'px'}, 500 );
	};
	
	function prevPicture(){
		var prev  = current - 1;
		if (prev < 1) prev = total;
		if (current != 1) {
			$('#photo' + current).fadeOut('slow');
			$('#photo' + prev).fadeIn('slow');
			current = prev;
			setHeight(current)
			$('#imagenumber').html(current + '/' + total)
		} else {
			$('#photo' + current).fadeOut('slow');
			$('#photo' + prev).fadeIn('slow');
			current = prev;
			setHeight(current)
			$('#imagenumber').html(current + '/' + total);
		}
	}
	
	function nextPicture(){
		var next = current + 1;
		if (next > total) next = total;
		if (current != total) {
			$('#photo' + current).fadeOut('slow');
			$('#photo' + next).fadeIn('slow');
			current = next;
			setHeight(current)
			$('#imagenumber').html(current + '/' + total)
		} else {
			next = 1;
			$('#photo' + current).fadeOut('slow');
			$('#photo' + next).fadeIn('slow');
			current = 1;
			setHeight(current)
			$('#imagenumber').html(current + '/' + total)
		}
	}
};

//packed version. see calendar.js in src dir


/* packed verson. see globekey.js in src dir */
var daysinAdvance=1;var numberNights=2;var numberYears=4;var numberNightsMin=1;var imgDir="/images/global/";var wdDisplay=0;var numberNightsDisplay=1;var departDateDisplay=1;var departDateUpdate=1;var wdArray=new Array("");var nightTxt=" Night";var nightsTxt=" Nights";var invalidDateTxt="Invalid Arrival Date. Please check number of days selected";var invalidDatePriorTxt="Arrival Date selected is prior Today's date. Please change...";var invalidDepartDateTxt="Invalid Departure Date. Please check number of days selected";var invalidDepartTxt="Departure Date is prior to Arrival Date selected. Please change...";var invalidNightsTxt="Sorry, reservations under "+numberNightsMin+" nights are not accepted.";var aNumDays=new Array(31,0,31,30,31,30,31,31,30,31,30,31);if(departDateDisplay==0){numberNightsDisplay=0;departDateUpdate=0};function calendarCallback(day,month,year,objName,formName){if(objName=="calendarArrive"){document.forms[formName].fd.selectedIndex=day-1;document.forms[formName].fm.selectedIndex=month-1;document.forms[formName].fy.selectedIndex=year-document.forms[formName].fy.options[0].text;updateDates(document.forms[formName]);setWkd(formName,1)}else{document.forms[formName].td.selectedIndex=day-1;document.forms[formName].tm.selectedIndex=month-1;document.forms[formName].ty.selectedIndex=year-document.forms[formName].ty.options[0].text;setWkd(formName,1)}};function updateDates(form,loadDates){if(form.fm.selectedIndex==1){var leapYear=new Date(form.fy.options[form.fy.selectedIndex].text,form.fm.selectedIndex+1,1);var leapYear=new Date(leapYear-(24*60*60*1000));var numDaysInMonth=leapYear.getDate()}else{var numDaysInMonth=aNumDays[form.fm.selectedIndex]}if(loadDates==1||departDateUpdate==1){var selectDate=new Date(form.fy.options[form.fy.selectedIndex].text,form.fm.selectedIndex,form.fd.selectedIndex);var setDate=new Date(selectDate.getTime()+((numberNights+1)*86400000));var setDay=setDate.getDate();var setMonth=setDate.getMonth();var setYear=setDate.getFullYear()-form.fy.options[0].text;var checkinDate=new Date(form.fy.options[form.fy.selectedIndex].text,form.fm.selectedIndex,form.fd.selectedIndex+1);var checkoutDate=new Date(form.ty.options[form.ty.selectedIndex].text,form.tm.selectedIndex,form.td.selectedIndex+1);if(checkinDate>checkoutDate){if(setYear==form.ty.length){form.td.options[30].selected=1;form.tm.options[11].selected=1;form.ty.options[form.ty.length-1].selected=1}else{form.td.options[setDay-1].selected=1;form.tm.options[setMonth].selected=1;form.ty.options[setYear].selected=1}}}if(form.fd.selectedIndex+1>numDaysInMonth){alert(invalidDateTxt);form.fd.selectedIndex=numDaysInMonth-1}};function setWkd(form,calendar){if(calendar)form=document.forms[form];for(var i=0;i<form.fy.length;i++){if(form.fy.options[i].selected)var fyear=form.fy.options[i].text;if(departDateDisplay==1&&form.ty.options[i].selected)var tyear=form.ty.options[i].text}var checkinDate=new Date(fyear,form.fm.selectedIndex,form.fd.selectedIndex+1);if(departDateDisplay==1)var checkoutDate=new Date(tyear,form.tm.selectedIndex,form.td.selectedIndex+1);var numNights=Math.round((checkoutDate-checkinDate)/86400000);if(numNights==1)numNights+=nightTxt;else numNights+=nightsTxt;if(wdDisplay==1&&document.getElementById){document.getElementById('inWd').firstChild.nodeValue='('+wdArray[checkinDate.getDay()]+')';if(departDateDisplay==1)document.getElementById('outWd').firstChild.nodeValue='('+wdArray[checkoutDate.getDay()]+')'}if(numberNightsDisplay==1&&document.getElementById)document.getElementById('lengthStay').firstChild.nodeValue=numNights};function LoadDates(form){var curDate=new Date();var setDate=new Date(curDate.getTime()+(daysinAdvance*86400000));var setDay=setDate.getDate();var setMonth=setDate.getMonth();var setYear=setDate.getFullYear()-form.fy.options[0].text;form.fd.selectedIndex=setDay-1;form.fm.selectedIndex=setMonth;form.fy.selectedIndex=setYear;updateDates(form,departDateDisplay);if(wdDisplay==1||numberNightsDisplay==1)setWkd(form)};function checkDates(form){form.elements["d-in"].value=$('#fd').val();form.elements["d-out"].value=$('#td').val();form.elements["my-in"].value=$('#fy').val()+'-'+$('#fm').val();form.elements["my-out"].value=$('#ty').val()+'-'+$('#tm').val();var curDate=new Date();for(var i=0;i<form.fy.length;i++){if(form.fy.options[i].selected)var fyear=form.fy.options[i].text;if(departDateDisplay==1&&form.ty.options[i].selected)var tyear=form.ty.options[i].text}var checkinDate=new Date(fyear,form.fm.selectedIndex,form.fd.selectedIndex+2);if(departDateDisplay==1){if(form.tm.selectedIndex==1){var leapYear=new Date(form.ty.options[form.ty.selectedIndex].text,form.tm.selectedIndex+1,1);var leapYear=new Date(leapYear-(24*60*60*1000));var numDaysInMonth=leapYear.getDate()}else{var numDaysInMonth=aNumDays[form.tm.selectedIndex]}if(form.td.selectedIndex+1>numDaysInMonth){alert(invalidDepartDateTxt);form.td.selectedIndex=numDaysInMonth-1;return false}var checkoutDate=new Date(tyear,form.tm.selectedIndex,form.td.selectedIndex+2);var numNights=Math.round((checkoutDate-checkinDate)/86400000)}else{var numNights=form.numnights.selectedIndex+1}if(checkinDate.getTime()<curDate.getTime()){alert(invalidDatePriorTxt);return false}if(numNights<1){alert(invalidDepartTxt);return false}if(numNights<numberNightsMin){alert(invalidNightsTxt);return false}};function year_option(form){curDate=new Date();curYear=curDate.getFullYear();for(i=curYear;i<=curYear+(numberYears-1);i++){document.write('<option value="'+i+'">'+i+'</option>')}};

/*
 * tools.overlay 1.0.4 - Overlay HTML with eye candy.
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/overlay.html
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 */
(function($){$.tools=$.tools||{version:{}};$.tools.version.overlay='1.0.4';var instances=[];function Overlay(el,opts){var self=this,w=$(window),closeButton,img,oWidth,oHeight,trigger,bg,exposeApi;var expose=opts.expose&&$.tools.version.expose;function bind(name,fn){$(self).bind(name,function(e,args){if(fn&&fn.call(this)===false&&args){args.proceed=false}});return self}$.each(opts,function(name,fn){if($.isFunction(fn)){bind(name,fn)}});var jq=opts.target||el.attr("rel");var o=jq?$(jq):null;if(!o){o=el}else{trigger=el}w.load(function(){bg=o.attr("overlay");if(!bg){bg=o.css("backgroundImage");if(!bg){throw"background-image CSS property not set for overlay element: "+jq;}bg=bg.substring(bg.indexOf("(")+1,bg.indexOf(")")).replace(/\"/g,"");o.css("backgroundImage","none");o.attr("overlay",bg)}oWidth=o.outerWidth({margin:true});oHeight=o.outerHeight({margin:true});img=$('<img src="'+bg+'"/>');img.css({border:0,position:'absolute',display:'none'}).width(oWidth).attr("overlay",true);$('body').append(img);if(trigger){trigger.bind("click.overlay",function(e){self.load(e.pageY-w.scrollTop(),e.pageX-w.scrollLeft());return e.preventDefault()})}opts.close=opts.close||".close";if(!o.find(opts.close).length){o.prepend('<div class="close"></div>')}closeButton=o.find(opts.close);closeButton.bind("click.overlay",function(){self.close()});if(opts.preload){setTimeout(function(){var img=new Image();img.src=bg},2000)}});$.extend(self,{load:function(top,left){if(!img){w.load(function(){self.load(top,left)});return self}if(self.isOpened()){return self}if(opts.oneInstance){$.each(instances,function(){this.close()})}var p={proceed:true};$(self).trigger("onBeforeLoad",p);if(!p.proceed){return self}if(expose){img.expose(opts.expose);exposeApi=img.expose().load()}top=top||opts.start.top;left=left||opts.start.left;var toTop=opts.finish.top;var toLeft=opts.finish.left;if(toTop=='center'){toTop=Math.max((w.height()-oHeight)/2,0)}if(toLeft=='center'){toLeft=Math.max((w.width()-oWidth)/2,0)}if(!opts.start.absolute){top+=w.scrollTop();left+=w.scrollLeft()}if(!opts.finish.absolute){toTop+=w.scrollTop();toLeft+=w.scrollLeft()}img.css({top:top,left:left,width:opts.start.width,zIndex:opts.zIndex}).show();img.animate({top:toTop,left:toLeft,width:oWidth,height:640},opts.speed,function(){o.css({position:'absolute',top:toTop,left:toLeft});var z=img.css("zIndex");closeButton.add(o).css("zIndex",++z);o.fadeIn(opts.fadeInSpeed,function(){$(self).trigger("onLoad")})});return self},close:function(){if(!self.isOpened()){return self}var p={proceed:true};$(self).trigger("onBeforeClose",p);if(!p.proceed){return self}if(exposeApi){exposeApi.close()}if(img.is(":visible")){o.hide();var top=opts.start.top;var left=opts.start.left;if(trigger){p=trigger.offset();top=p.top+trigger.height()/2;left=p.left+trigger.width()/2}img.animate({top:top,left:left,width:0,height:0},opts.closeSpeed,function(){$(self).trigger("onClose",p)})}return self},getBackgroundImage:function(){return img},getContent:function(){return o},getTrigger:function(){return trigger},isOpened:function(){return o.is(":visible")},getConf:function(){return opts},onBeforeLoad:function(fn){return bind("onBeforeLoad",fn)},onLoad:function(fn){return bind("onLoad",fn)},onBeforeClose:function(fn){return bind("onBeforeClose",fn)},onClose:function(fn){return bind("onClose",fn)}});$(document).keydown(function(evt){if(evt.keyCode==27){self.close()}});if(opts.closeOnClick){$(document).bind("click.overlay",function(evt){if(!o.is(":visible, :animated")){return}var target=$(evt.target);if(target.attr("overlay")){return}if(target.parents("[overlay]").length){return}self.close()})}}$.fn.overlay=function(conf){var el=this.eq(typeof conf=='number'?conf:0).data("overlay");if(el){return el}var w=$(window);var opts={start:{top:Math.round(w.height()/2),left:Math.round(w.width()/2),width:0,absolute:false},finish:{top:30,left:'center',absolute:false},speed:'normal',fadeInSpeed:'fast',closeSpeed:'fast',close:null,oneInstance:true,closeOnClick:true,preload:true,zIndex:9999,api:false,expose:null,target:null};if($.isFunction(conf)){conf={onBeforeLoad:conf}}$.extend(true,opts,conf);this.each(function(){el=new Overlay($(this),opts);instances.push(el);$(this).data("overlay",el)});return opts.api?el:this}})(jQuery);

/*
 * tools.tooltip 1.0.2 - Tooltips done right.
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tooltip.html
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 */
(function(c){c.tools=c.tools||{version:{}};c.tools.version.tooltip="1.0.2";var b={toggle:[function(){this.getTip().show()},function(){this.getTip().hide()}],fade:[function(){this.getTip().fadeIn(this.getConf().fadeInSpeed)},function(){this.getTip().fadeOut(this.getConf().fadeOutSpeed)}]};c.tools.addTipEffect=function(d,f,e){b[d]=[f,e]};c.tools.addTipEffect("slideup",function(){var d=this.getConf();var e=d.slideOffset||10;this.getTip().css({opacity:0}).animate({top:"-="+e,opacity:d.opacity},d.slideInSpeed||200).show()},function(){var d=this.getConf();var e=d.slideOffset||10;this.getTip().animate({top:"-="+e,opacity:0},d.slideOutSpeed||200,function(){c(this).hide().animate({top:"+="+(e*2)},0)})});function a(f,e){var d=this;var h=f.next();if(e.tip){if(e.tip.indexOf("#")!=-1){h=c(e.tip)}else{h=f.nextAll(e.tip).eq(0);if(!h.length){h=f.parent().nextAll(e.tip).eq(0)}}}function j(k,l){c(d).bind(k,function(n,m){if(l&&l.call(this)===false&&m){m.proceed=false}});return d}c.each(e,function(k,l){if(c.isFunction(l)){j(k,l)}});var g=f.is("input, textarea");f.bind(g?"focus":"mouseover",function(k){k.target=this;d.show(k);h.hover(function(){d.show()},function(){d.hide()})});f.bind(g?"blur":"mouseout",function(){d.hide()});h.css("opacity",e.opacity);var i=0;c.extend(d,{show:function(q){if(q){f=c(q.target)}clearTimeout(i);if(h.is(":animated")||h.is(":visible")){return d}var o={proceed:true};c(d).trigger("onBeforeShow",o);if(!o.proceed){return d}var n=f.position().top-h.outerHeight();var k=h.outerHeight()+f.outerHeight();var r=e.position[0];if(r=="center"){n+=k/2}if(r=="bottom"){n+=k}var l=f.outerWidth()+h.outerWidth();var m=f.position().left+f.outerWidth();r=e.position[1];if(r=="center"){m-=l/2}if(r=="left"){m-=l}n+=e.offset[0];m+=e.offset[1];h.css({position:"absolute",top:n,left:m});b[e.effect][0].call(d);c(d).trigger("onShow");return d},hide:function(){clearTimeout(i);i=setTimeout(function(){if(!h.is(":visible")){return d}var k={proceed:true};c(d).trigger("onBeforeHide",k);if(!k.proceed){return d}b[e.effect][1].call(d);c(d).trigger("onHide")},e.delay||1);return d},isShown:function(){return h.is(":visible, :animated")},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return f},onBeforeShow:function(k){return j("onBeforeShow",k)},onShow:function(k){return j("onShow",k)},onBeforeHide:function(k){return j("onBeforeHide",k)},onHide:function(k){return j("onHide",k)}})}c.prototype.tooltip=function(d){var e=this.eq(typeof d=="number"?d:0).data("tooltip");if(e){return e}var f={tip:null,effect:"slideup",delay:30,opacity:1,position:["top","center"],offset:[0,0],api:false};if(c.isFunction(d)){d={onBeforeShow:d}}c.extend(f,d);this.each(function(){e=new a(c(this),f);c(this).data("tooltip",e)});return f.api?e:this}})(jQuery);

/*
 * tools.tabs 1.0.1 - Tabs done rigth.
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tabs.html
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 */ 
(function($){$.tools=$.tools||{version:{}};$.tools.version.tabs='1.0.1';$.tools.addTabEffect=function(name,fn){effects[name]=fn};var effects={'default':function(i){this.getPanes().hide().eq(i).show()},fade:function(i){this.getPanes().hide().eq(i).fadeIn(this.getConf().fadeInSpeed)},slide:function(i){this.getCurrentPane().slideUp("fast");this.getPanes().eq(i).slideDown()},horizontal:function(i){if(!$._hW){$._hW=this.getPanes().eq(0).width()}this.getCurrentPane().animate({width:0},function(){$(this).hide()});this.getPanes().eq(i).animate({width:$._hW},function(){$(this).show()})}};function Tabs(tabs,panes,opts){var self=this;var current;function bind(name,fn){$(self).bind(name,function(e,args){if(fn&&fn.call(this,args.index)===false&&args){args.proceed=false}});return self}$.each(opts,function(name,fn){if($.isFunction(fn)){bind(name,fn)}});$.extend(this,{click:function(i){if(i===current){return self}var pane=self.getCurrentPane();var tab=tabs.eq(i);if(typeof i=='string'){tab=tabs.filter("[href="+i+"]");i=tabs.index(tab)}if(!tab.length){if(current>=0){return self}i=opts.initialIndex;tab=tabs.eq(i)}var args={index:i,proceed:true};$(self).triggerHandler("onBeforeClick",args);if(!args.proceed){return self}tab.addClass(opts.current);effects[opts.effect].call(self,i);$(self).triggerHandler("onClick",args);tabs.removeClass(opts.current);tab.addClass(opts.current);current=i;return self},getConf:function(){return opts},getTabs:function(){return tabs},getPanes:function(){return panes},getCurrentPane:function(){return panes.eq(current)},getCurrentTab:function(){return tabs.eq(current)},getIndex:function(){return current},next:function(){return self.click(current+1)},prev:function(){return self.click(current-1)},onBeforeClick:function(fn){return bind("onBeforeClick",fn)},onClick:function(fn){return bind("onClick",fn)}});tabs.each(function(i){$(this).bind(opts.event,function(e){self.click(i);if(!opts.history){return e.preventDefault()}})});if(opts.history){tabs.history(function(evt,hash){self.click(hash||0)})}if(location.hash){self.click(location.hash)}else{self.click(opts.initialIndex)}panes.find("a[href^=#]").click(function(){self.click($(this).attr("href"))})}$.fn.tabs=function(query,arg){var el=this.eq(typeof conf=='number'?conf:0).data("tabs");if(el){return el}var opts={tabs:'li',current:'active',onBeforeClick:null,onClick:null,effect:'default',history:false,initialIndex:0,event:'click',api:false};if($.isFunction(arg)){arg={onBeforeClick:arg}}$.extend(opts,arg);this.each(function(){var els=$(this).find(opts.tabs);if(!els.length){els=$(this).children()}var panes=query.jquery?query:$(query);el=new Tabs(els,panes,opts);$(this).data("tabs",el)});return opts.api?el:this}})(jQuery);(function($){var hash,iframe;$.prototype.history=function(fn){var el=this;if($.browser.msie){if(!iframe){iframe=$("<iframe />").hide().get(0);$("body").append(iframe);setInterval(function(){var idoc=iframe.contentWindow.document;var h=idoc.location.hash;if(hash!==h){$.event.trigger("hash",h);hash=h}},100)}el.bind("click.hash",function(e){var doc=iframe.contentWindow.document;doc.open().close();doc.location.hash=$(this).attr("href")});el.eq(0).triggerHandler("click.hash")}else{setInterval(function(){var h=location.hash;if(el.filter("[href*="+h+"]").length&&h!==hash){hash=h;$.event.trigger("hash",h)}},100)}$(window).bind("hash",fn);return this}})(jQuery);