
// LE FUNZIONI MM_ SONO QUELLE DI DEFAULT MESSA DA DREAMWEAVER E PER ORA NON SONO UTILIZZATE

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


// opre una popup, NON  + USATO
function info(url)
{
var top=0
var left=0
var width=420
var height=437
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(url, 'ZED', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// opre una popup
function pop(url)
	{
	 nuova=open(url,'PREVIEW','toolbar=no,resize=yes,scrollbars=yes,width=420,height=437,left=0,top=0');
	}
	
 

// VERIFICA SE CELLULARE e' VALIDO
function validateTEL(tel) 
	{ 
	 var PREFISSI =new Array("02","06");
         if(tel.length > 11 || tel.length < 9) return false;
         if(isNaN(tel)) return false;
         if(tel.substring(0,1)=="+") return false;
         if(tel.substring(0,1)=="0") return false;
         if(tel=="3351234567") return false;
         if(tel=="123456789") return false;
         if(tel=="39347880673") return false;

         for (i = 0; i < PREFISSI.length; i++)
		   {
		   if(PREFISSI[i]==tel.substring(0,2)) 
		   	{
		   	alert("Il prefisso "+tel.substring(0,2)+" non deve essere inerito");
		   	return false;
		   	}
		  }
	return true;
	}

// SOLO PER ALICE
function iscrivitiALICE() 
	{ 

	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	else
		{
		document.form1.submit();	
		}
	}

// controllo client x pagina MAGLIETTE
function iscrivitiMAGLIETTE(tel) 
	{ 

	if(document.form1.NOME.value=="" || document.form1.NOME.value.indexOf(' ')>0)
		{
		alert("Devi inserire il nome senza spazi");
		return 0;
		}
	if(document.form1.NUMERO.value=="" ||  !IsNumeric(document.form1.NUMERO.value))
		{
		alert("Devi inserire il numero della maglia");
		return 0;
		}
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// controllo client x pagina MAGLIETTE
function iscrivitiMAGLIETTECHECKBOX(tel) 
	{ 
	if(document.form1.conditions.checked==false)
		{
		alert("Devi approvare le condizioni per proseguire");
		return 0;
		}
	if(document.form1.NOME.value=="" || document.form1.NOME.value.indexOf(' ')>0)
		{
		alert("Devi inserire il nome senza spazi");
		return 0;
		}
	if(document.form1.NUMERO.value=="" ||  !IsNumeric(document.form1.NUMERO.value))
		{
		alert("Devi inserire il numero della maglia");
		return 0;
		}
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// SE SONO STATI INSERITI TUTTI I CAMPI PASSA ALLA PAGINA OK.PHP
function iscriviti(tel) 
	{ 
	if(document.form1.conditions.checked==false)
		{
		alert("Devi approvare le condizioni per proseguire");
		return 0;
		}
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// SE SONO STATI INSERITI TUTTI I CAMPI PASSA ALLA PAGINA OK.PHP
function iscrivitiCHECKBOX(tel) 
	{ 
	if(document.form1.conditions.checked==false)
		{
		alert("Devi approvare le condizioni per proseguire");
		return 0;
		}
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}


// SE SONO STATI INSERITI TUTTI I CAMPI PASSA ALLA PAGINA OK.PHP - CASO SENZA OPERATORE
function iscriviti_nooperatore(tel) 
	{ 
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// SE SONO STATI INSERITI TUTTI I CAMPI PASSA ALLA PAGINA OK.PHP - CASO SENZA PRODOTTO
function iscriviti_OK(tel) 
	{ 
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// SERVE PER CHECCARE LA CKECKBOX ANCHE SE SI CLICCA SU UN LINK
function prodotto()
	{
	
	for (i = 0; i < document.form1.PROD.length; i++)
		{
		
		if(document.form1.FREE.value==document.form1.PROD[i].value) document.form1.PROD[i].checked=true;
		}  
	} 

// USATO NELLA PAGINA OK.PHP PER CONTROLLARE SE LA PASSWORD E' STATA INSERITA
function iscriviti2() 
	{ 
	if(document.form1.PASS.value=="")
		{
		alert("Inserisci la password che ti abbiamo inviato sul cellulare");
		}
	else
		{
		document.form1.submit();	
		}
	}

// USATO NELLA PAGINA OK.PHP PER CONTROLLARE SE LA PASSWORD E' STATA INSERITA con CHECKBOX
function iscriviti2CHECKBOX() 
	{ 
	if(document.form1.conditions.checked==false)
		{
		alert("Devi approvare le condizioni per proseguire");
		return 0;
		}
	if(document.form1.PASS.value=="")
		{
		alert("Inserisci la password che ti abbiamo inviato sul cellulare");
		}
	else
		{
		document.form1.submit();	
		}
	}
	
	


// USATO SOLO PER CAMPAGNA http://web.zed.it/PARTNER/AFFINION/ 
// PER VERIFICARE SE IL CODICE PROMOZIONE E' STATO INSERITO
function iscrivitiAFFINION(tel) 
	{ 
	if(document.form1.CODICE.value=="")
		{
		alert("Devi inserire il codice promozione");
		return 0;
		}
	if(document.form1.FREE.value=="")
		{
		alert("Devi selezionare un prodotto");
		return 0;
		}
	if(document.form1.OP.value=="")
		{
		alert("Seleziona l'operatore dalla lista");
		return 0;
		}
	if(!validateTEL(document.form1.CELL.value))
		{
		alert("Il cellulare non e' valido");
		}
	else
		{
		document.form1.submit();	
		}
	}

// IS NUMERIC ?
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
