// JavaScript Document

	$(document).ready(function() {		
		
		// for the menu dropdowns
		function menuHoverOver(){
			$(this).children("div").animate({height: "show", width: "show"}, 5);		
		}
		
		function menuHoverOut(){
				$(this).children("div").animate({height: "hide", width: "hide"}, 5);
		}
		var config = {    
				 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
				 interval: 200, // number = milliseconds for onMouseOver polling interval    
				 over: menuHoverOver, // function = onMouseOver callback (REQUIRED)    
				 timeout: 200, // number = milliseconds delay before onMouseOut    
				 out: menuHoverOut // function = onMouseOut callback (REQUIRED)    
		};
		$("#bottom-nav li:has(div)").hoverIntent(config);
		$("#shopping-cart li:has(div)").hoverIntent(config);
		// end menu dropdowns
		
	// for the daily deals arrow buttons when clicked
		// the previous arrow
		function scrollPrevClick(event){
			var prodContainer = $("div.allScrollingProdContainer");
			var that = $(this);
			
			var location = prodContainer.position().left;
			var newLocation = location + event.data.elementWidth;
			$(this).unbind('click');
			
			// we stop it from going to the previous one if there is no previous
			if (location < 0){
				prodContainer.stop('true', 'true').animate({left: newLocation}, 'slow', '', function(){
					that.bind('click', event.data, scrollPrevClick);
					});
			} else {
					that.bind('click', event.data, scrollPrevClick);
			}
			return false;
		}

// the next arrow
		function scrollNextClick(event){
			var prodContainer = $("div.allScrollingProdContainer");
			var that = $(this);
			
			var location = prodContainer.position().left;
			var newLocation = location - event.data.elementWidth;
			var numOfChildren = prodContainer.children(".allPagesProdHolder").size();
			var lengthOfChildren = -((numOfChildren * event.data.elementWidth) - event.data.widthShown);
			$(this).unbind('click');
			
			if (newLocation >= lengthOfChildren){
				prodContainer.animate({left: newLocation}, 'slow', '', function(){
					that.bind('click', event.data, scrollNextClick);
					});
			} else {
					that.bind('click', event.data, scrollNextClick);
			}
			return false;
		}
		
		var dropdownConfig = {
			widthShown: 666,
			elementWidth: 222
		};
		
		$("a.scrollNext").bind('click', dropdownConfig, scrollNextClick);
		$("div a.scrollPrev").bind('click', dropdownConfig, scrollPrevClick);
	
// for the daily deals arrow buttons when clicked end

	//arrow buttons when clicked on department landing page
		// the previous arrow
		function scrollPrevClickAlt(event){
			var prodContainer = $("div.allScrollingProdContainerAlt");
			var that = $(this);
			
			var location = prodContainer.position().left;
			var newLocation = location + event.data.elementWidth;
			$(this).unbind('click');
			
			// we stop it from going to the previous one if there is no previous
			if (location < 0){
				prodContainer.stop('true', 'true').animate({left: newLocation}, 'slow', '', function(){
					that.bind('click', event.data, scrollPrevClickAlt);
					});
			} else {
					that.bind('click', event.data, scrollPrevClickAlt);
			}
			return false;
		}

// the next arrow
		function scrollNextClickAlt(event){
			var prodContainer = $("div.allScrollingProdContainerAlt");
			var that = $(this);
			
			var location = prodContainer.position().left;
			var newLocation = location - event.data.elementWidth;
			var numOfChildren = prodContainer.children(".allPagesProdHolderLanding").size();
			var lengthOfChildren = -((numOfChildren * event.data.elementWidth) - event.data.widthShown);
			$(this).unbind('click');
			
			if (newLocation >= lengthOfChildren){
				prodContainer.animate({left: newLocation}, 'slow', '', function(){
					that.bind('click', event.data, scrollNextClickAlt);
					});
			} else {
					that.bind('click', event.data, scrollNextClickAlt);
			}
			return false;
		}
		
		var dropdownConfig = {
			widthShown: 666,
			elementWidth: 200
		};
		
		$("a.scrollNextAlt").bind('click', dropdownConfig, scrollNextClickAlt);
		$("div a.scrollPrevAlt").bind('click', dropdownConfig, scrollPrevClickAlt);
	
// for the daily deals arrow buttons when clicked on department landing page end




			$("#hpTopTabs a").click(function()
				{
					if($(this).attr("id") === "hpTopTabsTextOff")
					{
						//$(this).attr("src", "/images/product_detail_tab1.gif");  
						$(this).attr("id", "hpTopTabsTextOn");
						$(this).siblings("#hpTopTabsTextOn").attr("id", "hpTopTabsTextOff");
						var test1 = $(this).parent();
						
						if(test1.css("background-image") === 'url("http://www.westpointgiftstore.com/images/hp_best_sellers.gif")')
						{
							test1.css("background-image", "url('http://www.westpointgiftstore.com/images/hp_new_arrivals.gif')");	
							$("#newArrivals").show();
							$("#bestSellers").hide();
						}
						else
						{
							test1.css("background-image", "url('http://www.westpointgiftstore.com/images/hp_best_sellers.gif')");	
							$("#newArrivals").hide();
							$("#bestSellers").show();
						}
					}
				});
		
	});
	
	
	
			// used for magic zoom so the alt image will be displayed in the magic zoom
			function changeZoomImage() {
			
			// Step 1
			// Stop Magic Zoom
			MagicZoom_stopZooms();
			
			
			// Step 2
			// Re-initialize Magic Zoom
			MagicZoom_findZooms();
			}
			
			
			
			
