var clrSel="#2D5284";
var clrUnSel="#1c3453";

function init()
{
  	$(".mnuBarItmLnk").hover(menuBarIn,menuBarOut);	
  	$(".mnuLayer").mouseleave( function() {hideMenuById(this.id)} ).mouseenter( function() {resetTimer(this.id)} );;
  	$(".mnuLayer tr").mouseenter( optOver ).mouseleave( optOut ).click(function() {hideMenu($(this).closest(".mnuLayer"))});	
}

function resetTimer( id )
{
	var $id="#"+id;

	clearTimeout($($id).data("timer"));
}
function showMenu( element )
{
	var id = $(element).attr("id")+"Layer";
	var $id ="#"+id;
	var position = $(element).parent().position();

    resetTimer( id );
	$($id).css("top",position.top + $(element).height() + 9).css("left",position.left).fadeIn(400);
}

function hideMenuById( id )
{
	var $id="#"+id;
	$($id).data( "timer" , setTimeout( function(){ $($id).fadeOut(400); },300) );	
}

function hideMenu( element )
{
	var id = $(element).attr("id")+"Layer";
	
	hideMenuById( id );
}


function menuBarIn( event )
{
	var $target = $(event.target);
	$target.parent().addClass("mnuBarItmSel");
	showMenu( $target );
}

function menuBarOut( event )
{
	var $target = $(event.target);
	$target.parent().removeClass("mnuBarItmSel");
	
	hideMenu( $target );
}

function optOver() {$(this).css("background-color",clrSel).find("a").toggleClass("option");	}
function optOut() { $(this).css("background-color",clrUnSel).find("a").toggleClass("option");}
