// JavaScript Document
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function ge(x){
	return document.getElementById(x);
}
function showDv(x,arg){ return ge(x).style.display=arg; }

function hideDv(x){ return ge(x).style.display="none"; }

function AbrirEvento(galeria,left,top,width,heigth){
	 window.open('galeria/'+galeria+'.html', 'GALERIA', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, top='+top+', left='+left+', width='+width+', height='+heigth);
}

function optEnquete(idenquete){
	var opcao = ge('resposta');
	var i;
	var totalr = opcao.value.length +1;
	var box = ge('enquetebox');
	var pC = new Date().getTime();
	var valid;
	
	for(i=0; i<=totalr; i++){
		if(document.frmenquete.resposta[i].checked){
			var escolha = document.frmenquete.resposta[i].value;
			valid = "sim";
			break;
		} else {
			valid = "nao";
		}
	}
	if(valid != "sim"){ alert('Por favor escolha uma resposta antes de votar!'); }
	if(valid != "nao"){ 
	
		box.innerHTML = "<br><br><br><center><img src=\"imgs/loader.gif\" border=\"0\"></center><br><br><br>";		
		xmlhttp.open("GET", "scripts/enquete_votar.php?enquete="+idenquete+"&resposta="+escolha+"&h="+pC,true);
		
    	xmlhttp.onreadystatechange = function(){		
        if (xmlhttp.readyState == 4){
            var texto=xmlhttp.responseText;
            texto = texto.replace(/\+/g," ");
            texto = unescape(texto);
            box.innerHTML = texto;
        }
     }
	}
	xmlhttp.send(null);
}

function enqueteResult(enquete,left,top,width,height){

   window.open('enquete/'+enquete+'.html','ENQUETE', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function contactar(){
	var nome = ge('anome');
	var email = ge('aemail');
	var assunto = ge('aassunto');
	var msg = ge('amsg');
	
	var em1 = email.value.indexOf('@');
	var em2 = email.value.indexOf('.');
	var em3 = email.value.length;
	
	if(nome.value == ""){
		ge('a1').style.display="block";
		ge('a1').innerHTML="Preencha com seu nome para prosseguir.";
		nome.focus();
	}
	else if(email.value == ""){
		ge('a2').style.display="block";
		ge('a2').innerHTML="Preencha com seu e-mail para prosseguir.";
		email.focus();
	}
	else if(!(em1 >= 3 && em2 >= 6 && em3 >= 9)){
		ge('a2').style.display="block";
		ge('a2').innerHTML="Preencha com um e-mail válido para prosseguir.";
		email.focus();
	}
	else if(assunto.value == ""){
		ge('a3').style.display="block";
		ge('a3').innerHTML="Preencha com o assunto para prosseguir.";
		assunto.focus();
	}
	else if(msg.value == ""){
		ge('a4').style.display="block";
		ge('a4').innerHTML="Preencha com a mensagem para prosseguir.";
		msg.focus();
	} else {
		
		document.frmcontato.submit();
		
	}
	
}

function OpenPlayer(){
	window.open('http://www.sistemanovadimensao.com.br/radio.html','popup','width=310,height=220,scrolling=auto,top=0,left=0')
}
