function orango(testo1,testo2) {
	num_righe = testo2=="" ? 1 : 2
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="260" height="190" id="animazione_orango" align="middle">')
	document.write('<param name="allowScriptAccess" value="sameDomain" />')
	document.write('<param name="movie" value="animazione_orango.swf?num_righe=' + num_righe + '&testo1=' + testo1 + '&testo2=' + testo2 + '">')
	document.write('<param name="quality" value="high" />')
	document.write('<param name="bgcolor" value="#b3b3b3" />')
	document.write('<embed src="animazione_orango.swf?num_righe=' + num_righe + '&testo1=' + testo1 + '&testo2=' + testo2 + '" quality="high" bgcolor="#b3b3b3" width="260" height="190" name="animazione_orango" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
	document.write('</object>')
}

function PiuMeno(refdiv, refimg) {
	if (refimg.src.search("_piu")>0) {
		document.getElementById(refdiv).style.display='block'
		refimg.src = "img/dett_meno.gif"
	} else {
		document.getElementById(refdiv).style.display='none'
		refimg.src = "img/dett_piu.gif"
	}
}

function CheckFormDati() {
	giusti_tot = 14
	giusti = 0
	if (document.utente.dato1.value.length>0) giusti++
	if (document.utente.dato2.value.length>0) giusti++
	if (document.utente.dato3.value.length>0) giusti++
	if (document.utente.dato4[0].checked || document.utente.dato4[1].checked) giusti++
	if (document.utente.dato6.value.length>0) giusti++
	if (document.utente.dato7.value.length>0) giusti++
	if (document.utente.dato8.value.length>0) giusti++
	if (document.utente.dato9.value.length>0) giusti++
	if (document.utente.dato10.value.length>0) giusti++
	if (document.utente.dato11.value.length>0) giusti++
	if (document.utente.dato13.value.length>0) giusti++
	if (document.utente.dato15.value.length>0) giusti++
	if (document.utente.dato16.value.length>0) giusti++
	if (document.utente.dato17.checked) giusti++
	if (giusti==giusti_tot) {
		errore = 0
		if (document.utente.dato5.value.length>0)
			verificaData(document.utente.dato5.value)
		if (errore==0)
			document.utente.submit()
		
	} else
		alert("Non hai inserito tutti i campi obbligatori")
}

function trim(stringa) {
	while (stringa.substring(0,1) == ' ')
		stringa = stringa.substring(1, stringa.length)
	while (stringa.substring(stringa.length-1, stringa.length) == ' ')
		stringa = stringa.substring(0,stringa.length-1)
	return stringa
}

function verificaData(quale1) {
	var re = /\d{2}\/\d{2}\/\d{4}/
	quale = trim(quale1)
	document.utente.dato5.value = quale
	var sDate=quale1
	var IsDate=true
	if (re.test(sDate)) {
		var dArr = sDate.split("/");
		sDate = dArr[1] + "/" + dArr[0] + "/" + dArr[2]
		var d = new Date(sDate);
		if ((d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2])==false)
			IsDate = false
	} else
		IsDate = false
	if (IsDate==false) {
		alert("Data errata: " + quale + "\n\nControllala e inseriscila nuovamente.")
		errore++
	}
}

function CheckForm() {
	num_dom = 0																							// n° domande
	num_ris = 0																							// n° radio box checkati dall'utente
	for (t=1; t<=15; t++) {																	// guarda tutti i radio presenti
		if (typeof(eval("document.test.d"+t))=="object") { 		// c'è la domanda t
			num_dom++
			for (g=0; g<3; g++)
				if (eval("document.test.d"+t)[g].checked)
					num_ris++
		}
	}
	if (num_dom!=num_ris)
		alert("Non hai inserito tutte le risposte!")
	else {
		if (confirm("Confermi l'invio delle risposte?"))
			document.test.submit()
	}
}

// SlideShow
var numImmagini = 19;																		// n° immagini totali da far girare
var immagine = new Array();
var imgAttuale =  numImmagini * Math.random()
imgAttuale = Math.ceil(imgAttuale)-1
var tempoPermanenza = 3000;															// in millisecondi

function startSlideShow() {
	for (i=0; i<numImmagini; i++) {
		immagine[i] = new Image();
		immagine[i].src = 'img/top' + i + '.jpg';
	}
	runSlideShow()
}

function runSlideShow() {
  if (immagine[imgAttuale].complete == true) {
		if (document.all) {
			document.images.SlideShow.style.filter = "blendTrans(duration=1)"
	    document.images.SlideShow.filters.blendTrans.Apply()
	  }
	 	document.images.SlideShow.src = immagine[imgAttuale].src
	  if (document.all) {
	  	document.images.SlideShow.filters.blendTrans.Play()
	  }
	  imgAttuale = (imgAttuale+1) % numImmagini
	  setTimeout('runSlideShow()', tempoPermanenza)
	}
	else
  	setTimeout('runSlideShow()', 300)
}

