/*
// Drop down controls
*/

var navControl = {
	init: function() {
	
		// This is to keep the main section headers highlighted as you hover over the sub items below
		$$('.listitem').each(function(el) {
				Event.observe(el, 'mouseover', navControl.makeActive.bindAsEventListener(el), true);
				Event.observe(el, 'mouseout', navControl.makeNormal.bindAsEventListener(el), true);
			});	
		// This is for all of the topnav drop down effects
		if ($('cart') != undefined) {
			new Event.observe('cart', 'mouseover', navControl.showCart);
			new Event.observe('cart', 'mouseout', navControl.hideCart);
		}
		if ($('account') != undefined) {
			new Event.observe('account', 'mouseover', navControl.showAccount);
			new Event.observe('account', 'mouseout', navControl.hideAccount);
		}
		if ($('location') != undefined) {
			new Event.observe('location', 'mouseover', navControl.showLocation);
			new Event.observe('location', 'mouseout', navControl.hideLocation);
		}
		if ($('saveshare') != undefined) {
		    new Event.observe('saveshare', 'mouseover', navControl.showSaveshare);
		    new Event.observe('saveshare', 'mouseout', navControl.hideSaveshare);
		}
		
		var print = $('printpage');
		if( print ) {
			print.onclick = navControl.print.bindAsEventListener( this );
		}
	}, 
	makeActive: function() {
		var anchorTag = this.down('a');
		anchorTag.addClassName('activetoggle');
	}, 
	makeNormal: function() {
		var anchorTag = this.down('a');
		anchorTag.removeClassName('activetoggle');
	},
	showCart: function() {
		$('cartmenu').setStyle({display: 'block'});	
	}, 
	hideCart: function() {
		$('cartmenu').setStyle({display: 'none'});
	}, 
	showAccount: function() {
		if ($('accountmenu') != undefined) {
			$('accountmenu').setStyle({display: 'block'});
		}
	}, 
	hideAccount: function() {
		if ($('accountmenu') != undefined) {
			$('accountmenu').setStyle({display: 'none'});
		}
	}, 
	showLocation: function() {
		if ($('locationmenu') != undefined) {
			$('locationmenu').setStyle({display: 'block'});
		}
	}, 
	hideLocation: function() {
		if ($('locationmenu') != undefined) {
			$('locationmenu').setStyle({display: 'none'});
		}
	},
	showSaveshare: function() {
		$('sscontent').setStyle({display: 'block'});
	}, 
	hideSaveshare: function() {
		$('sscontent').setStyle({display: 'none'});
	},
	localize: function( input ) {
		return function(e) {
			Cookie.set("localZip", $F(input));
			navControl.hideLocation();
		}
	},
	print: function(e) {
		Event.stop(e);
		window.print();
	}
}
	
Event.observe(window, 'load', navControl.init);


