$j(function(){
	//Homepage Banner	
	/*$j(".bannerNav li").mouseenter(function(){
		//Remove active, add active state to selected li
		$j(".bannerNav li a").removeClass("active");
		$j(this).find("a").addClass("active");		
		
		var cName = $j(this).attr("class");					
		$j(".bannerWrapper li").hide().removeClass("active");
			$j(".bannerWrapper li."+cName).fadeIn();		
	});*/
       // $j(".bannerNav").show();
        $j(".bannerNav a:first").addClass("active");
        var imageWidth = $j(".bannerWindow").width();
        var imageSum = $j(".bannerWrapper img").size();
        var imageReelWidth = imageWidth * imageSum;
        $j(".bannerWindow").css({'width' : imageReelWidth});
        
        rotate = function(){
            var triggerID = $active.attr("rel") - 1;
            //console.log(triggerID);
            var image_reelPosition = triggerID * imageWidth;
            //console.log(image_reelPosition);
            $j(".bannerNav a").removeClass('active');
            $active.addClass('active');
            $j(".bannerWrapper").animate({
                left: -image_reelPosition
            }, 500);
        };
        rotateSwitch = function(){
           play = setInterval(function(){
               $active = $j('.bannerNav a.active').next();
               if($active.length === 0){
                   $active = $j('.bannerNav a:first');
               }
               rotate();
           }, 7000); 
        };
        rotateSwitch();
        $j(".bannerWrapper a").hover(function(){
            clearInterval(play);
        }, function(){
            rotateSwitch();
        });
        $j(".bannerNav a").click(function() {
            $active = $j(this);
            clearInterval(play);
            rotate();
            rotateSwitch();
            return false;
        });
});

$j(function(){
	//Show/Hide Featured
	$j("a.hide").click(function(){
		var hClass = $j(this).hasClass("hide");
		if(hClass){
			$j(this).removeClass("hide");
			$j("ul.featuredCat").slideUp();
				$j(".pager").css("marginTop","15px");
		}else{
			$j(this).addClass("hide");
			$j("ul.featuredCat").slideDown();		
			$j(".pager").css("marginTop","0");	
		}
	});		
});

$j(function(){
	//Show all categories
//	$j("li.topLi").mouseenter(function(){
//		$j("li.topLi > ul").stop(true,true).slideDown('fast');
//	}).mouseleave(function(){
//		$j("li.topLi > ul").stop(true,true).slideUp('fast');
//	});	
	$j(".mainNav li").mouseenter(function(){
		$j(this).find("ul").first().show();
	}).mouseleave(function(){
		$j(this).find("ul").first().hide();
	});		
	
});

$j(function(){
	//Product View Tabs	
	$j(".box-collateral").hide().first().addClass("active").show();
		
	$j("ul.pTabs li a").click(function(){
		$j("ul.pTabs li a").removeClass("active");
		
		var tab = $j(this).attr("class");
		$j(this).addClass("active");
		
		$j(".box-collateral").hide();		
		$j("."+tab).show();		
	});
});

$j(function(){
	// Product View "Be the first to review
	$j('a.reviewForm').click(function(){
		$j("ul.pTabs li a").removeClass("active");
			$j(".box-reviews").addClass("active");
		$j(".box-collateral").hide();
			$j("#customer-reviews").show();		
	});
});



$j(function(){
	//Fancybox Main Image	
	if($j("a.zoom").length > 0){
	$j("a.zoom").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});	
	//Fancybox More Views Gallery
	$j("a[rel=gallery]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	}
});

