/*	Used in conjunction with getViaJQ.asp file
'		
'		STYLE
'		adding a border to center element in the intranet menus
'		FUNCTIONS
'		(".dropdown").change - Calls a function to automatically populate another dropdown item based on the selection made
'
*/

jQuery(document).ready( function () {
	// STYLE
	jQuery("#leftcolumn").height((jQuery("#rightcolumn").height())+90);
	jQuery('#intranetMenu > ul.select > li:nth-child(2)').css({'border-left':'1px solid #FFF','border-right':'1px solid #FFF'});
	jQuery('#intranetMenuFooter > ul.select > li:nth-child(2)').css({'border-left':'1px solid #FFF','border-right':'1px solid #FFF'});
	
	//FUNCTION
	jQuery("#sel_image").change( function() {
		var imagePath = jQuery("#sel_image > option[value='"+this.value+"']").attr("title");
		jQuery("#photo_preview").attr("src",imagePath).css({'max-width':'250px'});
		return false;
	});

	
	function zIndexWorkaround()
	{//Used to make sure that the dropdown menus on the front page do not submit to the faulty Ie7 z-index stacking bug
		// If the browser is IE,
		if(jQuery.browser.msie)
		{
			/*
			** For each div with class menu (i.e.,
			** the thing we want to be on top),
			*/
			$("#MainMenu ul li a").parents().each(function() {
				var p = $(this);
				var pos = p.css("position");

				// If it's positioned,
				if(pos == "relative" ||
				   pos == "absolute" ||
				   pos == "fixed")
				{
					/*
					** Add the "on-top" class name when the
					** mouse is hovering over it, and remove
					** it when the mouse leaves.
					*/
					p.hover(function() {
							$(this).addClass("on-top");
						},
						function() {
							$(this).removeClass("on-top");
						});
				}
			});
		}
	}

	zIndexWorkaround()
	
	//Display second level menu
	jQuery('#MainMenu ul li').hover(
		function(){
			//jQuery('#MainMenu ul li a').css('color','red');

			jQuery('ul', this).slideDown('fast');
		}
	,
		function(){
			jQuery('ul', this).fadeOut('fast');
			//jQuery('#MainMenu ul li a').css('color','blue');
		}
	);
	
});	

/*// BELOW IS CODE to use, if showing/hiding areas, such as when doing a 'review' page on a registrations
	// Show the Submit button, and get the person to review their registration
	jQuery("#reviewLink").click( function() {
		jQuery("#reviewRegMessage").hide(500);
		jQuery("#reviewText").show(1000);
		jQuery("#sel_crm_sales").focus();
		return false;
	});
*/
