$(document).ready(function() {
						   
	function _getUserAgent() {
	
		var browserName;
		
		//test for MSIE x.x;
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
			// capture x.x portion and store as a number
			var ieversion = new Number(RegExp.$1);
			
			if (ieversion>=8) {
				browserName = 'IE8';
			} else if (ieversion>=7) {
				browserName = 'IE7';
			} else if (ieversion>=6) {
				browserName = 'IE6';
			} else if (ieversion>=5) {
				browserName = 'IE5';
			}
		} else {
			browserName = 'ok';
		}
		
		return browserName;
		
	}
	
	browserName = _getUserAgent();

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		Show and hide the tooltips for the Email.
		Block showcase10 with blockUI plugin.
	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	 
	$('#fnav-email .footerLinks').click( 
		function(event) {
			event.preventDefault();
			if (browserName!="IE6") $('#showcase').block();
			$('.tt', '#globalwebsite').hide();
			$('.tt', '#fnav-email').fadeIn(400);
			$('.footerLinks', '#fnav-email').addClass('tooltipVisibleTextHover');
			gaTrackPageview("<?=URLDIR?>/footer/email-sign-up/form");
		}
	);
	
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		Show and hide the tooltips for the Global Website.
	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	 
	$('#globalnav .open-globalwebsite-bubble').click( 
		function(event) {
			event.preventDefault();
			if (browserName!="IE6") $('#showcase').block();
			$('.tt', '#fnav-email').hide();
			$('.tt', '#globalwebsite').fadeIn(400);
		}
	);
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		Handle close window icons
	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	
	$('#fnav-email .closewin').click(function() {
			$('#fnav-email .footerLinks').removeClass('tooltipVisibleTextHover');
			$('#fnav-globalwebsite .footerLinks').removeClass('tooltipVisibleTextGlobeHover');
			$('#showcase').unblock();
			$('.tt').fadeOut('fast');
			return false;
		}
	);
	
	$('#globalwebsite .closewin').click(function() {
			$('#fnav-email .footerLinks').removeClass('tooltipVisibleTextHover');
			$('#showcase').unblock();
			$('.tt').fadeOut('fast');
			return false;
		}
	);	
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		Hide footer bubbles when other content is clicked.
	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	 
	$('#content').click( 
		function() {
			$('#fnav-email .tt').hide();
			$('#fnav-globalwebsite .tt').hide();
			$('#fnav-email .footerLinks').removeClass('tooltipVisibleTextHover');
			$('#fnav-globalwebsite .footerLinks').removeClass('tooltipVisibleTextGlobeHover');
			$('#showcase').unblock();
		}
	);
	 
	$('#showcase').click( 
		function() {
			$('#fnav-email .tt').hide();
			$('#fnav-globalwebsite .tt').hide();
			$('#fnav-email .footerLinks').removeClass('tooltipVisibleTextHover');
			$('#fnav-globalwebsite .footerLinks').removeClass('tooltipVisibleTextGlobeHover');
			$('#showcase').unblock();
		}
	);
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		Submit E-mail Form
	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - */		 
	
	 $('#fnav-email #emailsubmit').hover(
		function() {
			$(this).css("cursor", "pointer");
		},
		function() {
			$(this).css("cursor", "default");				
		}			
	);
	
	$('#fnav-email #emailsubmit').click(		
		function() {
			if( checkEmail('email-signup') ) {
				$('#emaillabel').removeClass('error');
				emailSignup();
				gaTrackPageview("<?=URLDIR?>/footer/email-sign-up/submit");
			}
			else {
				//alert("Please enter a valid email address.");
				$('#emaillabel').addClass('error');
				return;
			}
		}
	);

});