/*	GLOBAL NAV JS
	$Id: GlobalNav.js,v 1.12.4.3 2012/01/27 22:11:45 dgasior Exp $
*/

document.observe('dom:loaded', function() {
	var screenName = $('screenName');
	if(screenName) {
		var screenNameValue = adobe.Cookie.get("SCREENNAME"),
		authenticAdobeId = adobe.Cookie.get('AUID'),
		WCDServerGUID = adobe.Cookie.get('WCDServer'),
		rememberMe = adobe.Cookie.get('RMID');
		
		if(screenNameValue) {
			screenName.innerHTML = screenNameValue;
		}
		
		if ((screenNameValue) && ((authenticAdobeId) || (rememberMe) || (WCDServerGUID) )) {
			$('shWelcome').show();
			$('shSignInBlock').hide();
		}
		else {
			$('shWelcome').hide();
			$('shSignInBlock').show();
		}
	}
});

Event.observe(window, 'load', function() {
	var wp = $('WelcomePanel');
	if (($('SiteFooter') != null) || ($('SiteFooterPDC') != null)) {
		var rp = $('RegionPanel');
	}
		
	Event.observe(document, 'click', function(event) {
		var el = event.element();
		var elid = el.id;
				
		if (elid == "shProducts" || elid == "shSolutions" || elid == "shLearning" || elid == "shHelp" || elid == "shDownloads" || elid == "shStore" || elid == "shCompany") {
			$(elid).addClassName('SiteHeaderBarItemActive');
		}
		else if (elid == "shWelcome" || elid == "screenName") {
			var wpHeight = $('WelcomePanel').getHeight();
			$('WelcomePanelShadow').style.height = (wpHeight + 2) + 'px';
			$('WelcomePanelShadow', 'WelcomePanel').invoke('toggle');
			if ($('SiteFooter') != null) {
				$('RegionPanel').hide();
			}
			Event.stop(event);
		}
		else if ((el == wp) || (el.descendantOf(wp))) {
			if (!el.descendantOf(wp)) {
				Event.stop(event);
			}
		}
		else if (elid == "sfRegion" || elid == "sfRegionChange" || elid == "sfRegionClose" || el == rp || el.descendantOf(rp)) {
		}
		else {
			$('WelcomePanel', 'WelcomePanelShadow').invoke('hide');
			if ($('SiteFooter') != null) {
				$('RegionPanel').hide();
			}
		}
	});
	
	Event.observe('shStore', 'mouseover', function() { 
		$('WelcomePanel', 'WelcomePanelShadow').invoke('hide');
		if ($('SiteFooter') != null) {
			$('RegionPanel').hide();
		}
	});

	Event.observe('shProducts', 'mouseover', function() { 
		$('WelcomePanel', 'WelcomePanelShadow').invoke('hide');
		if ($('SiteFooter') != null) {
			$('RegionPanel').hide();
		}
	});

	Event.observe('shSolutions', 'mouseover', function() { 
		$('WelcomePanel', 'WelcomePanelShadow').invoke('hide');
		if ($('SiteFooter') != null) {
			$('RegionPanel').hide();
		}
	});

	Event.observe('shInfo', 'mouseover', function() { 
		var ipHeight = $('InfoPanel').getHeight();
		$('InfoPanelShadow').style.height = (ipHeight + 2) + 'px';
		$('InfoPanelShadow', 'InfoPanel').invoke('show');
		if ($('SiteFooter') != null) {
			$('RegionPanel').hide();
		}
	});
	Event.observe('shInfo', 'mouseout', function() { 
		$('InfoPanelShadow', 'InfoPanel').invoke('hide');
	});
	
	if ($('shProducts1')) {
		Event.observe('shProducts1', 'mouseover', function() { 
			$('shProducts1').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts1', 'mouseout', function() { 
			$('shProducts1').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts2')) {
		Event.observe('shProducts2', 'mouseover', function() { 
			$('shProducts2').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts2', 'mouseout', function() { 
			$('shProducts2').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts3')) {
		Event.observe('shProducts3', 'mouseover', function() { 
			$('shProducts3').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts3', 'mouseout', function() { 
			$('shProducts3').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts4')) {
		Event.observe('shProducts4', 'mouseover', function() { 
			$('shProducts4').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts4', 'mouseout', function() { 
			$('shProducts4').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts5')) {
		Event.observe('shProducts5', 'mouseover', function() { 
			$('shProducts5').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts5', 'mouseout', function() { 
			$('shProducts5').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts6')) {
		Event.observe('shProducts6', 'mouseover', function() { 
			$('shProducts6').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts6', 'mouseout', function() { 
			$('shProducts6').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shProducts7')) {
		Event.observe('shProducts7', 'mouseover', function() { 
			$('shProducts7').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shProducts7', 'mouseout', function() { 
			$('shProducts7').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions1')) {
		Event.observe('shSolutions1', 'mouseover', function() { 
			$('shSolutions1').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions1', 'mouseout', function() { 
			$('shSolutions1').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions2')) {
		Event.observe('shSolutions2', 'mouseover', function() { 
			$('shSolutions2').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions2', 'mouseout', function() { 
			$('shSolutions2').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions3')) {
		Event.observe('shSolutions3', 'mouseover', function() { 
			$('shSolutions3').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions3', 'mouseout', function() { 
			$('shSolutions3').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions4')) {
		Event.observe('shSolutions4', 'mouseover', function() { 
			$('shSolutions4').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions4', 'mouseout', function() { 
			$('shSolutions4').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions5')) {
		Event.observe('shSolutions5', 'mouseover', function() { 
			$('shSolutions5').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions5', 'mouseout', function() { 
			$('shSolutions5').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSolutions7')) {
		Event.observe('shSolutions7', 'mouseover', function() { 
			$('shSolutions7').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSolutions7', 'mouseout', function() { 
			$('shSolutions7').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shStore1')) {
		Event.observe('shStore1', 'mouseover', function() { 
			$('shStore1').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shStore1', 'mouseout', function() { 
			$('shStore1').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shStore2')) {
		Event.observe('shStore2', 'mouseover', function() { 
			$('shStore2').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shStore2', 'mouseout', function() { 
			$('shStore2').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shStore3')) {
		Event.observe('shStore3', 'mouseover', function() { 
			$('shStore3').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shStore3', 'mouseout', function() { 
			$('shStore3').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shStore4')) {
		Event.observe('shStore4', 'mouseover', function() { 
			$('shStore4').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shStore4', 'mouseout', function() { 
			$('shStore4').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shStore5')) {
		Event.observe('shStore5', 'mouseover', function() { 
			$('shStore5').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shStore5', 'mouseout', function() { 
			$('shStore5').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shMyAccount')) {
		Event.observe('shMyAccount', 'mouseover', function() { 
			$('shMyAccount').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shMyAccount', 'mouseout', function() { 
			$('shMyAccount').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shMyOrders2')) {
		Event.observe('shMyOrders2', 'mouseover', function() { 
			$('shMyOrders2').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shMyOrders2', 'mouseout', function() { 
			$('shMyOrders2').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shMyInformation')) {
		Event.observe('shMyInformation', 'mouseover', function() { 
			$('shMyInformation').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shMyInformation', 'mouseout', function() { 
			$('shMyInformation').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shMyPreferences')) {
		Event.observe('shMyPreferences', 'mouseover', function() { 
			$('shMyPreferences').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shMyPreferences', 'mouseout', function() { 
			$('shMyPreferences').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
	
	if ($('shSignOut')) {
		Event.observe('shSignOut', 'mouseover', function() { 
			$('shSignOut').addClassName('SiteHeaderPanelLinkHover');
		});
		Event.observe('shSignOut', 'mouseout', function() { 
			$('shSignOut').removeClassName('SiteHeaderPanelLinkHover');
		});
	}
});

if (!window.XMLHttpRequest) {
	Event.observe(window, 'load', function() {
		if ($$('div.SiteHeaderDropdownLink')) {
			$$('div.SiteHeaderDropdownLink').each( function(e) {
				Event.observe(e, 'mouseenter', function() {
					Element.addClassName(e, 'hover');
					$$('select').each( function(st) {
						st.setStyle({visibility: 'hidden'});
					});
				});
				Event.observe(e, 'mouseleave', function() {
					Element.removeClassName(e, 'hover');
					$$('select').each( function(st) {
						st.setStyle({visibility: 'visible'});
					});
				});
			});
		}
	});
}
