// JavaScript Document

// debug
if (typeof console == "undefined") {
    console = {
        log: function (v) {
        }
    };
}

function HoverMethod(el){
     if(!IsInPlayback()){
   if (typeof ClickTaleExec == "function")   {
         ClickTaleExec("ClickTaleHoverMocking("+ this.id +")");
   }
      }

      $(this).next('ul').addClass('hovered').stop(true, true).slideDown();
          $(this).next('ul').removeClass('hovered');
      $(this).oneTime(500, 'remover', function() {
         if ($(this).next('ul').hasClass('hovered') == false)
            $(this).next('ul').slideUp();
      });
}



function ClickTaleHoverMocking(el_id){
   var el = $("#"+el_id);
   HoverMethod(el);
}

function IsInPlayback(){
    try { return parent && parent.WebPlayer; }
    catch(e) { return false; }
}


window.setTimeout(function () {
    var externalLinks = $("a");

    for(var i = 0; i < externalLinks.length; i++) {
       if (externalLinks[i].getAttribute("href")) {
           if(externalLinks[i].getAttribute("href").indexOf("http") >= 0) {
               if(externalLinks[i].getAttribute("href").indexOf("garda-see.com") < 0) {
                  var hostname = parseUri(externalLinks[i].getAttribute("href")).host;
                  externalLinks[i].setAttribute("trackKey",hostname);
                  externalLinks[i].onclick = externalLinkClick;
               }
           }
       }
    }
},800);

function externalLinkClick () {
    var trackKey = this.getAttribute("trackKey");
    _gaq.push(['_trackPageview','/external/' + trackKey]);
}

function parseUri (str) {
    var o   = parseUri.options,
    m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
    uri = {},
    i   = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
       if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
}

