var opaqueMenu = function(options){

	var menuClassName = 'leftNavMenu', // class of Parent UL tag
		colWidth = 132, // Width of each menu column in pixels
		colHeight = 465, // Height of each menu column in pixels (ignored in horizontal mode)
		colSpacing = 4, // spacing between columns in pixels
		colOpactiy = 0.5, // Column Background opacity (Master)
		colBgColor = '#FFF', // Background color for Columns (default is white - vaild Hex or css color (Master) )
		parentBgOpacity = '', // optional parent Background opacity
		parentBgColor = '', // optional parent Background color
		subBgOpacity = '', // optional submenu Background opacity
		subBgColor = '', // optional submenu Background color
		hoverBgColor = '', // anchor link Background color
		hoverColor = '',  // anchor link Font color
		yPadLinks = 2, // top/bottom padding of Menu A Links
		xPadLinks = 2, // left/right padding of Menu A Links
		yPadList = 3, // top/bottom padding of Menu LI elements
		xPadList = 3, // left/right padding of Menu LI elements
		showFirstColBg = true, // show opaque background on parent column/row
		orientation = 1, // 0 Vertical, 1 Horizontal
		zIndex = 1, // option to increase base zIndex of menu and backgrounds if menu exists on a zIndex layer
		delay = 50, // delay to hide submenus on mouseout (best left as is)
		numCols = 0, // used internally to draw columns based on number of submenus detected (do not change) 
		options = options || {};
	
	// setup options
	for(var x in options) eval(x +'= options[x]');
	// fix Safari Rendering bug
	$j('ul.'+menuClassName).css({visibility:'hidden'});
	
	// Show Submenu function
	var showSubmenu = function(){
		var child = this.childSubmenu || false;
		var i = child.navMenuColIndex || false;
		var col = (orientation == 1)? $j(this).prev('div.hCol')[0] : $j('#opaqueCol'+i)[0];
		if(child){
			clearTimeout(child.hideTimeout);
			$j(child).css({visibility:'visible'});
		}
		if(col){
			clearTimeout(col.Timeout);
			 $j(col).css({visibility:'visible'});
		}
	}
	// Hide Submenu function
	var hideSubmenu = function(){
		var child = this.childSubmenu || false;
		var i = child.navMenuColIndex || false;
		var col = (orientation == 1)? $j(this).prev('div.hCol')[0] : $j('#opaqueCol'+i)[0];
		if(child){
			child.hideTimeout = setTimeout(function(){ $j(child).css({visibility:'hidden'}); }, delay);
			if(col) col.Timeout = setTimeout(function(){ $j(col).css({visibility:'hidden'});  }, delay*2);
		}
	}
	// create Vertical opaque columns
	var verticalColumns = function(){
		/** Setup Opaque background divs container */
		$j('<div id="opaqueCols"/>').css({position:'absolute', height:colHeight+'px', width: (numCols+1)*(colWidth+colSpacing)+'px'}).insertBefore($j('ul.'+menuClassName).css({visibility:'visible', zIndex:zIndex+10}));
		/** Setup Opaque background div columns */
		var bg = subBgColor? subBgColor : colBgColor;
		var op = subBgOpacity? subBgOpacity : colOpactiy;
		var colCss = { width: colWidth+'px', height: colHeight+'px', zIndex: zIndex, backgroundColor: bg, float:'left', opacity: op, visibility: 'hidden', marginRight: colSpacing+'px', padding:'0' };
		// Show or Hide first column background
		showFirstColBg = (showFirstColBg==true)? 'visible' : 'hidden';
		bg = parentBgColor? parentBgColor : colBgColor;
		op = parentBgOpacity? parentBgOpacity : colOpactiy;
		$j('<div id="opaqueCol0"/>').css(colCss).css({visibility: showFirstColBg, backgroundColor: bg, opacity: op}).appendTo($j('#opaqueCols'));
		// Add in column backgrounds for each column 
		for(var i=1; i<=numCols; i++){ $j('<div id="opaqueCol'+i+'"/>').css(colCss).appendTo($j('#opaqueCols')); }
	}
	// create Horizontal opaque columns
	var horizontalColumns = function(hWidth, hHeight){
		showFirstColBg = (showFirstColBg==true)? 'visible' : 'hidden';
		var bg = parentBgColor? parentBgColor : colBgColor;
		var op = parentBgOpacity? parentBgOpacity : colOpactiy;
		$j('<div id="opaqueCols"/>').css({display: 'block', visibility: showFirstColBg, position:'absolute', height: hHeight+'px', width: hWidth+'px', backgroundColor: bg, opacity: op}).insertBefore($j('ul.'+menuClassName).css({visibility:'visible', zIndex:zIndex+10}));
		$j('div.hCol').each(function(i){
			var li = $j(this).next('li');
			var ul = $j('ul', li)[0];
			var p = $j(li).position();
			var w = $j(ul).outerWidth();
			var h = $j(ul).outerHeight();
			if(ul.navMenuColIndex == 1){
				p.top = 16 + ((yPadList + yPadLinks)*2);
			}else{
				p.left += w;
				w -= colSpacing;
			}
			bg = subBgColor? subBgColor : colBgColor;
			op = subBgOpacity? subBgOpacity : colOpactiy;
			$j(this).css({backgroundColor:bg, opacity: op, width:w+'px', height:h+'px', left:p.left+'px', top:p.top+'px'});		
		});
	}
	
	/**
	 * Setup Css for menu UL and LI elements
	 */
	$j('ul.'+menuClassName+', .'+menuClassName+' li').css({
		margin: 0, padding: 0, listStyle: 'none outside none', position: 'relative'
	});
	// Set css for all LI elements
	$j('.'+menuClassName+' li').css({
		width: colWidth+'px', lineHeight:'16px', padding: yPadList+'px 0', position:'relative', zIndex:zIndex+10
	});
	// Set LI Anchors CSS
	$j('.'+menuClassName+' li a').css({
		display:'block', width: (colWidth-(xPadList*2)-(xPadLinks*2))+'px', padding: yPadLinks+'px '+xPadLinks+'px', margin:'0 '+xPadList+'px', lineHeight:'16px', position:'relative'
	});
	// Set css for all UL subMenu Elements contained in an LI
	$j('.'+menuClassName+' li ul').css({
		position:'absolute', top:'0', left:'0', margin:'0 0 0 '+colWidth+'px', padding: '0 0 0 '+colSpacing+'px', zIndex:zIndex+10
	})	
	// Set events and vars for all UL subMenu Elements
	.each(function(i){
		var childUL = this;
		var parentLI = $j(this).parent('li')[0];
		var index = $j(this).parents('ul').length;
		parentLI.childSubmenu = childUL;
		childUL.navMenuColIndex = index;
		numCols = (index > numCols)? index : numCols;
		$j(parentLI).mouseover(showSubmenu).mouseout(hideSubmenu);
		$j(parentLI).children('a').addClass('subMenu');
		$j(this).css({visibility:'hidden'});
		if(orientation == 1){			
			$j('<div class="hCol"/>').css({position:'absolute', zIndex:zIndex, visibility:'hidden'}).insertBefore($j(parentLI));
		}
	});
	/**
	 * Setup Column displays
	 */
	if(orientation == 1){
		var hWidth = 0, hHeight = 0;
		$j('.'+menuClassName+'>li').each(function(i){
			$j(this).css({float:'left', margin:'0 '+colSpacing+'px 0 0'});
			hWidth += $j(this).outerWidth()+colSpacing;
			hHeight = $j(this).outerHeight() > hHeight? $j(this).outerHeight() : hHeight;
			$j($j('ul', this)[0]).css({top: hHeight+'px',margin:0, padding:0});
		});
		$j('ul.'+menuClassName).css({width:hWidth+'px', height:hHeight+'px', overflow:'visible'})
		horizontalColumns(hWidth, hHeight);
	}else{
		verticalColumns();
	}
	/**
	 * Add Anchor link hover styles
	 */
	$j('.'+menuClassName+' li a').each(function(){
		var bg = this.style.backgroundColor;
		var c = this.style.color;   
		$j(this).bind('mouseover',function(){
			if(hoverBgColor) $j(this).css({backgroundColor:hoverBgColor});
			if(hoverColor) $j(this).css({color:hoverColor});
		}).bind('mouseout',function(){
			$j(this).css({backgroundColor:bg, color:c});
		});
	});
	/**
	 * Remove bound events on unload
	 */
	$j(window).bind('unload',function(){$j('li, a').unbind();});
	
}