 
jQuery(function($){
	var email = $(".tx-tcshop-pi1 input.invoice_email").val();
	if($(".tx-tcshop-pi1 .new_account_container input#newaccount").attr("checked") || email != invoice_email) {
		$(".tx-tcshop-pi1 .new_account_container").show();
	}
	
	$(".tx-tcshop-pi1 input.invoice_email").keyup(function(){
		var $this = $(this);
		if($(this).val() != invoice_email) {
			showHideMessageNewAccount($this, "show");
		}
		else {
			showHideMessageNewAccount($this, "hide");
		}
	});
	
	
	function showHideMessageNewAccount($this, mode) {
		if(mode == "show") {
			$this.parent().siblings(".new_account_container").slideDown();
		}
		else {
			$this.parent().siblings(".new_account_container").find("input#newaccount").attr("checked","");
			$this.parent().siblings(".new_account_container").slideUp();
		}
	}
	
	/** Single product view unit prices **/
	if($(".tx-tcshop-pi1 .addToBasket_price label.units").length) {
		var val = $(".tx-tcshop-pi1 .addToBasket_price label.units:eq(0) input")
			.attr("checked", "checked")
			.attr("id");
		$(".tx-tcshop-pi1 form #productId").val(val.substr(2));
		$(".tx-tcshop-pi1 .priceunits > div:not(." + val + ")").css("display","none");

		$(".tx-tcshop-pi1 .addToBasket_price label.units input").click(function() {
			var val = $(this).attr("id");
			$(".tx-tcshop-pi1 form #productId").val(val.substr(2));
			$(".tx-tcshop-pi1 .priceunits > div:not(." + val + ")").css("display","none");
			$(".tx-tcshop-pi1 .priceunits > div." + val).css("display","block");
		});
	}
		
});

