$(document).ready(function(){

	$("#navigation li").each(function(){
		if ($(this).find("ul").length > 0) $(this).hover(function(){
		  $("#navigation ul ul").hide();
			$(this).find("ul").stop().show().animate({opacity: 1},1);
		},function(){
			if ($(this).find("ul").is(':animated')) $(this).find("ul").stop();	
			$(this).find("ul").stop().animate({opacity: 1},240,function(){
				$(this).fadeOut("normal");
			})
		})
	})
	
  $(".news").hover(function(){
    $(this).addClass("newshover");
  },function(){
    $(this).removeClass("newshover");
  }).click(function(){
	if($(this).attr("pid"))	location.href='?pid='+$(this).attr("pid")+'&nid='+$(this).attr("rel"); 
	else location.href='?pid='+$(this).attr("rel"); 
  })
  
  $(window).resize(function(){placeContainer();}); placeContainer();

})

function placeContainer() {
  var totalheight = $(window).height();
  var containerheight = $("#container").outerHeight();
  var fromtop = ( totalheight - containerheight )/2; if (fromtop < 0) fromtop = 0;
  $("#container").css("position","relative").css({position: "relative", top: fromtop})
}