(function($) {
	$.fn.fullBg = function(){
		var bgImg = $(this);
		bgImg.addClass('fullBg');
		function resizeImg() {
			var ratio=1.6;//1280/800;
 		var winwidth = $(window).width();
			var winheight = $(window).height();
			var winratio = winwidth / winheight;

			if(winratio>ratio) {
				bgImg.css({
					width: winwidth+'px',
					height: (winwidth/ratio)+'px'
				});
			} else {
				bgImg.css({
					width: (winheight*ratio)+'px',
					height: winheight+'px'
				});
			}
		} 
		resizeImg();
		$(window).resize(function() {
			resizeImg();
		}); 
	};
})(jQuery)

jQuery(function($) {
	$("#background").show();
	$("#background").fullBg();
	$("#background2").show();
	$("#background2").fullBg();
});

$(function() {
 //$("#effect").draggable();
 $('#foto1').click(function(e) {clearInterval(BBsetInterval);$('#background2').fadeOut(1500);$('#background').fadeIn(1500);var image = images[0];$('#background').attr('src', image);});
 $('#foto2').click(function(e) {clearInterval(BBsetInterval);$('#background2').fadeOut(1500);$('#background').fadeIn(1500);var image = images[1];$('#background').attr('src', image);});
	$('#foto3').click(function(e) {clearInterval(BBsetInterval);$('#background2').fadeOut(1500);$('#background').fadeIn(1500);var image = images[2];$('#background').attr('src', image);});
	$('#foto4').click(function(e) {clearInterval(BBsetInterval);$('#background2').fadeOut(1500);$('#background').fadeIn(1500);var image = images[3];$('#background').attr('src', image);});
	});

$(function() {function runEffect(val,eff) {var selectedEffect = "clip";if (eff==1) {selectedEffect = "blind";};var options = {};$( val ).toggle( selectedEffect, options, 500 );};
		$("#haupttextclose-de").addClass("haupttextcloseC-de");
		$("#haupttextclose-it").addClass("haupttextcloseC-it");
		$("#haupttextclose-en").addClass("haupttextcloseC-en");
		$("#haupttextcloseL-de").addClass("haupttextcloseC-de");
		$("#haupttextcloseL-it").addClass("haupttextcloseC-it");
		$("#haupttextcloseL-en").addClass("haupttextcloseC-en");
		$("#haupttextcloseNews-de").addClass("haupttextcloseC-de");
		$("#haupttextcloseNews-it").addClass("haupttextcloseC-it");
		$("#haupttextcloseNews-en").addClass("haupttextcloseC-en");
		$("#haupttextcloseAnfrage-de").addClass("haupttextcloseC-de");
		$("#haupttextcloseAnfrage-it").addClass("haupttextcloseC-it");
		$("#haupttextcloseAnfrage-en").addClass("haupttextcloseC-en");
		
		$("#angebote-news").click(function() {runEffect("#effect");return false;});
		
		$("#haupttextclose-de").click(function() {$(this).toggleClass("haupttextcloseC-de");runEffect("#haupttext",1);runEffect("#haupttextLarge",1);runEffect("#haupttextPreise",1);runEffect("#lmenu",1);runEffect("#haupttextRooms",1);return false;});
		$("#haupttextclose-it").click(function() {$(this).toggleClass("haupttextcloseC-it");runEffect("#haupttext",1);runEffect("#haupttextLarge",1);runEffect("#haupttextPreise",1);runEffect("#lmenu",1);runEffect("#haupttextRooms",1);return false;});
		$("#haupttextclose-en").click(function() {$(this).toggleClass("haupttextcloseC-en");runEffect("#haupttext",1);runEffect("#haupttextLarge",1);runEffect("#haupttextPreise",1);runEffect("#lmenu",1);runEffect("#haupttextRooms",1);return false;});
		$("#haupttextcloseL-de").click(function() {$(this).toggleClass("haupttextcloseC-de");runEffect("#haupttextL",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseL-it").click(function() {$(this).toggleClass("haupttextcloseC-it");runEffect("#haupttextL",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseL-en").click(function() {$(this).toggleClass("haupttextcloseC-en");runEffect("#haupttextL",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseNews-de").click(function() {$(this).toggleClass("haupttextcloseC-de");runEffect("#haupttextNews",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseNews-it").click(function() {$(this).toggleClass("haupttextcloseC-it");runEffect("#haupttextNews",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseNews-en").click(function() {$(this).toggleClass("haupttextcloseC-en");runEffect("#haupttextNews",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseAnfrage-de").click(function() {$(this).toggleClass("haupttextcloseC-de");runEffect("#haupttextAnfrage",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseAnfrage-it").click(function() {$(this).toggleClass("haupttextcloseC-it");runEffect("#haupttextAnfrage",1);runEffect("#lmenu",1);return false;});
		$("#haupttextcloseAnfrage-en").click(function() {$(this).toggleClass("haupttextcloseC-en");runEffect("#haupttextAnfrage",1);runEffect("#lmenu",1);return false;});
});

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var sais=true;var heuteZ=new Date();var vorZ=new Date(heuteZ.getFullYear()+"/04/10");var nachZ=new Date(heuteZ.getFullYear()+"/09/01");vorZ = Date.parse(vorZ);nachZ = Date.parse(nachZ);heuteZ = Date.parse(heuteZ);if ((heuteZ<vorZ) || (heuteZ>nachZ)) {sais=false};

var index1 = 0;
var primogiro=1;
var indexImg="";
function rotateImage()
{
	if (primogiro==1) {
		primogiro=0;
		$('#background2').fadeOut(0, function(){$(this).attr('src', images[0]);});
		};
$('#background'+indexImg).fadeOut(1500, function(){$(this).attr('src', images[index1]);});
		indexImg=(indexImg==""?"2":"");
$('#background'+indexImg).fadeIn(1500);		
	index1=index1+1;if (index1>images.length-1) index1=0;
}
$(document).ready(function(){if(images.length>1) {$.each(images,function(e){$(new Image()).load().attr("src",this)});BBsetInterval=setInterval (rotateImage, 7000);}});

