<!--

VBS.Home = {};
VBS.Home.nextStep = 1;
VBS.Home.spotLightEffectInterval = null;
VBS.Home.spotlightGroupLinkRollOver = false; 
VBS.Home.bestsellerGroupLinkHasRollover = false; 

VBS.Home.init = function () {
	VBS.Home.addHomeListRollover();
	VBS.Home.addSpotLightRollover();
	VBS.Home.addSpotLightEffect();	
}

VBS.Home.addHomeListRollover = function () {
	var links = $$(".home-list a.title");
    for(var i=0; i<links.length; i++)  {
		var holder = links[i].getParent().getParent().getParent().getParent();
		holder.navigationLink = links[i];
		
		holder.addEvents({
				"mouseover": function() { 
						if(!VBS.Home.bestsellerGroupLinkHasRollover && this.className.indexOf("rollover") == -1) { 
							this.className = this.className + " rollover"; 
						} 
					},
				"mouseout": function() { 
						if(!VBS.Home.bestsellerGroupLinkHasRollover && this.className.indexOf("rollover") != -1) { 
							this.className = this.className.replace(" rollover", ""); 
						} 
					},
				"click": function() { if(!VBS.Home.bestsellerGroupLinkHasRollover) { location.href = this.navigationLink;} }
			});
	}
	
	var groupLinks = $$(".home-list a.more-link");
	for(var i=0; i<groupLinks.length; i++)  {
		groupLinks[i].addEvents({
				"mouseover": function() { VBS.Home.bestsellerGroupLinkHasRollover = true; this.getParent().className = "home-list-bottom rollover";  },
				"mouseout": function() { VBS.Home.bestsellerGroupLinkHasRollover = false;  this.getParent().className = "home-list-bottom"; }
			});
	}
}

VBS.Home.addSpotLightRollover = function () {
	if(!$("Spotlight1")) { return; }
	
	var spotlightItemLinks = $$("#SpotlightInner a");
	for(var i=0; i<spotlightItemLinks.length; i++)  {
		var holder = spotlightItemLinks[i].getParent().getParent().getParent();
		holder.navigationLink = spotlightItemLinks[i].href;
		
		holder.addEvents({
				"mouseover": function() { if(!VBS.Home.spotlightGroupLinkRollOver) { this.getParent().getParent().getParent().className = "rollover"; } },
				"mouseout": function() { this.getParent().getParent().getParent().className = ""; },
				"click": function() { location.href = this.navigationLink; }
			});
	}
	
}

VBS.Home.addSpotLightEffect = function () {	
    var scroll = new Fx.Scroll("SpotlightSlider", {
		wait: false,
		duration: 1000,
		offset: {"x": 0, "y": 0},
		transition: Fx.Transitions.Quad.easeInOut
    });

    var clearNavigationState = function () {
        var spotlightNavigationLinks = $$("#SpotlightNavigation a");
	
		for(var i=0; i<spotlightNavigationLinks.length; i++)  {
			spotlightNavigationLinks[i].parentNode.className = spotlightNavigationLinks[i].parentNode.className.replace("-active", "");
		}
	}

    var addAnimation = function(step) {
        if($("SpotlightLink" + step)) {
	        $("SpotlightLink" + step).addEvent("click", function(event) {
			    event = new Event(event).stop();
			    animate(step, true)
		    });
	    }	
    }

    var intervalAnimate = function() {
        var step = VBS.Home.nextStep;
        VBS.Home.nextStep++;
        if(VBS.Home.nextStep>5) { VBS.Home.nextStep = 1; }
        try { animate(step, false); }
        catch(err) { VBS.Home.nextStep = 1; }
    }

    var animate = function(step, clearTimer) {  
        if(clearTimer) { clearInterval (VBS.Home.spotLightEffectInterval); }

        scroll.toElement("Spotlight" + step);	   
	    clearNavigationState();
        if(step=="1") { $("SpotlightLink" + step).parentNode.className = "one-active";  $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink1; }
        else if(step=="2") { $("SpotlightLink" + step).parentNode.className = "two-active";  $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink2; }
        else if(step=="3") { $("SpotlightLink" + step).parentNode.className = "three-active";  $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink3; }
        else if(step=="4") { $("SpotlightLink" + step).parentNode.className = "four-active";   $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink4;}
        else if(step=="5") { $("SpotlightLink" + step).parentNode.className = "five-active";  $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink5; }
    }
	
	addAnimation(1); addAnimation(2); addAnimation(3); addAnimation(4); addAnimation(5); 
    
    $("SpotlightBottom").innerHTML =  VBS.Home.spotLightLink1;   
	$("SpotlightGroupLink").addEvents({
		"mouseover": function() { VBS.Home.spotlightGroupLinkRollOver = true; spotlightBottom.className = "rollover"; },
		"mouseout": function() {  VBS.Home.spotlightGroupLinkRollOver = false;spotlightBottom.className = ""; }
	});

    intervalAnimate();
    VBS.Home.spotLightEffectInterval =  window.setInterval(intervalAnimate, 5000);
}

window.addEvent("domready", function(){ VBS.Home.init(); }); 
-->
