// JavaScript Document
function startAjax(){
	try {
		xmlhttp = new XMLHttpRequest();
	} catch(e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ee){
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E){
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

/* CHAMA O FLASH */
function callFlash(_path,_w,_h) {
	 var flash = "";  
	 flash = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + _w + "' height='" + _h + "'>";
	 flash += "<param name='movie' value='" + _path + "' />";
	 flash += "<param name='quality' value='high' />";
	 flash += "<param name='wmode' value='transparent' />";
	 flash += "<embed src='" + _path + "' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + _w + "' height='" + _h + "'></embed>";
	 flash += "</object>";  
	 document.write(flash);  
}


function erase(_id){
	var el = document.getElementById(_id);
	el.parentNode.removeChild(el);
}

function flyBanner(){
	document.getElementById("fly_banner").style.display = 'block';
}



/*
	NECESSITAM DA BIBLIOTECA prototype.js
*/

function e_mail_CHECKER(){
	
	var em = $F("frm_email");
	var url = "../default/email.asp";
	var pars = 'e_mail=' + em + "&pergunta=" + Enquete.__pergunta + "&resposta=" + Enquete.__resposta;
	
	var myAjax = new Ajax.Request(
		url, 
		{
			parameters: pars, 
			onSuccess: function(t){
				switch (parseInt(t.responseText)){
					case 0: 
						alert("E-mail não encontrado");
						location.href = "../cadastro/cadastro.asp";					
						break;
					case 1:
							Enquete.Resultados();
						break;
					case 9:
						alert("Erro! Não foi possível computar seu voto\nTente novamente mais tarde");
						break;
				}
			},
			onFailure: function(t){
				document.write(t.responseText)
			}
		});		
	

}
	
var Enquete = {
	
	__resposta: null,
	__pergunta: null,

	Resposta: function(_value){
		this.__resposta = _value;
	},
	
	Resultados: function(){
		
		$("enquete_email").innerHTML += "Carregando resultados...";
		
		var url = "../default/enquete_resultado.asp";
		var pars = "pergunta=" + this.__pergunta

		var myAjax = new Ajax.Request(
		url, 
		{
			parameters: pars, 
			onSuccess: function(t){
				$("enquete_email").innerHTML = t.responseText;
			},
			onFailure: function(t){
				document.write(t.responseText)
			}			
		});	
		
	},
	
	
	ComputarVoto: function(_enqueteID){
		this.__pergunta = _enqueteID;
		$("enquete_form").hide();
		$("enquete_email").show();
	}
	
}


/*
	FIM
*/

