// su carrello
function MM_closeBrWindow() 
{ 
	CartWin=window.close();
}
function menu_img_act(imgName, moduleID) 
{
	if (selectedModule != moduleID)
		document[imgName].src = eval(moduleID + "_image_o.src");
}
function menu_img_inact(imgName, moduleID) 
{
	if (selectedModule != moduleID) 
		document[imgName].src = eval(moduleID + "_image_n.src");
}
function closecarrello() {
//$("#cpanel").slideToggle("slow");
if ($(".carrello").hasClass("cactive")) { 
        $("#cpanel").slideToggle("slow");
        $(".carrello").removeClass("cactive")
    } 
}


function openCart() { //v2.0
  CartWin=window.open('ec-carrello.asp','Cart','height=480,width=550,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,top=1,left=1');
  CartWin.focus();
}

function submitForm(value, moduleID)
{
	selectedModule = moduleID;
//	document.carrello.IMGROLL.name  = imgName;
//	document.carrello.IMGROLL.value = value;
	document.carrello.mode.value  = moduleID;
	document.carrello.submit();
}
function checkout(value, moduleID)
{
	selectedModule = moduleID;
	document.carrello.action = "ec-carrello.asp";
//	document.carrello.IMGROLL.name  = imgName;
//	document.carrello.IMGROLL.value = value;
	document.carrello.mode.value  = moduleID;
	document.carrello.submit();
}

