function clearText(thefield){
		var phvalue = $(thefield).attr("placeholder");
		if (phvalue){
			if (phvalue == $(thefield).val()) {
			$(thefield).val("");
			}
		}
	} 

	function setBackText(thefield){
		var phvalue = $(thefield).attr("placeholder");
		if (phvalue){
			if ($(thefield).val() == "") {
				$(thefield).val(phvalue);
			}
		}
	} 
	
	function checkall(checkbox){
		$("#searchsub #indept .columns  input[type='checkbox']").attr('checked', $('#checkall').is(':checked')).attr('disabled', $('#checkall').is(':checked'));
	}
	

$(document).ready(function() {

	//$(".registernowshowhide, .shippingdetails").hide();
	
	
	$(".registernow").live("click",function() {
		$(".registernowshowhide").slideToggle(300);
	});
	
	$("#diffship").live("click",function() {
		$(".shippingdetails").fadeToggle(300);
	});
	

	if($("input[type='radio']").hasClass("radio")) {
		$("input[type='radio']").parent("label").addClass("inlinelabel");
	}

	$(".sitemap > li:nth-child(7)").css({
		float: "right",
		marginRight: "60px"
	});

	$(".spinbox").spinbox({
	  min: 1,    // Set lower limit or null for no limit.
	  max: null,  // Set upper limit or null for no limit.
	  step: 1 // Set increment size.
	});

	$('#checkall').click(function() {
		checkall();
	});
	
	$('#checkall').ready(function() {
		checkall();
	});
	
	$("#qtyname").outerClick(function() {
		$("#qtydrop").slideUp(200);
		$("#qtydrop").removeClass("isopen");
	});

	$("#sizename").outerClick(function() {
		$("#sizedrop").slideUp(200);
		$("#sizedrop").removeClass("isopen");
	});
	
	/* -- */

	$(".addtocart").click(function() {
		$(window).scrollTo(0,300, function() {
			$("#basket").animate({
				backgroundColor: "#1CBCB4"
			}, 300, function() {
				$("#basket").animate({
				backgroundColor: "#DDDDDD"
				}, 300, function() {
					$("#basket").animate({
					backgroundColor: "#1CBCB4"
					}, 300, function() {
						$("#basket").delay(1000).animate({
						backgroundColor: "#DDDDDD"
						}, 300);
					});
				});
			});
		});
	});
	
	/* -- */

	$("#featured .wrapper #productlist li:nth-child(6n)").css({
		marginRight: "0"
		});
	

	$("#categoryproducts #productlist li:nth-child(4n)").css({
		marginRight: "0"
		});
		
	$("#youmightlike #productlist li:nth-child(5n)").css({
		marginRight: "0"
		});

	$("#productlist li").hover(function() {
		$(this).children(".overlay").fadeIn(200);
		$(this).children(".bottom").children(".price").hide();
		$(this).children(".bottom").children("h5").hide();
	}, function() {
		$(this).children(".overlay").hide();
		$(this).children(".bottom").children(".price").show();
		$(this).children(".bottom").children("h5").show();
	});

	/* -- */		

	$("#sizename").click(function() {
		$("#sizedrop").slideDown(200);
	});	

	$("#sizedrop span").click(function() {
		$("#sizedrop").slideUp(200);
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		var size = $(this).html();
		$("#sizetext").html(size)
	});

	/* -- */

	$("#qtyname").click(function() {
		$("#qtydrop").slideDown(200);
		$("#qtydrop").addClass("isopen");
	});

	$("#qtydrop span").click(function() {
		$("#qtydrop").slideUp(200);
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		var size = $(this).html();
		$("#qtytext").html("Quantity: "+size);
		$("#qnt").val(size);
		$("#qtydrop").removeClass("isopen");
	});

	/* -- */

	$("#colorlist li").click(function() {
		if($(this).hasClass("active")) {
			$(this).siblings().animate({
				opacity: "1"
			}, 200);
			$(this).removeClass("active");
			$("#option_2").attr("value", "");
		} else {
			$(this).animate({
				opacity: "1"
			}, 200);
			$(this).siblings().animate({
					opacity: "0.2"
			}, 200);
			$(this).addClass("active");
			$(this).siblings().removeClass("active");
		}
	});

	$("#searchfield").focus(function() {
		$("#indept").fadeIn(200);
	});
	$("#searchfield").click(function() {
		$("#indept").fadeIn(200);
	});
	$("#departmentlist").hover(function() {
	}, function() {
		$("#indept").fadeOut(200);
	});
	
	/* -- */

	$(".addtolove").click(function() {
		if($("#login").hasClass("active")) {
				$("#login").slideUp(200);
				$("#login").removeClass("active");
				$(".login").children("a").removeClass("active");
			}
		$(window).scrollTo(0,300, function() {
		$(".wishlist").children("a").addClass("active");
		$("#wishlist").slideDown(200, function() {
			$("#wishlist").delay(3000).slideUp(200, function() {
			$(".wishlist").children("a").removeClass("active");
			});
		});
		});
	});


	/* -- */


	$("#wishlist").hide();
	$(".wishlist > a").click(function() {
		if($("#login").hasClass("active")) {
			$("#login").slideUp(200);
			$("#login").removeClass("active");
			$(".login").children("a").removeClass("active");
		}

		if($("#wishlist").hasClass("active")) {
			$("#wishlist").slideUp(200);
			$("#wishlist").removeClass("active");
			$(".wishlist").children("a").removeClass("active");
		} else {
			$("#wishlist").slideDown(200);
			$("#wishlist").addClass("active");
			$(".wishlist").children("a").addClass("active");
		}

		return false;

	});
	

	/* -- */
	

	$("#login").hide();
	$(".login > a").click(function() {
		if($("#wishlist").hasClass("active")) {
			$("#wishlist").slideUp(200);
			$("#wishlist").removeClass("active");
			$(".wishlist").children("a").removeClass("active");
		}

		if($("#login").hasClass("active")) {
			$("#login").slideUp(200);
			$("#login").removeClass("active");
			$(".login").children("a").removeClass("active");
		} else {
			$("#login").slideDown(200);
			$("#login").addClass("active");
			$(".login").children("a").addClass("active");
		}
		return false;
	});

	
	/* -- */

	
	$("nav .products_categories li").hover(function () {
		$(this).children(".sub-menu").fadeIn(200);
	}, function () {
		$(this).children(".sub-menu").hide();
	});

	
	/* -- */

	
	$(".sub-menu li").has(".sub-menu").addClass("haschild");
	
	
	/* -- */

	
	function placeholder(){
		$("#searchfield,.col-last input[type=text],.login input[type=text]").each(function(){
			var phvalue = $(this).attr("placeholder");
			$(this).val(phvalue);
		});
	}
	placeholder();
	
	
	/* -- */

	
	$("#searchfield,.col-last input[type=text],.login input[type=text]").focusin(function(){
		clearText(this);
	});

	$("#searchfield,.col-last input[type=text],.login input[type=text]").focusout(function(){
		setBackText(this);
	});

});



$(window).load(function() {

	$('#featuredpr').orbit({
		animation: 'fade', // fade, horizontal-slide, vertical-slide, horizontal-push
		animationSpeed: 1000,
		timer: true,
		advanceSpeed: 8000,
		pauseOnHover: false,
		startClockOnMouseOut: true,
		startClockOnMouseOutAfter: 1000,
		directionalNav: true,
		captions: true, 
		captionAnimation: 'fade',
		captionAnimationSpeed: 800,
		bullets: false,
		bulletThumbs: false,
		bulletThumbLocation: ''
	});

});