parseUri.options = {
    strictMode: false,
    key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
    q:   {
                   name:   "queryKey",
                   parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
                   strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
                   loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};


function adreiseplan(oid,language){
    $.ajax({
        type: "POST",
        url: "?controller=accomodation&action=adreiseplan",
        data: "accoid= "+oid+"&language="+language,
        success: function(msg){

            $("#tripplanner").html(msg);

            $.fancybox({
                'padding'		: 10,
                'href'			: '/'+language+'/reiseplanok/?oid='+oid,
                'transitionIn'	: 'elastic',
                'transitionOut'	: 'elastic'
            });

            setTimeout("$.fancybox.close()", 3000);

            TripPlanner();

        }
    });
}



function removereiseplan(oid,lang){
    $.ajax({
        type: "POST",
        url: "?controller=accomodation&action=removereiseplan",
        data: "accoid= "+oid+"&step=remove&language="+lang,
        success: function(msg){
            $("#rplan").html(msg);
        }
    });
}

function deletereiseplan(language){
    $.ajax({
        type: "POST",
        url: "?controller=accomodation&action=removereiseplan",
        data: "step=removeall&language="+language,
        success: function(msg){
            $("#rplan").html(msg);
            $("#tripplanner").html("");
        }
    });
}




function gotoLink (htmlElement) {

	var destinationURL = "";
	var target = "";

	if( htmlElement.href ) {
		destinationURL = htmlElement.href;
		target = htmlElement.getAttribute("target");
	}
	else {
		if( htmlElement.childNodes ) {
			if( htmlElement.getElementsByTagName("a") ) {
				destinationURL = htmlElement.getElementsByTagName("a")[0].href;
				target = htmlElement.getElementsByTagName("a")[0].getAttribute("target");
			}
		}
	}

	if( destinationURL.length > 0 ) {
		if( target == "_blank" ) {
			window.open(destinationURL);
		}
		else {
			location.href = destinationURL;
		}
	}
	return false;
}

function showwhitelable(url){
    $.fancybox({
        'width'				: 800,
        'height'			: '100%',
        'autoScale'     	: false,
        'href'              : url,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'type'				: 'iframe'
    });
}

function showmapinfo(){
    $("#showmapinfo").fadeIn("slow");
}

function setSubCateg(cat,ucat){

    $.ajax({
        type: "POST",
        url: "?controller=Objects&action=ukcat",
        data: "cat="+cat+"&ucat="+ucat+"&lang="+lang,
        success: function(msg){
            $("#ucateg").html(msg);
        }
    });


}

function calcNights(){

    var start = new Date($('#arrival').datepicker('getDate'));
    var end = new Date($('#departure').datepicker('getDate'));
    var diff = end-start;

    //console.log(start);
    //console.log(end);

    if(diff > 0){
        //alert("right date");

        nights = diff/86400000;
        $("#nights").attr("value", nights);
        anfrageform.submit();
    } else {
        //alert("wrong date");

            $.fancybox({
                'padding'		: 0,
                'href'			: '/'+lang+'/dateinfo',
                'width'         : 200,
                'height'         : 200,
                'type'          : 'iframe',
                'transitionIn'	: 'elastic',
                'transitionOut'	: 'elastic'
            });
            return false;
    }

}

function calcNightsinBox(){

    var start = new Date($('#arrival').datepicker('getDate'));
    var end = new Date($('#departure').datepicker('getDate'));
    var diff = end-start;

    //console.log(diff);
    if(diff > 0){
        //alert("right date");

        nights = diff/86400000;
        $('#data').find("#nights").attr("value", nights);

        changetraveldata();

    } else {
        //alert("wrong date");

            $.fancybox({
                'padding'		: 0,
                'href'			: '/'+lang+'/dateinfo',
                'width'         : 200,
                'height'         : 200,
                'type'          : 'iframe',
                'transitionIn'	: 'elastic',
                'transitionOut'	: 'elastic'
            });
            return false;
    }

}

function datepopup() {
/*	$.tools.dateinput.localize("de",  {
	   months:        'J&auml;nner,Februar,M&auml;rz,April,Mai,Juni,Juli,August,' +
						'September,Oktober,November,Dezember',
	   shortMonths:   'Jan,Feb,Mar,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez',
	   days:          'Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag',
	   shortDays:     'So,Mo,Di,Mi,Do,Fr,Sa'
	});

	$.tools.dateinput.localize("it",  {
	   months:        'Gennaio,Febbraio,Marzo,Aprile,Maggio,Giugno,Luglio,Agosto,' +
						'Settembre,Ottobre,Novembre ,Dicembre',
	   shortMonths:   'Gen,Feb,Mar,Apr,Mag,Giu,Lug,Ago,Sep,Ott,Nov,Dic',
	   days:          'Domenica,Lunedì,Marted,Mercoledì,Giovedì,Venerdì,Sabato',
	   shortDays:     'Dom,Lun,Mar,Mer,Gio,Ven,Sab'
	});

	$(":date").dateinput({
        trigger: true,
        min: -1,
		format: "dd.mm.yyyy",
		lang: lang,
        offset: [10, -105],
		firstDay: 7
	});*/




$("#arrival").datepicker({
    prevText: '< Zurück',
    nextText:  'Vor >',
    monthNames: ['Jänner','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
    dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
    showOn: 'button',
    buttonImageOnly: true,
    regional: lang,
    buttonImage: '/static/img/calcicon.png',
    closeText: '', closeStatus: '',
    prevStatus: '',
    currentText: '', currentStatus: '',
    weekHeader: 'Wk', weekStatus: '',
    gotoCurrent: true,
    dateFormat: 'dd.mm.yy',
    minDate: 'today',
    onClose: function() {

        var start = new Date($('#arrival').datepicker('getDate'));

    },
    firstDay: 1
});



$("#departure").datepicker({
    showOn: 'button',
    buttonImageOnly: true,
    regional: lang,
    closeText: '', closeStatus: '',
    buttonImage: '/static/img/calcicon.png',
    prevText: '< Zurück',
    nextText:  'Vor >',
    monthNames: ['Jänner','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
    dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
    currentText: '', currentStatus: '',
    weekHeader: 'Wk', weekStatus: '',
    dateFormat: 'dd.mm.yy',
    beforeShow: function(){
        var mndate = new Date($('#arrival').datepicker('getDate'));
        var miltime = mndate.getTime();
        miltime = miltime+86400000;
        var enddate = new Date(miltime);
        $(this).datepicker("option",{ minDate: enddate});
    },
    firstDay: 1
});



}



function slideSwitch(activeelem, elem) {
    var $active = $(activeelem);

    if ( $active.length == 0 ) $active = $(elem+':last');

    var $next =  $active.next().length ? $active.next()
        : $(elem+':first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}



function showwinfo(){
	$('.weatherblock a').click(function() {
		$(".names div").css("display","none");
		$(".weatherblock a").removeClass("active");
		if($(this).hasClass("active")){
			$(this).removeClass("active");
			$(this).next().css("display","none");
			$(this).next().children(".wname").css("display","none");
			$(this).next().children(".wimage").css("display","none");
			$(this).next().children(".winfo").css("display","none");
			$(this).next().children(".wtemp").css("display","none");
			$(this).next().children(".wlink").css("display","none");
		} else {
			$(this).addClass("active")
			$(this).next().css("display","block");
			$(this).next().children(".wname").css("display","block");
			$(this).next().children(".wimage").css("display","block");
			$(this).next().children(".winfo").css("display","block");
			$(this).next().children(".wtemp").css("display","block");
			$(this).next().children(".wlink").css("display","block");
		}
	});
	
	$('span.cls').click(function() {
		$(this).parent().css("display","none");
		$(".weatherblock a").removeClass("active");
	});
	
	
	
}

function switchdropdown(){
	$(".top_value").hover(
		function() {
		$(this).find(".dropdown").toggleClass("visible");
		$(this).parent().parent().css("z-index",51);
	});
}
/*
function Search() {
	if ( $("#searchfield").length > 0 ) {
		$(function() {

			function log( message ) {}

			$( "#searchfield" ).autocomplete({
				source: function( request, response ) {
					$.ajax({
						url: "http://ws.geonames.org/searchJSON",
						dataType: "jsonp",
						data: {
							featureClass: "P",
							style: "full",
							maxRows: 5,
							name_startsWith: request.term
						},
						success: function( data ) {
							response( $.map( data.geonames, function( item ) {
								return {
									label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
									value: item.name
								}
							}));
						}
					});
				},
				minLength: 2,
				select: function( event, ui ) {
					log( ui.item ?
						"Selected: " + ui.item.label :
						"Nothing selected, input was " + this.value);
				},
				open: function() {
					var search = $("#search");
					search.addClass("open");
				},
				close: function() {
					var search = $("#search");
					search.removeClass("open");
				}
			});
		});
	}
}
*/
function ContentTeaser() {
	var left_teasers = $("#contentarea #leftcol").find(".teaser").size() - 1;
	var right_teasers = $("#contentarea #rightcol").find(".teaser").size() - 1;

	
	
	for ( i=0; i <= left_teasers; i++) {
		teaserheight = $("#contentarea #leftcol").find(".teasercontainer:eq(" + i + ")").height();
		
		$(".teasercontainer:eq(" + (i+1) + ")").height(teaserheight);
	}

	$("#contentarea .teasercontainer .teaser").hover(
		function() {
			if(!$(this).hasClass("active") && !$(this).hasClass("sfhover")){
				$(this).addClass("sfhover");
				$(this).parent().css("z-index",2);
			}
		},
		function(){
			$(this).removeClass("sfhover");
			$(this).parent().css("z-index",0);
		}
	);
}

function ContentTabs(index) {
	if ( $("ul.contenttabs").length > 0 ) {
			//$("ul.contenttabs").tabs("div.panes > div");
			$("ul.contenttabs").tabs("div.panes > div", {
				initialIndex: index
			});
			$("ul.contenttabs li:last a").css("border-right","1px solid #c8c8c8");
	}
}

function MetaNavTabs() { 
	if ( $(".submetanav ul.tabs").length > 0 ) {
		$(".submetanav ul.tabs").tabs(".submetanav div.panes > div");
		$("#metanav ul.tabs li a:last").css("border-right","1px solid #c8c8c8");
		$("#metanav ul.contenttabs li a:last").css("border-right","1px solid #c8c8c8");
	}
}

function setpoints(reg){
    $.ajax({
        type: "POST",
        url: "?controller=Navigation&action=setcitypoints",
        data: "region="+reg,
        success: function(msg){
            $("#mappointsnormal").html(msg);
        }
    });
}

function showheadbanners(){
    $("#headertippbig").fadeIn("slow");
}

function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
    $(".jcarousel-control a").removeClass("active");
    curr = idx-1;
    $(".jcarousel-control a:eq("+curr+")").addClass("active");
};

function headertippcallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('#headertippbig-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#headertippbig-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
}


function setportalheadtipp(){
    $("#headertippbig").jcarousel({
        scroll: 1,
        auto: 5,
        wrap: 'last',
        initCallback: headertippcallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
       itemVisibleInCallback: {
            onAfterAnimation:  mycarousel_itemVisibleInCallbackAfterAnimation
        }
    });
}




function ForeCast() {
	var wfcount = $(".weatherforecast .container .movingcontainer").children().size();
	var wfwidth = $(".weatherforecast .container .movingcontainer .weatherboxc").width();
	var wfwidth = 157 + 1;
	var wf_maxlength = wfcount * wfwidth;
	var wfcontrol = 0;

	if ( $(".weatherforecast").length > 0 ) {
		$(".movingcontainer").width(wf_maxlength);
		$(".weatherforecast .right").click(
			function() {
				if (wfcontrol < (wf_maxlength - (wfwidth*4))) {
					$(".weatherforecast .movingcontainer").animate({
						left: "-="+wfwidth
					}, 300, function() {
						wfcontrol = wfcontrol + wfwidth;
					});
				}
			}
		);
		$(".weatherforecast .left").click(
			function() {
				if (wfcontrol > 0) {
					$(".weatherforecast .movingcontainer").animate({
						left: "+="+wfwidth
					}, 300, function() {
						wfcontrol = wfcontrol - wfwidth;
					});
				}
			}
		);

	}
}

function MetaNav() {
	$("#maincontainer #head #h_base #metanav ul li").mouseover(function() {
		//if ( $(this).children().children().size() > 0 ) {
			if(!$(this).hasClass("active") && !$(this).hasClass("sfhover")){

				// Check if this is the first dropdown and call MetaNavTabs & MapLocator

				if ($(this).hasClass("first")) {
					MetaNavTabs();
					MapLocator();
				}

				$("#calroot").css("display","none");
				$(this).addClass("sfhover");
				$(this).next().find("a").addClass("nobg");

				if ( $(this).children().hasClass("service") ) {
					$(this).addClass("relative");
				}
			}
		//}
	}).mouseleave(function(){
		if ($("#calroot").length > 0) {
			if ($("#calroot").css("display") === "none") {
				$(this).removeClass("sfhover");
				$(this).next().find("a").removeClass("nobg");
			}
		}
		else {
			$(this).removeClass("sfhover");
			$(this).next().find("a").removeClass("nobg");
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6)
				{
					try
					{
						$("#bannerarea select").show();
					}
					catch (err)
					{
				}
			}
		}
	});
}

function WeatherBox() {
	var wcount = $(".weatherbox").children().size() - 2;
	
	
	var wcontrol = $(".weatherbox > .visible").index();

	$(".weatherdetails .switch .right").click(
		function() {
			if ( wcontrol < wcount ) {
				$(".weatherbox").find(".weatherdetails.visible").removeClass("visible").next().addClass("visible");
				wcontrol++;
		}
		//console.log(wcontrol);
	});
	$(".weatherdetails .switch .left").click(
		function() {
			if ( wcontrol > 1 ) {
				$(".weatherbox").find(".weatherdetails.visible").removeClass("visible").prev().addClass("visible");
				wcontrol--;
		}
		//console.log(wcontrol);
	});
}

function TripPlanner() {
	$("#maincontainer #head #h_base #tripplanner ul li").mouseenter(function() {
		if ( $(this).children().children().size() > 0 ) {
			if(!$(this).hasClass("active") && !$(this).hasClass("sfhover")){
				$(this).addClass("sfhover");
				if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6)
					{
						try
						{
							$(".accomodations").hide();
						}
						catch (err)
						{
					}
				}
			}
		}
	}).mouseleave(function(){
		$(this).removeClass("sfhover");
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6)
					{
						try
						{
							$(".accomodations").show();
						}
						catch (err)
						{
					}
				}
	});
	$(".plan_item:last").css("border-bottom","1px solid transparent");
    
}

function SelectBoxes() {
	if ( $(".accomodations").length > 0 ) {
		$(":date").bind("onShow", function() {
			$("select").hide();
		});

		$(":date").bind("onHide", function() {
			$("select").show();
		});
	}
}

function MenuTeaser() {
	$("#menu_teaser .teaser").hover(
		function() {
			$(this).find(".qualities").hide();
			$(this).find(".hidden").show();
		},
		function() {
			$(this).find(".qualities").show();
			$(this).find(".hidden").hide();
		}
	);
}

function RemoveBorder() {
		$(".contentbox .linecontainer .line:last-child").css("border-bottom","none");
}

function Switcher(dir) {
	var count = $("#switcher").children().size() - 2;
    var visibleitem = $("#switcher .offer").index($('.visible'));

	if(dir == "next"){
        if ( visibleitem != count ) {
            $("#switcher").find(".offer.visible").removeClass("visible").next().addClass("visible");
        } else {
            $("#switcher").find(".offer.visible").removeClass("visible");
            $("#switcher").find(".offer:eq(0)").addClass("visible");
        }

    }
    
    if(dir == "back"){
        if ( visibleitem != 0 ) {
            $("#switcher").find(".offer.visible").removeClass("visible").prev().addClass("visible");
        }
	}
}



function Switcher_BACKUP() {
	var count = $("#switcher").children().size() - 1;
	var control = 1;

	$("#switcher .right").click(
		function() {
			if ( control < count ) {
				$("#switcher").find(".offer.visible").removeClass("visible").next().addClass("visible");
				control++;
		}
	});
	$("#switcher .left").click(
		function() {
			if ( control > 1 ) {
				$("#switcher").find(".offer.visible").removeClass("visible").prev().addClass("visible");
				control--;
		}
	});
}

function Scrollable() {
	$(".scrollable").scrollable({"circular" : true}).navigator();
	$(".scrollable a.zoom").hover(function() {
		$(this).find(".transparenthover").toggleClass("visible");
	}, function() {
		$(this).find(".transparenthover").toggleClass("visible");
	})
}


function LangSelect() {
	$("#maincontainer #head #h_top #lang #lang_selector").click(function() {
            if($(this).hasClass("hover")){
                $(this).removeClass("hover");
            } else {
                $(this).addClass("hover");
            }
			//$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
	});
}

function HotelResultsMark() {
	$(".linecontainer .line").click(function() {
		$(".line.active").toggleClass("active");
		$(this).toggleClass("active");
		//return false;
	})
}

function HotelResultsSwitch() {
	$(".header .updown .down ").click(function() {
		//$(".linecontainer").find(".box").toggleClass("visible");
		//return false;

        aktbox = $(".linecontainer").find(".box.visible");
        aktboxindex = $(".linecontainer").find(".box.visible").index();

        //console.log(aktbox1);
        $(aktbox).removeClass("visible");
        $(aktbox).next().addClass("visible");

	});
	$(".header .updown .up ").click(function() {
		//$(".linecontainer").find(".box").toggleClass("visible");
		//return false;
        aktboxindex = $(".linecontainer").find(".box.visible").index();
        aktbox = $(".linecontainer").find(".box.visible");
        if(aktboxindex != 0){
            $(aktbox).removeClass("visible");
            $(aktbox).prev().addClass("visible");
        }

	});
}





function setfilterbox(){
	if($(".personalbox .change").children().length <= 2){
		$("#maincontainer #leftcol .personalbox .change").css("padding","0");
		$("#maincontainer #leftcol .personalbox .change").css("height","0");
		$("#maincontainer #leftcol .personalbox .change h3").css("display","none");
	} else {
		$("#maincontainer #leftcol .personalbox .change").css("padding","0 0 10px 0");
		$("#maincontainer #leftcol .personalbox .change").css("height","auto");
		$("#maincontainer #leftcol .personalbox .change h3").css("display","block");
	}
}

function Thumbnails() {
	$(".fotocontainer a.zoom").hover(function() {

            txtlen = $(this).find(".tooltip").text().length;

            if(txtlen > 0){
                $(this).find(".transparenthover").toggleClass("visible");
                $(this).find(".tooltip").show();
                $(this).parent().css("z-index",5);
            }

		},
		function() {
			$(this).find(".transparenthover").toggleClass("visible");
			$(this).find(".tooltip").hide();
			$(this).parent().css("z-index",1);
		}
	);
}

function ActiveState() {
	$(".showas .button").click(
		function() {
			$(this).toggleClass("active");
			$(this).next().toggleClass("active");
			$(this).prev().toggleClass("active");
		}
	);
}

function HiddenList() {
	$(".contentbox .branch a.showit").live("click",
		function() {
			$(this).removeClass("showit").addClass("closeme").text("Erweitere Optionen ausblenden");
			$(".contentbox .branch li.hidden").addClass("isvisible");
			return false;
		}
	);
	$(".contentbox .branch a.closeme").live("click",
		function() {
			$(this).removeClass("clsoeme").addClass("showit").text("Alle Optionen anzeigen");
			$(".contentbox .branch li.hidden").removeClass("isvisible");
			return false;
	});
}

function MapLocator() {
	if ( $(".regioncol").length > 0 ) {
		$(".locator").css("top","-9999px").css("left","-9999px")
		$(".regioncol ul li a").hover
			(function() {
				var x = $(this).attr("rev");
				var y = $(this).attr("rel");
				$(".locator").css("left",x+"px");
				$(".locator").css("top",y+"px");
			}
		);
	}
}

function PlusMinus () { 
	$(".topic, .plusminus").click(
		function() {
			$(this).parent().toggleClass("open");
			$(this).parent().find(".plusminus").toggleClass("closed");
		}
	);
}



function FancyBox() {
	$("a.zoom").fancybox({
		'transitionIn'	:	'swing',
		'transitionOut'	:	'linear',
		'speedIn'		:	200,
		'speedOut'		:	200,
		'overlayShow'	:	true,
		'overlayOpacity':   0.4
	});
	
	$("a.zoomwebcam").fancybox({
		'transitionIn'	:	'swing',
		'transitionOut'	:	'linear',
		'speedIn'		:	200,
		'speedOut'		:	200,
		'overlayShow'	:	true,
		'overlayOpacity':   0.4
	});


    $("a.datenschutz").fancybox({
        'width'				: '50%',
        'height'			: '60%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'type'				: 'iframe'
    });

}




function openbox(url,title){
	$.fancybox({
		'padding'		: 0,
		'autoScale'		: false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'title'			: title,
		'width'			: 680,
		'height'		: 495,
		'href'			: url.replace(new RegExp("watch\\?v=", "i"), 'v/'),
		'type'			: 'swf',
		'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
		}
	});
}



