dw_Tooltip.content_vars = {
	L1: 'Site criado e desenvolvido pela Digital Way'

}
function pinta(obj) {
	obj.style.backgroundColor="#FFFFFF";
}
function apaga(obj) {
	obj.style.backgroundColor="#EAEAEA";
}
function checkEmail(valor){
	if(valor==''){return false;}
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){return true;}
	return false;
}



window.onload = function(){
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].outerHTML = objs[i].outerHTML;
		}
	}
}
window.onunload = function() {
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].outerHTML = "";
		}
	}
}



function validaForm(obj) {
	if (obj.nome.value=='') {
		alert('Informe o seu Nome.');
		obj.nome.focus();
		return false;
	}	
	if (checkEmail(obj.email.value)==false) {
		alert('E-mail inválido.');
		obj.email.focus();
		return false;
	}
	if (obj.ddd.value=='') {
		alert('Informe o DDD do seu telefone.');
		obj.ddd.focus();
		return false;
	}	
	if (obj.fone.value=='') {
		alert('Informe o seu Telefone.');
		obj.fone.focus();
		return false;
	}	
	if (obj.cidade.value=='') {
		alert('Informe a sua Cidade.');
		obj.cidade.focus();
		return false;
	}	
	if (obj.assunto.value=='') {
		alert('Informe o Assunto.');
		obj.mensagem.focus();
		return false;
	}	
	if (obj.mensagem.value=='') {
		alert('Digite uma Mensagem.');
		obj.mensagem.focus();
		return false;
	}
}

function valida_radio(){
	valor = 0;
	tam = document.form.opcao.length;
	b=0;
	for (i=1;i<=tam;i++) {
		if (document.form.opcao[b].checked == true) {
			valor = i;
		}
		b++;
	}
	return valor;
}

function vota(cod){
	try {
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			}
			catch(exc) {
				alert("Esse navegador de internet não tem recursos para funcionamento correto deste site!");
				ajax = null;
			}
		}
	}
	if(ajax) {
		var file = "envia_voto.php";
		idDiv = document.getElementById('content_enq');
		marcado = valida_radio();
		if(marcado!=0){
			var resposta = marcado;
			ajax.open("POST", file, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) {
					idDiv.innerHTML = "Enviando voto...";   
				}
				if(ajax.readyState == 4 ) {
					if(ajax.responseXML) {
						processXML(ajax.responseXML);
						//idDiv.innerHTML = "Seu voto foi registrado! Obrigado por participar.";
					}
					else {
						idDiv.innerHTML = "Erro: não foi possível o envio.";
					}
				}
			}
			var params = 'cod='+cod+'&resposta='+marcado;
			ajax.send(params);
		}
		else{
			alert('Selecione uma resposta para votar!');
		}
	}
}
function processXML(obj){
	var dataArray = obj.getElementsByTagName("tudo");
	if(dataArray.length > 0) {
		for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			var retorno =  item.getElementsByTagName("retorno")[0].firstChild.nodeValue;
			idDiv.innerHTML = retorno;
		}
	}
	else {
		idDiv.innerHTML = "Erro ao enviar o voto! Por favor tente mais tarde.";
	}	  
}
