//по находим по классу, линкуем связанные объекты по id

var g_LastBtnId = 'menu_1';
function menuBtnMouseOver() {

$('.menu_btn').mouseover(function(){

    var id =$(this).attr("id").substr(0,6);
	var menu = $('#'+id);
	var offs = $(this).offset();

//	offs.top+=75;
//по верху полосы
	offs.top+=80;
//	offs.left+=$(this).width()/2;

//по левому краю
//	offs.left+=$(this).width()/2-50;
//	offs.left+=0;
//по центру
	offs.left+=$(this).width()/2-menu.width()/2;



//	offs.top+=75-menu.height()/2;
//	offs.left+=$(this).width()/2-menu.width()/2;
	//offs.left+=$(this).width()/2-$('#'+id).width()/2;

//	for(var i=1;i<6;i++)
//	$('#menu_'+i).hide('slow');  

                   
	if($('#'+id).css("display") == "none" )
	{           
	  $('#'+g_LastBtnId).css('display','none'); 
		g_LastBtnId = id;  
				
	  $('#'+id).css('display','inline');
//	  $('#'+id).css('background-color','#EEEEEE');
//      $('#'+id).corner('transparent');
//		$('#'+id).corner('20px');

	  //$('#'+id).corner('tr bl br');
	  $('#'+id).css('top',offs.top);
	  $('#'+id).css('left',offs.left);

	  //pom_setFooterPos(0);
	  
	  //$('.menu_1_btn').css('background-color','#DDDDDD');
	  //$('.menu_1_btn').corner();
	  
	//$('#menu_1').show('slow');  
	}

	//$('#user_settings').hide('slow');  

	
	//.trigger('click');
	return false;
});

$('.menu_btn').mouseout(function(e){
    var id =$(this).attr("id").substr(0,6);

	var menu = $('#'+id);

	var offset = $(this).offset();
    var relativeX = parseInt(e.pageX - offset.left);
    var relativeY = parseInt(e.pageY - offset.top);

	if(
		(relativeX<0)||(relativeX>=$(this).width())
		||(relativeY<0)||(relativeY>=$(this).height()+100)
		)
		menu.css('display','none');

	return false;
});

$('.icomenu').mouseout(function(e){

	var offset = $(this).offset();
    var relativeX = parseInt(e.pageX - offset.left);
    var relativeY = parseInt(e.pageY - offset.top);

	if(
		(relativeX<0)||(relativeX>=$(this).width())
		||(relativeY<0)||(relativeY>=$(this).height())
		)
	{
		$('.icomenu').css('display','none');
	}

//    var id =$(this).attr("id");
//	$('#'+g_LastBtnId).css('display','none');

   //	var offs = $(this).offset();

   //	offs.top+=80;
   //	offs.left+=67;
	

	return false;
});


}


   function pom_setFooterPos(h) {
   	var top = $(window).height()+$(window).scrollTop()-(h?h:50);
   	var topDoc = $(document).height()-50;
	$('#footer').css('top',(top>topDoc)?top:topDoc);
	$('#footer').css('left',0);
	}

   function pom_layout() {
   var height = $(window).height();
   var middle = height/2;
   var third = height/3.2;

   $('#index_page').css('background-position','0px 188px');
   $('#menu').css('top',140);
	pom_setFooterPos(0);
   }
   
   
   //pom_layout();
   

   $(window).resize(function(){
		pom_layout();
	});

   $(window).scroll(function(){
		pom_setFooterPos(0);
	});

        /*
   var g_ResizeTimer = null;
   $(window).resize(function(){

			if (g_ResizeTimer)
				clearTimeout(g_ResizeTimer);

			g_ResizeTimer = setTimeout(function(){ window.location.reload();},2000);
	});
          */
		  
function pom_footer2() {  		  
    if($.cookie("footer2")==null) { 	
		$('#footer2').css('top',$(window).height()+$(window).scrollTop()-64);
		setTimeout( "$('#footer2').fadeOut(1000);", 5000);
		$.cookie("footer2", "1", { expires: 31 });
	} else 
		$('#footer2').hide();
};		
