function numero_rnd(quanto_rnd){  
  
      return Math.floor(Math.random()*quanto_rnd)  
 }  

function createXMLHTTP() {


	try {
		ajax = new XMLHttpRequest();
		 return ajax;
		} 
	catch(e){
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex){
			   try{
					ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
					}
			   catch(exc){
						   alert("Esse browser não tem recursos para uso do Ajax");
							ajax = null;
						  }
					}
      }
	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 recuperarInfo(modo,campo,valida,tag){
// Criação do objeto XMLHTTP

document.getElementById(tag).innerHTML ='carregando...' 

var oHTTPRequest = createXMLHTTP();



// A função abaixo é executada sempre que o estado do objeto muda (onreadystatechange)

if(modo == 'get') 
{
	oHTTPRequest.open('get', campo+'&s='+numero_rnd(999), valida);
} else
{        
	oHTTPRequest.open('post', campo+'&s='+numero_rnd(999), valida);
	oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	oHTTPRequest.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	oHTTPRequest.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	oHTTPRequest.setRequestHeader("Pragma", "no-cache")
 }    
	
  
oHTTPRequest.onreadystatechange=function() {
	// O valor 4 significa que o objeto já completou a solicitação
	if (oHTTPRequest.readyState==4){
		// Abaixo o texto é gerado no arquivo del_result.asp e colocado no div
		document.getElementById(tag).innerHTML = oHTTPRequest.responseText;
	 }
}
// Abaixo é enviada a solicitação. Note que a configuração
// do evento onreadystatechange deve ser feita antes do send.
oHTTPRequest.send(null);
}

//}
// JavaScript Document

function IEHoverPseudo() {

    var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
    
    for (var i=0; i<navItems.length; i++) {
        if(navItems[i].className == "menuparent") {
            navItems[i].onmouseover=function() { this.className += " over"; }
            navItems[i].onmouseout=function() { this.className = "menuparent"; }
        }
    }

}
window.onload = IEHoverPseudo;


//Fumção da Caixa de Email
function expandcollapse (postid) { 
   whichpost = document.getElementById(postid); 
   if (whichpost.className=="postshown") { 
      whichpost.className="posthidden"; 
   } 
   else { 
      whichpost.className="postshown"; 
   } 
} 

//Função do Menu
startList = function() {

	//code only for IE
	if(!document.body.currentStyle) return;
	var subs = document.getElementsByName('submenu');
	for(var i=0; i<subs.length; i++) {
		var li = subs[i].parentNode;
		if(li && li.lastChild.style) {
			li.onmouseover = function() {
				this.lastChild.style.visibility = 'visible';
			}
			li.onmouseout = function() {
				this.lastChild.style.visibility = 'hidden';
			}
		}
	}
}
window.onload=startList;


//função para validar e-mail

function validar()

{
   if (document.tvcreci.nome.value.length == 0)
   {
      alert("Nome em branco");
	  
      return false;
   }
   if (document.tvcreci.numero.value.length == 0)
   {
      alert("Creci em branco");
	  
      return false;
   }
      if (document.tvcreci.email.value.length == 0)
   {
      alert("E-mail em branco");
	  
      return false;
   }
      if (document.tvcreci.assunto.value.length == 0)
   {
      alert("Assunto em branco");
	  
      return false;
   }

}


//cadastro.asp
function File(){
open('arquivo.asp?id=' + document.prog.id.value, 'iframe') 
	    return true;

	}
	function Div(id) { 
	open('arquivo.asp?id=' + document.prog.id.value, 'iframe');
   whichpost = document.getElementById(id); 
   if ( document.prog.aovivo.value== 1) { 
      whichpost.className="div"; 
	 
   } 
   else { 
      whichpost.className="divoc"; 
	  
   } 
} 

 // url_encode version 1.0 
    function url_encode(str) { 
        var hex_chars = "0123456789ABCDEF"; 
        var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
        var n, strCode, hex1, hex2, strEncode = ""; 

        for(n = 0; n < str.length; n++) { 
            if (noEncode.test(str.charAt(n))) { 
                strEncode += str.charAt(n); 
            } else { 
                strCode = str.charCodeAt(n); 
                hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
                hex2 = hex_chars.charAt(strCode % 16); 
                strEncode += "%" + (hex1 + hex2); 
            } 
        } 
        return strEncode; 
    } 

    // url_decode version 1.0 
    function url_decode(str) { 
        var n, strCode, strDecode = ""; 

        for (n = 0; n < str.length; n++) { 
            if (str.charAt(n) == "%") { 
                strCode = str.charAt(n + 1) + str.charAt(n + 2); 
                strDecode += String.fromCharCode(parseInt(strCode, 16)); 
                n += 2; 
            } else { 
                strDecode += str.charAt(n); 
            } 
        } 

        return strDecode; 
    } 
	
function mudar(txt){
	
	var teste = new String(txt); 
  	teste = teste.replace(/[ó]+/g,"&ocirc;");
	return teste;
}
	
	
	