/* ------------------- popups ------------------ */

    function openPopup (__url,_w,_h,_type,_winName){
    	if (_w=="") _w = 600;
    	if (_h=="") _h = 400;
    	
    	_features = "";
    	switch (_type) {
    		case 0 : _features += "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"; break;
    		case 1 : _features += "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes"; break;
    		case 2 : _features += "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no"; break;
    	}
    	window.open(__url,_winName,"'"+_features+",width="+_w+",height="+_h+"'");
    }


    function apriPop(url,x,y,scrolling){
        window.open(url,'zoom','width=' + x + ', height=' + y + ' ,toolbar=no, location=no, status=no, menubar=no, scrollbars=' + scrolling + ', resizable=no');
    }

/* ------------------- alert su links esterni al sito ------------------ */
	
    function lnk_esterno(valoreUrl){
		apriDiv('lnk_alert');
		document.getElementById("urlEsterno").value = valoreUrl;
	}
    	
    function lnk_esternoOk(){
    	chiudiDiv('lnk_alert');
    	window.open(document.getElementById("urlEsterno").value);
	}
	
	
/* ------------------- links da menu a tendina edicolaArchive ------- */
	
    function selectLink(url){
    	chiudiDiv('selectOption');
    	window.document.location.href=url ;
    }
	
	
/* ------------------- aperture e chiusure div dinamiche ------- */
	
    function chiudiDiv(box){
		document.getElementById(box).style.display ="none";
	}
    	
    function apriDiv(box){
		document.getElementById(box).style.display ="block";
	}
	
	
/* -------------------- sistema votazione edicola ------------ */
	
    voti = new Array();
	
    function votaStoria(storia,voto){
    	
    	//attivo-disattivo il check grafico
    	chiudiGruppoVoti(storia);
    	selezione = "voto_"+storia+"_"+voto;
    	document.getElementById(selezione).innerHTML = "<img src='azzurro/imgs/voto.gif' border='0'/>";
    	
    	voti[(storia-1)]=voto;
    	// costruisco la stringa della votazione
    	//document.getElementById('voti').value = document.getElementById('voti').value + " | " + storia + "," + voto;
    }
	
    function chiudiGruppoVoti(storia){
    	for (i=1; i<=5; i++) {
    		document.getElementById("voto_"+storia+"_"+i ).innerHTML = "<img src='azzurro/imgs/voto_"+i+".gif' border='0'/>";
    	}
    }
	
	
    function inviaVoti(numeroTopo, numeroStorie, siteUrl){
    
		var mancanti = 0;
		for (i=0; i<numeroStorie; i++) {
			if (voti[i] == null) {
			mancanti = mancanti +1;
			}
		}
		
		if (mancanti == 0){
			document.getElementById('voti').value = numeroTopo;
			for (i=0; i<numeroStorie; i++) {
				document.getElementById('voti').value = document.getElementById('voti').value  + "|" + i + "," + voti[i];
			}
			stringaVoti = document.getElementById('voti').value;
			apriPop(siteUrl+"inEdicola/edicolaVota.jsp?numero="+numeroTopo+"&voti="+stringaVoti,500,200,"no");
			
			//alert("questo è il valore del campo nascosto \"voti\"\n\n"+stringaVoti);
			//document.forms['votazioniEdicola'].submit();
		} else {
		    if(mancanti==1){
                alert("Ti manca da votare " + mancanti + " storia!");
            }else{
                alert("Ti mancano da votare " + mancanti + " storie!");
            }
		}
    }


	
/* -------------------fumetto in apertura personaggi ------- */
	
    function fumetto(dove,chi){
		document.getElementById(dove).innerHTML = "leggi la scheda di "+"<font color='red'>"+chi+"</a>";
	}
	
    function chiudiFumetto(dove){
		document.getElementById(dove).innerHTML = "scegli il personaggio";
	}
	
	
	
	function coloreHome(colore) {
document.body.style.backgroundColor =colore;
    }
    
/* -------------------- sistema votazione sondaggio ------------ */
    function inviaSondaggio(numeroStorie){
    
		var mancante = true;
		
		for (i=0; i<numeroStorie; i++) {
		    var tmpCheck = document.sondaggioForm.value[i].checked;
		    //alert(i + " --> " + tmpCheck);
		    if (tmpCheck==true) {
		        mancante = false;
		        break;
		    }
		}
		
		if (!mancante){
		    document.sondaggioForm.submit();
		}else{
		    alert("Seleziona almeno una risposta");
		}
    }
    
/* -------------------- sistema votazione test ------------ */
    function inviaTest(numeroDomande){
        var punteggio = 0;
 	
		for (i=1; i<=numeroDomande; i++) {
		    var mancante = true;
		    var numAnswer = eval("document.test.question" + i + ".length");
    		for (y=0; y<numAnswer; y++) {
    		    
    		    var tmpCheck = eval("document.test.question" + i + "[" + y + "].checked");
    		    if (tmpCheck==true){
    		        mancante = false;
    		        break;
    		    }
    		} 
   		    if (mancante) {
   		        break;
            }else{
                punteggio += parseInt(eval("document.test.question" + i + "[" + y + "].value"));
            }
        }
		
		if (!mancante){
		    document.test.totale.value = punteggio;
		    document.test.submit();
		}else{
		    alert("Rispondi a tutte le domande");
		}
    }
   
    
	
/* ------------------ dimensione max container ------------- */

function hContainer() {
	if (window.innerHeight){
	Hpx = window.innerHeight;
	}else{
	Hpx = 	document.documentElement.clientHeight;
	}

document.getElementById("container").style.height = (Hpx-70)+"px";
}

/* -------------------- sistema votazione sondaggio ------------ */
    function inviaPosta(){
    
        var errore = false;
        
		if (document.moduloForm.nome.value=="") errore = true;
		if (document.moduloForm.email.value=="") errore = true;
		if (document.moduloForm.messaggio.value=="") errore = true;
		
		if (!errore){
		    document.moduloForm.submit();
		}else{
		    alert("Controlla di aver compilato tutti i campi");
		}
    }



