$(document).ready(function(){

   //--- Link non link tags such as tr,td,div
   $('* [href!=""]').each(function() {
      var href = $(this).attr('href');
      if(href) {
         if($(this)[0].tagName == 'LINK') return;
         if($(this)[0].tagName == 'A') return;
         $(this).click(function() { document.location = href; });
      }
   });

   positionFooter();
   $(window).scroll(positionFooter).resize(positionFooter);

   $('a').each(function() {
       var rel = $(this).attr('rel');
       if('lightbox' == rel) {
          $(this).lightBox();
       }
   });

});

function positionFooter(){
   var t = parseInt($(window).scrollTop())+parseInt($(window).height())-parseInt($("#footer").height()) - 10;
   //parseInt($("#footer").height());
   //alert(t);
   $("#footer").css({position: "absolute",top:(t+"px")});
}

var nav1timeout    = 500;
var nav1closetimer = 0;
var nav1menuitem = 0;


function nav1_close() {
   if(nav1menuitem) nav1menuitem.css('visibility', 'hidden');
}


function nav1_canceltimer() {
   if(nav1closetimer) {
      window.clearTimeout(nav1closetimer);
      nav1closetimer = null;
   }
}

$(document).ready(function() {
   $('#nav1 > ul > li').mouseover(function() {
      nav1_canceltimer();
      nav1_close();
      nav1menuitem = $(this).find('ul').css('visibility', 'visible');
   });
   $('#nav1 > ul > li').mouseout(function() {
      nav1closetimer = window.setTimeout(nav1_close, nav1timeout);
   });
});

document.onclick = nav1_close;

function m_alert(title,body,opts) {
   var ele = document.createElement('div');
   ele.title = title;
   ele.innerHTML = body;
   $(ele).dialog(opts);
}

