
   /*verifica e-mails*/
function is_email(email) 

    {
      er = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;
      
      if(er.exec(email))
        {
          return true;
        } else {
          return false;
        }
    }

   /*Pai das Mascaras*/
    function Mascara(o,f){
        v_obj=o
        v_fun=f
        setTimeout("execmascara()",1)
    }
    
    /*Executa os objetos*/
    function execmascara(){
        v_obj.value=v_fun(v_obj.value)
    }
    
    /*Determina as expressões regulares dos objetos*/
    function leech(v){
        v=v.replace(/o/gi,"0")
        v=v.replace(/i/gi,"1")
        v=v.replace(/z/gi,"2")
        v=v.replace(/e/gi,"3")
        v=v.replace(/a/gi,"4")
        v=v.replace(/s/gi,"5")
        v=v.replace(/t/gi,"7")
        return v
    }
    
    /*permite apenas numeros*/
    function Integer(v){
        return v.replace(/\D/g,"")
    }

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function envia() {
if (document.formcadastro.nome.value == '') 
  { 
  window.alert('Campo nome deve ser preenchido !');
  }
  else
  {
     if (document.formcadastro.empresa.value == '')
     {
     window.alert('Campo empresa deve ser preenchido !');
     }
     else
     {
        if (document.formcadastro.email.value == '')
        {
        window.alert('Campo e-mail deve ser preenchido !');
        }
        else
        {
           if (is_email(document.formcadastro.email.value) == false)
           {
           window.alert('E-mail invalido! Verifique.');
           return false;
           }
           else
           {
              if (document.formcadastro.ddd.value == '')
              {
              window.alert('Campo DDD deve ser preenchido !');
              }
              else
              {
                 if (document.formcadastro.ddd.value.length < 2)
                 {
                 window.alert('DDD com menos de 2 digitos ! Verifique.');
                 }
                 else
                 {
                    if (Left(document.formcadastro.ddd.value, 1) == '0')
                    {
                    window.alert('DDD invalido ! Verifique.');
                    }
                    else
                    {
                       if (document.formcadastro.telefone.value == '')
                       {
                       window.alert('Campo telefone deve ser preenchido !');
                       }
                       else
                       {
                          if (document.formcadastro.telefone.value.length < 8)
                          {
                          window.alert('Telefone com menos de 8 digitos ! Verifique.');
                          }
                          else
                          {
                          document.formcadastro.submit();
                          }
                       }
                    } 
                 }   
              }
           }
        }
     }
  }
}

/*limita o text area do txtobs*/
function limitaareaobs(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs').value = valor.substr(0,quant);
    }
}


function limitaarealivro(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontassuntolivro').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtassuntolivro').value = valor.substr(0,quant);
    }
}

function limitaareanorma(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontassuntonorma').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtassuntonorma').value = valor.substr(0,quant);
    }
}

function limitaareaperiodico(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontassuntoperiodico').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtassuntoperiodico').value = valor.substr(0,quant);
    }
}


<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


// NOVO A PARTIR DAQUI!

/*limita o text area do txtobs1*/
function limitaareaobs1(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs1').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs1').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs2*/
function limitaareaobs2(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs2').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs2').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs3*/
function limitaareaobs3(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs3').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs3').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs4*/
function limitaareaobs4(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs4').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs4').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs5*/
function limitaareaobs5(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs5').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs5').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs6*/
function limitaareaobs6(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs6').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs6').value = valor.substr(0,quant);
    }
}

/*limita o text area do txtobs7*/
function limitaareaobs7(valor)
{
    quant = 255;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontobs7').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtobs7').value = valor.substr(0,quant);
    }
}

/*limita o text area do campo endereço*/
function limitaareaendereco(valor)
{
    quant = 100;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('txtcontendereco').innerHTML = resto;
    }
    else
    {
        document.getElementById('txtendereco').value = valor.substr(0,quant);
    }
}


function enviarIbisFull() {
if (confirm('\n\nAs informacoes deste cadastro nao serao\nfornecidas para terceiros sem a sua previa\nautorizacao.\n\nDeseja realizar este cadastro?\n\n')) 
 {
  if (document.formcadastro.txtnome.value == '')
     {
      window.alert('Campo nome deve ser preenchido!');
      return false;
     }
  else
     {
      if (document.formcadastro.txtempresa.value == '')
         {
          window.alert('Empresa/instituicao deve ser preenchido!');
          return false;
         }
      else
         {
          if (document.formcadastro.txtfuncao.value == '')
             {
              window.alert('Funcao deve ser preenchida');
              return false;
              }
                       else
                          {
                           if (document.formcadastro.txtdddtelefone.value == '')
                              {
                               window.alert('DDD do telefone deve ser preenchido!');
                               return false;
                              }
                           else
                              {
                               if (document.formcadastro.txttelefone.value == '')
                                  {
                                   window.alert('Telefone deve ser preenchido!');
                                   return false;
                                   }
                               else
                                   {
                                    if (document.formcadastro.txtemail.value == '')
                                       {
                                        window.alert('E-mail deve ser preenchido!');
                                        return false;
                                       }
                                    else
                                       {
                                        if (is_email(document.formcadastro.txtemail.value) == false)
                                           {
                                            window.alert('E-mail invalido! Verifique.');
                                            return false;
                                           }
                                           else
                                           {
                                            if (document.formcadastro.txtobs1.value == '')
                                               {
                                                window.alert('Item A da area de interesse deve ser preenchido!');
                                                return false;
                                                }
                                            else
                                                {
                                                 if (document.formcadastro.numusuarios.value == '')
                                                    {
                                                     window.alert('Selecione a quantidade de usuarios!');
                                                     return false;
                                                     }
                                                 else
                                                     {
                                                      document.formcadastro.submit();
                                                      return true;
                                                     }
                                                }
                                           }
                                       }
                                   }
                              }
                          }
                      }
                  }
              }

 else
 {
 return false;
 }
}

