$(function()
{
	$("a:contains('Guest Reviews'), a:contains('Hotelbewertungen')").click(function(){
		window.open("/layout/set/popup"+$(this).attr("href"),'newwin','menubar=0,status=0,toolbar=0,location=0,resizable=1,scrollbars=1,width=600');
		return false;
	});
	
	$("ul#nav li.active ul").addClass("hold");
	$("ul#nav li:not(ul#nav li.active, ul#nav li li)").hover(function()
	{
		if(!$(this).parent().hasClass("hold"))
			$(".hold").hide();
		
		$(this).addClass("active");
		$("ul", $(this)).show();
	}, function()
	{
		$(this).removeClass("active");
		$("ul", $(this)).hide();
		
		if($(this).parent().attr("id")=="nav")
			$(".hold").show();
	});
	
	$("#language").change(function(){
		if($(this).val()!="Location")
			window.location = $(this).val();		
	});


	$(".photo-tour").hover(function()
	{
		$("a.btn_photo-tour", $(this)).addClass("active").next("ul").show();
	}, function()
	{
		$("a.btn_photo-tour", $(this)).removeClass("active").next("ul").hide();
	});
	/*$("#index #header-slideshow").cycle(
	{
		fx: "fade",
		speed: 800,
		timeout: 4000
	});*/
	
	$('#header-slideshow').cycle({
        fx:     "fade",
        speed:  800,
        timeout: 4000,
        pager:  '#slideshow-nav ul.slides',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#slideshow-nav ul.slides li:eq(' + (idx) + ') a';
        }
    });

	
	$(".sidebar-slides .slide").cycle(
	{
		fx: "scrollHorz",
		speed: 500,
		timeout: 5000,
		pager: ".sidebar-slides ul.slide-pager",
		pagerAnchorBuilder: function(idx, slide)
		{
			return '<li><a href="#">&nbsp;</a></li>';
		}
	});
	// Sets up and clears email address input on focus, adds label back in when empty on blur
	$("form.subscribe input.input-text").each(function()
	{
		$(this).data("default", $(this).val());
	});
	$("form.subscribe input.input-text").focus(function()
	{
		($(this).val() == $(this).data("default")) ? $(this).val('') : null;
	}).blur(function()
	{
		($(this).val() == '') ? $(this).val($(this).data("default")) : null;
	});
	if ($("body").attr("id") != "index")
	{
		$("#header-slideshow img").each(function(i)
		{
			if (i == 0) return true;
			$(this).css({zIndex: (i + 1)}).hide();
		});
	}
	$("#slideshow-nav ul.slides a").click(function()
	{
		$link = $(this);
		num = $("#slideshow-nav ul.slides a").index($link);
		$("#header-slideshow img").not("#header-slideshow img:eq(" + num + ")").fadeOut(800);
		$("#header-slideshow img:eq(" + num + ")").fadeIn(800);
		return false;
	});
});