
//init

function init_menu(){
    i=1;
    var timer = null;
     while($('#top_menu' + i,document.body).length){
         if($('#submenu' + i,document.body).length)
         {    
            $('#top_menu' + i).mouseover(
                    function(){
                        n = extractId($(this));
                        $('#submenu' + n).show();
                    }
            );
            $('#top_menu' + i).mouseout(
                    function(){
                        n = extractId($(this)); 
                        timer = setTimeout("delay('#submenu"+n+"')",100);
                    }
            );
             
             $('#submenu' + i).hover(
                    function(){
                        if (timer) clearTimeout(timer);
                        $(this).show();

                    },
                    function(){
                        $(this).hide(); 
                    }
             );
         }
         
         $('#top_menu' + i).click(function(){
                  n = extractId($(this));
                  window.location.href = $('#link'+n).attr('href');
             });
             
         i++;
     }
}


function delay(el)
{
      $(el).hide();
}

function extractId(jQ_obj)
{
    attr_id = jQ_obj.attr('id');
    id = attr_id.charAt(attr_id.length-1);  
    return id;
}