/*
* $Id: cs_eventhandlers.js,v 1.1 2010/01/27 10:19:55 annette Exp $ 
*/
jQuery.noConflict();


jQuery(document).ready(function($){ 
// TopUp
/*
  
 	TopUp.host = "http://80.87.160.50/";
	TopUp.images_path = "fileadmin/templates/images/top_up/";
	//TopUp.players_path = "fileadmin/templates/flash/";
	TopUp.addPresets({
		"#bxMain .top_up": {
			group: "images",
			resizable: 1
		}
	}); 
*/	
// Akkordeon
	$(".accordion .content-inner-wrapper").hide();
	$(".accordion .content-inner-wrapper").append("<a href=\"#\" class=\"accordeon-close-link\"><img src=\"fileadmin/templates/images/accordeon_schliessen.png\" class=\"accordeon-close\"/></a>");
	$(".accordion .content-inner-wrapper .accordeon-close-link").click(function(){
		$(this).parent().slideToggle();
		$(this).parent().prev().toggleClass("active");
		return false;
	});
	
	$(".accordion h2, .accordion h2").click(function(){
		if($(this).is(".active")) {
			$(this).toggleClass("active");
			$(this).parent().next(".content-inner-wrapper").slideToggle();
			return false;
		} else {
			$(".accordion .content-inner-wrapper:visible").slideUp("slow"); // close all visible divs with the class of .content
			$(".accordion h2.active").removeClass("active");  // remove the class active from all h1's with the class of .active
			$(this).toggleClass("active");
			$(".accordion .active .arrow").addClass('active');
			$(this).parent().next(".content-inner-wrapper").slideToggle();
			return false;
		}
	});

// handlers for header navigation	  
	$('.nav-menu').hover(function() {
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
	
	$('.nav-home').hover(function() {
		if($('.nav-home').hasClass('nav-active')) {
			return;
		}
		$(this).removeClass('hover');
		$(this).addClass('home-hover');
		}, function() {
		$(this).removeClass('home-hover');
	});

// handlers for search form
	  		

	$('.theSelect').click(function(){
		var isVisible = "";
		$(this).removeClass('selectHover');
		$('.theSelect').removeClass('selectActive');
		$('.theSelect').addClass('selectInactive');
		$(this).removeClass('selectInactive');
		$(this).addClass('selectActive');
		if($(this).parent().hasClass('inVisible'))
			isVisible = false;
		else
			isVisible = true;
		$('.dropdownContainer').addClass('inVisible');
		if(!isVisible)
		$(this).parent().removeClass('inVisible');
	});
	
	$('.theSelect').mouseover(function(){
		if(!$(this).hasClass('selectActive')){
			$(this).removeClass('selectInactive');
			$(this).addClass('selectHover');
		}
	});
	
	$('.theSelect').mouseout(function(){
		if(!$(this).hasClass('selectActive')){
			$(this).removeClass('selectHover');
			$(this).addClass('selectInactive');
		}
	});
	$('.theOptions li').click(function(){
//		alert('option clicked');
		$('.theOptions li').removeClass('highlighter');
		$(this).addClass('highlighter');
		$('.dropdownContainer').addClass('inVisible');
	});
	      
	$('.theOptions li').hover(function(){
		$('.theOptions li').removeClass('highlighter');
		$(this).addClass('highlighter');
	});
	      
	$('#departure .theOptions li').click(function(){
		$('#departure .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		$('#departureField').get(0).value = val;
		//alert(val);
		$('#departure').addClass('inVisible');
		
		// console.log($('#departureField').get(0).value);
	});
	$('#country .theOptions li').click(function(){
		$('#country .selectText').html($(this).text());
		var idval = $(this).get(0).id;
		val = idval.slice(1);
		$('#countryField').get(0).value = val;
		$('#country').addClass('inVisible');
		
		$('#destinationHotel li.li_child').hide();
		$('#destinationHotel li.top_'+idval).show();
		$('#destinationHotel li.top_c').show();
		//alert('#destinationHotel li.top_'+idval);
		$('#destinationHotel .selectText').html('Bitte wählen');
		
		//$('#destinationHotel ul').prepend('<li id="c" class="li_child">Alle Regionen</li>');
		if (val=='-1') {
			$('#destinationHotel li.li_child').show();
		}
		// console.log($('#departureField').get(0).value);
	});

	$('#destination .theOptions li').click(function(){
		$('#destination .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		$('#destinationField').get(0).value = val;
	});
	$('#destinationHotel .theOptions li').click(function(){
		$('#destinationHotel .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(1);
		$('#destinationFieldHotel').get(0).value = val;
		$('#destinationDetail').get(0).value = 'hotel';
	});

	$('#participants .theOptions li').click(function(){
		$('#participants .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		val = val.replace(/-/gi,';');
		$('#participantsField').get(0).value = val;  
	});
	$('#participantsHotel .theOptions li').click(function(){
		$('#participantsHotel .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		val = val.replace(/-/gi,';');
		$('#participantsFieldHotel').get(0).value = val;  
	});
	$('#duration .theOptions li').click(function(){
		$('#duration .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		$('#durationField').get(0).value = val;  
//		$('#duration').get(0).selectedIndex = val;
		adjustEndDate('lmFormFp_lastMinute','ibeStartDate','ibeEndDate','durationField',isTT);
	});
	$('#durationHotel .theOptions li').click(function(){
		$('#durationHotel .selectText').html($(this).text());
		var val = $(this).get(0).id;
		val = val.slice(3);
		$('#durationFieldHotel').get(0).value = val;  
		//$('#durationHotel').get(0).selectedIndex = val;
		adjustEndDate('lmFormFp_hotel','ibeStartDateHotel','ibeEndDateHotel','durationFieldHotel',isTT);
	});
	$('#searchButton').click(function(){
		document.forms['lmFormFp'].submit();
	});
	
	$('body').click(function() {
		$('.fespUswFpBlock').removeClass('hide');
		$('.dropdownContainer').addClass('inVisible');
		//alert('body clicked');
	});
	 
	$('.dropdownContainer').click(function(event){
		event.stopPropagation();
	});
	      
});

