// JavaScript Document
function autofitIframe(id){
parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
}

function autofitIframe1(id){
if (!window.opera && !document.mimeType && document.all && document.getElementById){
parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
}
else if(document.getElementById) {
parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
}
}

function pripro1(){
modulo.Ragione_sociale.style.backgroundColor="#CCCCCC"
modulo.Ragione_sociale.value=""
modulo.Ragione_sociale.disabled=true
modulo.Partita_iva.style.backgroundColor="#CCCCCC"
modulo.Partita_iva.value=""
modulo.Partita_iva.disabled=true
}
function pripro2(){
modulo.Ragione_sociale.style.backgroundColor="#FFFFFF"
modulo.Ragione_sociale.disabled=false
modulo.Partita_iva.style.backgroundColor="#FFFFFF"
modulo.Partita_iva.disabled=false
}

function controlla_invio(){
	
	if (modulo.Informativa.checked==false){
	 alert("Per registrarsi occorre l'autorizzazione.")
	 return false
	}

	if (modulo.Cognome.value==""){
	 alert("Inserire Cognome.")
	 return false
	}
	
	if (modulo.Nome.value==""){
	 alert("Inserire Nome.")
	 return false
	}
	
	if (modulo.Indirizzo.value==""){
	 alert("Inserire Indirizzo.")
	 return false
	}
	
	if (modulo.Citta.value==""){
	 alert("Inserire Citta.")
	 return false
	}
	
	if (modulo.Provincia.value==""){
	 alert("Inserire Provincia.")
	 return false
	}
	
	if (modulo.Numero_tel.value==""){
	 alert("Inserire Numero Telefonico.")
	 return false
	}
	
	
	
	
	
	//email--------------------------------------
	var arrMail
	var arrPunto
	arrMail = modulo.Email.value.split("@");
	if (arrMail.length>1){arrPunto = arrMail[1].split(".")};
	if (arrPunto){
		if (arrPunto.length>1){ bMail = true;} else {bMail = false;};
	}
	else{
		bMail = false;
	}
	
	if (!bMail){
	 alert("Inserire l'indirizzo di posta elettronica corretto.")
	 return false
	}
	//email--------------------------------------
	
	
	if (modulo.Pass1.value==""){
	 alert("Inserire Password.")
	 return false
	}
	
	if (modulo.R1[1].checked && modulo.Ragione_sociale.value==""){
	 alert("Inserire Ragione Sociale.")
	 return false
	}
	
	if (modulo.R1[1].checked && modulo.Partita_iva.value==""){
	 alert("Inserire Partita Iva.")
	 return false
	}
	
	if (modulo.R1[1].checked && isNaN(modulo.Partita_iva.value)){
	 alert("Inserire solo numeri nel campo Partita Iva.")
	 return false
	}
			
return true
}


function controlla_invio_1(){
	
	if (ordini.TXTC.value==""){
	 alert("Inserire Cognome.")
	 return false
	}
	
	if (ordini.TXTN.value==""){
	 alert("Inserire Nome.")
	 return false
	}
	
	if (ordini.TXTI.value==""){
	 alert("Inserire Indirizzo.")
	 return false
	}
	
	if (ordini.TXTA.value==""){
	 alert("Inserire Citta.")
	 return false
	}
	
	if (ordini.TXTP.value==""){
	 alert("Inserire Provincia.")
	 return false
	}
	
	if (ordini.TXTT.value==""){
	 alert("Inserire Numero Telefonico.")
	 return false
	}
	
	
	
	
	
	//email--------------------------------------
	var arrMail
	var arrPunto
	arrMail = ordini.TXTE.value.split("@");
	if (arrMail.length>1){arrPunto = arrMail[1].split(".")};
	if (arrPunto){
		if (arrPunto.length>1){ bMail = true;} else {bMail = false;};
	}
	else{
		bMail = false;
	}
	
	if (!bMail){
	 alert("Inserire l'indirizzo di posta elettronica corretto.")
	 return false
	}
	//email--------------------------------------

	
return true
}



