$(document).ready(function(){
//----------------------------------------


//------------------------------------------	
	
//$('.flightInfo_button').click(
//	function(){
//		$('#flugInfos').fadeIn();
//	});
//$('#flugInfos').click(
//	function(){
//		$(this).fadeOut();
//	});
$('a.info').click(function(){
	$(this).siblings('div.infoLayer').slideToggle();
	$('a.info').not(this).siblings('div.infoLayer').hide();
	$('a.info').not(this).parent().removeClass('active');
	$(this).parent().toggleClass('active');
	});


$('div.infoLayer').click(function(){
	$(this).slideUp().parent().removeClass('active');
	});

	
//---------------------------------------------

$('input, textarea, select').focus(
	function(){
		$(this).parents('.group').addClass("over");
		}).blur(
	function(){
		$(this).parents('.group').removeClass("over");
});
$('.labelify').labelify();

//----------------------------------------

  $('.accordion-slider').kwicks({
					  isVertical   : false,        // Kwicks will align vertically if true
					  sticky       : true,        // One kwick will always be expanded if true
					  defaultKwick : 0,            // The initially expanded kwick (if and only if sticky is true). zero based
					  activeClass  : 'active',     // 
					  event        : 'mouseenter', // The event that triggers the expand effect
					  eventClose   : 'mouseleave', // The event that triggers the collapse effect
					  spacing      : 2,            // The width (in pixels) separating each kwick element
					  duration     : 400,          // The number of milliseconds required for each animation to complete
					  easing       : 'swing',      // Custom animation easing (requires easing plugin if anything other than 'swing' or 'linear')
					  max          : null,         // The width or height of a fully expanded kwick element
					  min          : 30,         // The width or height of a fully collapsed kwick element
					
					  init         : null,         // event called when the event occurs (click or mouseover)
					  expanding    : null,         // event called before kwicks expanding animation begins
					  collapsing   : null,         // event called before kwicks collapsing animation begins
					  completed    : null          // event called when animation completes
 });
 $('.accordion-slider li').mouseover(function(){
	  $(this).children().children('li.description').slideDown(400);
	 // $(this).children().children('li.objectNr').animate({bottom: 55},400);
	 });
 $('.accordion-slider li').mouseleave(function(){
	  $(this).children().children('li.description').slideUp(400);
	  $(this).children().children('li.objectNr').animate({bottom: 15},400);
	 });
 //$('li.description').mouseleave(function(){
	 
	 // $(this).sibblings('li.objectNr').animate({bottom: 15},400);
	 //});
//----------------------------------------

$('div.packageObjektBox .images a').css('display', (function(){
		var position1 = $(this).parent().siblings('.packageObjectDescription').children('.room_board').children('.room_board-inner').children('.board').position();
		var position2 = $(this).position();
		var position3 = position2.top - 20 ;
		var display = 'inline';
		
		if( position1.top < position3){
			var display = 'none';
			var color = 'red';		
			};
		
		return display;
		
		}));

$('.expand').click(function(){
		
		$(this).siblings('.images').children('a:hidden').slideDown(1000);
		$(this).siblings('.packageObjectDescription').children('.additionalContent').slideDown(1000);
		$(this).hide();
		$(this).siblings('.reduce').show();
		
		
		
		});
$('.reduce').click(function(){
		
						var ziel = $(this).parent().parent();
						$('html,body').animate({
						scrollTop: $(ziel) .offset().top
						});
						
		$(this).siblings('.packageObjectDescription').children('.additionalContent').slideUp();
		$(this).hide();
		$(this).siblings('.expand').show();		
		$(this).siblings('.images').children('a').css('display', (function(){
		var position1 = $(this).parent().siblings('.packageObjectDescription').children('.room_board').children('.room_board-inner').children('.board').position();
		var position2 = $(this).position();
		var position3 = position2.top;
		var display = 'inline';
		
		if( position1.top < position3){
			var display = 'none';
			var color = 'red';		
			};
		
		return display;
		
		}));
		
		});		
		
//----------------------------------------


$('#requestFormSwitch').click(function(){
	$('.optional').show();
	$(this).hide();
	$('input.mand_fields').removeClass('mand_fields');
	
	/*var ziel = $(this).parent().parent();
						$('html,body').animate({
						scrollTop: $(ziel) .offset().top
						});*/
	});
$('#requestFormSwitch_mand').click(function(){
	$('.optional').hide();
	$(this).hide();
	$('#requestFormSwitch').show();
	var ziel = $(this).parent().parent();
						$('html,body').animate({
						scrollTop: $(ziel) .offset().top
						});
	});


//----------------------------------------
//$('#formSwitch').click(function(){
//	$('.obj').toggle();
//	
//	});
//----------------------------------------

	$('dl.faqList > dt').click(function(){
		$(this).toggleClass('active');
		$(this).next('dd').slideToggle();
		//$('dt.active').not(this).removeClass('active').siblings('dd').hide();
		
		
		});

//----------------------------------------
$('ul#headerImg_large > li.start').show();
$('ul#headerImg_large > li').not('.start').css('right','-409px');
$('ul#headerImg_small > li').mouseover(function(){
	
	var thumbNr = $(this).attr('class').trim().charAt(5);
	$('ul#headerImg_large > li.img' + thumbNr).css({'z-index':'1000','display':'block'}).animate({
		right:0	},400);
	$('ul#headerImg_large > li:visible').not('.start').not('ul#headerImg_large > li.img' + thumbNr).animate({
		right:409},400, function(){
			$(this).css({'z-index':'0','display':'none','right':'-409px'});
			});
	});
$('div#headerImgs').mouseleave(function(){
	$('ul#headerImg_large > li').not('.start').animate({
		right:409},400, function(){
		$('ul#headerImg_large > li').not('.start').css('right','-409px').hide()
		});
	});

//----------------------------------------


$('.container1').show();

$('ul.buttons > li').click(function(){
	
	var buttonNr = $(this).attr('class').trim().charAt(6);
	$('.container' + buttonNr).show();
	$('.container').not('.container' + buttonNr).hide();
	$(this).addClass('active');
	$('ul.buttons > li').not(this).removeClass('active');
	
	});





//----------------------------------------

$('a#descriptionSwitch').click(function(){
	$('.additional').slideToggle();
	
	
	}).toggle(
	
		  function () {
			$(this).text("Weniger Inhalt");
		  },
		  function () {
			$(this).text("Mehr");
		  }
	);

//----------------------------------------
$("a.iframe").fancybox({
		'hideOnContentClick': true,
		'scrolling':true,
		'width':680,
		'height':600
	});
//----------------------------------------

$(document).scroll(function(){
           var position = $('#sidebar').offset();
		   var top = position.top;
		  
            if(window.pageYOffset >= top){
                $('#configuratorContainer').attr("style", "position:fixed; top:20px;");
				$('#configurator').animate({left:0	},400);
				
            }else{
                $('#configuratorContainer').attr("style", "position:absolute; top:top");
				
				
            }
        });
		 
				
$('.editButton').click(function(){
	var current = $(this).parent().parent().parent();
	$(this).parent().next('li').slideToggle();
	$(current).toggleClass('active');
	$('.active').not(current).removeClass('active');
	
 });
//----------------------------------------

//$('.container').jScrollPane();

//----------------------------------------

});
