$(document).ready(function(){

	$("input[numonly='true']").keypress(function(e) { if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) return false; });

	$("div.tablinks a").click(function(){

		$(this).parent().find("a").removeClass("active");
		$(this).addClass("active");

		return false;
	});

	$("div.quickview a.close").click(function(){

		$(this).parent().hide();
		$(this).parents("div.product").removeClass("active");
		$(this).parents("div.window").removeClass("active");
		return false;

	});

	$("div.product a.moreinfo").click(function(){

		var active = $(this).parent().hasClass("active");
		if (!active) {

			
			$("div.product div.quickview").hide();
			$("div.product").removeClass("active");
			$("div.window").removeClass("active");
			
			$(this).parent().find("div.quickview").show();
			$(this).parent().addClass("active");
			$(this).parents("div.window").addClass("active");

		}
		return false;

	});

	$("form a[rel='submitform']").click(function(){
		$(this).parents("form").submit();
		return false;
	});

	
	
	var validationSettings = {
	errorDiv: 'div#error',
	loopTypes: 'input,select,textarea',
	appendErrorBesideField: false,
	confirmName: ['conf','confirm']
	}
	
	$("form#loginform").validate(validationSettings);

	$("form#regStep1").validate(validationSettings);
	$("form#regStep2").validate(validationSettings);
	$("form#regStep3").validate(validationSettings);
	//$("form#regStep4").validate(validationSettings);
	
	$("form#accountStep1").validate(validationSettings);
	$("form#accountStep2").validate(validationSettings);
	$("form#accountStep3").validate(validationSettings);
	//$("form#accountStep4").validate(validationSettings);

	$("form#purchaseform").validate(validationSettings);
	$("form#forgotpassword").validate(validationSettings);

});

function showtab (obj) {
	$("div.tabcontent.show").hide().removeClass("show");
	$(obj).show().addClass("show");
}

function quickview (obj) {
	$("div#quickview div.slab").hide();
	$(obj).show();
}

function togglePObox (obj) {

	var o1 = $(obj);
	var o2 = o1.nextAll("input[name='ponumber']");
	var bChecked = o1.attr("checked");
	var bDisabled = o2.attr("disabled");
	var url = '/_customelements/_actions/savePO.php?checked='+bChecked;

	$.get(url);
	
	var bDisabled_new = (bDisabled)? false:true;
	o2.attr("disabled",bDisabled_new);

}
