<!--
function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

function noAlpha(obj){
	reg = /[^0-9.,]/g;
	obj.value =  obj.value.replace(reg,"");
 }


function MM_openBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='- '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='- '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('Attenzione, si sono verificati i seguenti errori:\t\t\t\t\t\n\n'+s);
  document.MM_returnValue = false;
  } else {
  document.MM_returnValue = true;
  }
}

function YY_checkform_MMPLUS() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform_MMPLUS.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='- '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='- '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('Attenzione, si sono verificati i seguenti errori:\t\t\t\t\t\n\n'+s);
  document.MMPLUS_returnValue = false;
  //UploadProgress.close();
  } else {
  document.MMPLUS_returnValue = true;
  }
}
//-->

<!--

function ControllaCF(cf)
{
	var validi, i, s, set1, set2, setpari, setdisp;
	if( cf == '' )  return '';
	cf = cf.toUpperCase();
	if( cf.length != 16 )
		return "La lunghezza del codice fiscale non è\n"
		+"corretta: il codice fiscale dovrebbe essere lungo\n"
		+"esattamente 16 caratteri.\n";
	validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for( i = 0; i < 16; i++ ){
		if( validi.indexOf( cf.charAt(i) ) == -1 )
			return "Il codice fiscale contiene un carattere non valido `" +
				cf.charAt(i) +
				"'.\nI caratteri validi sono le lettere e le cifre.\n";
	}
	set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
	s = 0;
	for( i = 1; i <= 13; i += 2 )
		s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	for( i = 0; i <= 14; i += 2 )
		s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
		return "Il codice fiscale non è corretto:\n"+
			"il codice di controllo non corrisponde.\n";
	return "";
}

function checkOra(field)
{
	var myVal = field.value;
	if (myVal != null)
	{
		if (myVal.length ==3 && myVal.charAt(2) != ":")
		{
			myVal = myVal.charAt(0) + myVal.charAt(1) + ":" + myVal.charAt(2);
			field.value = myVal;
		}
		return;
	}
};


function ControllaPIVA(pi)
{
	if( pi == '' )  return '';
	if( pi.length != 11 )
		return "La lunghezza della partita IVA non è\n" +
			"corretta: la partita IVA dovrebbe essere lunga\n" +
			"esattamente 11 caratteri.\n";
	validi = "0123456789";
	for( i = 0; i < 11; i++ ){
		if( validi.indexOf( pi.charAt(i) ) == -1 )
			return "La partita IVA contiene un carattere non valido `" +
				pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";
	}
	s = 0;
	for( i = 0; i <= 9; i += 2 )
		s += pi.charCodeAt(i) - '0'.charCodeAt(0);
	for( i = 1; i <= 9; i += 2 ){
		c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
		if( c > 9 )  c = c - 9;
		s += c;
	}
	if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
		return "La partita IVA non è valida:\n" +
			"il codice di controllo non corrisponde.\n";
	return '';
}


function verifica(formfield)
{	
	cod = formfield.value;
	//cod = document.form1.cod.value;
	//document.form1.cod.focus();
	formfield.focus();
	if( cod == '' )
		err = "hai lasciato in bianco il campo!\n";
	else if( cod.length == 16 )
		err = ControllaCF(cod);
	else if( cod.length == 11 )
		err = ControllaPIVA(cod);
	else
		err = "Il codice introdotto non è valido:\n\n" +
			"  - un codice fiscale deve essere lungo 16 caratteri;\n\n" +
			"  - una partita IVA deve essere lunga 11 caratteri.\n";

	if( err > '' )
		{
			//document.MM_returnValue = false;
			alert("Codice Fiscale / P.IVA non valido.\n\n" + err + "\nCorreggi e riprova!");
			document.MM_returnValue = false;
		}

}

function ConfermaDati()
{	
	if (document.MM_returnValue)
		{
			if (confirm('Confermi i dati inseriti?'))
			{
				document.MM_returnValue = '';
			}
			else
			{
				document.MM_returnValue= false;
			}
		}
		
		
}

