/* jQuery Scripts Information
-----------------------------------------------------------
Author: Jaymie Jones
Author Company: Xtreme.com.au
Author Website: http://www.xtreme.com.au
Designed For: http://www.aromamatic.com.au
Date: 2010/12/03
Last Modification: 2010/06/06
-----------------------------------------------------------*/

/* Summary
-----------------------------------------------------------
01. General
02. Blocks
03. Products
04. Navigation
05. General
-----------------------------------------------------------*/

$.noConflict();

jQuery(document).ready(function($) {

/* @group 01. General
-----------------------------------------------------------*/

$('#footer ul li:last-child').css({"border-right" : "none"});

if ($('.actions button.button').length != "0") {
	
	$('.actions button.button').hover(function(){
		
		$(this).stop().animate({
			opacity: 0.7
		});
		
	}, function(){
	
		$(this).stop().animate({
			opacity: 1
		});
		
	});
	
}

if ($('#highlight-slideshow p').length > "1") {
	
	var noSlices = $('#highlight-slideshow p').length

	$('#highlight-slideshow').nivoSlider({
	    effect: 'fade', //Specify sets like: 'fold,fade,sliceDown'
	    slices: noSlices,
	    animSpeed: 500, //Slide transition speed
	    pauseTime: 3000,
	    startSlide: 0, //Set starting Slide (0 index)
	    directionNav: false, //Next & Prev
	    directionNavHide: true, //Only show on hover
	    controlNav: false, //1,2,3...
	    keyboardNav: false, //Use left & right arrows
	    pauseOnHover: false, //Stop animation while hovering
	    manualAdvance: false, //Force manual transitions
	    captionOpacity: 0, //Universal caption opacity
	    beforeChange: function(){},
	    afterChange: function(){},
	    slideshowEnd: function(){}, //Triggers after all slides have been shown
	    lastSlide: function(){}, //Triggers when last slide is shown
	    afterLoad: function(){} //Triggers when slider has loaded
	});
	
}

/* @end */

/* @group 02. Blocks
-----------------------------------------------------------*/

if ($('.block.block-cart').length != "0") {
	
	$('.block.block-cart .actions').append('<a href="/checkout/cart/" title="View Cart">View Cart</a>');
	
}

/* @end */

/* @group 03. Products
-----------------------------------------------------------*/

if ($('.catalog-category-view')) {
	$('.catalog-category-view #content-main > table a').attr("target", "_blank");
}

if ($('.category-products ul.products-grid')) {
	if ($('.category-products ul.products-grid li.item').length == "1") {
		$('.category-products ul.products-grid').addClass('products-1');
	}
	
	if ($('.category-products ul.products-grid li.item').length == "2") {
		$('.category-products ul.products-grid').addClass('products-2');
	}
	
	if ($('.category-products ul.products-grid li.item').length == "3") {
		$('.category-products ul.products-grid').addClass('products-3');
	}
}

if ($('a#currency-converter').length != "0") {
	$('a#currency-converter').click(function(e){
		window.open("http://www.xe.com/pca/input.cgi", "XE Universal Currency Converter","location=1,status=1,scrollbars=1, width=760,height=215");
		e.preventDefault();
	});
}

if ($('.product-view .more-views ul li').length != "0") {

	$('.product-view .more-views ul li img').css({"opacity" : "0.6"});
	
	$('.product-view .more-views ul li img').hover(function(){
		$(this).stop(true, true).animate({
			"opacity": 1
		}, "slow");
	}, function(){
		$(this).stop(true, true).animate({
			"opacity": "0.6"
		}, "slow");
	});

}

if ($('.product-view ul.product-tabs li').length != "0") {

	$('.product-view ul.product-tabs li a').click(function(){
		$(this).parent('li').toggleClass("active");
		$(this).parent('li').find('.content-item-content').toggle("slow");
		return false;
	});
	
}

if ($('.product-view .product-image-box .image-container').length != "0") {

	$('.product-view .product-image-box .image-container .image-hover').css({ "display" : "block", "opacity" : "0" });
	
	$('.product-view .product-image-box .image-container a').hover(function(){
		$('.image-hover', this).stop().animate({
			opacity: 0.9
		}, "slow");
	}, function(){
		$('.image-hover', this).stop().animate({
			opacity: 0
		}, "slow");
	});

}

if ($('.products-grid .product-image').length != "0") {

	$('.products-grid .product-image .image-hover').css({ "display" : "block", "opacity" : "0" });
	
	$('.products-grid .product-image-thumb a').hover(function(){
		$('.image-hover', this).stop().animate({
			opacity: 0.9
		}, "slow");
	}, function(){
		$('.image-hover', this).stop().animate({
			opacity: 0
		}, "slow");
	});

}

if ($('.products-list .product-image').length != "0") {

	$('.products-list .product-image .image-hover').css({ "display" : "block", "opacity" : "0" });
	
	$('.products-list .product-image a').hover(function(){
		console.log("HOVERING IMAGE");
		$('.image-hover', this).stop().animate({
			opacity: 0.9
		}, "slow");
	}, function(){
		$('.image-hover', this).stop().animate({
			opacity: 0
		}, "slow");
	});

}

if ($('.product-view ul.product-tabs li#product_tabs_upsell_products table#upsell-product-table td').length != "0") {

	$('.product-view ul.product-tabs li#product_tabs_upsell_products table#upsell-product-table td .image-hover').css({ "display" : "block", "opacity" : "0" });
	
	$('.product-view ul.product-tabs li#product_tabs_upsell_products table#upsell-product-table td a.product-image').hover(function(){
		$('.image-hover', this).stop().animate({
			opacity: 0.9
		}, "slow");
	}, function(){
		$('.image-hover', this).stop().animate({
			opacity: 0
		}, "slow");
	});

}

/* @end */

/* @group 04. Navigation
-----------------------------------------------------------*/

$('#navigation ul.links li.first a').attr("title", "My Profile").text("My Profile");

if ($('.block-category-navigation ul#categories li.level0').length != "0") {

	/* $('.block-category-navigation ul#categories li.level0 ul').hide();
	
	$('.block-category-navigation ul#categories li.level0').each(function(){
		if ($(this).hasClass('active')){
			$('> ul', this).show();
		} else {
			$('> ul', this).hide();
		}
	})
	
	$('.block-category-navigation ul#categories li.level0 a').click(function(){
	
		if ($(this).parent('li.level0').find('> ul').length != "0") {
		
			$(this).parent('li.level0').find('> ul').toggle('slow');
			
			$(this).parent('li').toggleClass('active');
			
			return false; // Disable click functionality
		
		}
		
	}); */
	
	$('.block-category-navigation ul#categories li.level0.nav-2 ul').hide();
	
	if ($('.block-category-navigation ul#categories li.level0.nav-2').hasClass('active')){
		$('.block-category-navigation ul#categories li.level0.nav-2 ul').show();
	} else {
		$('.block-category-navigation ul#categories li.level0.nav-2 ul').hide();
	}

}

/* @group 05. General
-----------------------------------------------------------*/

if ($('.box-attachments-ext').length != "0") {

	if ($('.box-attachments-ext ul li').length == "0") {
		
		$('.box-attachments-ext').css({"display" : "none"});
		
	}	
	
}

/* @end */
	
});
