// JavaScript Document
$(document).ready(function() {

	// global
	// d_bar_tab show, hide and change picture
	$(".d_bar_tab").toggle(
		function() { $(".destination_bar").animate( { top:"0px" }, 500); $(".d_bar_tab").attr({src: "/img/d_bar_tab_close.gif"}); },
		function() { $(".destination_bar").animate( { top:"-75px" }, 500); $(".d_bar_tab").attr({src: "/img/d_bar_tab_open.gif"}); }
	);
	
	// language handler
	$("#l_link").toggle(
		function() { $("#l_box").show(); $("#l_link").removeClass("l_link_unselected").addClass("l_link_selected"); },
		function() { $("#l_box").hide(); $("#l_link").removeClass("l_link_selected").addClass("l_link_unselected"); }
	);
	
	
	// tabs handler
	$("#tabs ul li a:first").removeClass('inactive');
	$("#tabs ul li a").click(function () {
		$("#tabs ul li a").addClass('inactive');
		$(this).removeClass('inactive');
		var currentTab = $(this).attr('href');
		$('.tab').hide();
		$(currentTab).show();
		return false;
	});
	
	// tabs weather
	$("#tab_weather ul li a:first").removeClass('inactive');
	$("#tab_weather ul li a").click(function () {
		$("#tab_weather ul li a").addClass('inactive');
		$(this).removeClass('inactive');
		var currentTab = $(this).attr('href');
		$('.tab_weather').hide();
		$(currentTab).show();
		return false;
	});	
	
	// js template1
	// home accordion handler
	$(".ah").click(function() {
		$(this).parent().parent().find(".ah.open").addClass("closed").removeClass("open");
		$(this).parent().parent().find(".ac.open").addClass("closed").removeClass("open");
		$(this).addClass("open").next().removeClass("closed").addClass("open");
	});
	

	// js template2
	// content accordion handler
	$(".ac_info_head a.closed").click(function() {
		
		$(this).parent().next().toggle();
		$(this).toggleClass("open");
		
	
	//	$(this).parent().children(".ac_info_cont").toggle();
	//	$(this).children("a").toggleClass("open");
	//	$(this).children(".closed").live('click', function(event) {
	//		event.preventDefault();
	//	}
		
	return false;	
	});

	/* OLD CODE (14/12/2010)
	// js template2
	// content accordion handler
	$(".ac_info_head").click(function() {
		$(this).parent().children(".ac_info_cont").toggle();
		$(this).children("a").toggleClass("open");
		$(this).children(".closed").live('click', function(event) {
			event.preventDefault();
		}
		
	});
	*/
	
	// Cufon 
	// Navigation Schriftaustausch
	Cufon.replace('#nav_main a.wn1', { hover: true });
	
  <!-- NM_RESIZE -->
  jQuery("#header_image,#header_image_home").nm_resize({
    image_width:1400, // Picture's original width
    image_height:400  // Picture's original height
  });
               
  <!-- SWITCH-TEASER -->
  $(".slidetabs").tabs(".images > div", {
  
  	// enable "cross-fading" effect
    effect: 'fade',
    fadeOutSpeed: "slow",
      
    // start from the beginning after the last tab
    rotate: true
      
    // use the slideshow plugin. It accepts its own configuration
  }).slideshow();
  
  // Sitemap Hauptmenupunkte aus Footermenu ausblenden
  $("div.sitemapContent:eq(1) ul.sitemap a[href*='hauptnavigation']").parent().hide();
  
  $('div.thumbs a').click(function(){ return false; });



	// tomas 
	$( '#quickBook' ).change(function() {
  		if ($(this).val() == 'AMDEN,AAMDEN,AARVENBUEL,ARVENBUEL' ) {
  			$("#quickBookTomas option[value='']").attr('selected',true);
  			$( '#quickFormTomas' ).show();
  			$( '#quickForm' ).hide();
  		}
	});
	
	$( '#quickBookTomas' ).change(function() {
  		if ($(this).val() == '1' ) {
  			$( '#quickFormTomas' ).hide();
  			$("#quickBook option[value='']").attr('selected',true);
  			$( '#quickForm' ).show();
  		}
  		if ($(this).val() == '2' ) {
  			$( '#quickFormTomas' ).hide();
  			$("#quickBook option[value='']").attr('selected',true);
  			$( '#quickForm' ).show();
  		}
  		if ($(this).val() == '3' ) {
  			$( '#quickFormTomas' ).hide();
  			$("#quickBook option[value='']").attr('selected',true);
  			$( '#quickForm' ).show();
  		}
  		if ($(this).val() == '4' ) {
  			$( '#quickFormTomas' ).hide();
  			$("#quickBook option[value='']").attr('selected',true);
  			$( '#quickForm' ).show();
  		}
	});



});


////// Popup Funktionen //////
function changeImage (imagePath, ImageUrl) {
	document.getElementById('_bigImg').src = imagePath;
}

function openWin (URL,Wid,Hei) {
	aWindow = window.open(URL,"OpenWin",
        'toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no,width=' + openWin.arguments[1] +
        ',height=' + openWin.arguments[2]);
}

function openWinToolbar (URL,Wid,Hei) {
     aWindow = window.open(URL,"_blank",
        'toolbar=yes,status=no,scrollbars=yes,resizable=yes,menubar=no,width=' + openWinToolbar.arguments[1] +
        ',height=' + openWinToolbar.arguments[2]);
}

function openWinTravelfrom (URL,Wid,Hei) {
     aWindow = window.open(URL,"OpenWin",
        'toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no,width=300,height=200');
}


//////////////////// Regionenauswahl - Formulare /////////////////////////////////

// Textfeld mit dem Checkbox-Title fuellen

function setRegionText() {
	var titleAll="";
	var regionKeys="";
	for (var i = 0; i < document.getElementsByName("region").length; i++) {
		
  	if (document.getElementsByName("region")[i].checked) {
			var titleText = document.getElementsByName("region")[i].getAttribute('title');
			if (titleAll == "") {
				titleAll = titleText;
			} else {
				titleAll = titleAll + ", " + titleText;
				if (i == (document.getElementsByName("region").length)-1) {
					var titleAll = "";
				}
			}
		} 
	}
	
	if (titleAll == "") {
		var titleAll = LB_APPLY_REGION;
	}
	$('#regionLink').text(titleAll);
	
	// Schliessen der Thickbox bei Uebernehemen
	tb_remove();
}

// Alle Checkboxen aktivieren
function Aktivieren () {
	for (var i = 0; i < document.getElementsByName("region").length; i++) {
  	document.getElementsByName("region")[i].checked = true;
		// $("#selectAll").css('display','none');
		// $("#deselectAll").css('display','inline');
	}
}

// Alle Checkboxen deaktivieren
function Deaktivieren () {
	for (var i = 0; i < document.getElementsByName("region").length; i++) {
  	document.getElementsByName("region")[i].checked = false;
	// $("#selectAll").css('display','inline');
  	// $("#deselectAll").css('display','none');
	}
}

// alle diese orte checken, falls einer davon gecheckt wird
function regionTrigger(id){
	if(document.getElementById(id).checked){
		switch(id){
			case 'rid631': case 'rid1975': case 'rid1040': case 'rid948': case 'rid1976':
				document.getElementById('rid631').checked=true;
				document.getElementById('rid1975').checked=true;
				document.getElementById('rid1040').checked=true;
				document.getElementById('rid948').checked=true;
				document.getElementById('rid1976').checked=true;
			break;
		}
	}
}
