$(document).ready(function() {
						   
	/* $('ul.sf-menu').superfish({ 
		delay:       50,								// delay on mouseout, in ms
		animation:   {opacity:'show',height:'show'},	// fade-in and slide-down animation 
		speed:       75,								// animation speed in ms -- lower number is faster
		autoArrows:  false,								// disable generation of arrow mark-up 
		dropShadows: false								// disable drop shadows 
	}); */
	
	var orig_color;
	
	$('#nav > li > ul').hover(
		function() {
			orig_color = $(this).parent().css('background-color');
			$(this).parent().css('background-color', '#fff');
		},
		function() {
			$(this).parent().css('background-color', orig_color);
		}
	);

	// construct subnav from section of main nav (based on the class of #content)
	var section = $('#content')[0].className;
	var query = '#' + section + '_nav > ul > li';
	$(query).clone().prependTo($('#sidenav > ul'));
	$('#sidenav *').removeAttr('style');
	
	// special cases for "What We Do" section -- hide sub-items that are not in this subsection
	var the_page = window.location.pathname.split('/').pop();
	var page_id = window.location.search.split('=').pop();
	if ( the_page == 'PIC.aspx' || (the_page == 'Page.aspx' && page_id == '10') ) {
		$('#sidenav > ul > li:eq(1) ul').hide();
		$('#sidenav > ul > li:eq(2) ul').hide();
	}
	if ( the_page == 'ProcessAutomation.aspx' || (the_page == 'Page.aspx' && page_id == '3') ) {
		$('#sidenav > ul > li:eq(0) ul').hide();
		$('#sidenav > ul > li:eq(2) ul').hide();
	}
	if ( the_page == 'StaffingServices.aspx' || (the_page == 'Page.aspx' && page_id == '4') ) {
		$('#sidenav > ul > li:eq(0) ul').hide();
		$('#sidenav > ul > li:eq(1) ul').hide();
	}
	$('#sidenav > ul > li div.dropdown').hide();
	
//misc doc ready
$('p#lang_button').toggle(
		function() {
			$('div#lang_popup').fadeIn();
		},
		function() {
			$('div#lang_popup').fadeOut();
		}
	);

if ((document.location.pathname.indexOf('PIC.aspx') != -1) && (document.location.search.indexOf('id=0') != -1)) {
	$('#reveal_link').colorbox({width:'600px', height:'500px', opacity:0.5, inline:true, scrolling:false, href:'#reveal'});
}

//two lined main nav detection
  for(n=0; n<=100; n++) {
		if ($("ul#nav > li li a:eq("+n+")").height() > 35) {
			$("ul#nav > li li a:eq("+n+")").css("line-height", "14px");
			$("ul#nav > li li a:eq("+n+")").css("padding-bottom", "2px");
			$("ul#nav > li li a:eq("+n+")").css("padding-top", "3px");
		}
	}
//alert("height is " + $("ul#nav > li li a:eq(4)").height());

/* Media Library hover states */
$('.media_lib_links a').hover(
	function() {
		$(this).find('span').addClass('over');
	},
	function() {
		$(this).find('span').removeClass('over');
	}
);


/* FANCYBOX */
/* ----------------------------------------- */
/*
	$(".expand").fancybox({
		'overlayOpacity': 0.9,
		'overlayColor'		: '#848484',
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'padding'			: 0
	});
*/
});