function requestForm() {


        $("input.radio").live("click",function() {
            var txtname = "roomtype" + $(this).next().next().html();
            
            $(this).attr("name", txtname);
        });
    


		// Remove Line

		$(".formblock a.delete").live("click",function() {
			$(this).parent().remove();
			var anzahl = $(".formblock .rooms").children().length;
			for (i=0; i<=anzahl; i++) {
				$("span.countzi:eq(" + i + ")").text(i+1);
				$("span.countrm:eq(" + i + ")").text(i+1);
				$("span.countcp:eq(" + i + ")").text(i+1);
                $("#numofroomtype").attr("value",i);
			}
			return false;
		});

		// Add Numbers

		var anzahl = $(".formblock .rooms").children().length;
		for (i=0; i<=anzahl; i++) {
			$("span.countzi:eq(" + i + ")").text(i+1);
			$("span.countrm:eq(" + i + ")").text(i+1);
			$("span.countcp:eq(" + i + ")").text(i+1);
		}

		// Add Line



		$("#anfrageform a.add").live("click",function() {

		
			var lng = ($('#anfrageform .rooms').children().length)+1;

			//var line = "<div class='line'><span class='room'>Zimmer <span class='count'></span></span><label>Erw.</label><select name='adults[]'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select><label> Kinder </label><select class='nr' name='children[]' ><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select><div class='inputs'></div><a class='delete'>entfernen</a></div>";
            if(lang == 'it'){
                var line = "<div class='line'><span class='room'><input style='float: left;' type='radio' class='radio' name='' value='Zimmer'><label style='float: left;'>Camera</label> <span class='countzi'></span><input style='float: left;' type='radio' class='radio' name='' value='Fewo'><label style='float: left;'>Appartamento</label> <span class='countrm'></span><input style='float: left;' type='radio' class='radio' name='' value='Camping'><label style='float: left;'>Camping</label> <span class='countcp'></span></span><label>Ad.</label><select name='adults[]'><option value='0'>0</option><option selected='selected' value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option></select><label> Bambini </label><select class='nr' name='children[]' ><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select><div class='inputs'></div><a class='delete'>cancella</a></div>";
            } else {
			    var line = "<div class='line'><span class='room'><input style='float: left;' type='radio'  class='radio' name='' value='Zimmer'><label style='float: left;'>Zimmer</label> <span class='countzi'></span><input style='float: left;' type='radio' class='radio' name='' value='Fewo'><label style='float: left;'>Wohnung</label> <span class='countrm'></span><input style='float: left;' type='radio' class='radio' name='' value='Camping'><label style='float: left;'>Camping</label> <span class='countcp'></span></span><label>Erw.</label><select name='adults[]'><option value='0'>0</option><option selected='selected' value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option></select><label> Kinder </label><select class='nr' name='children[]' ><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select><div class='inputs'></div><a class='delete'>entfernen</a></div>";
            }

			$(".formblock .rooms").append(line);
			var anzahl = $(".formblock .rooms").children().length;
			for (i=0; i<=anzahl; i++) {
				$("span.countzi:eq(" + i + ")").text(i+1);
				$("span.countrm:eq(" + i + ")").text(i+1);
				$("span.countcp:eq(" + i + ")").text(i+1);
				$("#numofroomtype").attr("value",i);
			}
			$(this).blur();
			return false;
		});

		// Add Inputs depending on Nr.

		$('.formblock .line select.nr').live("change",function() {
			row = $(this).attr("name");
			var selected = $(this).val();
			var inputs = "<label>Alter</label>";
			if ( selected > 0 ) {
				$(this).parent().find(".inputs").empty();
				$(this).parent().find(".inputs").append(inputs);
				for ( i=1; i<=selected; i++ ) {
					$(this).parent().find(".inputs").append("<input class='age' name='age_children[]' type='text' />")
				}
			}
		});

}

