﻿$(document).ready(function() {

/*
$('.simpleSlideShow').slideShow();

$('#gallery_slideshow_container').slideShow();
*/

//ie has a weird bug that it shows the first image and then fades it in a few seconds later.  this is the fix.
if ($.browser.msie)
{
	setTimeout( function(){	$('.simpleSlideShow, #gallery_slideshow_container').slideShow({start:1}); }, 5000);

}
else{
	$('.simpleSlideShow, #gallery_slideshow_container').slideShow();
}




	
	/*Custom select boxes*/
	$('form#resForm select')
	.styledSelect({
	}).parents('form').show();


/*$('form#contact_form select')
	.styledSelect({
	}).parents('form').show();*/

	
	/* Make all divs in content_container the same height - only works for pages with one row of divs*/		
	$('#content_container > div.sameheight, #content_container > div.floorplan_slide > div.sameheight, #contact div.sameheight')
	.each(
		function(){
			var tallest=0;
			var this_height = $(this).height();
			if(this_height > tallest)
			{
				tallest = this_height;
			}
			
			if ($.browser.msie && $.browser.version == 6.0)
			{
				$('.sameheight').css({'height': tallest});
			}
			else
			{
				$('.sameheight').css({'min-height': tallest}); 
			}

		}
	);
	
	
	/**********   Dropdown Navigation **********/
	  
	
	
	if ($.browser.msie && $.browser.version == 6.0)
	{
		$("#nav ul li ul").hide(); 
		
		$("#nav ul li").hoverIntent (  			
			function() {  $("ul", this).slideDown("fast"); } , 
			function() { $("ul", this).slideUp("fast"); }
			); 
	}
	
	$("a.slideOpener").click(
		function() { return false;}
	);
	
	
	
	/**********   Datepicker for booking widget **********/
	$(function() {
		$('#linkedDatepicker')
			.datepicker({
				dateFormat: 'dd/mm/yy',
				beforeShow: readLinked,
				onSelect: updateLinked,
				showOtherMonths:false,
				selectOtherMonths:false,
				mandatory: true,
				changeMonth: false,
				changeYear: false, 
				minDate: '+0D',
				maxDate: '+1Y',
				showOn: 'both', buttonImageOnly: true, buttonImage: 'assets/images/icon_calendar.png'}); 
		 
		// Prepare to show a date picker linked to three select controls  
		function readLinked() {  
			$('#linkedDatepicker').val( $('#checkin_day').val() + '/' + $('#checkin_month_year').val()  );
			
			/*extra stuff for custom select*/
			$('#datepicker1 li').attr({ rel : $('#arrival2 li').attr('rel') + '/' + $('#arrival1 li').attr('rel') });
			
			return {};  
		}  
	  
		// Update three select controls to match a date picker selection  
		function updateLinked(date) { 
			$('#checkin_month_year').val(	date.substring(3, 11) );  
			$('#checkin_day').val(	date.substring(0, 2)	);			
			
			/*extra stuff for custom select*/
			$('#arrival1 li').html( $('#checkin_month_year :selected').text() ).attr({rel : date.substring(3, 11) });    
			$('#arrival2 li').html( date.substring(0, 2)).attr({rel : date.substring(0, 2)	}); 
		}
		
		$('#linkedDatepicker2')
			.datepicker({
				dateFormat: 'dd/mm/yy',
				beforeShow: readLinked2,
				onSelect: updateLinked2,
				showOtherMonths:false,
				selectOtherMonths:false,
				mandatory: true,
				changeMonth: false,
				changeCurrent:false,
				changeYear: false,
				minDate: '+1D',
				maxDate: '+1D +1Y', 
				showOn: 'both', buttonImageOnly: true, buttonImage: 'assets/images/icon_calendar.png'}); 
		
		 
		// Prepare to show a date picker linked to three select controls  
		function readLinked2(input, inst) {
			var minday = $('#checkin_day').val();
			var minmonth = ( $('#checkin_month_year').val() ).substring(0,2);
			var minyear = ( $('#checkin_month_year').val() ).substring(3,8);			

			$('#linkedDatepicker2').val( $('#checkout_day').val() + '/' + $('#checkout_month_year').val()  );
			
			/*extra stuff for custom select*/
			$('#datepicker2 li').attr({ rel : $('#departure2 li').attr('rel') + '/' + $('#departure1 li').attr('rel') });
			
			return {minDate:new Date(minyear, minmonth-1, minday)};			
		}  
	  
		// Update three select controls to match a date picker selection  
		function updateLinked2(date) { 
			$('#checkout_month_year').val(	date.substring(3, 11) );  
			$('#checkout_day').val(	date.substring(0, 2)	); 
			
			/*extra stuff for custom select*/
			$('#departure1 li').html( $('#checkout_month_year :selected').text() ).attr({rel : date.substring(3, 11) });    
			$('#departure2 li').html( date.substring(0, 2)).attr({rel : date.substring(0, 2)	}); 			
		}
	});

});

