$(document).ready(function(){
    $("#nav .submenu").mouseover(function() {
        showmenu(this.parentNode.id);
//        menusaway();
    });
    $("#nav li ul").mouseover(function() {
        menu_on = 1;
    });
    $("#nav li ul").mouseout(function() {
        menu_on = 0;
    });
    $(".rolloff").mouseover(function() {
        $("#nav li ul").css('display','none');
    });
});

$(window).resize(setedge);

function get_window_size() {
  var window_width = 0;
  if( typeof(window.innerWidth) == 'number' ) {//Non-IE
    window_width = window.innerWidth;
  } else if(document.documentElement && (document.documentElement.clientWidth)) {//IE 6+ in 'standards compliant mode'
    window_width = document.documentElement.clientWidth;
  } else if(document.body && (document.body.clientWidth)) {//IE 4 compatible
    window_width = document.body.clientWidth;
  }
return window_width;
}

function setedge() {
    window_width = get_window_size();
    var leftedge = (parseInt(window_width) - 862)/2;
    $("#nav li ul").css('margin-left',leftedge+'px');
}

function showmenu(which) {
    setedge();
    $("#nav li ul").css('display','none');
    $("#"+which+" ul").css('display','block');
}

function goThere(form){
    var URL = document.form.highdemand.options[document.form.highdemand.selectedIndex].value;
    window.location.href = URL;
}

