function getPageSize() {
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) { // all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}


	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};

var cur = 0;
var len = 0;
var zi  = 0;
function wechsel() {
	next = (cur+1!=len) ? cur+1 : 0;
	$("#bildwechsel img").eq(cur).fadeOut(3000);
	$("#bildwechsel img").eq(next).fadeIn(3000);
	cur = next;
}

$(document).ready(function(){
	$(".lightbox").lightbox();
	if($("#bildwechsel").length!=0) {
		len = $("#bildwechsel img").length;
		if(1<len) window.setInterval("wechsel()",8000);
	}
	$("#infos .info div").hover(
		function() {
			zi = $(this).parent().css('z-index');
			$(this).parent().css('z-index',99);
			if($(this).children('ul').length!=0) {
				if(parseInt($(this).parent().attr('class').substr(9))%2==1) {
					$(this).parent().animate({top:'-213px'},'fast');
				} else {
					$(this).parent().animate({top:'-299px'},'fast');
				}
				$(this).animate({height:'325px'},'fast');
			}
		},
		function() {
			$(this).parent().css('z-index',zi);
			if($(this).children('ul').length!=0) {
				if(parseInt($(this).parent().attr('class').substr(9))%2==1) {
					$(this).parent().stop().animate({top:'-41px'},'fast');
				} else {
					$(this).parent().stop().animate({top:'-127px'},'fast');
				}
				$(this).stop().animate({height:'153px'},'fast');
			}
		}
	);
	$("#anreise_datepicker").click(function() { return false; }).datepicker({
		maxDate: '+12m',
		minDate: '+0d',
		dateFormat: 'yy-m-d',
		onClose: function(dateText, inst) {
			if(dateText.indexOf("-")!=-1) {
				var part = dateText.split("-");
				$("#anreise_tag").val(part[2]);
				$("#anreise_monat").val(part[1]);
				$("#anreise_jahr").val(part[0]);
			}
		}
	});
	$("#anreise").click(function() { return false; }).datepicker({
		maxDate: '+12m',
		minDate: '+0d',
		dateFormat: 'D, dd.mm.yy',
		buttonImage: 'images/btn_datepicker_2.gif',
		showOn: 'both',
		buttonImageOnly: true,
		buttonText: 'Anreisedatum auswählen',
		onClose: function(selectedDate) {
			var instance = $(this).data("datepicker");
			var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
			if(date) {
				date.setTime(date.getTime() + 24*60*60*1000);
				$('#abreise').datepicker("option", 'minDate', date);
			}
		}
	});
	$("#abreise").datepicker({
		maxDate: '+12m',
		minDate: '+1d',
		dateFormat: 'D, dd.mm.yy',
		buttonImage: 'images/btn_datepicker_2.gif',
		showOn: 'both',
		buttonImageOnly: true,
		buttonText: 'Abreisedatum auswählen',
		onClose: function(selectedDate) {
			var instance = $(this).data("datepicker");
			var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
			if(date) {
				date.setTime(date.getTime() - 24*60*60*1000);
				$('#anreise').datepicker("option", 'maxDate', date);
			}
		}
	});
	$(".angebote:has(h2)").each(function(index) {
		if(typeof(is_send) == "undefined") {
			var alias = 0;
			var p = document.URL.indexOf('#');
			var check = false;
			if(p!=-1 && p+1!=document.URL.length) {
				alias = document.URL.substr(p+1);
				check = true;
			}
			if($('#buchen').length==0 || $('#angebote_opt').length!=0) {
				if(index==alias || (check && $(this).attr('id')!='' && $(this).attr('id').indexOf(alias)!=-1)) {
					//if($('#isBookingForm').length!=0) $(this).children("h2").children("a").addClass("activ");
				} else {
					//if($('#isBookingForm').length!=0) $(this).children(".block").hide();
				}
			} else if($(".liste_liste").length!=0) {
				//$(this).children(".block").hide();
			}
		} else {
			if(index!=0) {
				//$(this).children("h2").children("a").addClass("activ");
			} else {
				//$(this).children(".block").hide();
			}	
		}
	});
	if($(".angebote:has(h2)").length!=0 && $("#buchen").length==0) {
		$("<p style=\"text-align:right; clear:both\"><a href=\"#\" id=\"show_all\" style=\"display:none\">+ [alle Pakete anzeigen]</a> <a href=\"#\" id=\"hide_all\">- [alle Pakete schließen]</a></p>").insertBefore('.angebote:has(h2):first');
		$("#show_all").click(function() {
			$(".angebote:has(h2)").each(function(index) {
				$(this).children("h2").children("a").addClass("activ");
				$(this).children(".block").slideDown('slow');
			});
			$(this).hide(); $("#hide_all").show();
		});
		$("#hide_all").click(function() {
			$(".angebote:has(h2)").each(function(index) {
				$(this).children("h2").children("a").removeClass("activ");
				$(this).children(".block").slideUp('slow');
			});
			$(this).hide(); $("#show_all").show();
		});
	}
	$(".angebote h2 a").click(function() {
		var id = "#angebote_"+$(this).attr('id').substr(2);
		if($(this).parents('#buchen').length!=0 && $(this).parents('.liste_liste').length==0) {
			if(id=='#angebote_opt') {
				$("#buchen h2 a").not("#"+$(this).attr('id')).removeClass("activ");
				$("h2 ~ .block").not(id).hide();
				if($(id).is(":hidden")) {
					$(this).addClass("activ");
					$(id).slideDown('slow');
				}
			} else {
				$("#a_opt").removeClass("activ");
				$("#angebote_opt").hide();
				$("#buchen h2 a").not("#a_opt").addClass("activ");
				$("h2 ~ .block:hidden").not("#angebote_opt").slideDown('slow');
			}
		} else {
			$(".angebote h2 a").not(this).removeClass("activ");
			$("h2 ~ .block").not(id).hide();
			$(this).toggleClass("activ");
			$(id).slideToggle('slow');
		}
		return false;
	});
	$("#angebote_opt ul").each(function(index) {
		if(index==0) {
			$('#show_'+$(this).attr('id')).css('font-weight','bold');
		} else {
			$(this).hide();
		}
	});
	$(".opt a").click(function() {
		$("#angebote_opt").slideDown('slow');
		$(".opt a").css('font-weight','normal');
		$("#angebote_opt ul").hide();
		$("#"+$(this).attr('id').substr(5)).show();
		$(this).css('font-weight','bold');
		return false;
	});
	$(".show_anfrage").click(function() {
		$('#overlay').remove();
		window.scrollTo(0, 0);
		$('select').css('visibility','hidden');
		$('<div id="overlay">&nbsp;</div><div class="anfrage_overlay"></div>').appendTo('body');
		var arrayPageSize = getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : 0.6}).fadeIn();
		$(".anfrage_overlay").css({height: arrayPageSize[1]+'px'});		
		var src = this.href.replace(/\.html/,'/frame.html');
		$('<p style="padding:10px 10px 0; margin:0; text-align:right;"><a href="#" title="schlie&szlig;en" class="close_overlay"><img src="images/closelabel.gif" alt="" border="0" /></a></p><iframe width="100%" height="95%" id="anfrage_pad" frameborder="0" src="'+ src+'"><p>Ihr Browser kann leider keine eingebetteten Frames anzeigen: Sie k&ouml;nnen die eingebettete Seite &uuml;ber den folgenden Verweis aufrufen: <a href="'+src+'">unverbindliche Buchungsanfrage</a></p></iframe>').appendTo('.anfrage_overlay')
		$(".close_overlay").click(function() {
			$("#overlay").remove();
			$(".anfrage_overlay").remove();
			$('select').css('visibility','visible');
			return false;
		});
		return false;
	});
	/*
	$(".show_buchen").click(function() {
		$('#overlay').remove();
		window.scrollTo(0, 0);
		$('select').css('visibility','hidden');
		$('<div id="overlay">&nbsp;</div><div class="anfrage_overlay"></div>').appendTo('body');
		var arrayPageSize = getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : 0.6}).fadeIn();
		$(".anfrage_overlay").css({height: arrayPageSize[1]+'px'});
		$('<p style="padding:10px; margin:0; text-align:right;"><a href="#" title="schlie&szlig;en" class="close_overlay"><img src="images/closelabel.gif" alt="" border="0" /></a></p><iframe width="100%" height="95%" id="anfrage_pad" frameborder="0" src="'+ this.href+'"><p>Ihr Browser kann leider keine eingebetteten Frames anzeigen: Sie k&ouml;nnen die eingebettete Seite &uuml;ber den folgenden Verweis aufrufen: <a href="'+this.href+'">unverbindliche Buchungsanfrage</a></p></iframe>').appendTo('.anfrage_overlay')
		$(".close_overlay").click(function() {
			$("#overlay").remove();
			$(".anfrage_overlay").remove();
			$('select').css('visibility','visible');
			return false;
		});
		return false;
	});
	*/
	$(".show_gutschein").click(function() {
		window.scrollTo(0, 0);
		$('#overlay').remove();
		$('select').css('visibility','hidden');
		$('<div id="overlay">&nbsp;</div><div class="anfrage_overlay"></div>').appendTo('body');
		var arrayPageSize = getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : 0.6}).fadeIn();
		$(".anfrage_overlay").css({height: arrayPageSize[1]+'px'});
		var src = this.href.replace(/\.html/,'/frame.html');
		$('<p style="padding:10px 10px 0; margin:0; text-align:right;"><a href="#" title="schlie&szlig;en" class="close_overlay"><img src="images/closelabel.gif" alt="" border="0" /></a></p><iframe width="100%" height="95%" id="anfrage_pad" frameborder="0" src="'+ src+'"><p>Ihr Browser kann leider keine eingebetteten Frames anzeigen: Sie k&ouml;nnen die eingebettete Seite &uuml;ber den folgenden Verweis aufrufen: <a href="'+src+'">unverbindliche Buchungsanfrage</a></p></iframe>').appendTo('.anfrage_overlay')
		$(".close_overlay").click(function() {
			$("#overlay").remove();
			$(".anfrage_overlay").remove();
			$('select').css('visibility','visible');
			return false;
		});
		return false;
	});
	$(".show_hochzeit").click(function() {
		$('#overlay').remove();
		window.scrollTo(0, 0);
		$('select').css('visibility','hidden');
		$('<div id="overlay">&nbsp;</div><div class="anfrage_overlay"></div>').appendTo('body');
		var arrayPageSize = getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : 0.6}).fadeIn();
		$(".anfrage_overlay").css({height: arrayPageSize[1]+'px'});
		var src = this.href.replace(/\.html/,'/frame.html');
		$('<p style="padding:10px 10px 0; margin:0; text-align:right;"><a href="#" title="schlie&szlig;en" class="close_overlay"><img src="images/closelabel.gif" alt="" border="0" /></a></p><iframe width="100%" height="95%" id="anfrage_pad" frameborder="0" src="'+ src+'"><p>Ihr Browser kann leider keine eingebetteten Frames anzeigen: Sie k&ouml;nnen die eingebettete Seite &uuml;ber den folgenden Verweis aufrufen: <a href="'+src+'">unverbindliche Hochzeitsanfrage</a></p></iframe>').appendTo('.anfrage_overlay')
		$(".close_overlay").click(function() {
			$("#overlay").remove();
			$(".anfrage_overlay").remove();
			$('select').css('visibility','visible');
			return false;
		});
		return false;
	});
	$("#angebote_opt li a").click(function() { return false; }).tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " ~~ ",
		fade: 250
	});
});
function inquiry(e) {
	if(e.selectedIndex==1) {
		document.anfrage.action = link_buchung;	
		document.anfrage.target = '_blank';
		document.anfrage.submit();
	}
	e.selectedIndex = 0;
}
function uaz(e,zaehler) {
	var id1 = 'anzahl_erwachsene_'+zaehler;
	if(e.selectedIndex!=0) {		
		$('#'+id1).replaceWith('<select name="'+id1+'" id="'+id1+'"></select>');
		var i_start = (e.options[e.selectedIndex].text.match(/doppelzimmer/i)) ? 2 : 1;
		var i_stop  = ma[e.selectedIndex-1];
		for(var i=i_stop; i_start<=i; i--) {
			$('#'+id1).append('<option value="'+i+'">'+i+'</option>');	
		}
	} else {
		$('#'+id1).replaceWith('<input type="text" name="'+id1+'" id="'+id1+'" value="" size="30" maxlength="255" />');
	}
}
