$(document).ready(function(){

	$("#Menu li:last-child").addClass("last");
	$("#Menu li.First").remove();

	$("#actionpoints").cycle({fx:"fade"});
	$("#slides").cycle({
		fx: 	'scrollHorz',
		pause: true,
		timeout: 10000,
		pager: 	"#slidenav",
		pagerAnchorBuilder: function(index, el) {
		return '<a href="#"></a>';
				}

		//pagerAnchorBuilder: buildPagerAnchors
	});
	
	function buildPagerAnchors(i, el) {
		var content = '', href = '';
		var img = "/templates/__custom/img/slides/img-tab", ext = "png";
		switch(i+1){
		case 1:
			content = "V-SOLE Wedges - Any Lie. AnyShot. Any Golfer.";
			href = '#';
			break;
		case 2:
			content = "Bounce Matters - Tired of leaving shots in the bunker?";
			href = '#';
			break;
		case 3:
			content = "One Extraordinary Set of Scoring Tools.";
			href = '#';
			break;
		case 4:
			content = "Lower Scores Guaranteed - Risk free for 60 days.";
			href = '#';
			break;
		case 5:
			content = "Spin and Feel - No other wedge gives your more.";
			href = '#';
			break;
		case 6:
			content = "Custom built by golfers for golfers in Victoria, TX.";
			href = '#';
			break;
		}
		
		return '<a href="'+href+'">'+content+'<img src="'+img+(i+1)+'.'+ext+'" alt="" /></a>';
	}
	
	function textReplacement(input) {
		var originalvalue = input.val();
		input.focus(function() {
			if($.trim(input.val()) == originalvalue){ input.val(""); }
		});
		input.blur(function() {
			if($.trim(input.val()) == ""){ input.val(originalvalue); }
		});
	}

	textReplacement($("#search_query"));
	textReplacement($("#side_nl_email"));
	textReplacement($("#footer_nl_email"));
	
	$("#ProductReviews a[onclick*=show_product_review_form]").addClass("button");
	$("#ProductReviews a[onclick*=show_product_review_form] img").replaceWith("Write a Review");
	
	// Replace 'add to cart' links for each product with a 'learn more' link, going to the product
	$(".CategoryContent .ProductList li").each( function(i,e) {
		var href_txt = $(this).children(".ProductImage").children('a').attr('href');
		//alert(href_txt);
		var $a = $(this).children(".ProductActionAdd").children('a');
		$a.attr('href', href_txt);
		$a.html("Learn More >");
	})
	
//	jCarouselLite example -- you will need to add a <div class="ProductListContainer"> around the <ul>
//	in the HomeFeaturedProducts Panel

//	$("#HomeFeaturedProducts .ProductListContainer").jCarouselLite({
//        btnNext: "#featured-next",
//        btnPrev: "#featured-prev",
//	      visible: 5,
//	 	  scroll: 5,
//		  speed: 800
//   });
	
//	$("a.fancybox").fancybox();

});

