//' 1.06 / 2003-09-10 / DB => modif des calculs de la page DEST
//' 1.05 / 2002-10-10 / PL => Utilisation de 'checkUserPIN'
//' 1.04 / 2002-09-18 / RS => Ajout code parrainage
//' 1.03 / 2002-02-19 / CB => Intégration vxx
//' 1.02 / 2001-12-29 / CB => Support de 'BCurrency_convert' dans 'amountToMn' pour les tarifs différents
//'														de la monnaie de paiement.
//' 1.01 / 2001-12-13 / CB => Suppression 'vLOC_check_form_12' déjà dans check_form.js
//'														Prise en compte si aucun paiement choisi
//' 1.00 / 2001-xx-xx / CB => Création

function budgetOnLoad() {
	calculer();
}
function submit_form_show_alldest() {
	document.form_buy.action= 'show_alldest.asp';
	document.form_buy.submit();	
}

//'Fonction vérification si le compte n'existe pas déjà
function verify(){
	var vCli1 = document.form_buy.cli_1.value;
	var vCli2 = document.form_buy.cli_2.value;
	var vCli3 = document.form_buy.cli_3.value;
	var vCli4 = document.form_buy.cli_4.value;
	var vCliUserPin = document.form_buy.cli_userPin.value;
	var vURL= document.form_buy.URL_VERIFY.value + '?partner=' + document.form_buy.partner.value+ '&cli_1='+vCli1+'&cli_2='+vCli2+'&cli_3='+vCli3+'&cli_4='+vCli4+'&cli_userPin='+vCliUserPin+'';
	window.open(vURL,'verify','scrollbars=no,width=250,height=200');
}
function submit_form_buy() {
	if (document.form_buy.cond_vente.checked == false) {
		alert('Debes aceptar las condiciones generales de venta\nantes de seguir comprando.');
		return;
	}
	if (checkPhone(document.form_buy.cli_1, 'Linea 1', 9)==false)	return;
	if (document.form_buy.cli_2.value!="" &&
		 checkPhone(document.form_buy.cli_2, 'Linea 2', 9)==false)	return;
	if (document.form_buy.cli_3.value!="" &&
		 checkPhone(document.form_buy.cli_3, 'Linea 3', 9)==false)	return;
	if (document.form_buy.cli_4.value!="" &&
		 checkPhone(document.form_buy.cli_4,	'Linea 4', 9)==false)	return;
	if (checkUserPIN(document.form_buy.cli_userPin, 'Código secreto', 4)==false) return;
	if (checkEMailField	(document.form_buy.email,	'EMail', 5)==false)	return;

	//'Extention interdite suite à fraude .ru
	var vDotPlace = document.form_buy.email.value.lastIndexOf(".", document.form_buy.email.value.length);
	var vCountry = document.form_buy.email.value.substring(vDotPlace+1, document.form_buy.email.value.length);
	vCountry = vCountry.toLowerCase();
	if (vCountry == "ru")
	{
		return;
	}


	//'if (checkCheckField(document.form_buy.email,	document.form_buy.email_check, 'EMail')==false)	return;

	var vIsCB= false;
	var vIsCK= false;
	var vIsTS= false;
	for (var i=0; i<document.form_buy.payment_mode.length; i++) {
		var vElem= document.form_buy.payment_mode[i];
		if (vElem.value=="mode_cb") vIsCB= vElem.checked;
		if (vElem.value=="mode_ck") vIsCK= vElem.checked;
		if (vElem.value=="mode_ts") vIsTS= vElem.checked;
	}

	if (vIsCB) {
		document.form_buy.action= "Buy/PayBox.asp";
		document.form_buy.paymentCurrency.value=document.form_buy.paymentCurrency_cb.value;
	} else	
	if (vIsCK) { 
		document.form_buy.action= "Buy/Check.asp";
		document.form_buy.paymentCurrency.value=document.form_buy.paymentCurrency_ck.value;
	} else	
	if (vIsTS) { 
		document.form_buy.action= "Buy/Transfer.asp";
		document.form_buy.paymentCurrency.value=document.form_buy.paymentCurrency_ts.value;
	} else {
		alert('Debes escoger una forma de pago\nantes de seguir comprando.');
		return;
	}
			
	//' Fixe la zone
	for (var i=0; i<document.form_buy.length; i++) {
		var vElem= document.form_buy[i];
		if (vElem.name=="PxDestEMinutes") {
			vZItem= vElem.selectedIndex>0?getZItemAtPos(vElem.selectedIndex):null;
			if (vZItem==null)
				document.form_buy.zoneName.value= ""
			else
				document.form_buy.zoneName.value= vZItem.zoneName;
		}
	}


	if (document.form_buy.discount.value>0)
		verify();
	else
		document.form_buy.submit();

}

