// JavaScript Document

// Top icons fade in out
$(document).ready(function(){
	$(".LargeIcon").fadeTo(0, 0.6);
	$(".LargeIcon").hover(
 		function(){
 			$(this).fadeTo("fast", 1);
 			},
 		function(){
 			$(this).fadeTo("fast", 0.6);
 		}
	);
});

// Rollover images
$(document).ready(function(){
$("img.rolloverImage").hover(
 function()
 {
  this.src = this.src.replace("_off","_on");
 },
 function()
 {
  this.src = this.src.replace("_on","_off");
 }
);
});

// Navigation bg colour fade
$(document).ready(function(){
	$("#sideBar li").css('background-color','#ece6f2');
	$("#sideBar li").animate({'backgroundColor' : '#ece6f2'});
	$("#sideBar li").hover(
 		function(){
 			$(this).animate({'backgroundColor' : '#cfbae0'}, "fast");
 			},
 		function(){
 			$(this).animate({'backgroundColor' : '#ece6f2'}, "fast");
 		}
	);
});

// homepage promo boxes
$(document).ready(function(){
	$(".homepagePromoRollover").fadeTo(0, 0);
	$(".homepagePromoImage").hover(
 		function(){
 			$(this).find(".homepagePromoRollover").fadeTo("def", 0.9);
 		},
 		function(){
 			$(this).find(".homepagePromoRollover").fadeTo("def", 0);
 		}
	);
});

// Slideshow
function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

// Site credit rollover
$(document).ready(function(){
	$("#siteCredit").hover(
 		function(){
 			$("#siteCredit img.off").fadeTo("def", 0);
			$("#siteCredit p").animate({ left: "10px"}, "fast" );
 			},
 		function(){
 			$("#siteCredit img.off").fadeTo("def", 1);
			$("#siteCredit p").animate({ left: "100px"}, "fast" );
 		}
	);
});

// detail page related products
$(document).ready(function(){
	$(".relatedProductCaption").fadeTo(0, 0);
	$(".relatedProductThumbnail").hover(
 		function(){
 			$(this).find(".relatedProductCaption").fadeTo("def", 0.9);
 		},
 		function(){
 			$(this).find(".relatedProductCaption").fadeTo("def", 0);
 		}
	);
});

