    // ADDITIONAL INFORMATION FORM VALIDATION
    function ValidateADDITIONALINFO(){
        if (document.frm.add_info.value=="") {
        	alert("Por favor digite a informação adicional.")
        	document.frm.add_info.focus()
        return false }
    }
    // CLEAR BOOKMARKS
    function ClearBooks() {
    	if (confirm("Limpar todos os seus favoritos?")) {
    		window.location.replace("bookmarks.asp?clear=true");
    	}
    }
    // CLOSE ISSUE
    function CloseIssue(ID) {
    	if (confirm("Você gostaria de sair dessa edição?")) {
    		window.location.replace("update.asp?ID=" + ID + "&closed=True");
    	}
    }    
    // VALIDATE STATUS
    function ValidateStatus(){
        if (document.frm.id.value=="") {
        	alert("Por favor digite o número do ID para continuar.")
        	document.frm.id.focus()
        return false }
    }    
    // ADD BOOKMARK
    function AddBookmark(ID, CATE) {
    	if (confirm("Adicionar essa edição aos seus favoritos?")) {
    		window.location.replace("bookmark_add.asp?ID=" + ID + "&CATE=" + CATE);
    	}
    }
    // REMINDER FORM VALIDATION
    function ValidateREMINDER(){
        if (document.frm.email.value=="") {
        	alert("Por favor digite seu e-mail.")
        	document.frm.email.focus()
        return false }
    }
    // SEND EMAIL FORM VALIDATION \\
    function ValidateSENDEMAIL(){
        if (document.frm.y_name.value=="") {
        	alert("Por favor digite seu nome.")
        	document.frm.y_name.focus()
        return false }
        if (document.frm.y_email.value=="") {
        	alert("Por favor digite seu e-mail.")
        	document.frm.y_email.focus()
        return false }
        if (document.frm.f_name.value=="") {
        	alert("Por favor digite o nome do seu amigo.")
        	document.frm.f_name.focus()
        return false }
        if (document.frm.f_email.value=="") {
        	alert("Por favor digite o e-mail do seu amigo.")
        	document.frm.f_email.focus()
        return false }
    }
    // SEARCH FORM VALIDATION \\
    function ValidateSEARCH(){
        if (document.frm.search.value=="") {
        	alert("Digite uma frase para localizar o que deseja.")
        	document.frm.search.focus()
        return false }
    }
    // MY QUESTIONS LOGIN FORM VALIDATION \\
    function ValidateMYQUESTIONS(){
        if (document.frm.username.value=="") {
        	alert("Por favor digite seu nome de usuário.")
        	document.frm.username.focus()
        return false }
        if (document.frm.password.value=="") {
        	alert("Por favor digite sua senha.")
        	document.frm.password.focus()
        return false }
    }
    // AJUSTE PARA VALIDAR CPF ou CNPJ
	function Altera_campo()
	{
		if (document.frm.Tipo_Cad[0].checked==true)
		{
			document.frm.CPF.maxLength= "14";
			document.frm.CPF.value = '';
			document.frm.CPF.onkeypress = function() {numeros(); formatar(this, '###.###.###-##')}
			document.frm.cf1.disabled = true;
			document.frm.RG_Estado.disabled = false;
			document.frm.CODIGO.disabled = false;
			document.frm.cf1.value= "Desabilitado para Pessoa Fisica"
			//alert(document.frm.cf1.value);
			if ((document.frm.CODIGO.value == ""))
			{
				document.frm.CODIGO.value = "";
			}
		}
			else if(document.frm.Tipo_Cad[1].checked==true)
			{
				document.frm.CPF.maxLength = "18";
				document.frm.CPF.value = '';
				document.frm.CPF.onkeypress = function() {numeros(); formatar(this, '##.###.###/####-##')}	
				document.frm.cf1.disabled = false;
				document.frm.RG_Estado.disabled = true;
				document.frm.CODIGO.disabled = true;
				document.frm.CODIGO.value ="Desabilitado para Pessoa Jurídica"; 
				document.frm.cf1.value= "";
			}
		else
		{
			alert("Selecione o tipo de cadastro");
			document.frm.Tipo_Cad[0].focus();
		}
	}
	//Mascara do Telefone
	function tel(evento, objeto)
{
	var keypress=(window.event)?event.keyCode:evento.which;
	campo = eval (objeto);
	if (campo.value == '(00) 0000-0000')
	{
		campo.value=""
	}

	caracteres = '0123456789';
	separacao1 = '(0';
	separacao2 = ') ';
	separacao3 = '-';
	conjunto1 = 0;
	conjunto2 = 4;
	conjunto3 = 10;
	conjunto4 = 15;
		
	if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (15))
	{
		if (campo.value.length == conjunto1 )
		campo.value = campo.value + separacao1;
		else if (campo.value.length == conjunto2)
		campo.value = campo.value + separacao2;
		else if (campo.value.length == conjunto3)
		campo.value = campo.value + separacao3;
	}
	else
		event.returnValue = false;
}
	function formatar(src, mask)
	{
	  //Exemplo: OnKeyPress="formatar(this, '##/##/####')"
	  var i = src.value.length;
	  var saida = mask.substring(0,1);
	  var texto = mask.substring(i)
		if (texto.substring(0,1) != saida)
	  {
		src.value += texto.substring(0,1);
	  }
	}
	// VERIFICAÇÃO DO CPF
	function checaCPF (CPF) 
	 {
		CPF =CPF.replace('.','');
		CPF =CPF.replace('.','');
		CPF =CPF.replace('-','');
	
		if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
			CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
			CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
			CPF == "88888888888" || CPF == "99999999999")
			return false;
		soma = 0;
		for (i=0; i < 9; i ++)
			soma += parseInt(CPF.charAt(i)) * (10 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11)
			resto = 0;
		if (resto != parseInt(CPF.charAt(9)))
			return false;
		soma = 0;
		for (i = 0; i < 10; i ++)
			soma += parseInt(CPF.charAt(i)) * (11 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11)
			resto = 0;
		if (resto != parseInt(CPF.charAt(10)))
			return false;
		return true;
	 }
	// VALIDA CNPJ 
	function checaCNPJ(CNPJ) 
	{
                 erro = new String;
                 if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ! \n\n"; 
                 if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
                 if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
                 }
                 //substituir os caracteres que não são números
               if(document.layers && parseInt(navigator.appVersion) == 4){
                       x = CNPJ.substring(0,2);
                       x += CNPJ. substring (3,6);
                       x += CNPJ. substring (7,10);
                       x += CNPJ. substring (11,15);
                       x += CNPJ. substring (16,18);
                       CNPJ = x; 
               } else {
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace (".","");
                       CNPJ = CNPJ. replace ("-","");
                       CNPJ = CNPJ. replace ("/","");
               }
               var nonNumbers = /\D/;
               if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n"; 
               var a = [];
               var b = new Number;
               var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
               for (i=0; i<12; i++){
                       a[i] = CNPJ.charAt(i);
                       b += a[i] * c[i+1];
 }
               if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
               b = 0;
               for (y=0; y<13; y++) {
                       b += (a[y] * c[y]); 
               }
               if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
               if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
                       erro +="Dígito verificador com problema!";
               }
               if (erro.length > 0){
                       alert(erro);
                       return false;
               } else {
                       alert("CNPJ valido!");
               }
               return true;
       }

	// VERIFICA TIPO DE CADASTRO.
	function Verifica_Tipo_Cad()
	{
		var d = document.frm;
		
		if (((d.Tipo_Cad[0].checked == false)||(d.Tipo_Cad[1].checked == true))&&((d.Tipo_Cad[0].checked == true)||(d.Tipo_Cad[1].checked == false)))
		{
			alert("Selecione o tipo de cadastro\n Pessoa Fisica ou Juridica");
			document.frm.Tipo_Cad[0].focus();
		}
	}
	// SUBMIT ISSUE FORM VALIDATION \\
    function ValidateNEWISSUE(){
       d = document.frm
		nome = d.name.value.split(" ")
		tmp = nome.length
		if (tmp <= 1)
		{
			alert("Informe nome e sobrenome!!!");
			d.name.focus();
			return false;
		}
		else
		{
			if ((nome[0].length < (3))||(nome[1].length < (2))||(nome[0] == nome[1]))
			{
				alert("Informe nome e sobrenome correto!!!");
				d.name.focus();
				return false;
			}
	
		}
		var mail = d.email.value
		var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); 
		var erro = 1 
		if(typeof(mail) == "string")
		{                
			if(er.test(mail))
			{ erro = 0; }        
		}
		else if(typeof(mail) == "object")
		{                
			if(er.test(mail.value))
			{                                         
				erro = 0;                                 
			}        
		}
		else
		{                
			erro= 1
		}
      	if (erro == 1)
		{
			alert("Informe um E-mail valido");
			d.email.focus();
			return false; 
		}
       	if (d.url.selectedIndex =='')
		{
			alert("Selecione uma das opções \"Tipo de Acesso\".");
			d.url.focus();
			return false;
		}
		if (document.frm.DTNASC_Dia.value == "")
		{
			alert("Selecione o dia da data nascimento");
			document.frm.DTNASC_Dia.focus();
			return false;
		}
		else if(document.frm.DTNASC_Mes.value == "")
		{
			alert("Selecione o mês da data nascimento");
			document.frm.DTNASC_Mes.focus();
			return false;
		}
		else if (document.frm.DTNASC_Ano.value == "")
		{
			alert("Selecione o ano da data nascimento");
			document.frm.DTNASC_Ano.focus();
			return false;
		}
		else
		{
			var dia = document.frm.DTNASC_Dia.selectedIndex;
			var mes = document.frm.DTNASC_Mes.selectedIndex;
			var ano = document.frm.DTNASC_Ano.selectedIndex;
			
			document.frm.DTNASC.value = dia+"/"+mes+"/"+document.frm.DTNASC_Ano[ano].value;
		}
		
		if (document.frm.CODIGO.value=="") 
		{
        	alert("Por favor digite seu RG .")
        	document.frm.CODIGO.focus()
       		return false 
		}
		if (d.RG_Estado.selectedIndex =='')
		{
			alert("Selecione uma das opções \"Estado emissor do RG\".");
			d.RG_Estado.focus();
			return false;
		}
		if (document.frm.CPF.value=="") 
		{
        	alert("Por favor digite seu CPF.")
        	document.frm.CPF.focus()
        	return false 
		}
		else
		{
			if (d.Tipo_Cad[0].checked == true)
			{
				if(checaCPF(d.CPF.value))
			    {}
				else
				{
					alert("informe um CPF Valido");
					return false;
				}
			}
			else if (d.Tipo_Cad[1].checked == true)
			{
				if (checaCNPJ(d.CPF.value))
				{}
				else
				{
					alert("informe um CNPJ Valido");
					return false; 
				}
			}
		}
		var tel = d.TELEFONE.value
		tel = tel.replace("-","");
		tel = tel.replace(" ","");
		tel = tel.replace(")","");
		tel = tel.replace("(","");
		if(tel.length != 11)
		{
			alert("Informe o telefone corretamente \ndigitar apenas numeros.");
			d.TELEFONE.focus();
			return false;
		}
		if (d.cate.selectedIndex =='')
		{
			alert("Selecione uma das opções \"Selecionar o Assunto\".");
			d.cate.focus();
			return false;
		}
		if (document.frm.question.value=="") 
		{
        	alert("Por favor digite sua questão.")
        	document.frm.question.focus()
        	return false 
		}
		if ((document.frm.username.value == "") || (document.frm.username.value.length < (5)))
		{
			alert("Informe o login no minimo de 5 caracteres.");
			document.frm.username.focus();
			return false;
		}
		if((document.frm.password.value == "") || (document.frm.password.value.length < (5)))
		{
			alert("Informe o senha no minimo de 5 caracteres.");
			document.frm.password.focus();
			return false;	
		}
    }
	//Aceita apenas numeros
	function numeros()
	{
	  var tecla = window.event.keyCode;
	  tecla     = String.fromCharCode(tecla);
	  if(!((tecla >= "0") && (tecla <= "9")))
	  {
		window.event.keyCode = 0;
	  }
	}
	
	function formatar(src, mask){
	  //Exemplo: OnKeyPress="formatar(this, '##/##/####')"
	  var i = src.value.length;
	  var saida = mask.substring(0,1);
	  var texto = mask.substring(i)
	if (texto.substring(0,1) != saida)
	  {
		src.value += texto.substring(0,1);
	  }
	}
    // OPEN SIDE WIDNOW PANEL
    function MDM_openWindow(theURL,winName,features) { 
	  window.resizeTo(screen.width-280,screen.height-26)
	  window.moveTo(0,0);
      var _W=window.open(theURL,winName,features);
	  _W.focus();
	  _W.resizeTo(280,screen.height-26)
      _W.moveTo(screen.width-280,0); 	  
      _W.opener.name = "opener";
    }
    // ASK BEFORE LAUNCHING
    function ASK_MDM_openWindow(theURL,winName,features) { 
        if (confirm("Abrir a janela lateral? \n\nUma nova janela será aberta\ para a visualização dos chamados e busca rápida.")) {
    	  window.resizeTo(screen.width-280,screen.height-26)
    	  window.moveTo(0,0);
          var _W=window.open(theURL,winName,features);
    	  _W.focus();
    	  _W.resizeTo(280,screen.height-26)
          _W.moveTo(screen.width-280,0); 	  
          _W.opener.name = "opener";
    	}
    }      
    // VALIDATE COMMENT FORM
    function ValidComment(){
        if (document.frm.comment.value=="") {
        	alert("Por favor digite seu comentário.")
        	document.frm.comment.focus()
        return false }
    }
    // DROP DOWN NAVIG    
    function Jump(fe){
        var opt_key = fe.selectedIndex;
        var uri_val = fe.options[opt_key].value;
        window.open(uri_val,'_top');
        return true;
    }