$(document).ready(function(e){	
	//Gallery
	$("#content .main .gallery .up").click(function(e){
		e.preventDefault();
		index = ($("#content .main .gallery .window .thumb.on").index()-1)/2 - 1;
		index = index < 0 ? $("#content .main .gallery .window .thumb").length-1 : index;
		change_banner(index);
	});	
	$("#content .main .gallery .down").click(function(e){
		e.preventDefault();
		index = ($("#content .main .gallery .window .thumb.on").index()-1)/2 + 1;
		index = index >= $("#content .main .gallery .window .thumb").length ? 0 : index;
		change_banner(index);
	});
	$("#content .main .gallery .window .thumb").click(function(e){
		e.preventDefault();
		index = ($(this).index()-1) / 2;
		change_banner(index);
	});
	$('#content .main .listing').mousemove(function(e){
		bubble = $(this).children('.balloon');
		offset = $(this).offset();
		left = e.pageX - offset.left  - 90;
		topper = e.pageY - offset.top - bubble.height() - 40;
		//bubble.children('.middle').html(top);
		bubble.css({top:topper,left:left});
	});
	//Reservation / Cancelation
	//Question Mark
	$(".policy").click(function(e){
		e.preventDefault();
		height = $(window).height() - 100;
		$("#overlay").css({"z-index":"7","display":'table'});
		$("#overlay .box .content").css('max-height',height+"px");
		$("#overlay .box .content").html($(this).parent().parent().children('.hidden').html());
		$("#overlay .box").show();
	});
	$("#overlay .clickarea,#overlay .box .close").click(function(e){
		e.preventDefault();
		$("#overlay").css({"z-index":"3","display":'none'});
		$("#overlay .box .content").html("");
		$("#overlay .box").hide();
	});
});
function change_banner(index){
	max = $("#content .main .gallery .window .thumb").length-4;
	reel_index = index < max ? index : max;
	offset = reel_index * (-72.4);
	$("#content .main .gallery .reel").animate({top: offset+"px"},300,"swing");
	$("#content .main .single .banner img.on").removeClass("on");
	$("#content .main .single .banner img").eq(index).addClass("on");
	$("#content .main .gallery .window .thumb.on").removeClass('on');
	$("#content .main .gallery .window .thumb").eq(index).addClass('on');
}
