function createXMLHTTP(){
try {
 ajax = new ActiveXObject("Microsoft.XMLHTTP");
} 
catch(e){
 try{
  ajax = new ActiveXObject("Msxml2.XMLHTTP");
  alert(ajax);
 }
 catch(ex){
 try{
  ajax = new XMLHttpRequest();
 }
 catch(exc){
  alert("Esse browser não tem recursos para uso do Ajax");
  ajax = null;
 }
}
 return ajax;
}
 

var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for (var i=0; i < arrSignatures.length; i++) {
try {
 var oRequest = new ActiveXObject(arrSignatures[i]);
 return oRequest;
} catch (oError) {
}
}
 
throw new Error("MSXML is not installed on your system.");
}


function SalvarVoto(id_participacao,tipo_voto){
 	obj=document.getElementById('dv_'+id_participacao);
 	
   obj.innerHTML = "<img src='util/img/carregando.gif' style='vertical-align:absmiddle;'/>Carregando...";
   var oHTTPRequest=createXMLHTTP(); 
   oHTTPRequest.open("post", "votar.php?id_participacao="+id_participacao+"&tipo_voto="+tipo_voto+"&x="+Math.random(), true);
   oHTTPRequest.onreadystatechange = function(){
   		if (oHTTPRequest.readyState == 4) {
      		//if (oHTTPRequest.status == 200 || oHTTPRequest.status == 0) {
         		 var response = oHTTPRequest.responseText;
				 if (obj){
					 obj.style.display="inline";
					 obj.innerHTML=response;
				 }
		    //}
	   }
   }
   oHTTPRequest.send("votar.php?id_participacao="+id_participacao+"&voto="+tipo_voto+"&x="+Math.random());
}

function ConteudoPartic(id_participacao){
 	obj=document.getElementById('conteudoParticipacao');
 
   var oHTTPRequest=createXMLHTTP(); 
   oHTTPRequest.open("post", "conteudo_participacao.php?id_participacao="+id_participacao+"&x="+Math.random(), true);
   oHTTPRequest.onreadystatechange = function(){
   		if (oHTTPRequest.readyState == 4) {
      		//if (oHTTPRequest.status == 200 || oHTTPRequest.status == 0) {
         		 var response = oHTTPRequest.responseText;
				 if (obj){
					 obj.innerHTML=response;
				 }
		    //}
	   }
   }
   oHTTPRequest.send("conteudo_participacao.php?id_participacao="+id_participacao+"&x="+Math.random());
}

function fnPopup(id) {
	_div = document.getElementById(id).style.display;
	if (_div == 'none') {
		document.getElementById(id).style.display = 'block';
	}
	else {
		document.getElementById(id).style.display = 'none';
	}
}

function Verifica(campo,quantidade){
	document.getElementById("valor").innerText=quantidade-campo.value.length;
	if((campo.value.length) >= quantidade){
		alert('Atenção, você atingiu o limite máximo de caracteres!');
		campo.value = campo.value.substring(0,quantidade - 1);
	}
}

function PulaDDD(valor){
    if(valor.value.length==2)
	    document.getElementById('celular').focus();
}

function VerificaCel(campo){
	if((8-campo.value.length) == 0)
		document.getElementById('cidade').focus();
}

function $(id){
	return document.getElementById(id);
}

function setaImg(idImg, urlImg){
	//alert(document.getElementById(idImg));
	document.getElementById(idImg).src = urlImg;
}

function Mostrar(objeto) 
{
	var id = objeto.id;
	id = id.replace('_m','');
	var indice = document.getElementById( id + '_e' );
	var menu = document.getElementById( 'menu_' + id );
	menu.style.display = 'block';
	objeto.style.display = 'none';
	indice.style.display = 'block';
}

function Esconder(objeto)
{
	var id = objeto.id;
	id = id.replace('_e','');
	var indice = document.getElementById( id + '_m' );
	var menu = document.getElementById( 'menu_' + id );
	menu.style.display = 'none';
	objeto.style.display = 'none';
	indice.style.display = 'block';
}


function openBox(){

	    document.getElementById('fade').style.display='block';
	    document.getElementById('light').style.display='block';
}
    
function closeBox(){

	   document.getElementById('light').style.display='none';
	   document.getElementById('fade').style.display='none';		
}

var esqueciSenha = function() {
	
	window.open('box-esqueci.htm','esqueci','height=150,width=200');
	
	
	
};

/*function esqueciSenha(){

		var email = document.getElementById("email").value;
		
		var valEmail = /^[A-Za-z.0-9_-]{2,}@[A-Za-z]{2,}[.][A-Za-z]{3}([.][A-Za-z]{2})?$/;
		
		if(email == ""){
			alert("Preencha o seu e-mail.");
			return;
		}
		valEmail = valEmail.exec(email);
		if(!valEmail){
			alert("O e-mail digitado não é valido.");
			return;
		}

		makeRequestWithContainer('esqueciSenha.php?email='+email,'esqueciSenha');
}*/
