function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
    {
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
          {  break; }
          obj = obj.offsetParent;
        }
    }
    else if(obj.x)
    { curleft += obj.x; }
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
           { break; }
          obj = obj.offsetParent;
        }
    }
    else if(obj.y)
    {   curtop += obj.y; }
    return curtop;
  }
  




function hideAllMenus()
{
	$('.top_nav li ul').css('display','none');
}



$(document).ready(function() {

$('ul.top_nav li').bind('mouseover',function() {
  
     
     var mainMenu = $('ul.top_nav');
     var theLeft = findPosX(mainMenu);
     var theTop = findPosY(mainMenu);

		var count = $(this).children('ul').length;
		if(count > 0)
		{
     $(this).children('ul').css('display','block');  
     $(this).children('ul').css('left',theLeft + "px");
     $(this).children('ul').css('top',(theTop+30) +"px");	
    }
});


$('ul.top_nav li').bind('mouseout',function() {

 $(this).children('ul').css('display','none');  
   
});


   
});