function ukteasers(){
    $(".move .bookbutton").mouseenter(function() {
		$(this).css('background-position', '0 -36px');
	}).mouseleave(function(){
		$(this).css('background-position', '0 0');
	});

    $(".move .enquirybutton").mouseenter(function() {
		$(this).css('background-position', '0 -108px');
	}).mouseleave(function(){
		$(this).css('background-position', '0 -72px');
	});

    $(".move .detailsbig").mouseenter(function() {
		$(this).css('background-position', '0 -175px');
        $(this).find('a').css('color', '#0a6b9d');
	}).mouseleave(function(){
		$(this).css('background-position', '0 -144px');
        $(this).find('a').css('color', '#3c3c3c');
	});


    $(".move .enquirysmall").mouseenter(function() {
		$(this).css('background-position', '0 -237px');
        $(this).find('a').css('color', '#0a6b9d');
	}).mouseleave(function(){
		$(this).css('background-position', '0 -206px');
        $(this).find('a').css('color', '#3c3c3c');
	});

    $(".move .detailssmall").mouseenter(function() {
		$(this).css('background-position', '0 -237px');
        $(this).find('a').css('color', '#0a6b9d');
	}).mouseleave(function(){
		$(this).css('background-position', '0 -206px');
        $(this).find('a').css('color', '#3c3c3c');
	});

    $(".merklistbt").mouseenter(function() {
		$(this).css('background-position', '0 -301px');
        $(this).find('a').css('color', '#4894d0');
	}).mouseleave(function(){
		$(this).css('background-position', '0 -268px');
        $(this).find('a').css('color', '#646464');
	});

    $(".ukteasercontainer").mouseenter(function() {
        //HoverMethod(this);
        $(this).find('.move').animate({
          top: "135px"
        }, 300, function() {
          // Animation complete.
            HoverMethod(this);
        });
	}).mouseleave(function(){
        $(this).find('.move').animate({
          top: "245px"
        }, 300, function() {
          // Animation complete.
        });
	});


    $("#leftcol .ukteasercontainer").mouseenter(function() {
        //HoverMethod(this);
        $(this).find('.move').animate({
          top: "167px"
        }, 300, function() {
          // Animation complete.
            HoverMethod(this);
        });
	}).mouseleave(function(){
        $(this).find('.move').animate({
          top: "245px"
        }, 300, function() {
          // Animation complete.
        });
	});
    
    $("#rightcol .ukteasercontainer").mouseenter(function() {
        //HoverMethod(this);
        $(this).find('.move').animate({
          top: "167px"
        }, 300, function() {
          // Animation complete.
            HoverMethod(this);
        });
	}).mouseleave(function(){
        $(this).find('.move').animate({
          top: "245px"
        }, 300, function() {
          // Animation complete.
        });
	});

    $(".cttabs .ukteasercontainer").mouseenter(function() {
        //HoverMethod(this);
        $(this).find('.move').animate({
          top: "167px"
        }, 300, function() {
          // Animation complete.
            HoverMethod(this);
        });
	}).mouseleave(function(){
        $(this).find('.move').animate({
          top: "245px"
        }, 300, function() {
          // Animation complete.
        });
	});

    $(".ukteasercontainer.small").mouseenter(function() {
        $(this).find('.move').animate({
          top: "126px"
        }, 300, function() {
          // Animation complete.
        });
	}).mouseleave(function(){
        $(this).find('.move').animate({
          top: "203px"
        }, 300, function() {
          // Animation complete.
        });
	});

}

	// IE6?

	if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6) {
		try {
			var ie6 = true;
		}
		catch (err) {
		}
	}
	else {
		var ie6 = false;
	}

