//CUFON FIX
document.documentElement.className = 'js';

$(document).ready(function() {	
	
	//ADD CONTENT
	$('.newsDivArchiveTitle').html('<h1>Testimonials</h1>');
	$('.ccvTxt').html('<p>The 3 digits located on the reverse of your credit card. For AMEX use the 4 digit code on the front of card.</p>');
	$('.dataForm_row td:first').css('width', '175px');
	$(".product_ProductDescMoreText a").text("+ Read More");
	$(".cart_wrapper").append("<p class=\"country-disclaimer\">* Australian orders only. All USA and UK orders please click on international orders. All other countries please contact us</p>");
	$(".CheckoutButtonUpdatePurchase").append("<p class=\"country-disclaimer\">NOTE: Once you proceed to the Payment page you will not be able to return and change your order as all cart items will be cleared.</p>");
	$('.paymentThankyouMessage').html('<h1>Confirmation</h1><p>Your payment was successful. An invoice has been sent to your email address.</p>');
	$('.loginMemberSignUpBack a').html('Continue through to checkout');
	
	$('.memberLoginAuthenticationRegister input').before('<h1>Become a Member</h1><p>Becoming an Oakwood member will give you access to exclusive members only <strong>specials</strong> and <strong>savings</strong>.</p>');	
	
	//DISPLAY CUFON ELEMENTS ONCE LOADED				   
	$('.js h1, .js h2, .js h3, .js .tagline, .js .product_ProductName a, .js .product_DetailsName, .js .loginMemberSignUpHeader, .js .loginMemberSignUpAddressBillingHeader, .js .loginMemberSignUpAddressDeliveryHeader, .js .loginMemberSignUpHeader, .js .cart_header, .js .hpbtn').css('text-indent','0px');	
	$('html').removeClass('js');
		
	catNameTagline();
	//HOVER BUTTONS
	$(".hover").fadeTo(0, 0.8);
	$(".hover").hover(function(){
		$(this).stop().fadeTo(150, 1.0);
	},function(){
		$(this).stop().fadeTo(150, 0.8);
	});
	
	$(".product_ProductItemWrapper").mouseenter(function() {Cufon.refresh();});
	$(".product_ProductItemWrapper").mouseleave(function() {Cufon.refresh();});
	
	productGalleries();

	//NEWS SCROLLER V2
	var visibleNewsItems = 3;//SET MAX NUMBER OF VISIBLE ITEMS
	var totalNewsItems = $(".newsTicker li").length;
	if (visibleNewsItems > totalNewsItems)
	{
	visibleNewsItems = totalNewsItems;
	}	
	$(".newsTicker").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: visibleNewsItems,
		auto:3000,
		speed:1000
	});
});

//Product Flash Galleries
var strFolder = "../flashgallery/product-banner.swf";
// SWFObject embed
var flashvars = {
	paramXMLPath: "param.xml",
	initialURL: escape(document.location),
	startAlbumID: "album-"
}
var params = { 
	base: ".",
	bgcolor: "#121212",
	allowfullscreen: "false",
	wmode: "transparent"
}                
var attributes = {}
	
function flashPutHref(href) {location.href = href;}

function productGalleries() {
	var catId = getQueryStringItem("categoryID");
	switch(catId){
	case "1573": //Household Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '796';
		break;
	case "1574": //Pet Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '794';
		break;
	case "1572": //Leather and Horse Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '797';
		break;
	case "1845": //Leather and Horse Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '797';
		break;
	case "1846": //Leather and Horse Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '797';
		break;
	case "1575": //Automotive Care
		showGallery();
		flashvars['startAlbumID'] = "album-" + '795';
		break;
	}
}

function showGallery(){
	$("#productGallery").css("display", "block");
}	

//Retrieve Query String
function getQueryStringItem(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return decodeURIComponent(results[1].replace(/\+/g, " "));
}

//Insert Product Category Name into tagline
function catNameTagline(){
	
	if ( $('.product_CategoryName').length ) {
		catName = $('.product_CategoryName').text();
		$('.tagline').text(catName);
		$('.tagline').addClass("taglinespaced");
		Cufon.refresh();
	}
}