function conford(){
ordina()
}
somma=0
totale()

function setOgg(){
//SCONTR.style.visibility="hidden"
ordini.B1.disabled=true
ordini.B3.disabled=false
ordini.B4.disabled=false
ordini.TXTC.disabled=false
ordini.TXTN.disabled=false
ordini.TXTI.disabled=false
ordini.TXTA.disabled=false
ordini.TXTP.disabled=false
ordini.TXTT.disabled=false
ordini.TXTE.disabled=false
ordini.TXTC.focus()
}

function resetOgg(){
//SCONTR.style.visibility = (somma==0)? "hidden":"visible"
ordini.B1.disabled=false
ordini.B3.disabled=true
ordini.B4.disabled=true
ordini.TXTC.disabled=true
ordini.TXTN.disabled=true
ordini.TXTI.disabled=true
ordini.TXTA.disabled=true
ordini.TXTP.disabled=true
ordini.TXTT.disabled=true
ordini.TXTE.disabled=true
}

function totale(){
var quant = new Array(5)
for (i = 0; i < 6; i++){quant[i]=0;}
coll=document.all.tags("SELECT")
somma=0
for (x=0; x<coll.length; x++){
	if (coll[x].selectedIndex>0){
		scelta=x-parseInt(x/6)*6
		quant[scelta]+=parseInt(coll[x].value)
}	}
NRI1.innerText = (quant[0]==0)? "":quant[0]
NRI2.innerText = (quant[1]==0)? "":quant[1]
NRI3.innerText = (quant[2]==0)? "":quant[2]
NRI4.innerText = (quant[3]==0)? "":quant[3]
NRI5.innerText = (quant[4]==0)? "":quant[4]
NRI6.innerText = (quant[5]==0)? "":quant[5]
somma+=quant[0]*ordini.COSTO1.value
somma+=quant[1]*ordini.COSTO2.value
somma+=quant[2]*ordini.COSTO3.value
somma+=quant[3]*ordini.COSTO4.value
somma+=quant[4]*ordini.COSTO5.value
somma+=quant[5]*ordini.COSTO6.value
tsped=0
if (ordini.R1[0].checked){
	tsped=COSTO7.value
}else if (ordini.R1[1].checked){
	tsped=COSTO8.value
}else if (ordini.R1[2].checked){
	tsped=COSTO9.value
}
SPED.innerText = (tsped==0)? "":"€ " + converti(tsped*1)
TOTA.innerText = (somma==0)? "":"€ " + converti(somma+(tsped*1))
//O2.disabled = (somma==0)? true: false
Tasto3.style.visibility = (somma==0)? "hidden": "visible"
//SCONTR.style.visibility = ((somma==0)||(ordini.B3.disabled==false))? "hidden":"visible"
}

function getFileExtension(filePath){ 
fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length));
return fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
}

function checkFileUpload(form){ 
document.MM_returnValue = true;
vuoto = true;
vfile = true;
for (x=1; x<6; x++){
	vcampo=eval("pubblica.F"+x+".value")
	if (vcampo != ''){
		vuoto = false;
		nomefile=getFileExtension(vcampo).toUpperCase()
   		if ((nomefile.indexOf("JPG") == -1)&&(nomefile.indexOf("BMP") == -1)&&(nomefile.indexOf("PNG") == -1)){
			vfile = false;
} 	}	}
if (vuoto){
	alert('Selezionare un file!');
   document.MM_returnValue = false;
	pubblica.F1.focus();
}else if (!vfile){
	alert('Selezionare solo file \"JPEG\" e \"BMP\" e \"PNG\"!');
   document.MM_returnValue = false;
	pubblica.F1.focus();
}else{
	attesa.style.visibility="visible"
}
}

function carica(Valore){
	//myform.ricarica.value 	= taglio;
	Taglio					= Valore.split("_");
	myform.taglio.value 	= Taglio[1];
	Quantita				= Valore.value;
	//alert(Quantita);
	//myform.quantita.value	= ;
	}

