/*-------------------------------------------------------------------
Name: SiteHeader (Global Nav) JS
$Author: dgasior $
$DateTime: 2011/07/18 16:36:56 $
$Revision: #24 $
 -------------------------------------------------------------------*/

/**
 * Initialize Global Nav behaviors
 * @returns nothing
 * @author David Gasior
 */
(function($) { 
	adobe.fn.initGlobalNav = function() {
		var screenName = $('#screenName');
		if (screenName) {
			if ($.cookies) {
				var screenNameValue = $.cookies.get('SCREENNAME'),
					authenticAdobeId = $.cookies.get('AUID'),
					rememberMe = $.cookies.get('RMID');
			}
			if (screenNameValue) {
				$('#screenName').text(screenNameValue);
			}
	
			if ((screenNameValue) && ((authenticAdobeId) || (rememberMe))) {
				$('#shWelcome').show();
				$('#shSignInBlock').hide();
			}
			else {
				$('#shWelcome').hide();
				$('#shSignInBlock').show();
			}
		}
	
		if (isDesktop()) {
			$('#search-input').autofill();
	
			$('#globalnav-search').bind('submit', function() {
				var searchText = $('#search-input').val();
				if (searchText == "" || searchText == null) {
					return false;
				}
			});
	
			$('#WelcomePanel').bind("clickoutside", function() {
				$('#WelcomePanel').hide();
				$('#WelcomePanelShadow').hide();
			});
	
			$('#shWelcome').bind("click", function() {
				var wpHeight = $('#WelcomePanel').height();
				$('#WelcomePanelShadow').height(wpHeight + 14);
				$('#WelcomePanelShadow').toggle();
				$('#WelcomePanel').toggle();
				if ($('#SiteFooter') != null) {
					$('#RegionPanel').hide();
				}
				return false;
			});
	
			$('#shWelcomeHover').bind({
				mouseenter: function() {
					var ipHeight = $('#WelcomePanelHover').height();
					$('#WelcomePanelShadowHover').height(ipHeight + 14);
					$('#WelcomePanelShadowHover').show();
					$('#WelcomePanelHover').show();
					if ($('#SiteFooter') != null) {
						$('#RegionPanel').hide();
					}
				},
				mouseleave: function() {
					$('#WelcomePanelShadowHover').hide();
					$('#WelcomePanelHover').hide();
				}
			});        
			
			$('#shStore, #shStoreLink').bind("click", function() {
				$('#shStore').addClass('SiteHeaderBarItemActive');
			});
	
			$('#shInfo').bind({
				mouseenter: function() {
					var ipHeight = $('#InfoPanel').height();
					$('#InfoPanelShadow').height(ipHeight + 14);
					$('#InfoPanelShadow').show();
					$('#InfoPanel').show();
					$('#StorePanel').hide();
					if ($('#SiteFooter') != null) {
						$('#RegionPanel').hide();
					}
				},
				mouseleave: function() {
					$('#InfoPanelShadow').hide();
					$('#InfoPanel').hide();
				}
			});
	
			$('#shProducts').bind("mouseenter focusin", function() {
				$('#shProducts').addClass('SiteHeaderBarItemHover');
				$('#ProductsPanel').show();
				$('#StorePanel').hide();
				$('#WelcomePanel').hide();
				$('#WelcomePanelShadow').hide();
				if ($('#SiteFooter') != null) {
					$('#RegionPanel').hide();
				}
			});
			
			$('#shProducts').bind("mouseleave focusout", function() {
				$('#shProducts').removeClass('SiteHeaderBarItemHover');
				$('#ProductsPanel').hide();
			});
			
			$('#shStore').bind("mouseenter focusin", function() {
				$('#shStore').addClass('SiteHeaderBarItemHover');
				$('#StorePanel').show();
				$('#WelcomePanel').hide();
				$('#WelcomePanelShadow').hide();
				if ($('#SiteFooter') != null) {
					$('#RegionPanel').hide();
				}
			});
	
			$('#shStore').bind("mouseleave focusout", function() {
				$('#shStore').removeClass('SiteHeaderBarItemHover');
				$('#StorePanel').hide();
			});
			
			$('#shProducts1').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts1').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts2').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts2').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts3').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts3').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts4').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts4').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts5').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts5').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts6').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts6').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shProducts7').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shProducts7').toggleClass('SiteHeaderPanelLinkHover');
			});
				
			$('#shStore1').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shStore1').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shStore2').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shStore2').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shStore3').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shStore3').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shStore4').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shStore4').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shMyAccount').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shMyAccount').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shMyOrders2').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shMyOrders2').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shMyInformation').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shMyInformation').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shMyPreferences').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shMyPreferences').toggleClass('SiteHeaderPanelLinkHover');
			});
	
			$('#shSignOut').bind("mouseenter mouseleave focusin focusout", function() {
				$('#shSignOut').toggleClass('SiteHeaderPanelLinkHover');
			});
		}
	
		$('#shSolutions').bind("mouseenter mouseleave focusin focusout", function() {
			$('#shSolutions').toggleClass('SiteHeaderBarItemHover');
		});
	
		$('#shLearning').bind("mouseenter mouseleave focusin focusout", function() {
			$('#shLearning').toggleClass('SiteHeaderBarItemHover');
		});
	
		$('#shHelp').bind("mouseenter mouseleave focusin focusout", function() {
			$('#shHelp').toggleClass('SiteHeaderBarItemHover');
		});
	
		$('#shDownloads').bind("mouseenter mouseleave focusin focusout", function() {
			$('#shDownloads').toggleClass('SiteHeaderBarItemHover');
		});
	
		$('#shCompany').bind("mouseenter mouseleave focusin focusout", function() {
			$('#shCompany').toggleClass('SiteHeaderBarItemHover');
		});
	
		$('#shProducts').bind("click", function() {
			$('#shProducts').addClass('SiteHeaderBarItemActive');
		});
	
		$('#shSolutions').bind("click", function() {
			$('#shSolutions').addClass('SiteHeaderBarItemActive');
		});
	
		$('#shLearning').bind("click", function() {
			$('#shLearning').addClass('SiteHeaderBarItemActive');
		});
	
		$('#shHelp').bind("click", function() {
			$('#shHelp').addClass('SiteHeaderBarItemActive');
		});
	
		$('#shDownloads').bind("click", function() {
			$('#shDownloads').addClass('SiteHeaderBarItemActive');
		});
	
		$('#shCompany').bind("click", function() {
			$('#shCompany').addClass('SiteHeaderBarItemActive');
		});
	};
})(jQuery);  
