function nav_highlight(tag) {
	var myItem = $('#menu-'+tag);

	if (myItem.parents('ul').attr('id') == 'nav') {
		var paItem = myItem;
		var chItem = myItem.children('ul');
	}
	else {
		var paItem = myItem.parents('ul').parents('li');
		var chItem = myItem.parent();
		myItem.toggleClass('current_child_tab');
		myItem.children('a').attr('id','current_child_tab_link');
	}
	
	// highlight drop-down main menu item
	paItem.toggleClass('current_main_tab');
	paItem.children('a').attr('id','current_main_tab_link');

	/**
	* get rid of vertical line on main tab
	*/
	paItem.next('li').css('background-image','none');
	
	/**
	 * set left edge of child menus
	 */
		
	// first get the left position of parent item, both margin-left for use with child, 
	// and offset left for comparison to subnav (to prevent overflow to the left or right... see below)
	if (paItem.offset()) {
		var lefP = paItem.offset().left;
	}
	else lef = 0;
	
	if (typeof(chItem.css('margin-left')) == "undefined") return false;
	var lef = chItem.css('margin-left').replace(/[^\d]+/g, '');
	lef = lef*-1;

	// if the left position of the parent item is at the left edge of the subnav element,
	// then we'll just left the left position of the child to the left edge of parent.
			
	// Then get the width of parent item and divide by 2 to find center of parent
	var widP = paItem.width();
	var cenP = widP/2;
			
	// find the width of child and divide by 2 to find center of child
	var widC = chItem.width();
	var cenC = widC/2;
	
	// then subtract half of child elements total length from parent left position.
	var finlef = lef - cenC + cenP;
		
	// determine real position of child element.
	var lefC = lefP - cenC + cenP;
	
	// determine left position of parent nav UL
	var lefmos = paItem.parents('ul').offset().left;
	var widmos = paItem.parents('ul').width();
		
	// if lefC is less than 100, then set it to 200
	if (lefC < lefmos) {
		finlef += (lefmos - lefC);
	}
	// if it is more than 950, then put the right margin at the right end of the subnav
	else if (lefC > lefmos + widmos - widC - 50) {
		finlef = lef - widC - 45;
	}
	/**-/
	console.log('lefmos = %d',lefmos);
	console.log('widmos = %d',widmos);
	console.log('lefP = %d',lefP);
	console.log('lefC = %d',lefC);
	console.log('lef = %d',lef);
	console.log('finlef = %d',finlef);
	/**/
	
	// finally, set the left position of the first child.
	chItem.css('margin-left',finlef);
		
	// make drop down visible
	chItem.css('visibility','visible');
		
	// build bread crumbs
	var crumbs = new Array(myItem.children('a').text());
	myItem.parents('li').each(function(){
		var txt = $(this).children('a').text();
		var lnk = $(this).children('a').attr('href');
		crumbs.unshift('<a href="'+lnk+'">'+txt+'</a>');
	});
	
	crumb_str = crumbs.join(' ');
	$('#breadcrumbsholder').html('<a href="/">Home</a> '+crumb_str);
//	console.log(crumb_str);
}

jQuery(document).ready(
//$(
function(){
	nav_highlight(menu_item);
	
/*	 var load_page = function()
     {
       $("#vidPlayer1").dmxHTML5VideoPlayer(
         {width:325, height:183, playlist:[{0:{src:"/video/18minInstall_3.mp4", type:"video/mp4"}, config:{title:"125"}}]}
       );
     }

	load_page();
*/
});

