function PageInitiator(){
  this.initMainMenu = function(elemId){
    $("#"+elemId+" li").each(
      function(i){
        $(this).css("z-index", (10000-i));
      }
    );
    $("#"+elemId+" li.topmi").hover(      
      function(event){
          if($(this).parent().is("#"+elemId+""))
            $("select").css("visibility","hidden");
          this.className = "topmi_over";
		  if($(this).width()+32 > 130)
		  	$(this).children("ul").css("width", ($(this).width()+32)*1+"px");
          $(this).children("ul").slideDown(200);
					    
          
      },            
      function(event){
          if($(this).parent().is("#"+elemId))          
            $("select").css("visibility","visible");
          this.className = "topmi";
          $(this).children("ul").hide();
          var self = this;
          function tout(){
            if(self.className != "topmi_over")
              $(self).children("ul").hide();
          }
          setTimeout(tout,200);
      }
    );
    $("li.submi").hover(      
      function(event){
          if($(this).parent().is("#"+elemId+""))
            $("select").css("visibility","hidden");
          this.className = "submi_over";
		  if($(this).width()+32 > 130)
		  	$(this).children("ul").css("width", ($(this).width()+32)*1+"px");
		  	$(this).children("ul").css("left", ($(this).width()-2)*1+"px");
		  	$(this).children("ul").css("top", "0px");
          $(this).children("ul").slideDown(200);
      },            
      function(event){
          if($(this).parent().is("#"+elemId))          
            $("select").css("visibility","visible");
          this.className = "submi";
          $(this).children("ul").hide();
          var self = this;
          function tout(){
            if(self.className != "submi_over")
              $(self).children("ul").hide();
          }
          setTimeout(tout,200);
      }
    ); 
  }
}
$(document).ready(  
  function(){
    initiator = new PageInitiator();
    initiator.initMainMenu("main_menu");      
  }
);