function limparIbisFull() {
if (confirm('Deseja limpar os dados ja digitados ?')) 
 {
 document.formcadastro.reset();
 return true;
 }
 else
 {
 return false;
 }
}

function enviapesquisa() {
if (document.formbusca.pesquisa.value != '') 
  { 
  document.formbusca.submit();
  }
  else
  {
  window.alert('Campo de pesquisa deve ser preenchido !');
  }
}

function Trim(str){
return str.replace(/^\s+|\s+$/g,"");
}

function filtropesquisa2() {

window.alert('teste');

}

function filtropesquisa() {

var objRadio = document.formbusca.decx;

tamPesquisa = document.formbusca.pesquisa.value.length;
vlrPesquisa = document.formbusca.pesquisa.value.toLowerCase();
vlrPesquisa = vlrPesquisa.replace(' ','');
//vlrDecxZero = document.formbusca.decx(0).checked;
vlrDecxZero = objRadio[0].checked;
//vlrDecxUm = document.formbusca.decx(1).checked;
vlrDecxUm = objRadio[1].checked;

if (vlrDecxZero == false && vlrDecxUm == false)
	{
	window.alert('\n\nVocê deve selecionar o tipo da pesquisa!\n\n');
	}
	else
	{
		if (tamPesquisa < 3 && vlrDecxZero == true)
		{
		window.alert('\n\nConsulta deve ser maior ou igual a 3 caracteres!\n\n');	
		}
		else
		{
			if (tamPesquisa < 4 && vlrDecxUm == true)
			{
		    window.alert('\n\nConsulta deve ser maior ou igual a 4 caracteres!\n\n');
			}
			else
			{
				if (Trim(vlrPesquisa) == 'din' && vlrDecxZero == true)
				{
			    window.alert('\n\nSeja mais expecifico sobre a consulta da norma DIN, por exemplo DIN EN 13758 ou DIN 10.\n\n');
				}
				else
				{
					if (Trim(vlrPesquisa) == 'astm' && vlrDecxZero == true)
					{
				    window.alert('\n\nSeja mais expecifico sobre a consulta da norma ASTM, por exemplo ASTM D 1842.\n\n');
					}
					else
					{
						if (Trim(vlrPesquisa) == 'ansi' && vlrDecxZero == true)
						{
					    window.alert('\n\nSeja mais expecifico sobre a consulta da norma ANSI, por exemplo ANSI 179.\n\n');
						}
						else
						{
							if (Trim(vlrPesquisa) == 'iso' && vlrDecxZero == true)
							{
						    window.alert('\n\nSeja mais expecifico sobre a consulta da norma ISO, por exemplo ISO 4149.\n\n');
							}
							else
							{
								if (Trim(vlrPesquisa) == 'iec' && vlrDecxZero == true)
								{
							    window.alert('\n\nSeja mais expecifico sobre a consulta da norma IEC, por exemplo IEC 60880.\n\n');
								}
								else
								{
									if (Trim(vlrPesquisa) == 'sae' && vlrDecxZero == true)
									{
								    window.alert('\n\nSeja mais expecifico sobre a consulta da norma SAE, por exemplo SAE J 1245.\n\n');
									}
									else
									{
										if (Trim(vlrPesquisa) == 'jis' && vlrDecxZero == true)
										{
									    window.alert('\n\nSeja mais expecifico sobre a consulta da norma JIS, por exemplo JIS Z 8071.\n\n');
										}
										else
										{
											if (Trim(vlrPesquisa) == 'bs' && vlrDecxZero == true)
											{
										    window.alert('\n\nSeja mais expecifico sobre a consulta da norma BS, por exemplo BS 2468.\n\n');
											}
											else
											{
												if (Trim(vlrPesquisa) == 'nf' && vlrDecxZero == true)
												{
											    window.alert('\n\nSeja mais expecifico sobre a consulta da norma NF, por exemplo NF D36.\n\n');
												}
												else
												{
													if (Trim(vlrPesquisa) == 'itu' && vlrDecxZero == true)
													{
												    window.alert('\n\nSeja mais expecifico sobre a consulta da norma ITU, por exemplo ITU-R.\n\n');
													}
													else
													{
														if (Trim(vlrPesquisa) == 'ieee' && vlrDecxZero == true)
														{
													    window.alert('\n\nSeja mais expecifico sobre a consulta da norma IEEE, por exemplo IEEE 1194.\n\n');
														}
														else
														{
															if (Trim(vlrPesquisa) == 'asme' && vlrDecxZero == true)
															{
														    window.alert('\n\nSeja mais expecifico sobre a consulta da norma ASME, por exemplo ASME 3287.\n\n');
															}
															else
															{
															//window.alert('\n\nFaz a pesquisa ' + vlrPesquisa + ' !\n\n');
															enviapesquisa();
															MM_showHideLayers('carregando','','show');
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

