// BUILT ON TOP OF JQUERY /////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*************************************************************************************************************************/

$j(document).ready(function() {
							
	// move the images from homepage slideshowContent div into slideshow
	// this is so that any image maps stay within slideshowContent & don't affect the slideshow (all slideshow children are 'slides')
	$j(".home .slideshowContent img").appendTo(".home .slideshowCorrectedContent");
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	/*
	// setup the slideshow
	// fade up the first image too
	// and make it a random one
	// from http://malsup.com/jquery/cycle/fade-in-first2.html
	// see more at http://malsup.com/jquery/cycle/more.html?v2.23
	
	$j(".slideshow div").addClass("slideshow");
	
	$j('.slideshow img').css({
        opacity: 0
    });
	
	setTimeout(function() {
        $j('.slideshow div.slideshow').cycle({
            fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			speed:  2000,
			timeout: 2000,
			random: 1, // set randomness to true
            delay:  -3000
        });

	    $j('.slideshow img').css({
	        opacity: 0
	    });

    }, 0);
	*/
	
	//$(".home div.slideshow p").addClass("slideshow")
	
	$j('.slideshowCorrectedContent').cycle({
		fx:    'fade', 
		speed:  3500,
		timeout: 1000,
		delay:  -2500
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////
						   
	// SETUP GRADIENTS
	
	// shop elements
	$j('.shop-product-small').gradient({ from: 'FFFFFF', to: 'ededed', direction: 'horizontal', length: 100, position: 'bottom' });
	//$j('.productItemLast li').gradient({ from: 'FFFFFF', to: 'ededed' });
	//$j('.productfeaturelist li').gradient({ from: 'FFFFFF', to: 'ededed' });
	$j('.browsepaneltitle').gradient({ from: 'fafafa', to: 'C8BA97', direction: 'vertical' });
	$j('.browse-panel').gradient({ from: 'fafafa', to: 'E6E2D5', direction: 'vertical' });
	
	$j('.subcol .subnav h4').gradient({ from: 'fafafa', to: 'C8BA97', direction: 'vertical' });
	$j('.subcol .subnav').gradient({ from: 'fafafa', to: 'E6E2D5', direction: 'vertical' });
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// SETUP 'LIST CHILDREN' FOR CSS USE
	$j("ul li:first-child").addClass("first-child");
	$j("ul li:last-child").addClass("last-child");
	
	// none of this is necessary, BC already does enough by default
	//$j("ul.productfeaturelist li:nth-child(2)").addClass("mid-child")
	//$j("ul.productSmall li:nth-child(2)").addClass("mid-child")
	//$j("ul.productSmall li:nth-child(3n+1)").addClass("rowstart")
	//$j("ul.productSmall li:nth-child(3n+2)").addClass("rowmid")
	//$j("ul.productSmall li:nth-child(3n)").addClass("rowend")
	
	// this is needed though seemingly (list of work included on artist profiles)
	$j(".productfeaturelist li:nth-child(3n)").addClass("productItemLast");
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// APPLY DROP SHADOWS
	
	// some simple CSS ones
	///$j("h2").addClass("dropshadow");
	//$j(".tc-footer").addClass("dropshadow");
	
	// less simple JS ones
	//$j('.artistprofile .profileimg').dropShadow({left: 5, top: 5, opacity: 0.6, blur: 3});
	//$j('.shop-product-large .image img').dropShadow({left: 5, top: 5, opacity: 0.6, blur: 3});
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// TWEAK SOME BC STUFF (THAT CAN'T [YET] BE TWEAKED THRU THE BC SYSTEM)
	//$j(".cartSummaryLink").html("my basket");
	//$j('.productSubmitInput').click(function() { $j(".cartSummaryLink").html("my basket"); });
	
	// replace the : in catalogue breadcrumbs with >
	if($j('.breadcrumbs').length) $j('.breadcrumbs').html($j('.breadcrumbs').html().replace(/:/ig, ">"));
	
	// replace 'Sub Catalogs' with 'Sub Catalogues', if it exists
	if($j('.browse-panel h6:eq(0)').length) $j('.browse-panel h6:eq(0)').html($j('.browse-panel h6:eq(0)').html().replace(/Sub Catalogs/ig, "Sub Catalogues"));
	
	// replace 'catalog' with 'catalogue' when 'this catalog has no products
	if($j('li.productItemNotFound').length) $j('li.productItemNotFound').html($j('li.productItemNotFound').html().replace(/catalog/ig, "catalogue"));
	
	// swap prices with sub catalogues in the browse panel
	if($j('.browse-panel h6:eq(1)').length) $j('.browse-panel h6:eq(0)').swap('.browse-panel h6:eq(1)');
	if($j('.browse-panel h6:eq(1)').length) $j('.browse-panel .browse-price').swap('.browse-panel .browse-catalogue');
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// POPLET STUFF
	
	// if there are no poplet images hide the poplet div
	if($j('.poplets img').length==0	) $j('.poplets').addClass("hide");
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// MORE SIGNPOSTING TELLING THE USER WHERE THEY ARE, SPECIFICALLY WHEN THEY CHOOSE A PRICE BRACKET
	
	// append price bracket selections to breadcrumbs (get data from the querystring)
	var priceFrom = $j.jqURL.get('PriceFrom');
	var priceTo = $j.jqURL.get('PriceTo');
	if (priceFrom != undefined) {
		var breadcrumbsHtmlStr = $j('.breadcrumbs').html();
		$j('.breadcrumbs').html(breadcrumbsHtmlStr+" > &pound;"+priceFrom+" - &pound;"+priceTo);
	}
	
	// highlight browse panel elements if they contain querystring data
	//$j('ol.browse-price li a:contains("�'+priceFrom+' - �'+priceTo+'")').addClass("selected"); // doesn't like the pound signs, so search on href...
	$j('ol.browse-price li a[href$="PriceFrom='+priceFrom+'&PriceTo='+priceTo+'"]').addClass("selected");


});