var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 5
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.")
        self.status = "Voto processado! Obrigado."
    
    }
    else
    {
    

   // alert(secs)
        //self.status = secs
        self.status = "A processar o seu voto..."
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
        
        displaydesc(document.votos_form.votos.selectedIndex)
        document.votos_form.votos.options[0].selected=false
        
        if (secs==1) {
        document.votos_form.votos.selectedIndex = false;
        //document.form_ver_sumarios.justificationId.disabled = true;
        document.votos_form.votos.disabled = true;
        }
        
    }
}

											
function CheckarVoto(theOption,codigo,titulo,tipo,genero) {
	var codigo_item, titulo_item, tipo_ficheiro, genero_ficheiro, re, newStr, urlStr, voto, i;
				
	codigo_item = codigo.value;
	titulo_item = titulo.value;
	tipo_ficheiro = tipo.value;
	genero_ficheiro = genero.value;
				
	for (i=0;i<theOption.options.length;i++) {
		if (theOption.options[i]) {
			if (theOption.options[i].selected)
				voto = theOption[i].value;
		}
	}

	re = / /gi;
				
	newStr = "http://humornanet.com/hm/votos/dados.php?coditem=" + codigo_item + "&nomeitem=" + titulo_item  + "&pontuacao=" + voto + "&generoficheiro=" + genero_ficheiro + "&tipoficheiro=" + tipo_ficheiro;
	//alert(newStr);
	urlStr = newStr.replace(re,"%20");
	//alert(urlStr);
				
	TecWindow=window.open(urlStr,"Votaritem","width=468,height=510,toolbar=no,directories=no,status=no,scrollbars=no,resizable=yes,menubar=no,location=no")

} // -- Final da função CheckarVoto
			
//visit http://www.dynamicdrive.com

//CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
var textdisplay = new Array()
textdisplay[0]=""
textdisplay[1]="A processar o seu voto..."
textdisplay[2]="A processar o seu voto..."
textdisplay[3]="A processar o seu voto..."
textdisplay[4]="A processar o seu voto..."
textdisplay[5]="A processar o seu voto..."
textdisplay[6]="A processar o seu voto..."

function displaydesc(which){
	if (document.all)
		descriptions.innerHTML=textdisplay[which]
	else if (document.getElementById)
		document.getElementById("descriptions").innerHTML=textdisplay[which]
	return;
}

//displaydesc(document.votos_form.votos.selectedIndex)
//document.votos_form.votos.options[0].selected=true