"use strict";

jQuery(document).ready(function ($) {

	var self;

	// quick visual menu change
	$('.nav ul li a').click(function () {
	
		self = $(this);
		
		if (self.parent('li').hasClass('current_page_item')) {
			return false;
		}
		
		$('.current_page_item').removeClass('current_page_item').children('a').css('background', '#555');
		self.parent('li').addClass('current_page_item');

	});
	
	// nav background color animation
	$('.nav ul li a').hover(function () {
		$(this).stop().animate({ backgroundColor: "#333" }, 200);
	}, function () {
		if (!$(this).parent('li').hasClass('.current_page_item')) {
			$(this).stop().animate({ backgroundColor: "#555" }, 200);
		}
	});

	// dropdown grafik einfuegen
	$('.nav ul li:has(ul)').children('a').css('paddingRight', '22px').append('<div class="dropdown-arrow"/>');
	
	// dropdown menu animation
	$('.nav ul li').hover(function () {
		$(this).find('> ul').css('width', '150px').stop(true, true).show('fast');	
	}, function () {
		$(this).find('> ul').stop(true, true).hide();		
	});

	
	$("#certificates a").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	

	// hotels details toggle
	if ($('body').hasClass('page-id-96')) {
		
		$('#hotels .details').hide();

		$('#hotels.de .price').not(':first').after('<a href="#" class="more">mehr Infos</a>');
		$('#hotels.en .price').not(':first').after('<a href="#" class="more">more info</a>');

		$('.more').click( function () {
		
			$('#hotels .details:visible').not($(this).next('.details')).slideUp('fast');			

			$(this).next('.details').slideToggle('fast');
			
			return false;
		});
		
	}
	
	$('.to-top').click(function(){
        $('html, body').animate({scrollTop:0});
        return false;
    });

});