// JavaScript Document
var sitealias = sitealias;

$(window).resize(function() { doresize(); });


$(document).ready(function()
{ 
				$("#gallery_div").height($(window).height());
				$("#horizon").height($(window).height());
								
				$("#main a:has(img)").fancybox({'overlayColor' : '#000','transitionIn' : 'elastic', 'transitionOut' : 'elastic'});
				
				$('#bopen').hide();
				$('#bclose').click(function() {
										doclose();
				});
				
				$('#bopen').click(function() {
										doopen();
				});
				
				$('.image').click(function() {
										$('.image').removeClass("active");
										$(this).addClass("active");	
				});
				
				$('#bclose').mouseover(function() {
					  $(this).attr("src", "tl_files/eberl-sauna/images/info_close-h.png");
				}).mouseleave(function() {
					  $(this).attr("src", "tl_files/eberl-sauna/images/info_close.png");
				});
				
				$('#bopen').mouseover(function() {
					  $(this).attr("src", "tl_files/eberl-sauna/images/info_open-h.png");
				}).mouseleave(function() {
					  $(this).attr("src", "tl_files/eberl-sauna/images/info_open.png");
				});
				
				if(sitealias=="produkte") {
					doclosefast();
				}
				
				dolayout();
				doresize();				
});

function doclose() {
	$('#bclose').hide();
	$('#bopen').show();
	$('.inhalt').hide("slide", { direction: "down" }, 1000);
}

function doclosefast() {
	$('#bclose').hide();
	$('#bopen').show();
	$('.inhalt').hide("slide", { direction: "down" }, 1);
}

function doopen() {
	$('#bopen').hide();
	$('#bclose').show();
	$('.inhalt').show("slide", { direction: "down" }, 1000);
}

function dolayout() {
				$("#horizont").height($(window).height());
				$("#gallery_div").height($(window).height());
								
				
				var height = $('#content .inside').height() - $('#content .inside').height() - $('#content .inside').height() - 181;
				var mheight = 0 - 560;
				var btnheight = 0;
				if(height<mheight) { height = 0 - 552; $("#content").css({"margin-top": height}); } else { height = -396; btnheight = 29; }
								
				$("#content").css({"margin-top": height});
				$("#content .btn").css({"top": $('#content .inside').height() - 27 + btnheight});
				
				if($('#content .inside').height()>445) { 
					$("#content .btn").css({"top": 406});
					$('#content .inside').css({"height": 404});
					$('#content .inside').scrollbar();			
				}	
				
				if(sitealias=="produkte") { 
					var height = $('#content .inside').height() - $('#content .inside').height() - $('#content .inside').height() - 148;
					$("#content .btn").css({"top": $('#content .inside').height() + 02}); 
					$("#content").css({"margin-top": height});
				}

}

function doresize() {
	
				if($(window).width()>1015 && $(window).height()> 623) { 
					$("#horizont").height($(window).height());
					$("#gallery_div").height($(window).height()); 
					$("#top").width($(window).width());
					$("body").css({"overflow": "hidden"});
				} else { 
					$("#horizont").height(623); $("#gallery_div").height(623);
					$("body").css({"overflow": "scroll"});
					$("#top").width($(window).width());
				}
				
				if($(window).width()<1015) { $("#top").width(1015); }
				//$("#log").text($("#horizont").height() + " - " + $("#horizont").width() + " - " + $(window).height());

}
