/* -- Adobe GoLive JavaScript Library */

function apriHelp(parIdHelp){
	window.open('/help.aspx?pciCodHlp=' + parIdHelp,'Help','toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=470,height=550');
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}

function chkRegForm(theForm, parPagina, parIdShptu){
//	arrCampi = [pqtNomeUtente, pqtEMail];
	switch(parPagina){
		case 1:
			if(!Trim(theForm.pqiIdShptu.value)){
				alert("Attenzione! E' necessario scegliere la Tipologia di Utente!!");
				theForm.pqiIdShptu.focus(); return false;
			}
			break;
		case 2:
			if(!Trim(theForm.pqtNome.value)){
				alert("Attenzione! E' necessario inserire il Nome!!");
				theForm.pqtNome.value = "";
				theForm.pqtNome.focus(); return false;
			}
			if(!Trim(theForm.pqtCognome.value)){
				alert("Attenzione! E' necessario inserire il Cognome!!");
				theForm.pqtCognome.value = "";
				theForm.pqtCognome.focus(); return false;
			}
			if(!Trim(theForm.pqtNomeUtente.value)){
				alert("Attenzione! E' necessario inserire il Nome Utente!!");
				theForm.pqtNomeUtente.value = "";
				theForm.pqtNomeUtente.focus(); return false;
			}
			if(!Trim(theForm.pqtEMail.value)){
				alert("Attenzione! E' necessario inserire un indirizzo eMail!!");
				theForm.pqtEMail.value = "";
				theForm.pqtEMail.focus(); return false;
			}
			if(parIdShptu == 1){
				if(!Trim(theForm.pqdDtNascitaG.value)){
					alert("Attenzione! E' necessario inserire il giorno di nascita!!");
					theForm.pqdDtNascitaG.value = "";
					theForm.pqdDtNascitaG.focus(); return false;
				}
				if(!Trim(theForm.pqdDtNascitaM.value)){
					alert("Attenzione! E' necessario inserire il mese di nascita!!");
					theForm.pqdDtNascitaM.value = "";
					theForm.pqdDtNascitaM.focus(); return false;
				}
				if(!Trim(theForm.pqdDtNascitaA.value)){
					alert("Attenzione! E' necessario inserire l'anno di nascita!!");
					theForm.pqdDtNascitaA.value = "";
					theForm.pqdDtNascitaA.focus(); return false;
				}
			}
			if(parIdShptu == 2){
				if(!Trim(theForm.pqtRagSoc.value)){
					alert("Attenzione! E' necessario inserire la Ragione Sociale!!");
					theForm.pqtRagSoc.value = "";
					theForm.pqtRagSoc.focus(); return false;
				}
				if(!Trim(theForm.pqtPIva.value)){
					alert("Attenzione! E' necessario inserire la Partita Iva!!");
					theForm.pqtPIva.value = "";
					theForm.pqtPIva.focus(); return false;
				}
				if(!Trim(theForm.pqtCFiscale.value)){
					alert("Attenzione! E' necessario inserire il Codice Fiscale!!");
					theForm.pqtCFiscale.value = "";
					theForm.pqtCFiscale.focus(); return false;
				}
			}
			if(!Trim(theForm.pqtIndirizzo.value)){
				alert("Attenzione! E' necessario inserire l'indirizzo!!");
				theForm.pqtIndirizzo.value = "";
				theForm.pqtIndirizzo.focus(); return false;
			}
			if(!Trim(theForm.pqtLocalita.value)){
				alert("Attenzione! E' necessario inserire la localita'!!");
				theForm.pqtLocalita.value = "";
				theForm.pqtLocalita.focus(); return false;
			}
			if(!Trim(theForm.pqtCap.value)){
				alert("Attenzione! E' necessario inserire il cap!!");
				theForm.pqtCap.value = "";
				theForm.pqtCap.focus(); return false;
			}
			if(!Trim(theForm.pqtProv.value)){
				alert("Attenzione! E' necessario inserire la provincia!!");
				theForm.pqtProv.value = "";
				theForm.pqtProv.focus(); return false;
			}
			if(theForm._cboComeConosciuto.value == "0"){
				alert("Per favore, indica come hai conosciuto questo sito!");
				theForm._cboComeConosciuto.focus(); return false;
			}
			bAtOk=false
			bMailOk=false
			for(i=0;i<=theForm.pqtEMail.value.length;i++){
				if(theForm.pqtEMail.value.substring(i,i+1) == "@"){
					bAtOk=true;
				}
				if(bAtOk==true && theForm.pqtEMail.value.substring(i,i+1) == "."){
					bMailOk=true;
					break;
				}
			}
			if(bMailOk==false){
				alert("Attenzione! L'indirizzo mail non e' corretto!");
				theForm.pqtEMail.focus();
				return false;
			}
		
			if(! Trim(theForm.pqtPwd.value)){
				alert("Attenzione! E' necessario inserire la Password!!");
				theForm.pqtPwd.value = "";
				theForm.pqtPwd.focus(); return false;
			}
			if(theForm.pqtPwd.value != theForm._PwdConf.value){
				alert("Attenzione! La Password inserita non corrisponde a quella di verifica!!");
				theForm._PwdConf.value = "";
				theForm._PwdConf.focus(); return false;
			}
			if(!theForm.pqbConf675.checked){
				alert("Attenzione! E' necessario dare il consenso al trattamento dei dati!!");
				theForm.pqbConf675.focus(); return false;
			}
			break;
	}
//	if((theForm.pqtSesso[0].checked == false) && (theForm.pqtSesso[1].checked == false)){
//		alert("Attenzione! E' necessario indicare il sesso!!");
//		theForm.pqtSesso[0].focus(); return false;
//	}

}