var TINY={};function T$(i){return document.getElementById(i)}TINY.box=function(){var p,m,b,fn,ic,iu,iw,ih,ia,f=0;return{show:function(c,u,w,h,a,t){if(!f){p=document.createElement('div');p.id='tinybox';m=document.createElement('div');m.id='tinymask';b=document.createElement('div');b.id='tinycontent';document.body.appendChild(m);document.body.appendChild(p);p.appendChild(b);m.onclick=TINY.box.hide;window.onresize=TINY.box.resize;f=1}if(!a&&!u){p.style.width=w?w+'px':'auto';p.style.height=h?h+'px':'auto';p.style.backgroundImage='none';b.innerHTML=c}else{b.style.display='none';p.style.width=p.style.height='100px'}this.mask();ic=c;iu=u;iw=w;ih=h;ia=a;this.alpha(m,1,80,3);if(t){setTimeout(function(){TINY.box.hide()},1000*t)}},fill:function(c,u,w,h,a){if(u){p.style.backgroundImage='';var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){TINY.box.psh(x.responseText,w,h,a)}};x.open('GET',c,1);x.send(null)}else{this.psh(c,w,h,a)}},psh:function(c,w,h,a){if(a){if(!w||!h){var x=p.style.width,y=p.style.height;b.innerHTML=c;p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';w=parseInt(b.offsetWidth);h=parseInt(b.offsetHeight);b.style.display='none';p.style.width=x;p.style.height=y}else{b.innerHTML=c}this.size(p,w,h,4)}else{p.style.backgroundImage='none'}},hide:function(){TINY.box.alpha(p,-1,0,5)},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=TINY.page.theight()+'px';m.style.width='';m.style.width=TINY.page.twidth()+'px'},pos:function(){var t=(TINY.page.height()/2)-(p.offsetHeight/2);t=t<10?10:t;p.style.top=(t+TINY.page.top())+'px';p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'},alpha:function(e,d,a,s){clearInterval(e.ai);if(d==1){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';this.pos()}e.ai=setInterval(function(){TINY.box.twalpha(e,a,d,s)},20)},twalpha:function(e,a,d,s){var o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==p?TINY.box.alpha(m,-1,0,3):b.innerHTML=p.style.backgroundImage=''}else{e==m?this.alpha(p,1,100,5):TINY.box.fill(ic,iu,iw,ih,ia)}}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(e,w,h,s){e=typeof e=='object'?e:T$(e);clearInterval(e.si);var ow=e.offsetWidth,oh=e.offsetHeight,wo=ow-parseInt(e.style.width),ho=oh-parseInt(e.style.height);var wd=ow-wo>w?-1:1,hd=(oh-ho>h)?-1:1;e.si=setInterval(function(){TINY.box.twsize(e,w,wo,wd,h,ho,hd,s)},20)},twsize:function(e,w,wo,wd,h,ho,hd,s){var ow=e.offsetWidth-wo,oh=e.offsetHeight-ho;if(ow==w&&oh==h){clearInterval(e.si);p.style.backgroundImage='none';b.style.display='block'}else{if(ow!=w){e.style.width=ow+(Math.ceil(Math.abs(w-ow)/s)*wd)+'px'}if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}this.pos()}}}}();TINY.page=function(){return{top:function(){return document.body.scrollTop||document.documentElement.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight},theight:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))},twidth:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/*
 * jQuery Styled Select Boxes
 * version: 1.1 (2009/03/24)
 * @requires jQuery v1.2.6 or later
 *
 * Examples and documentation at: http://code.google.com/p/lnet/wiki/jQueryStyledSelectOverview
 *
 * Copyright (c) 2008 Lasar Liepins, liepins.org, liepins@gmail.com
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */
jQuery.fn.styledSelect=function(settings){settings=jQuery.extend({selectClass:'styledSelect',openSelectClass:'open',optionClass:'option',selectedOptionClass:'selected',closedOptionClass:'closed',firstOptionClass:'first',lastOptionClass:'last',zIndexApply:false,zIndexStart:250,deactiveOnBackgroundClick:true},settings);var currentZIndex=settings.zIndexStart;this.each(function(){var s=jQuery(this);var cs=jQuery('<div></div>').attr('class',settings.selectClass);if(settings.zIndexApply){cs.css('z-index',currentZIndex-2);};var csl=jQuery('<ul></li>');if(settings.zIndexApply){csl.css('z-index',currentZIndex-1);};cs.append(csl);s.hide(0).after(cs);cs=s.next();jQuery('option',s).each(function(){if(jQuery(this).attr('value')==undefined){jQuery(this).attr('value',jQuery(this).text());}});var closedSelect=function(){jQuery('ul',cs).html('');addOption(s.val(),jQuery(':selected',s).text(),clickSelect);cs.removeClass(settings.openSelectClass);jQuery('ul li',cs).removeClass(settings.selectedOptionClass).removeClass(settings.optionClass).addClass(settings.closedOptionClass);if(settings.deactiveOnBackgroundClick){$(document).unbind('mousedown',closedSelect);cs.unbind('mousedown');}};var clickSelect=function(){jQuery('ul',cs).empty();jQuery('option',s).each(function(i){addOption(jQuery(this).val(),jQuery(this).text(),clickOption);});cs.addClass(settings.openSelectClass);jQuery('ul li:first-child',cs).addClass(settings.firstOptionClass);jQuery('ul li:last-child',cs).addClass(settings.lastOptionClass);if(settings.deactiveOnBackgroundClick){$(document).bind('mousedown',closedSelect);cs.bind('mousedown',function(){return false;});}};var clickOption=function(){var val=jQuery(this).attr('rel');s.val(val);closedSelect();};var addOption=function(optVal,optName,callBack){var cso=jQuery('<li></li>').attr('rel',optVal).text(optName).click(callBack).addClass(settings.optionClass);if(settings.zIndexApply){cso.css('z-index',currentZIndex);};if(s.val()==optVal){cso.addClass(settings.selectedOptionClass);};jQuery('ul',cs).append(cso);};closedSelect();s.change(closedSelect);currentZIndex-=3;});return this;};

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