/*** DOCUMENT READY ***/

$(document).ready(function() {
	filterarray = [];

    ukteasers();

    showheadbanners();


    $(".rightimages a").mouseenter(function() {
		$(this).find('span').css('display', 'block');
	}).mouseleave(function(){
		$(this).find('span').css('display', 'none');
	});
	
	
	$("a.videoembend").click(function() {
        $.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
				'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			}
        });

        return false;
    });
	

	
	
	
	// IE7?

	if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 7) {
		try {
			var ie7 = true;
		}
		catch (err) {
		}
	}
	else {
		var ie7 = false;
	}

	// LANGUAGE SELECTOR

	if ( $("#maincontainer #head #h_top #lang #lang_selector").length > 0 ) {
		LangSelect();
	}

	// METANAV

	if ( $("#maincontainer #head #h_base #metanav").length > 0 ) {
		MetaNav();
	}

	// METANAV SUBMETANAV TABS

	if ($("#metanav ul li").length > 0 ) {
		MetaNavTabs();
	}

	// TRIPPLANNER

	if ( $("#maincontainer #head #h_base #tripplanner ul li").length > 0 ) {
		TripPlanner();
	}

// DATEPICKER

	//if ( $(":date").length > 0 ) {
		datepopup();
	//}

// IE6 SELECT BOXES

	if (ie6 == true) {
		SelectBoxes();
	}
	else {
	}

	// MENU TEASER

	if ( ("#menu_teaser").length > 0 ) {
		$("#menu_teaser").hover(function() {
			MenuTeaser();
		});
	}

	// CONTENT TEASER

	if (ie6 == true) {
	}
	else {
		if ( $(".teaser").length > 0 ) {
			ContentTeaser();
		}
	}

	// CONTENT TABS

	if (ie6 == true) {
		setTimeout(function() {
			ContentTabs();
		}, 5000);
	}
	else {
		ContentTabs();
	}


	// CONTENTBOX REMOVE LAST BORDER

	if (ie6 == true) {
	}
	else {
		RemoveBorder();
	}

	// SEARCH

	$("#searchfield").click(function() {
		//Search();
	})


	// SWITCHER WEATHERBOX

	//if ( $(".weatherdetails").length > 0 ) {
			WeatherBox();
	//}

	// THUMBNAILS HOVER & TOOLTIP


	if ( $(".fotocontainer").length > 0 ) {
		Thumbnails();
	}

	// JQ TOOLS SCROLLABLE

	if ( $(".scrollable").length > 0 ) {
		Scrollable();
	}

	// RESULTS HOTELS SWITCH

	if ( $("#maincontainer #leftcol .contentbox .header .updown").length > 0 ) {
		$("#maincontainer #leftcol .contentbox .header .updown").hover(function() {
			HotelResultsSwitch();
		});
	}

	// RESULTS HOTELS MARK

	if ( $("#maincontainer #leftcol .contentbox .header .updown").length > 0 ) {
		$("#maincontainer #leftcol .contentbox .line").hover(function() {
			HotelResultsMark();
		});
	}

	// FANCYBOX

	//if ( $("a.zoom").length > 0 ) {
		//$("a.zoom").hover(function() {
			FancyBox();
		//});
	//}




	// IE6-BANNERAREA SELECTBOX HIDER

	if (ie6 == true) {
		$("#metanav ul li").live("hover", function() {
			if ( $("#metanav ul li").hasClass("sfhover") ) {
				$("#bannerarea .accomodations .line .col select, #bannerarea .accomodations .line select").addClass("ishidden");
			}
			if ( !$("#metanav ul li").hasClass("sfhover") ) {
				$("#bannerarea .accomodations .line .col select, #bannerarea .accomodations .line select").removeClass("ishidden");
			}
		});
	}
	else {
	}

	// PERSONALBOX +/-

	//if ( $(".topic").length > 0 ) {
		$(".topic, .plusminus").hover(function() {
			PlusMinus();
		})
	//}

	// PERSONALBOX HIDDEN LIST

	//if ( $("a.showit").length > 0 ) {
		HiddenList();
	//}

	// SEARCHFILTER DROPDOWN

	//if ( $(".top_value").length > 0 ) {
		switchdropdown();
	//}
	
	

	// BUTTON SWITCH ACTIVESTATE

	if ( $(".showas .button").length > 0 ) {
		ActiveState();
	}

	// ADD FILTER

	if ( $(".personalbox").length > 0 ) {
		AddFilter();
	}

	// RANGEINPUT

	/*if ( $(".pricerange").length > 0 ) {
		$("#pricesmall").rangeinput();
	}*/

	// RANGEINPUT STARS
	/*
	$("#pricesmall").change(function(onSlide, value) {

		if(jQuery.inArray($(this).attr("id"), filterarray) == -1){ 
			filterarray.push($(this).attr("id"));
			$(".personalbox .change").append("<span class='filter' id='pricesmall'>Preis <span id='vpreis'>" + value + "</span><span id='bpreis'></span> Euro</span>");
		} else {
			$(".personalbox .change span#pricesmall #vpreis").html("  " + value + "");
		}
		
		$("#pricehight").attr("min", value+10);
		$("#pricehight").rangeinput();
		setfilterbox();
		return false;
	
	});
	
	
	$("#pricehight").change(function(onSlide, value) {

		if(jQuery.inArray("pricesmall", filterarray) == -1){ 
			filterarray.push("pricesmall");
			$(".personalbox .change").append("<span class='filter' id='pricesmall'>Preis <span id='vpreis'></span><span id='bpreis'> bis " + value + "</span> Euro</span>");
		} else {
			$(".personalbox .change span#pricesmall #bpreis").html(" bis " + value + "");
		}
		setfilterbox();
		return false;
	
	});
	
	
	
	
	
	
	$("#starssmall").change(function(onSlide, value) {

		if(jQuery.inArray($(this).attr("id"), filterarray) == -1){ 
			filterarray.push($(this).attr("id"));
			$(".personalbox .change").append("<span class='filter' id='starssmall'><span id='vstarr'>" + value + "</span><span id='bstarr'></span> Sterne</span>");
		} else {
			$(".personalbox .change span#starssmall #vstarr").html("  " + value + "");
		}
		setfilterbox();
		return false;
	
	});
	
	$("#starshight").change(function(onSlide, value) {

		if(jQuery.inArray("starssmall", filterarray) == -1){ 
			filterarray.push("starssmall");
			$(".personalbox .change").append("<span class='filter' id='starssmall'><span id='vstarr'></span><span id='bstarr'> bis " + value + "</span> Sterne</span>");
		} else {
			$(".personalbox .change span#starssmall #bstarr").html(" bis " + value + "");
		}
		setfilterbox();
		return false;
	
	});
	
	
	

	$(".pricerange.stars :range.iesmall").change(function(onSlide, value) {
		$(".pricerange.stars .stars.esmall .starrating .stars").empty();
		for (i=1; i<=value; i++) {
			$(".pricerange.stars .stars.esmall .starrating .stars").append("<div class='star'></div>");
		}
	});

	$(".pricerange.stars :range.ihigh").change(function(onSlide, value) {
		$(".pricerange.stars .stars.high .starrating .stars").empty();
		for (i=1; i<=value; i++) {
			$(".pricerange.stars .stars.high .starrating .stars").append("<div class='star'></div>");
		}
	});*/
	
	

	



	



	if ( $(".personalbox span.filter").length > 0 ) {
			//RemoveFilters();
	}

	if ( $("#leftcol .vnav li.header").length > 0 ) {
		$("#leftcol .vnav li.header").click(function() {
			$(this).toggleClass("open");
			$(this).parent().find(".hidden").toggleClass("isvisible");
			return false;
		});

	}

	if ( $("#leftcol .vnav a.allplaces").length > 0 ) {
		$("#leftcol .vnav a.allplaces").click(function() {
			$("#leftcol .vnav a.allplaces").toggleClass("ishidden");
			//$("#leftcol .vnav a.allplaces.ishidden").toggleClass("ishidden");
			$("#leftcol .vnav ul.current .hidden").toggleClass("isvisible");
			
			$("#leftcol .vnav ul li.current").toggleClass("open");
			return false;
		});

		$("letcol .vnav a.allplaces.ishidden").click(function() {
			$(this).toggleClass("isvisible");
			$(".vnav ul.current .hidden").toggleClass("isvisible");
			
			$("#leftcol .vnav ul.current").toggleClass("open");
			return false;
		});
	}
	
	
	$("#leftcol .vnav li.current").click(function() {
		$("#leftcol .vnav a.allplaces").toggleClass("ishidden");
		$("#leftcol .vnav ul.current .hidden").toggleClass("isvisible");
	});

	// IE7 MARGIN BENEATH LAST TEASER

	if (ie7 == true) {
		$("#leftcol .teasercontainer:last").css("margin-bottom","50px");
		$("#rightcol .teasercontainer:last").css("margin-bottom","50px");
	}



    // AD Teaser switch
    if($('.starttipp .ukteasercontainer').length > 1){
        setInterval( "slideSwitch('.starttipp .ukteasercontainer.active', '.starttipp .ukteasercontainer')", 4000 );
    }

    if($('#switcher .offer').length > 1){
        setInterval( "Switcher('next')", 3000 );
    }



});




