vTesti = new Object;

/*
Abbreviazione per document.getElementById(nomediv)
*/
function GID(id){
	return document.getElementById(id);
}

function PopUpPagina(paginarichiesta)
{

	var winLocation, winName, winParam, winObj;
	var winPos, winPosTop, winPosLeft, winWidth, winHeight;
	
	winWidth = 1000;
	winHeight = 580;
	
	winPosTop = (screen.height / 2) - winHeight / 2;
	winPosLeft = (screen.width / 2) - winWidth / 2;
	winPos = ',top=' + winPosTop + ',left=' + winPosLeft;
	
	winLocation = paginarichiesta;
	winName = 'popUp';

	winParam = 'status=0,toolbars=0,menubar=0,history=0,resizable=1,width=' + winWidth + ',height=' + winHeight + winPos;
	winObj = window.open(winLocation, winName, winParam);
	winObj.focus();
}

function PopUpZoom(paginarichiesta)
{

	var winLocation, winName, winParam, winObj;
	var winPos, winPosTop, winPosLeft, winWidth, winHeight;
	
	winWidth = 750;
	winHeight = 650;
	
	winPosTop = (screen.height / 2) - winHeight / 2;
	winPosTop=20;
	winPosLeft = (screen.width / 2) - winWidth / 2;
	winPos = ',top=' + winPosTop + ',left=' + winPosLeft;
	
	winLocation = paginarichiesta;
	winName = 'popUpZoom';

	winParam = 'status=0,toolbars=0,menubar=0,history=0,resizable=1,width=' + winWidth + ',height=' + winHeight + winPos;
	winObj = window.open(winLocation, winName, winParam);
	winObj.focus();
}

function CreaVettore(lang)
{
	if(lang=="en"){
		vTestorichiesta="Devi selezionare un Tipo Richiesta";
		vTesti[0]="Il campo Azienda é obbligatorio";
		vTesti[1]="Il campo Nome é obbligatorio";
		vTesti[2]="Il campo Cognome é obbligatorio";
		vTesti[3]="Il campo Telefono è obbligatorio";
		vTestomail="Devi specificare un Indirizzo E-mail valido!";
		vTesti[4]="Inserisci la Richiesta";
		vTestoprivacy="Devi accettare il trattamento dei Dati Personali per effettuare un'iscrizione!";
	}
	else{
		vTestorichiesta="Devi selezionare un Tipo Richiesta";
		vTesti[0]="Il campo Azienda é obbligatorio";
		vTesti[1]="Il campo Nome é obbligatorio";
		vTesti[2]="Il campo Cognome é obbligatorio";
		vTesti[3]="Il campo Telefono è obbligatorio";
		vTestomail="Devi specificare un Indirizzo E-mail valido!";
		vTesti[4]="Inserisci la Richiesta";
		vTestoprivacy="Devi accettare il trattamento dei Dati Personali per effettuare un'iscrizione!";
	
	
	}
}


function ControllaDati(lang){
	CreaVettore(lang);

	var lung=null;
	var stringa=null;
	
	
	/*if(document.SuperForm.tipo.value=='remove'){
		EmailAddr = document.SuperForm.removemail.value;
		if (Filtro.test(EmailAddr))
			return true;
		else{
			alert(vTesti[11]);
			document.SuperForm.removemail.focus();
			return false;
		}
	}*/
	
	var id=new Array();

	id[0]='azienda';
	id[1]='nome';
	id[2]='cognome';
	id[3]='telefono';
	id[4]='richiesta';
	
	
	
	if (document.SuperForm.tipo.value=='new')
	{
	
	   if (document.SuperForm.acce[0].checked==false)
	   {
	      alert(vTestoprivacy);
	      document.SuperForm.acce[0].focus();
	      return false;  
	   }
	   
	   //tipo_richiesta !=0
	   if (GID('tipo_richiesta').value=="0")
		      { 
			alert(vTestorichiesta);
			GID('tipo_richiesta').focus();
			return false; 
	              }
	   
	   
	   
	   	              //Controlla Correttezza mail
	   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	   EmailAddr = document.SuperForm.mail.value;
	   if (Filtro.test(EmailAddr))
	      {  }
	   else
	      {
	      alert(vTestomail);
	      document.SuperForm.mail.focus();
	      return false;
	      }
	
	
	
	
	for (i=0;i<id.length;i++){
	
	   stringa=GID(id[i]).value;
	   lung=stringa.length;
	   if (lung<=0)
		      { 
		     
			alert(vTesti[i]);
			GID(id[i]).focus();
			return false; 
			
	              }
	}
	   
	              

		
	}
	
	return true;

}




/*
Funzione per l'apertura di una PopUp dimensionata
*/

function PrevFoto(img){
    foto1= new Image();
    foto1.src=(img);
    Controlla(img);
    }

function Controlla(img){
    if((foto1.width!=0)&&(foto1.height!=0)){
        viewFoto(img);
        }
    else{
        funzione="Controlla('"+img+"')";
        intervallo=setTimeout(funzione,100);
    }
}

function viewFoto(img){

 var winLocation, winName, winParam, winObj;
 var winPos, winPosTop, winPosLeft, winWidth, winHeight;

 winWidth=foto1.width+20;
 winHeight=foto1.height+25;

 winPosTop = (screen.height / 2) - winHeight / 2;
 winPosLeft = (screen.width / 2) - winWidth / 2;

 winPos = ',top=' + winPosTop + ',left=' + winPosLeft;
 winLocation = "zoom.asp?img="+img;
 winName = 'popUp';
 winParam = 'status=0,toolbars=0,menubar=0,history=0,width=' + winWidth + ',height=' + winHeight + winPos;

 winObj = window.open(winLocation, winName, winParam);

}
//////////////////////////////////////////
//     CONTROLLA DATI PER CATALOGO	//
//////////////////////////////////////////
function CreaVettore2(lang)
{
	if(lang=="en"){
	
	
		vTesti[0]="Check the written name!";
		vTesti[1]="Check the written surname!";
		vTestomail="Check the written E-Mail address!";
		attendere="Sending mail...";
	
	
	}
	else{


		vTesti[0]="Il campo Nome é obbligatorio";
		vTesti[1]="Il campo Cognome é obbligatorio";
		vTestomail="Devi specificare un Indirizzo E-mail valido al quale verra inoltrato il catalogo scelto!";
		attendere="Attendere l\'invio della mail...";
	
	
	
	}
}

function ControllaDati2(lang){
	CreaVettore2(lang);

	var lung=null;
	var stringa=null;
	
	
	/*if(document.SuperForm.tipo.value=='remove'){
		EmailAddr = document.SuperForm.removemail.value;
		if (Filtro.test(EmailAddr))
			return true;
		else{
			alert(vTesti[11]);
			document.SuperForm.removemail.focus();
			return false;
		}
	}*/
	
	var id=new Array();


	id[0]='nome';
	id[1]='cognome';



	// DOWNLOAD CATALOGO
	for (i=0;i<id.length;i++){
		stringa=GID(id[i]).value;
		lung=stringa.length;
		if (lung<=0){ 
			alert(vTesti[i]);
			GID(id[i]).focus();
			return false; 
		}
	}

	//Controlla Correttezza mail
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	EmailAddr = document.SuperForm2.mail.value;
	if ( !Filtro.test(EmailAddr) ){
	      alert(vTestomail);
	      document.SuperForm2.mail.focus();
	      return false;
      	}
      	$('#btn_invia').val(attendere);
      	$('#loading').show();
      	$('#btn_invia').attr('disabled','disabled');
	return true;
}

