$(document).ready(function(){

	$("#PrimaryMenu > ul > li:last-child").addClass("last");
	
	$(".SubCategoryListGrid ul li.RowDivider").remove();
	$(".SubCategoryListGrid ul li:last-child").remove();
	
	$("#ProductReviews > a > img").replaceWith("write a review");
	$("#ProductReviews > a").addClass("button");
	
	/*
		This is a short and simple script that will create an Active class for your custom pages menu links(if you have to use stuff like Category pages for your main navigation).
		Keep in mind that this will also work for any other list (like custom Side Vendors, Side Categories, or Side Brands) by just changing the ID Selector. **Credit to Krystin Rice
	*/
	var loc_href = window.location;
		$('#SideCategoryList ul li a').each(function () {
		if (loc_href == $(this).attr('href')) {
			$(this).addClass('activePageLink');
		}
	});

	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); }
		});
	}
	
	$(".video").click(function() {
	        $.fancybox({
	            'padding'       : 0,
	            'autoScale'     : false,
	            'transitionIn'  : 'none',
	            'transitionOut' : 'none',
	            'title'         : this.title,
	            'width'         : 640,
	            'height'        : 480,
	            'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
	            'type'          : 'swf',
	            'swf'           : {
	            'wmode'             : 'transparent',
	            'allowfullscreen'   : 'true'
	            }
	        });
	 
	        return false;
	    });
	
/*	$('#featured-cycle').after('<ul id="featured-cycle-nav">').cycle({
            fx: 'fade',
            speed: 1000,
            timeout: 7000,
            pager: '#featured-cycle-nav',
            pagerAnchorBuilder: function(idx, slide) {
                var i=idx+1;
                var postID = $(slide).attr('id');
                return '<li><a href="#"><img src="' + $('li#' + postID + ' img').attr('src') + '" width="107" height="80">' + $(slide).attr('title') + '</a></li>';
            }
        });*/

	textReplacement($("#search_query"));
	textReplacement($("#nl_first_name"));
	textReplacement($("#nl_email"));
	
	
        /*$('#cycle-nav li').css('opacity','0.1');
        $('#cycle-nav li.activeSlide').css('opacity','1');*/
        
	
	 // // loads the cycle or whatever on specific url in this case the home page
	// //GET URL	
	var url = window.location.pathname;
	url = url.toLowerCase();
	// //READ URL
	// // uncomment alert to see what the url is in browser if needed
	// //alert(url);
	 if (url == '/' || url == "/index.php") {
	// //RUN CYCLE
		 $('#cycle').after('<ul id="cycle-nav">').cycle({
		fx: 'fade',
		speed: '2000',
		pager: '#cycle-nav',
		pagerAnchorBuilder: function(idx, slide) {
			var i=idx+1;
                var postID = $(slide).attr('id');
                return '<li><a href="#"><img src="' + $('li#' + postID + ' img').attr('src') + '" width="117">' + $(slide).attr('title') + '</a></li>';
            }
        });
        $('#cycle-nav li:nth-child(even)').addClass('even');
	};
	
	// // loads only if the cycle selector exists
	// if ($("#cycle").length > 0){	
		// $("#cycle").cycle({
			// fx: "fade"
		// });
	// };


	//	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
//   });

});
