$(document).ready(function(){
// main page menu
  var oldid = "";
  var getcurentid  = "";
  var CarouselItemPatch = $("div.menu > div.navmenu > ul#mainblockmenu > li");
  var CarouselMenuPatch = "";
  var imgsrc = "";
  var getall_menuitem  = $("ul#mainblockmenu").find("li");
  var selectiditem = 0;
  var _delay = 800;
  var blockwidth = $("div.navmenu").width();
  var itemwidth = $(getall_menuitem[0]).width();
  
  
  for (selectiditem; selectiditem < getall_menuitem.size(); selectiditem++){
    $(getall_menuitem[selectiditem])
      .delay(_delay)
      .css({"display": "block"})
      .animate({ marginLeft: "0px"}, 500);
    _delay += 350;

    if(selectiditem == getall_menuitem.size()-1){
        mouse_in(CarouselItemPatch.eq(0).attr("id"));
    }
  }

  
  CarouselItemPatch.hover(function(){

   if(getcurentid == ""){
         getcurentid =  CarouselItemPatch.eq(0).attr("id");
         maouse_out(imgsrc);
   }

    getcurentid = $(this).attr("id");

    mouse_in(getcurentid);

  }, function(){
    maouse_out(imgsrc);  
  });

  function maouse_out(imgsrc){
    imgsrc = imgsrc.replace(/color/,"black");
    CarouselItemPatch+$("#"+getcurentid+" > a > img").attr("src", ""+imgsrc);
  }

  function mouse_in(getcurentid){
    imgsrc = $("div.menu > div.navmenu > ul#mainblockmenu > li#"+getcurentid+" > a > img").attr("src");
    imgsrc = imgsrc.replace(/black/,"color");
    CarouselItemPatch+$("#"+getcurentid+" > a > img").attr("src", ""+imgsrc);

    CarouselMenuPatch = $("div.menu > div.menu_about > ul#viewmenunodetop > li#m"+getcurentid);

    if (oldid != getcurentid) {
      $("div.menu > div.menu_about > ul#viewmenunodetop > li#m"+oldid)
        .css({"display": "none", "margin-left": "300px"});
    }
    CarouselMenuPatch.stop()
      .css({"display": "none", "margin-left": "300px"})
      .delay(50)
      .css({"display": "block", "height": "100%"})
      .animate({marginLeft: "0px"}, 500);
    oldid = getcurentid;
  }

    

// all page dropdawnmenu
   /* $("ul.subnav").parent().find("a").wrap("<span></span>"); 

    $("ul.topnav li span").hover(function(){
      view_menu_node(this);
      if ($(this).parent().find("ul")){
        view_menu_node(this);
      }
      $(this).addClass("subhover");
    }, function(){	
			 $(this).removeClass("subhover");
	 }); */
  
});

  /* function view_menu_node(th){
     var curentid = $(th).parent().find("ul").attr("id");
     $(th).parent().find("ul#"+curentid).slideDown('fast').show(); 

		 $(th).parent().hover(function() {
		 }, function(){
			 $(this).parent().find("ul.subnav").slideUp('fast');
		 });
    
    } */
   
   
   

   
