/*

Comportanmentos JavaScript
Cliente: New Trafic
Autor: Henrique Paulino
Data: 26/12/2006

*/

//Pop up
function abre(URLStr, Name, width, height)
{
var left = (screen.width/2) - width/2;
var top = (screen.height/2) - ((height/2)+20);
newwindow=open(URLStr,Name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


//Efeito rollover
function over(img, imgOver){
	i = document.getElementById(img);
	i.src = "i/"+imgOver+"_over.gif";
}

function out(img, imgOut){
	i = document.getElementById(img);
	i.src = "i/"+imgOut+".gif";
}


//Mostra e esconde divs
function mostra(iDtarget, iDhide, iTarget, iHide){
	if(document.getElementById){	
		target = document.getElementById(iDtarget);
		hide = document.getElementById(iDhide);
		imgTarget = document.getElementById(iTarget);
		imgHide = document.getElementById(iHide);
	
		target.style.display = "";
		hide.style.display  = "none";
		
		imgTarget.src = "i/"+iTarget+".gif";
		imgHide.src = "i/"+iHide+"_over.gif";
	}
}


//Mostra o INOTERM selecionodo
function termo(termo){
	if(termo != ""){
		alvo = document.getElementById('t_termo');
		alvo.src = "termos/"+termo.options[termo.selectedIndex].value+".html";
	}else{
		alvo = document.getElementById('t_termo');
		alvo.src = " ";
	}
	
}

//Controle do Formulário
function mostra_f(alvo){
		for(i = 1; i <=4; i++){
			target = document.getElementById(i);
			it = 'i_'+i;
			i_target = document.getElementById(it)
			if(i == alvo){
				target.style.display = "";
				i_target.src = 'i/'+i+'_on.gif';
			}else{
				target.style.display = "none";
				i_target.src = 'i/'+i+'_off.gif';
			}
		}
}



//Tira espaçoes em branco para a validação do formulário
function Trim(str){
	while (str.charAt(0) == " ")
	str = str.substr(1,str.length -1);

	while (str.charAt(str.length-1) == " ")
	str = str.substr(0,str.length-1);

	return str;
	}


//Validação do Formulário
function validaForm(){
	
		empresa = document.getElementById("empresa");
		nome = document.getElementById("nome");
		email = document.getElementById("email");
		ddi_fone = document.getElementById("ddi_fone");
		fone = document.getElementById("fone");
		
	 
	  	if (empresa == ""){
			alert("O campo \"Empresa\" não pode ficar em branco.");
			return false;
		}		
		if (nome == ""){
			alert("O campo \"Nome\" não pode ficar em branco.");
			return false;
		}
		if (email == ""){
			alert("O campo \"email\" não pode ficar em branco.");
			return false;
		}
		if (ddi_fone == ""){
			alert("O campo \"DDI do telefone\" não pode ficar em branco.");
			return false;
		}
		if (fone == ""){
			alert("O campo \"Telefone\" não pode ficar em branco.");
			return false;
		}
		return true;
	}


//relogio--------------------------------------------------------------------------------------
var timerID = null;
var timerRunning = false;
function stopclock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false;
}

function startclock()
{
    stopclock();
    showtime();
}
		
function showtime(){ 
	hora = document.getElementById("hora").value;
	hora_n = document.getElementById("hora_n").value;
	hora_l = document.getElementById("hora_l").value;
	hora_s = document.getElementById("hora_s").value;
	
	minuto = document.getElementById("minuto").value;
	segundo = document.getElementById("segundo").value;
	
	if(segundo >= 59){
		segundo = 0;
		minuto++;
	}else{
		segundo++;
	}
	
	if(minuto >= 59){
		minuto = 0;
		hora++;
	}
	
	if(hora >= 24){
		hora = 0;
	}	
	
	if(hora_n >= 24){
		hora_n = 0;
	}
	
	if(hora_l >= 24){
		hora_l = 0;
	}
	
	if(hora_s >= 24){
		hora_s = 0;
	}
	
			
    timeValue = ((hora < 10) ? "0" : "") + hora;
    timeValue  += ((minuto < 10) ? ":0" : ":") + minuto;
    document.getElementById("face").innerHTML = timeValue;
	
	timeValue_n = ((hora_n < 10) ? "0" : "") + hora_n;
    timeValue_n  += ((minuto < 10) ? ":0" : ":") + minuto;
    document.getElementById("face_n").innerHTML = timeValue_n;
	
	timeValue_l = ((hora_l < 10) ? "0" : "") + hora_l;
    timeValue_l  += ((minuto < 10) ? ":0" : ":") + minuto;
    document.getElementById("face_l").innerHTML = timeValue_l;
	
	timeValue_s = ((hora_s < 10) ? "0" : "") + hora_s;
    timeValue_s  += ((minuto < 10) ? ":0" : ":") + minuto;
    document.getElementById("face_s").innerHTML = timeValue_s;
   
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
	
	img = document.getElementById("mapa");
	img.src = "i/relogio/"+hora+".gif"
	
	document.getElementById("hora").value = hora;
	document.getElementById("hora_n").value = hora_n;
	document.getElementById("hora_l").value = hora_l;
	document.getElementById("hora_s").value = hora_s;
	
 	document.getElementById("minuto").value = minuto;
	document.getElementById("segundo").value = segundo ;
}


//relogio--------------------------------------------------------------------------------------


//Função que redireciona para a página correspondente em ingles

function eng(pag){
	nova = "/eng"+pag ;
	window.location.href = nova;
}

