$(document).ready(function() {
	jQuery('#topNav li:last-child').addClass('last');
	jQuery('#footer li:last-child').addClass('last');
	jQuery('#nav li:last-child').children().addClass('prodlast');
	jQuery("#mainNav li a:contains('Product')").addClass('products');
	jQuery("#mainNav li a:contains('News & Events')").addClass('newsevents');
	jQuery("#mainNav li a:contains('Support')").addClass('support');
	jQuery("#mainNav li a:contains('Dealer Locator')").addClass('dealer');
	jQuery("#mainNav li a:contains('About')").addClass('about');
	//$("#home #mainNav li a:contains('Products')").addClass('current');
	//$("#home #mainNav li a:contains('Products')").parent().addClass('hover');
	
	//Add current page navigation highlight
	var path = location.pathname.substring(1);
   	if ( path ){
		jQuery('#mainNav a[href$="' + path + '"]').parent().addClass('current');
		jQuery('#topNav a[href$="' + path + '"]').parent().addClass('white');
	}
	//Navigation rollovers
	jQuery('#mainNav > li > a').mouseover(function(){
		jQuery(this).parent().addClass("hover");
	}).mouseout(function(){
		jQuery(this).parent().removeClass("hover");
	});
	//Product Search input
	if(jQuery('#search').val()=='')
		jQuery('#search').val('Product Search');
	jQuery('#search').focus(function() {
		if(jQuery(this).val()=='Product Search')
			jQuery(this).val('');
	}).blur(function() {
		if(jQuery(this).val()=='')
			jQuery(this).val('Product Search');
	});
	//Dealer Search Input
	if(jQuery('#dealer_search').val()=='')
		jQuery('#dealer_search').val('Enter Zip Code');
	jQuery('#dealer_search').focus(function() {
		if(jQuery(this).val()=='Enter Zip Code')
			jQuery(this).val('');
	}).blur(function() {
		if(jQuery(this).val()=='')
			jQuery(this).val('Enter Zip Code');
	});
	//newslettersignup
	if(jQuery('#newslettersignup').val()=='')
		jQuery('#newslettersignup').val('Enter Email Address');
	jQuery('#newslettersignup').focus(function() {
		if(jQuery(this).val()=='Enter Email Address')
			jQuery(this).val('');
	}).blur(function() {
		if(jQuery(this).val()=='')
			jQuery(this).val('Enter Email Address');
	});
	
	//More Colors / Related Products sliding effect
	jQuery("#cmotionb").addClass('disabled');
	jQuery("#cmotionf,#cmotionb").mouseover(function(){
		if(!jQuery(this).hasClass("disabled")){
			jQuery(this).addClass('over');
		}
	}).mouseout(function(){
		if(!jQuery(this).hasClass("disabled")){
			jQuery(this).removeClass("over");
		}
    });
	var totalThumbs = jQuery("#morecolors li").size();
	var countainerAmount = Math.ceil(totalThumbs / 4);
	var currentSlot = 1;
	jQuery("#cmotionf").click(function(){
		if(currentSlot < countainerAmount){
			jQuery("#morecolors ol").animate({
				left: "-=300px",
			}, 1000, "swing", function(){
				currentSlot++;
				if(currentSlot > 1){
					jQuery("#cmotionb").removeClass('disabled');
					
				}
				if(currentSlot > (countainerAmount-1)){
					jQuery("#cmotionf").addClass('disabled');
					jQuery(this).removeClass("over");
				}				
			});
		}
	});
	jQuery("#cmotionb").click(function(){
		if(currentSlot > 1){
			jQuery("#morecolors ol").animate({
				left: "+=300px",
			}, 1000, "swing", function(){
				currentSlot--;
				if(currentSlot >= 1){
					jQuery("#cmotionf").removeClass('disabled');
				}
				if(currentSlot <= 1){
					jQuery("#cmotionb").addClass('disabled');
					//jQuery("#cmotionb").css({'background-position' : 'bottom'});
					//isDisabledB = false;
				}
			});
		}
	});
});