var liftoffTime = new Date(2011,0,31); 
liftoffTime = new Date(liftoffTime); 

$(document).ready( function(){
	$("ul.active").show();
	$('#counter').countdown({until: liftoffTime, format: 'dHMS'});
	//slide("#sliding-navigation", 25, 15, 150, .8);
	
	
	$(".sub-nav").hoverIntent({
	    sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
	    interval: 50,   // number = milliseconds for onMouseOver polling interval
	    over: show,     // function = onMouseOver callback (required)
	    timeout: 250,   // number = milliseconds delay before onMouseOut
	    out: hide       // function = onMouseOut callback (required)
	  });
	
	$(".equal").equalHeights(); 
	
	$('#bgimg img').imgpreload(function(){
         
		$('#bgimg').fadeIn("slow");
                   
   	});  

});
	

(function($) { $.fn.equalHeights = function() { 
		var targetHeight = 0; 
		this.each(function() { 
	//		if ($(this).height() > targetHeight) targetHeight = $(this).height();
		}); 
		this.each(function() { 
		//	$(this).height(targetHeight); 		
			$(this).height($('div.navi').height());
			targetHeight = $('div#rechts').height();
		}); 

		$('#sociallinks').css("top",targetHeight-15);
		
		if($('div.navi').height() > $('div#content').height()){
			$('div#content').height($('div.navi').height());
		}
		
		
		return this; 
		}; 
	})(jQuery); 


function show() {
    var menu = $(this);
  	menu.children(".sub-menu").not(".active").slideDown();
  	
  }
 
function hide() { 

    var menu = $(this);
    if(menu.hasClass("current-cat-parent"))
    {
        //do nothing
    }
    else{
    	menu.children(".sub-menu").not(".active").slideUp();
    }
  }


function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li.sliding-element";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		$(this).css("margin-left","0px");
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ marginLeft: "0" }, timer);
		$(this).animate({ marginLeft: "15px" }, timer);
		$(this).animate({ marginLeft: "0" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	/*
	$(link_elements).each(function(i)
	{
		$(this).hover(
		function()
		{
			$(this).animate({ paddingLeft: pad_out }, 150);
		},		
		function()
		{
			$(this).animate({ paddingLeft: pad_in }, 150);
		});
	});
	*/
}



function switchmap(){

	$('#pic1').animate({
	    opacity: 0
	  }, 1000, function() {
	    // Animation complete.
		//  alert("done");
	  });

		
}

function switchmap2(){

	$('#pic1').animate({
	    opacity: 0
	  }, 1000, function() {
	    // Animation complete.
		//  alert("done");
		  $('#pic3').animate({
			    opacity: 1
			  }, 1000 )
	  });

		
}




