        $(document).ready(function(){
    var menu2_selected = $(".menu_ul_2 .selected");
    var menu1_selected = $(".menu_ul_1 .selected");
    var flag = 1;
    var flag2 = 1;
   // $(".parent").append("&lt;em&gt;&lt;/em&gt;");
      var menu_2_temp; menu_2_temp = '';
      var li_2_temp; li_2_temp = '';
      var menu_3_temp; menu_3_temp = '';
      var li_3_temp; li_3_temp = '';
      var height_temp;     
      var element_1;         
      var flag4 = 0;
      var flag5 = 0;
      
      if (menu1_selected.is('.selected')) {
       flag4 = 1;
      height_temp = menu1_selected.attr("id");
      if (height_temp == 28) {$(".line_2_").css("height",182); }
      else {$(".line_2_").css("height",120); };
      $(".line3_ .line_3_").css("height",17);
      element_1 = menu1_selected;
      if (menu_2_temp !='') menu_2_temp.css("display","none");
      id_val = menu1_selected.attr("id");
      $("."+id_val).css("display","");
      menu_2_temp = $("."+id_val); 
      $(".line1_ .line_1_").animate({ height: menu1_selected.attr("id")},  parseInt(300));     
      } ;
      
      if (menu2_selected.is('.selected')) {
        flag5 = 1;
        var height = 28 + 18*menu2_selected.attr("id");
        $(".line3_ .line_3_").animate({ height: height},  parseInt(300));
      }
      
    $(".menu_ul_1 li").hover(function() {
        flag3 = 1;
        if (flag4 == 1) menu1_selected.removeClass("selected");
        if (flag5 == 1 && flag != 0) {
          menu2_selected.addClass("selected"); 
          var height = 28 + 18*menu2_selected.attr("id");
          $(".line3_ .line_3_").animate({ height: height},  parseInt(100));
        };  
        if (li_3_temp != '') li_3_temp.css("color","");     
        $(".line1_ .line_1_").stop();
        var this_ = $(this);
        $(".line1_ .line_1_").animate({ height: this_.attr("id")},  parseInt(300));
        
        if (li_2_temp != '') {
          li_2_temp.css("color","");
        }   
        li_2_temp = this_;
        this_.css("color","#8FA818");
    }, function() {     
    });

    $(".menu_ul_2 li").hover(function() {
         flag3 = 1;
         if (flag5 == 1 && flag2 != 0) menu2_selected.removeClass("selected");
        //alert(menu2_selected.attr("id"));
        $(".line3_ .line_3_").stop();
        $(".line1_ .line_1_").animate({ height: height_temp},  parseInt(100));
        if (li_2_temp != '') li_2_temp.css("color","");
        li_2_temp = element_1;
        element_1.css("color","#8FA818");
        var this_ = $(this);
        var height = 28 + 18*this_.attr("id");
        $(".line3_ .line_3_").animate({ height: height},  parseInt(300));
        if (li_3_temp !='') li_3_temp.css("color","");
        li_3_temp = $(this).find('span');
        $(this).find('span').css("color","#CE951A");
    }, function() {
        
    });
    
    $(".top2").hover(function() {
        
    }, function() {
       if (element_1 != undefined) {
        $(".line3_ .line_3_").stop();
        $(".line1_ .line_1_").animate({ height: height_temp},  parseInt(100));
        if (li_2_temp != '') li_2_temp.css("color","");
        li_2_temp = element_1;
        element_1.css("color","#8FA818");
       } 
    });
    
    $(".menu_ul_1 li").bind("click", function(){
      flag = 0; flag3 = 1;
      if ($(this).attr("id") == menu1_selected.attr("id")) {
        flag = 1;
        if (flag5 == 1 && flag != 0) {
          menu2_selected.addClass("selected"); 
          var height = 28 + 18*menu2_selected.attr("id");
          $(".line3_ .line_3_").animate({ height: height},  parseInt(100));
        };          
      }  
      else $(".line3_ .line_3_").css("height",17);
      height_temp = $(this).attr("id");
      if (height_temp == 28) {$(".line_2_").css("height",182); }
      else {$(".line_2_").css("height",120); };
      
      element_1 = $(this);
      if (menu_2_temp !='') menu_2_temp.css("display","none");
      id_val = $(this).attr("id");
      $("."+id_val).css("display","");
      menu_2_temp = $("."+id_val);
    });
    
    $(".menu_main").hover(function() {}, function() {
    if (flag3 != 0 && flag4 == 1 && flag5 == 1) {
      menu1_selected.addClass("selected"); 
      menu2_selected.addClass("selected"); 
      if (li_2_temp != '') {
          li_2_temp.css("color","");
        }   
        li_2_temp = menu1_selected;
      if (li_3_temp !='') li_3_temp.css("color","");
        li_3_temp = menu2_selected;
      if (menu2_selected != null) {
        height = 28 + 18*menu2_selected.attr("id");
        $(".line3_ .line_3_").css("height",height);
      };
      if (menu1_selected != null) {
      height_temp = menu1_selected.attr("id");
      if (height_temp == 28) {$(".line_2_").css("height",182); }
      else {$(".line_2_").css("height",120); };
      element_1 = menu1_selected;
      if (menu_2_temp !='') menu_2_temp.css("display","none");
      id_val = menu1_selected.attr("id");
      $("."+id_val).css("display","");
      menu_2_temp = $("."+id_val); 
      $(".line1_ .line_1_").css("height",menu1_selected.attr("id"));
            } ;
      flag3 = 0;        
    }    
    });
});
