$(document).ready(function(){
	initStyles();
	$("#gallery img").fadeIn("slow",function(){$("#gallery_bg").html($("#gallery").html());});
});

function initStyles() {
	$("#upper_links_bg").fadeTo("slow",0.5);
	$("#banner,#banner_bg").hide();
	$("#gallery_bg").css("opacity",0.6);
	$(".more_ph a").lightBox();
}

function galleryEffects() {
	$("#gallery img").bind("load",function(){
		$(this).fadeIn("slow",function(){$("#gallery_bg").html($("#gallery").html());});
	});
}

var counter=0;
var x;
function picSwap() {
		var index=$("#gallery .cont").length;
		$("#gallery .cont").eq((counter%index)).fadeIn("slow");
		$("#gallery .cont").eq(((counter-1)%index)).fadeOut("slow");
		if($("#gallery .cont").eq((counter%index)).html()!=null) {
			$("#gallery_bg").html('<p>'+$("#gallery .cont").eq((counter%index)).html()+'</p>');
		}
		counter++;
}
function slideShow() {
	clearInterval(x);
	picSwap();
	x=setInterval("picSwap();",4500);
}
function closeBox() {
	$("#banner,#banner_bg").hide();
	$("#banner .error").remove();
}

/*function hotelBanner() {
	$("#accomodation tr td:first-child").each( function() {
		$(this).css( 'cursor', 'pointer' );
	});

	$("#accomodation tr td:first-child").click( function() {
		var hotel_name = $(this).text();
		var hotel_location = $(this).next( "td" ).text();
		$("#banner,#banner_bg").hide();
		$("#banner .error").remove();
		$("#b_email,#b_name,#b_comment").val("");
		$("#b_email,#b_name,#b_comment").css("border","1px solid #696A6D");

		$("#banner_bg").css("opacity",0.7);
		
		$("#banner_bg,#banner").slideDown(900);
		$("#banner .service").html(hotel_name + ", " + hotel_location );
		$("html,body").animate({scrollTop:0}, "slow");
		return false;
	});	
}*/

function CmsAjaxComplete() {
	setTimeout(function(){
		galleryEffects();
		initStyles();
	},800);
}