$(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 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3 Z=1;3 10=2;3 12=4;3 N=1;3 1s="/1t/1u/";3 O=0;3 D=1;3 u=1;3 P=1;3 Q=9 13("");3 14=" 1v";3 15=" 1w";3 16="17 R 8. E 18 19 1a 1b n";3 1c="R 8 n 1d 1e 1x\'s 1y. E 1f...";3 1g="17 1h 8. E 18 19 1a 1b n";3 1i="1h 8 1d 1e 1z R 8 n. E 1f...";3 1j="1A, 1B 1C "+N+" 1D 1E 1F 1G.";3 S=9 13(x,0,x,A,x,A,x,x,A,x,A,x);6(u==0){D=0;P=0};y 1H(a,b,c,d,e){6(d=="1I"){m.q[e].v.5=a-1;m.q[e].r.5=b-1;m.q[e].l.5=c-m.q[e].l.7[0].p;T(m.q[e]);F(e,1)}z{m.q[e].w.5=a-1;m.q[e].t.5=b-1;m.q[e].o.5=c-m.q[e].o.7[0].p;F(e,1)}};y T(a,b){6(a.r.5==1){3 c=9 8(a.l.7[a.l.5].p,a.r.5+1,1);3 c=9 8(c-(1k*G*G*1l));3 d=c.H()}z{3 d=S[a.r.5]}6(b==1||P==1){3 e=9 8(a.l.7[a.l.5].p,a.r.5,a.v.5);3 f=9 8(e.I()+((10+1)*J));3 g=f.H();3 h=f.1m();3 i=f.U()-a.l.7[0].p;3 j=9 8(a.l.7[a.l.5].p,a.r.5,a.v.5+1);3 k=9 8(a.o.7[a.o.5].p,a.t.5,a.w.5+1);6(j>k){6(i==a.o.K){a.w.7[A].n=1;a.t.7[11].n=1;a.o.7[a.o.K-1].n=1}z{a.w.7[g-1].n=1;a.t.7[h].n=1;a.o.7[i].n=1}}}6(a.v.5+1>d){B(16);a.v.5=d-1}};y F(a,b){6(b)a=m.q[a];V(3 i=0;i<a.l.K;i++){6(a.l.7[i].n)3 c=a.l.7[i].p;6(u==1&&a.o.7[i].n)3 d=a.o.7[i].p}3 e=9 8(c,a.r.5,a.v.5+1);6(u==1)3 f=9 8(d,a.t.5,a.w.5+1);3 g=1n.1o((f-e)/J);6(g==1)g+=14;z g+=15;6(O==1&&m.C){m.C(\'1J\').W.X=\'(\'+Q[e.1p()]+\')\';6(u==1)m.C(\'1K\').W.X=\'(\'+Q[f.1p()]+\')\'}6(D==1&&m.C)m.C(\'1L\').W.X=g};y 1M(a){3 b=9 8();3 c=9 8(b.I()+(Z*J));3 d=c.H();3 e=c.1m();3 f=c.U()-a.l.7[0].p;a.v.5=d-1;a.r.5=e;a.l.5=f;T(a,u);6(O==1||D==1)F(a)};y 1N(a){3 b=9 8();V(3 i=0;i<a.l.K;i++){6(a.l.7[i].n)3 c=a.l.7[i].p;6(u==1&&a.o.7[i].n)3 d=a.o.7[i].p}3 e=9 8(c,a.r.5,a.v.5+2);6(u==1){6(a.t.5==1){3 f=9 8(a.o.7[a.o.5].p,a.t.5+1,1);3 f=9 8(f-(1k*G*G*1l));3 g=f.H()}z{3 g=S[a.t.5]}6(a.w.5+1>g){B(1g);a.w.5=g-1;L M}3 h=9 8(d,a.t.5,a.w.5+2);3 j=1n.1o((h-e)/J)}z{3 j=a.1O.5+1}6(e.I()<b.I()){B(1c);L M}6(j<1){B(1i);L M}6(j<N){B(1j);L M}};y 1P(a){1q=9 8();Y=1q.U();V(i=Y;i<=Y+(12-1);i++){m.1Q(\'<1r 1R="\'+i+\'">\'+i+\'</1r>\')}};',62,116,'|||var||selectedIndex|if|options|Date|new||||||||||||fy|document|selected|ty|text|forms|fm||tm|departDateDisplay|fd|td|31|function|else|30|alert|getElementById|numberNightsDisplay|Please|setWkd|60|getDate|getTime|86400000|length|return|false|numberNightsMin|wdDisplay|departDateUpdate|wdArray|Arrival|aNumDays|updateDates|getFullYear|for|firstChild|nodeValue|curYear|daysinAdvance|numberNights||numberYears|Array|nightTxt|nightsTxt|invalidDateTxt|Invalid|check|number|of|days|invalidDatePriorTxt|is|prior|change|invalidDepartDateTxt|Departure|invalidDepartTxt|invalidNightsTxt|24|1000|getMonth|Math|round|getDay|curDate|option|imgDir|images|global|Night|Nights|Today|date|to|Sorry|reservations|under|nights|are|not|accepted|calendarCallback|calendarArrive|inWd|outWd|lengthStay|LoadDates|checkDates|numnights|year_option|write|value'.split('|'),0,{}));

/*
 * 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);
