var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open() {
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = $(this).find('div.level1').show();
}

function jsddm_close() {
    if(ddmenuitem)
        ddmenuitem.hide();
}

function jsddm_timer() {
    closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {
    if(closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

$(document).ready(function() {
    $('div#main-menu .level0 > li').bind('mouseover', jsddm_open)
    $('div#main-menu .level0 > li').bind('mouseout',  jsddm_timer)

//    $('body#index').css('background:transparent url(/img/bg_index.jpg) no-repeat scroll center 0');
///img/loading.gif') center center no-repeat;

});

document.onclick = jsddm_close;


/* $(document).ready(function(){
   check_width();
   $(window).resize(function(){
      check_width();
      });
   function check_width(){
     var width=0;
     if(window.innerWidth){
        width=window.innerWidth;
        }else{
          width=document.documentElement.clientWidth;
          }
     if(width<1021){
       $("body").css('background','url(/voffkas/img/bg.jpg) -335px 58px no-repeat');
       $(".navigation").css('width',1000);
        // left: 208px;
       }else{
         $("body").css('background','url(/voffkas/img/bg.jpg) center 58px no-repeat');
         $(".navigation").css('width','100%');
         }
     }
 });*/


