// +------------------------------------------------------------+
// | dfxUtil.js         v. 2.0 for Dynameeting                   |
// +------------------------------------------------------------+
// | Last Modified:     04/02/2006                              |
// | Web Site:          http://www.dfx.it                       |
// | EMail:             dfx@dfx.it                              |
// +------------------------------------------------------------+
// | dfx s.r.l.                                                 |
// | Via Sele, 20 - APRILIA - Italy                             |
// | Copyright 2005  All Rights Reserved.                       |
// +------------------------------------------------------------+

function setMsgPagam(){
  try{
	  divBonifico.style.display = "none";
	  divAssegno.style.display = "none";
	  if (document.forms[0].cmbModalPag.value == 57){
	  	divBonifico.style.display = "inline";
	  }
	  if (document.forms[0].cmbModalPag.value == 95){
	  	divAssegno.style.display = "inline";
	  }
	}catch(e){}
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+'.'+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + ',' + cents);
}

function ckPIVA(PIVA){
	if ((PIVA.length < 11) && (PIVA.length > 0)){ 
		alert ("La partita IVA non è corretta!")
		document.forms[0].txtPIVA.value= ""
		document.forms[0].txtPIVA.focus()
	}
}

function ckNCC(NCC){
	if (NCC.length == 0){
		return 0;
	}
	if (document.forms[0].cmbCC.value == 4492){
		if ((NCC.length < 14) || isNaN(NCC)){ 
			alert ("The credit card number is incorrect!");
			document.forms[0].txtNCartaCredito.value= "";
			document.forms[0].txtNCartaCredito.focus();
			return 0;
		}
	}
	if (document.forms[0].cmbCC.value == 4490){
		if ((NCC.length < 15) || isNaN(NCC)){ 
			alert ("The credit card number is incorrect!");
			document.forms[0].txtNCartaCredito.value= "";
			document.forms[0].txtNCartaCredito.focus();
			return 0;
		}
	}
	if ((document.forms[0].cmbCC.value != 4490) && (document.forms[0].cmbCC.value != 4492)){
		if ((NCC.length < 16) || isNaN(NCC)){ 
			alert ("The credit card number is incorrect!");
			document.forms[0].txtNCartaCredito.value= "";
			document.forms[0].txtNCartaCredito.focus();
			return 0;
		}
	}
}

function ckScadCC(ScadCC){
	if (ScadCC.length == 0){
		return 0;
	}
	if ((ScadCC.length < 4) || isNaN(ScadCC)){ 
		alert ("Expiration date is incorrect!");
		document.forms[0].txtScadCartaCredito.value= "";
		document.forms[0].txtScadCartaCredito.focus();
		return 0;
	}
	var L;
	var R;
	L = parseInt(ScadCC.substr(0,2));
	R = parseInt(ScadCC.substr(2,2));
	if ((L > 12) || (R < 5) || (R > 20)){
		alert("Expiration date is incorrect!");
		document.forms[0].txtScadCartaCredito.value= "";
		document.forms[0].txtScadCartaCredito.focus();
		return 0;
	}
}
