// JavaScript Document
function validate()
{
if (document.myform.Name.value.length==0)
{
alert("Per favore inserisci il tuo nome");
document.myform.Name.focus();
}
else if (document.myform.Cognome.value.length==0)
{
alert("Per favore inserisci il tuo cognome");
document.myform.Cognome.focus();
}
else if(document.myform.Email.value.length==0 || 
document.myform.Email.value.indexOf("@")==-1 || 
document.myform.Email.value.indexOf(".")==-1 || 
document.myform.Email.value.indexOf(" ")==0)
{
alert("Devi inserire una mail valida")
document.myform.Email.focus();
}
else if (document.myform.Password.value.length==0)
{
alert("Inserisci una password");
document.myform.Password.focus();
}
else if (document.myform.ConfirmPassword.value.length==0)
{
alert("Per favore inserisci la password ancora");
document.myform.ConfirmPassword.focus();
}
else if (document.myform.Password.value!=document.myform.ConfirmPassword.value)
{
alert("La password non e' corretta. Per favore ricontrolla");
document.myform.Password.focus();
}
else if(document.myform.cap.value==0 || isNaN(document.myform.cap.value))
{
alert("Inserisci il CAP corretto.");
document.myform.cap.focus();
}
else if(document.myform.azienda.value == "" )
{
	alert("Devi specificare l'attivita' dell'azienda.");
	document.myform.azienda.focus();
}
else
{
document.myform.submit()
}
}