function chkFormInvioImg(theForm, parStrErroreSelezione, parStrErroreFormato){
	var strNomeFile = theForm.pqfNomeFile.value.toLowerCase();
	if(!Trim(strNomeFile)){
		alert(parStrErroreSelezione);
		return false;
	}
	else{
		if(strNomeFile.substr(strNomeFile.length - 4, 4) != ".jpg"){
			alert(parStrErroreFormato);
			return false;
		}
		if(!Trim(theForm.pqtNome.value)){
			alert("Attenzione\nDevi inserire il titolo dell'immagine");
			theForm.pqtNome.focus();
			return false;
		}
		if(!theForm.chkConfModalita.checked){
			alert("Attenzione! E' necessario confermare di aver letto le condizioni di invio!!");
			theForm.chkConfModalita.focus();
			return false;
		}
	}
}

function chkFormInvioVid(theForm, parStrErroreSelezione){
	var strNomeFile = theForm.pqtHtmlCodiceMedia.value.toLowerCase();
	if(!Trim(strNomeFile)){
		alert(parStrErroreSelezione);
		return false;
	}
	else{
		if(!Trim(theForm.pqtNome.value)){
			alert("Attenzione\nDevi inserire il titolo del video!");
			theForm.pqtNome.focus();
			return false;
		}
		if(!theForm.chkConfModalita.checked){
			alert("Attenzione! E' necessario confermare di aver letto le condizioni di invio!!");
			theForm.chkConfModalita.focus();
			return false;
		}
	}
}

function chkFormInvioCommento(theForm){
	if(!theForm.chkApprovo.checked){
		alert("Attenzione\nDevi spuntare l'accettazione del regolamento!");
		return false;
	}
	else{
		document.getElementById('submitCommenti').innerHTML='Attendi mentre invio il commento!';
		return true;
	}
}

function chkFormSceltaMod(theForm){
	if(!Trim(theForm.pqiIdShpmp.value)){
		alert("Attenzione\nDevi scegliere una modalita' di pagamento!");
		theForm.pqiIdShpmp.focus();
		return false;
	}
	if(!Trim(theForm.pqiIdShpms.value)){
		alert("Attenzione\nDevi scegliere una modalita' di spedizione!");
		theForm.pqiIdShpms.focus();
		return false;
	}
}

function chkFormAggPro(theForm){
	var intQta = Number(theForm.pqiQta.value);

	if(intQta <= 0){
		alert("Attenzione\nLa quantita' minima ordinabile e' 1!");
		theForm.pqiQta.focus();
		return false;
	}
	else if(intQta > 100){
		alert("Attenzione\nLa quantita' massima ordinabile e' 100!");
		theForm.pqiQta.focus();
		return false;
	}
	else{
		return true;
	}
}

function chkFormOrdine(theForm){
	if(!theForm.chkConfModalita.checked){
		alert("Attenzione! E' necessario spuntare l'accettazione del contratto di vendita!!");
		theForm.chkConfModalita.focus(); return false;
	}
}

