/*
	Fonctions de manipulation et de vérifications des formulaires de gestion de client
*/


function terms(language){
var winopts = "toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=yes,width=870,height=500,copyhistory=0"
smallwindow=window.open('terms.asp?content=conditions&lang='+language,'algvoorwaarden',winopts);
smallwindow.focus();
}


function CheckShippingChoice() {
	var sError = "";
	
	if($("#shipping_destination").val() == 0) {
		sError += TradMes("Vous n'avez pas sélectionné de mode de livraison") + ".<br />";
	}

	if(sError.length > 6) {
		sError = sError.substr(0, sError.length - 6);
		$("#return_message").html(sError).show("slow");
		return false;
	} else {
		return true;
	}
}

$(document).ready(function(){
	if($("#return_message").html() != null) {
		if($("#return_message").html().length <= 15) {
			$("#return_message").hide();
		} else {
			$("#return_message").show("slow");
		};
	}
	
	$("input:text[id^='qty']").change(function () {
		if(isNaN($("input:text[id^='qty']").val()) || $("input:text[id^='qty']").val().trim().length <= 0) {
			$("#return_message").html(TradMes("Vous devez encoder un chiffre") + ".").show("slow");
		}
	});
	
	$("#basketadd_link").click(function () {
		if(isNaN($("input:text[id^='qty']").val()) || $("input:text[id^='qty']").val().trim().length <= 0) {
			$("#return_message").html(TradMes("Vous devez encoder un chiffre") + ".").show("slow");
			return false;
		} else {
			$("#basketadd").submit();
			return true;
		}
	});

	$("#basket_link").click(function () {
		if(isNaN($("input:text[id^='qty']").val()) || $("input:text[id^='qty']").val().trim().length <= 0) {
			$("#return_message").html(TradMes("Vous devez encoder un chiffre") + ".").show("slow");
			return false;
		} else {
			$("#basket").submit();
			return true;
		}
	});

	$("#basketadd").submit(function () {
		if(isNaN($("input:text[id^='qty']").val()) || $("input:text[id^='qty']").val().trim().length <= 0) {
			$("#return_message").html(TradMes("Vous devez encoder un chiffre") + ".").show("slow");
			return false;
		} else {
			return true;
		}
	});
	
	// validation du formulaire
	$("#shipping_destination_choice").submit(function () {
		var sError = "";
		
		if($("#shipping_destination").val() == 0) {
			sError += TradMes("Vous n'avez pas sélectionné de mode de livraison") + ".<br />";
		}

		if(sError.length > 6) {
			sError = sError.substr(0, sError.length - 6);
			$("#return_message").html(sError).show("slow");
			return false;
		} else {
			return true;
		}
	});	
});