function countdown(){
var t
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr+" 00:00:00"
//fa la differenza ed esegue i conteggi
dd=Date.parse(futurestring)-Date.parse(todaystring)  
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor(((dd%(60*60*1000*24))/(60*60*1000)*1)-1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//divide le cifre
if(dday<10)
d1="0.gif"
else
{
t = Math.floor(dday/10)
d1 = String(t) + ".gif"
}
t = dday%10
d2 = String(t) + ".gif"
if(dhour<10)
h1="0.gif"
else
{
t = Math.floor(dhour/10)
h1 = String(t) + ".gif"
}
t = dhour%10
h2 = String(t) + ".gif"
if(dmin<10)
m1="0.gif"
else
{
t = Math.floor(dmin/10)
m1 = String(t) + ".gif"
}
t = dmin%10
m2 = String(t) + ".gif"
if(dsec<10)
s1="0.gif"
else
{
t = Math.floor(dsec/10)
s1 = String(t) + ".gif"
}
t = dsec%10
s2 = String(t) + ".gif"

crosscount.innerHTML="<img src=img/arrivo/"+d1+">"+"<img src=img/arrivo/"+d2+">"+"<img src=img/arrivo/arrivo_ce_2.gif>"+"<img src=img/arrivo/"+h1+">"+"<img src=img/arrivo/"+h2+">"+"<img src=img/arrivo/arrivo_ce_3.gif>"+"<img src=img/arrivo/"+m1+">"+"<img src=img/arrivo/"+m2+">"+"<img src=img/arrivo/arrivo_ce_4.gif>"+"<img src=img/arrivo/"+s1+">"+"<img src=img/arrivo/"+s2+">"
//}
//ripete ogni secondo
setTimeout("countdown()",1000)
}

function setarrivo(anno,mese,giorno){
yr=anno;mo=mese;da=giorno
}

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

function conva_codice()
{
	var codice = document.concorso.codice.value;
	var val = window.open('copromo.asp?codice='+codice,'','width=360,height=250');
	prezzo();
	}
	
function calcola_codice(prezzo)
{
	var prezzo2;
	prezzo2 = 0;
	document.concorso.p_gara.value = prezzo2;
	}

function prezzo()
{
	var prezzo;
	var sele = document.concorso.gruppo1.value;
if ( sele == "Pubbli-redazionali"){prezzo = 80;}
else if ( sele == "Acquisto proprietà intellett. (Per tutti gli utilizzi)"){prezzo = 900;}
else if ( sele == "Pubbli-redazionali"){prezzo = 120;}
else if ( sele == "Magazine Advertising"){prezzo = 120;}
else if ( sele == "Newspaper Advertising"){prezzo = 120;}
else if ( sele == "Inserto in magazine"){prezzo = 180;}
else if ( sele == "Elenchi pagine gialle e similari"){prezzo = 80;}
else if ( sele == "Foto usate in Spot Televisivi"){prezzo = 180;}
else if ( sele == "Banner Web Advertising"){prezzo = 80;}
else if ( sele == "Campagna affissione  (Util. esclusivo 6 mesi)"){prezzo = 480;}
else if ( sele == "Campagna affiss. 6x3 (Util. esclusivo 6 mesi)"){prezzo = 800;}

else if ( sele == "Visual per stampa su Totem Paline ecc"){prezzo = 80;}
else if ( sele == "Slideshow - Presentazioni PPT o similari"){prezzo = 80;}
else if ( sele == "Visual in gara di creatività"){prezzo = 220;}
else if ( sele == "Inviti - Save the date - cartacei o web"){prezzo = 80;}

else if ( sele == "Magazine Quotidiani"){prezzo = 60;}
else if ( sele == "Periodici settore Food"){prezzo = 220;}
else if ( sele == "Copertina Magazine Periodici"){prezzo = 320;}
else if ( sele == "Periodici aziendali o scientifici"){prezzo = 60;}

else if ( sele == "Report Aziendali"){prezzo = 60;}
else if ( sele == "Brochure, Direct Mail"){prezzo = 120;}
else if ( sele == "Volantini, Cartoline promozionali"){prezzo = 120;}
else if ( sele == "Brochure On-line"){prezzo = 120;}
else if ( sele == "Calendari Promozionali"){prezzo = 160;}
else if ( sele == "Poster Promozionali"){prezzo = 320;}
else if ( sele == "Brochure catalogo turismo generica"){prezzo = 80;}
else if ( sele == "Brochure catalogo turismo in location"){prezzo = 120;}

else if ( sele == "Gara Creatività"){prezzo = 120;}
else if ( sele == "Gara  Location"){prezzo = 120;}
else if ( sele == "Gara RedCarpet"){prezzo = 80;}
else if ( sele == "Food, Prepara la ricetta e Scatta"){prezzo = 220;}

else if ( sele == "Report Aziendali"){prezzo = 60;}
else if ( sele == "Slideshow Presentazioni"){prezzo = 60;}
else if ( sele == "Video Aziendali"){prezzo = 60;}
else if ( sele == "Sito Web home page"){prezzo = 120;}
else if ( sele == "Newsletter"){prezzo = 60;}
else if ( sele == "Ufficio stampa, Media Kit"){prezzo = 60;}
else if ( sele == "Immagini coordinata, biglietti"){prezzo = 60;}
else if ( sele == "Locandine Manifesti"){prezzo = 180;}

else if ( sele == "Display Video, Kiosk"){prezzo = 80;}
else if ( sele == "Schermi infomativi esterni"){prezzo = 80;}
else if ( sele == "Maxi Schermi"){prezzo = 80;}

else if ( sele == "CD, Video, DVD"){prezzo = 240;}
else if ( sele == "etichette prodotto"){prezzo = 80;}
else if ( sele == "Packaging prodotto"){prezzo = 320;}
else if ( sele == "Arredamento Punto vendita"){prezzo = 150;}

else if ( sele == "Stampa su prodotti destinati alla vendita"){prezzo = 360;}
else if ( sele == "Carte di credito o bancarie"){prezzo = 320;}
else if ( sele == "Carte telefoniche"){prezzo = 320;}
else if ( sele == "Carte sconto"){prezzo = 120;}
else if ( sele == "Videogiochi/CD-ROM/Software"){prezzo = 240;}
else if ( sele == "Calendario destinato alla vendita"){prezzo = 180;}
else if ( sele == "Magliette Gadgets destinati alla vendita"){prezzo = 120;}
else if ( sele == "Cartoline postali/auguri destinate alla vendita"){prezzo = 100;}
else if ( sele == "Poster destinati alla vendita"){prezzo = 120;}
else if ( sele == "Stampati destinati alla vendita"){prezzo = 120;}

else if ( sele == "Sala Cine Spot"){prezzo = 120;}
else if ( sele == "Foto usate in Documentari"){prezzo = 80;}
else if ( sele == "Promozione Film - Trailers"){prezzo = 120;}
else if ( sele == "Foto usate in Film per la TV"){prezzo = 120;}
else if ( sele == "Foto usate in Video Clip Musicali"){prezzo = 80;}
else if ( sele == "Foto usate in Spot Televisivi"){prezzo = 180;}
else if ( sele == "Foto usate in Telepromozioni"){prezzo = 120;}
else if ( sele == "Foto usate in TG - Approfondimento - news"){prezzo = 80;}

else if ( sele == "Videogiochi/CD-ROM/Software"){prezzo = 80;}
else if ( sele == "Sito Web pagine interne"){prezzo = 80;}
else if ( sele == "Pubblicità su siti Web"){prezzo = 80;}
else if ( sele == "Campagne Email"){prezzo = 80;}
else if ( sele == "Brochure On-line"){prezzo = 80;}
else if ( sele == "Banner Web Advertising"){prezzo = 80;}

else if ( sele == "Tutta la categoria: Brochure - Depliants"){prezzo = 900;}
else if ( sele == "Tutte le categorie: Advertising - Web"){prezzo = 400;}
else if ( sele == "Tutte le categorie: Brochure - Adv - Web"){prezzo = 600;}
else if ( sele == "Tutte le categorie: Display- Broch. - Adv - Web"){prezzo = 700;}
else if ( sele == "Tutta la categoria: Aziendale - Corporate"){prezzo = 800;}
else if ( sele == "Tutta la categoria: Display - Kiosks"){prezzo = 220;}
else if ( sele == "Tutte le categorie: Advertising - Editoria"){prezzo = 140;}
	else prezzo =0;
	document.concorso.prezzo.value = prezzo;
	
	if (( document.concorso.codice.value == "" ) || ( document.concorso.valido.value == 0))
	{
	p_gara = (prezzo*40)/100;
	p_foto = (prezzo*60)/100;
	document.concorso.p_gara.value = p_gara;
	document.concorso.p_foto.value = p_foto;
	}
	else
	{
		calcola_codice(prezzo);
	}
	}

function altro_te()
{
//if( document.concorso.gruppo1.value.indexOf("A")==0 )
//{
//document.concorso.altro.style.display="block"; 
//}
//else document.concorso.altro.style.display="none"; 
prezzo();
}


function contratto()
{
window.open('contratto.html','NewWin','width=520,height=480,left=200,top=0,scrollbars=yes');
	}

function vali_form()
{
if (document.concorso.titolo.value.length==0)
{
alert("Per favore devi specificare un soggetto.");
document.concorso.titolo.focus();
}
else if (document.concorso.gruppo1.value.length==0)
{
alert("Per favore devi specificare il tipo di utilizzo immagine.");
document.concorso.gruppo1.focus();
}
else contratto();
}

function vali_date()
{
if ((document.concorso.select2.value == 4 ||document.concorso.select2.value == "6" || document.concorso.select2.value == "9" || document.concorso.select2.value == "11") && (document.concorso.select7.value > 30)) 
	{
	alert("Data non corretta");
	document.concorso.select7.focus();
}

else if ((document.concorso.select2.value == "2") && (document.concorso.select7.value > 29)) 
	{
	alert ("Data non corretta");
	document.concorso.select7.focus();
	}

else vali_form();
}