//su cliente
function trim(mystr){
	var i = 0;
	mystr=mystr+" "
	while (mystr.charAt(i)==" ")  {i++;}
	mystr=mystr.substring(i,mystr.length)
	i = mystr.length-1
	while (mystr.charAt(i)==" ")  {i--;}
	mystr=mystr.substring(0,i+1)
return (mystr)
}
function submitFormChk(value, imgName, moduleID)
{
	var pass = true;
	var cifre=" 1234567890";

	document.addcustomer.Nome.value=trim(document.addcustomer.Nome.value);
	document.addcustomer.Cognome.value=trim(document.addcustomer.Cognome.value);
	document.addcustomer.Email.value=trim(document.addcustomer.Email.value);
	document.addcustomer.Indirizzo.value=trim(document.addcustomer.Indirizzo.value);
	document.addcustomer.Comune.value=trim(document.addcustomer.Comune.value);
	document.addcustomer.Cap.value=trim(document.addcustomer.Cap.value);
	document.addcustomer.Telefono.value=trim(document.addcustomer.Telefono.value);
	document.addcustomer.Fax.value=trim(document.addcustomer.Fax.value);

	do {
		if (document.addcustomer.Nome.value == "")
          	{
           		alert("Inserire il Nome");
           		break;
          	}
		if (document.addcustomer.Cognome.value == "")
          	{
           		alert("Inserire il Cognome");
           		break;
          	}
		var email=document.addcustomer.Email.value;
		if (email.length > 0) 
		{
        	part1 = String(email+'@').split('@');
        	part2 = String(part1[1]+'.').split('.');
		if( part1[0].length < 1 ) {pass=false}
		if( part2[0].length < 1 ) {pass=false}
		if( part2[1].length < 1 ) {pass=false}
		if (!pass)
		  {
			alert("Controllare l'indirizzo E-Mail");
			break;
		  }
		}
		if (document.addcustomer.Indirizzo.value == "")
          	{
           		alert("Inserire l'Indirizzo");
           		break;
          	}
		if (document.addcustomer.Comune.value == "")
          	{
           		alert("Inserire il Comune");
           		break;
          	}
		if (document.addcustomer.Provincia.selectedIndex == 0)
          	{
           		alert("Definire la Provincia");
           		break;
          	}
		if (document.addcustomer.Cap.value == "")
          	{
           		alert("Inserire il CAP");
           		break;
          	}
		var cap=document.addcustomer.Cap.value;
		for (n=0;n<cap.length;n++)
		{
		  var cf=cap.substring(n,n+1);
		  if (cifre.indexOf(cf)<1) {pass = false}           
		}
		if (!pass||cap.length<5)
		{
			alert("Controllare il CAP");
           		break;
		}

       		if (document.addcustomer.Telefono.value == "")
          	{
           		alert("Inserire il numero di Telefono");
           		break;
          	}
		var telefono=document.addcustomer.Telefono.value;
		for (n=0;n<telefono.length;n++)
		{
		  var cf=telefono.substring(n,n+1);
		  if (cifre.indexOf(cf)<0) {pass = false}           
		}
		if (!pass||telefono.length<6)
		{
			alert("Controllare il numero di Telefono");
           		break;
		}
		var fax=document.addcustomer.Fax.value;
		if (fax.length > 0) 
		{
		for (n=0;n<fax.length;n++)
		{
		  var cf=fax.substring(n,n+1);
		  if (cifre.indexOf(cf)<0) {pass = false}           
		}
		if (!pass||fax.length<6)
		{
			alert("Controllare il numero di Fax");
           		break;
		}
		}

		var truthBeTold = window.confirm("Conferma dei dati immessi:\n\nOK per Procedere. Annulla per modificare.");
		if (truthBeTold) 
		{
      			selectedModule = moduleID;
			document.addcustomer.IMGROLL.name = imgName;
			document.addcustomer.IMGROLL.value = value;
			document.addcustomer.submit();
		}
	
	} while (false);	
}
// su regoracc
function submitForm1(value, imgName, moduleID)
{
	selectedModule = moduleID;
	document.customer.IMGROLL.name = imgName;
	document.customer.IMGROLL.value = value;
	document.customer.submit();
}
function submitForm2(value, imgName, moduleID)
{
	var pass = true;

	do {
		if (document.finduser.UserName.value == "")
          	{
           		alert("Inserire il Nome Utente");
           		break;
          	}
		if (document.finduser.Password.value == "")
          	{
           		alert("Inserire la Password");
           		break;
          	}


	selectedModule = moduleID;
	document.finduser.IMGROLL.name = imgName;
	document.finduser.IMGROLL.value = value;
	document.finduser.submit();
	} while (false);	
}
// su checkout
function Ordina()
{
	if ((document.mailer.cviaggio.checked)==0)
	  {
	  alert ('Leggere e accettare le condizioni di viaggio')
	  }
	else
	  {
	  document.mailer.submit();
	  }
}
// su username
function submitForm3Chk(value, imgName, moduleID)
{
	var pass = true;

	document.registra.UserName.value=trim(document.registra.UserName.value);
	document.registra.Password.value=trim(document.registra.Password.value);
	document.registra.Passconf.value=trim(document.registra.Passconf.value);

	do {
		if (document.registra.UserName.value == "")
          	{
           		alert("Inserire il Nome Utente");
           		break;
          	}
		if (document.registra.Password.value == "")
          	{
           		alert("Inserire la Password");
           		break;
          	}
		if (document.registra.Passconf.value == "")
          	{
           		alert("Inserire la Password ripetuta");
           		break;
          	}
		var username=document.registra.UserName.value;
		if( username.length < 6 || username.length > 12 ) {pass=false}
		if (!pass)
		  {
			alert("Controllare la lunghezza del Nome Utente");
			break;
		  }
		var password=document.registra.Password.value;
		if( password.length < 6  || password.length > 8 ) {pass=false}
		if (!pass)
		  {
			alert("Controllare la lunghezza della Password");
			break;
		  }

		var passconf=document.registra.Passconf.value;
		if( password!=passconf ) {pass=false}
		if (!pass)
		  {
			alert("Errore nel confronto della Password");
			break;
		  }

		var truthBeTold = window.confirm("Prendi nota del \"Nome Utente\" e \"Password\"\n\n       Conferma la registrazione")
		if (truthBeTold) 
		{
      			selectedModule = moduleID;
			document.registra.IMGROLL.name = imgName;
			document.registra.IMGROLL.value = value;
			document.registra.submit();
		}
	
	} while (false);	
}






