//Javascript Document
//Author: Jeff Mulder

$(document).ready(function(){
						   
	//----------------------------------Top Nav----------------------------------------------//					
	$('ul.sf-menu ul').hide();
	$("ul.sf-menu li").hover(function() {						  
		thisLink = $(this).find("> a");
		thisLink.addClass("hover");
		//animation
		$('> ul', this).animate({opacity: "show"}, "fast");
	}, function() {
		thisLink = $(this).find("> a");
		thisLink.removeClass("hover");
		//animation
		$('> ul', this).animate({opacity: "hide"}, "fast");
	});
	$("ul.sf-menu").hover(function() {
		//.sf-menu rollover					   
	}, function() {
		//.sf-menu rollout - reset all to inactive
		$(".active").removeClass("active");
	});	
	
	//----------------------------------Home Buttons------------------------------------------------//
	

	
	$("#home_button_indicators li").bind({
		click: function() {
			$(this).addClass('active').siblings().removeClass('active');
			animateLeft = $(this).index("#home_button_indicators li") * (-945) + 10;
			//slide to animateLeft
			$("#home_buttons ul").animate({left: animateLeft + "px"}, 500);
		},
		mouseenter: function() {
			$(this).addClass('hover');
		},
		mouseleave: function() {
			$(this).removeClass('hover');
		}
	});
			
	
	
	$(".home_button").hover(function() {
		 $(this).stop().animate({height: "205px", top : "0px"}, 250);
		 $(this).find(".rounded_corners").stop().animate({height: "205px"}, 250);
	}, function() {
		$(this).stop().animate({height: "175px", top : "30px"}, 100);
		$(this).find(".rounded_corners").stop().animate({height: "175px"}, 100);
	});
	
	$("img.rounded_corners").each(function() { 
		$(this).wrap('<div class="rounded_corners" />'); 
		var imgSrc = $(this).attr("src"); 
		var imgHeight = $(this).height(); 
		var imgWidth = $(this).width(); 
		$(this).parent()
		.css("background-image", "url(" + imgSrc + ")")
		.css("background-repeat","no-repeat")
		.css("height", "175px")
		.css("width", imgWidth + "px"); 
		$(this).remove(); 
	});
	
	//----------------------------------IMAGES GALLERY----------------------------------------------//
	
	$("#thumb_images li.active img").css({opacity: '.75'});
	
	$("#thumb_images li").hover(function() {
		$(this).not(".active").find("img").stop().animate({
			width: '80px',
			height: '80',
			top: '-15px',
			left: '-15px'				
		}, 250);									 
	}, function() {
		$(this).not(".active").find("img").stop().animate({
			width: '50px', 
			height: '50px', 
			top: '0px',
			left: '0px'				
		}, 500);
	});
										 
	
	$("#thumb_images li").click(function() {		
		$(this).addClass("active").siblings().removeClass("active");
		$("#thumb_images li img").css({opacity: '1'});
		$(this).find("img").css({
			opacity: '.75',
			width: '50px', 
			height: '50px', 
			top: '0px',
			left: '0px',	
		});
		
		//get src from the image clicked
		imageSRC = $(this).find("a").attr("href");
		//fade out
		$("#large_image img").hide();
		$(".product_display_banner .loader").show();
		//$("#largeImage img").animate({opacity: "hide"}, "fast");
		//change src
		$("#large_image img").attr("src", imageSRC).load(function () {
			//fade in
			$("#large_image img").animate({opacity: "show"}, "slow");
			$(".product_display_banner .loader").hide();
																   });
			
		return false;
			
	});
	
	
	
	//----------------------------------WARRANTY SLIDERS----------------------------------------------//
	
	$("ul.warranty li:first").addClass("active");
	$("ul.warranty li:not(.active) .warranty_content").hide();
	//active
	$(".warranty_head").bind({
		click: function() {	
			currentCat = $(this).parent("li");	
				if (currentCat.hasClass("active")) {
					currentCat.find(".warranty_content").slideUp("fast");
					currentCat.removeClass("active");
					return false;
				} else { 
					currentCat.siblings("li").find(".warranty_content").slideUp("fast");
					currentCat.find(".warranty_content").slideDown("fast");
					currentCat.addClass("active");
					currentCat.siblings("li").removeClass("active");
					return false;
				}
			
		},
		mouseenter: function() {
			currentCat = $(this).parent("li");
			currentCat.siblings("li").removeClass("rollover");
			currentCat.addClass("rollover");
		},
		mouseleave: function() {
			currentCat = $(this).parent("li");
			currentCat.removeClass("rollover");	
		}
	});
	
	//----------------------------------APPLE COMPATIBILITY----------------------------------------------//
	
	$("#apple_list").css({opacity: '0', right: '50px'});
	
	//rollover
	$("#apple_img").hover(function() {
		$("#apple_list").show().stop().animate({
			opacity: '1',
			top: '30px'
		}, 250);									 
	}, function() {
		$("#apple_list").stop().animate({
			opacity: '0',
			top: '0px'
		}, 500);
	});
	
		//----------------------------------MID NAV----------------------------------------------//
	
	
	  
	  
	
});
