/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */


(function($) {	
	//same as $(document).ready();
	$(function() {
		
	/*	
		$('.image-left .slideshow').cycle({
			random: 1,
			speed: 3000,
			delay: 5000,
			timeout: 10000,
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
		
		$('.image-right .slideshow').cycle({
			random: 1,
			speed: 3000,
			timeout: 10000,
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
		*/
		
		/*
		
		leftHeight = $(".main .left").height();
		rightImgHieght = 0;
		$(".main .right img").each(function(index){
		    rightImgHieght = rightImgHieght +$(this).outerHeight()
		});
		diff = leftHeight - rightImgHieght;
		makeUp =diff/($(".main .right img").size()-1);
		$(".main .right img:not(:last)").each(function(index){
		   $(this).css('marginBottom', makeUp);
		});
		
		
		*/
				
		$('.fancybox').fancybox();
		$('.fancybox-slideshow').fancybox({
			'onComplete'	:	function() {
				setTimeout("$('#fancybox-right').click()",5000);
			}
		});
		
		//"Sticky" main nav buttons
		$('.main-nav a').click(function(){
			$('.main-nav li').removeClass('active');
			$(this).parents('li').addClass('active');
		});
	});
	


	$(window).bind("load", function() {
		
		if ($("body").hasClass("page-rooms")){ pageRooms(); }
		if ($("body").hasClass("page-around-us")){ pageAroundUs(); }
	});
	
})(jQuery);


pageAroundUs = function(){
	leftHeight = $(".main .left").height();
	rightImgHieght = 0;
	$(".main .right img").each(function(index){
	    rightImgHieght = rightImgHieght +$(this).outerHeight()
	});
	diff = leftHeight - rightImgHieght;
	makeUp = diff/($(".main .right img").size()-1);
	$(".main .right img:not(:last)").each(function(index){
	   $(this).css('marginBottom', makeUp);
	});
};

pageRooms = function(){
	diff = ( $(".rates-table").offset().top+$(".rates-table").outerHeight() ) - ( $(".right img.bottom").offset().top+$(".right img.bottom").outerHeight());
	

	makeUp = diff/2;
	$(".right img.top").css("marginBottom", parseFloat($(".right img.top").css("margin-bottom").replace("px", ""))+makeUp);
	
	$(".right img.bottom").css("marginTop", parseFloat($(".right img.bottom").css("margin-top").replace("px", ""))+makeUp);
};



