$(window).load(function(){
	 resizeMenu($("div.topmenu"),$("div.topmenu").width());
	 $("div.topmenu").find("ul:first").children().hover(
		function(){
	       $(this).addClass("active");
		   $(this).find("ul:first").show();
		   $(this).find("ul:first").find("li:last").addClass("last");
		   var w0=0;
		   $(this).find("ul:first").find("li").each(function(){
			   if(w0<$(this).width()){
				  w0=$(this).width();
			   }											 
		   });
		   if(w0<($(this).width()-8)){
		      w0=$(this).width()-8;
		   }
		   $(this).find("ul:first").width(w0);
		   
	    },
		function(){
		   $(this).removeClass("active");
		   $(this).find("ul:first").hide();
		}
	 );
	 var temp=0;
	 $("ul.partners").children().each(function(){
		temp=temp+$(this).width();
	 });
	 $("ul.partners").width(temp);
	 var offset1=$("div#area2").offset();
	 $("div#area1").css("position","absolute");
	 $("div#area1").css("left",offset1.left);
	 $("div#area1").css("top",offset1.top);
	 $("div#area1").css("width",$("div#area2").width());
	 $("div#area1").show();
	 $("div#area2").height($("div#area1").height());
	 $(window).resize(function(){
		 offset1=$("div#area2").offset();
		 $("div#area1").css("left",offset1.left);
		 $("div#area1").css("top",offset1.top);
	 });
 });

function resizeMenu(menuHolder,menuWidth){
	var holder=menuHolder;
	var $items=$(holder).find("ul:first").children();
	$items.each(function(i){
		$(this).find("a:first").width("auto");		 
	});
	var w0=menuWidth;
	var w1=$(holder).find("ul:first").width();
	var w2=0;
	var mod=0;
	if($items.length>0 && w0>w1){
		w2=parseInt((w0-w1)/$items.length);
		mod=(w0-w1)%$items.length;
		$items.each(function(i){
			if(i<mod){
				$(this).find("a:first").width($(this).find("a:first").width()+w2+1);
			}else{
				$(this).find("a:first").width($(this).find("a:first").width()+w2);
			}
			
		});
	}
}