// -->
<!-- Begin
var Nome = "";
var Cognome = "";
//var Email = "";
//var Azienda = "";
var Indirizzo = "";
//var ShipAddress2 = "";
var Citta = "";
var Prov = "";
//var ShipStateIndex = 0;
var CAP = "";
//var ShipConfirm = 0;

function InitSaveVariables(form) {
NomeSpedizione = form.NomeSpedizione.value;
//CognomeCons = form.CognomeCons.value;
//ShipEmail = form.ShipEmail.value;
//AziendaCons = form.AziendaCons.value;
ShipIndirizzo = form.ShipIndirizzo.value;
//ShipAddress2 = form.ShipAddress2.value;
ShipCitta = form.ShipCitta.value;
ShipCAP = form.ShipCAP.value;
//ShipStateIndex = form.ShipState.selectedIndex;
ShipProv = form.ShipProv.value;
//ShipConfirm = form.ShipConfirm.checked;
}

function ShipToBillPerson(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.NomeSpedizione.value = form.Cognome.value + " " + form.Nome.value;
//form.CognomeCons.value = form.Cognome.value;
//form.AziendaCons.value = form.Azienda.value;
form.ShipIndirizzo.value = form.Indirizzo.value;
form.ShipCitta.value = form.Citta.value;
form.ShipCAP.value = form.CAP.value;
form.ShipProv.value = form.Prov.value;
}
else {
form.NomeSpedizione.value = NomeSpedizione;
//form.NomeCons.value = NomeCons;
//form.CognomeCons.value = CognomeCons;
//form.AziendaCons.value = AziendaCons;
form.ShipIndirizzo.value = ShipIndirizzo;
form.ShipCitta.value = ShipCitta;
form.ShipCAP.value = ShipCAP;       
form.ShipProv.value = ShipProv;
   }
}
//  End -->
<!-- Begin genera random password
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
latterNumber, latterLower, latterUpper, latterOther) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
}
return rc;
}
// End -->
<!-- Begin controllo lunghezza campo
function CheckFieldLength(FormField,MinLength,Messaggio) {
	var element = document.getElementById (FormField);
	if (element.value.length < MinLength)
	{
		alert(Messaggio);
		element.focus();
		document.MM_returnValue = false;
	}

}
// End -->

function isChecked(strField,messaggio){
 if (!strField.length) 
 {	document.CB_returnValue = strField.checked;
	 return; //strField.checked; // not a group
 }
 for(var i = 0; i < strField.length; i++){
      if(strField[i].checked) 
	  {
		  document.CB_returnValue = true;
		  return; // true; // yes one was ticked
	  }
  }
  alert(messaggio);
  document.CB_returnValue = false;
  //return false;
}

function checkAereiDaModello(strField,strCompleta){
	if(strCompleta == '') { 
		if (!strField.length) 
		 {	
			strField.checked = false;
		 }
		 else
		 {
			 for(var i = 0; i < strField.length; i++){
				  strField[i].checked = false;
			  }
			 }
		return;
		}
	//controllo se non è array
	 if (!strField.length) 
	 {	
		strField.checked = false;
		if(strCompleta.indexOf(strField.value) > 0) 
		  {
			  strField.checked = true;
			  return;
		  }		
	 }
	 //li deseleziono tutti
	  for(var i = 0; i < strField.length; i++){
			  strField[i].checked = false;
		  }
	  //verifico e check quelli del modello
	 for(var i = 0; i < strField.length; i++){
		  if(strCompleta.indexOf(strField[i].value) > 0) 
		  {
			  strField[i].checked = true;
		  }
	  }
}
//function isChecked(strField,messaggio) {
//	
//  if (!strField.length && strField.checked) {
//    return true;
//  }
//  for (var i = 0; i < e.length; i++) {
//    if (e[i].checked) {
//      return true;
//    }
//  }
//  alert('You must select an item to display.');
//  return false;
//}

function VerifySameField(field, field1,minLength,mess ) { 
if (field.value.length >= minLength) 
{
	if (field.value == field1.value) 
		{
			document.MM_returnValue = true;
			return;
		}
		else
		{
			alert(mess);
			document.MM_returnValue = false;
			return;
		}
}
else
alert(mess);
document.MM_returnValue = false;
return;
	
}


