    var xmlhttp;
    var id;

	function CriaObjetoAjax(){
    try
    {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
        try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {    
        xmlhttp = false;
        }
    }
    
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined' )
    {
        try
        {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e)
        {
            xmlhttp = false;
        }
    }
    }
	
    function changetut()
    {
        if (xmlhttp.readyState==4)
        {
			texto=unescape(xmlhttp.responseText.replace(/\+/g," "));
            document.getElementById(form).innerHTML=texto;
        }
    }	
	
    function TutorialVoto(id,ops){    
		CriaObjetoAjax();
		form = "confirma_voto";
		document.getElementById(form).innerHTML="";
		if (xmlhttp) {
			xmlhttp.open("GET","funcao.asp?acao=votar&tutorial="+id+"&ops="+ops,true);
			xmlhttp.onreadystatechange=changetut;
			xmlhttp.send(null);	
		}
    }
	
    function EnviaFormComentarioTut(url,campos){    
		CriaObjetoAjax();
		form = "confirma_voto";
		document.getElementById(form).innerHTML="";
		if (xmlhttp) {
			xmlhttp.open("GET",url+campos,true);
			xmlhttp.onreadystatechange=change1;
			xmlhttp.send(null);	
		}
    }
	
	function setarComentarioTut() {
		campos = "&comentario="+encodeURI(document.getElementById('comentario_voto').value);
		campos += "&tutorial="+encodeURI(document.getElementById('id_tutorial').value);		

		document.getElementById('comentario_voto').value = "";		
	}	
	
	

    function change1()
    {
        if (xmlhttp.readyState==4)
        {
			texto=unescape(xmlhttp.responseText.replace(/\+/g," "));
            document.getElementById(form).innerHTML=texto;
			extraiScript(texto);
			campos = ""
        }
    }	
	
    function EnviaForm(url,campos){    
		CriaObjetoAjax();
		form = "msgnews";
		document.getElementById(form).innerHTML="";
		if (xmlhttp) {
			xmlhttp.open("GET",url+campos,true);
			xmlhttp.onreadystatechange=change1;
			xmlhttp.send(null);	
		}
    }
	
	function setarNews() {
		campos = "&nome="+encodeURI(document.getElementById('nome_news').value);
		campos += "&email="+encodeURI(document.getElementById('email_news').value);
		
		if (document.frm_news.opcao_news[0].checked == true){
			campos += "&opcao=cadastrar";
		}
		if (document.frm_news.opcao_news[1].checked == true){
			campos += "&opcao=excluir";
		}	
		
		document.getElementById('nome_news').value = "";
		document.getElementById('email_news').value = "";		
	}		
	
	function extraiScript(texto){
	//Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
	//http://forum.imasters.com.br/index.php?showtopic=165277
		// inicializa o inicio ><
		var ini = 0;
		// loop enquanto achar um script
		while (ini!=-1){
			// procura uma tag de script
			ini = texto.indexOf('<script', ini);
			// se encontrar
			if (ini >=0){
				// define o inicio para depois do fechamento dessa tag
				ini = texto.indexOf('>', ini) + 1;
				// procura o final do script
				var fim = texto.indexOf('</script>', ini);
				// extrai apenas o script
				codigo = texto.substring(ini,fim);
				/**********************
				
				* Alterado por Micox - micoxjcg@yahoo.com.br
				* Alterei pois com o eval não executava funções.
				
				* Alterado por Everton D. Silva - everton.silva@streamingshop.com.br
				* não estava retornando o valor
				***********************/
				var novo = document.createElement('script');
				novo.type         = 'text/javascript';
				novo.language    = 'javascript';
				novo.text = codigo;
				document.body.appendChild(novo);
			}
		}
	}	