// JavaScript Document
function abre(pagina,janela,w,h,rolagem,maxi) {
if (maxi == '') maxi = 'no';
if (rolagem == '') rolagem = 'no';
window.open(pagina,janela,'width='+w+',height='+h+',scrollbars='+rolagem+',toolbar=no,location=no,status=no,menubar=no,resizable='+maxi+',left=200,top=5')
}


function redirectUrl(url) {
	window.location = url;
}
  
  function MouseOver(src,menu) {
    if (!src.contains(event.fromElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';

      menu.style.visibility="visible"
	}
  }
  function MouseOut(src,menu) {
	if (!src.contains(event.toElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';
	  src.style.cursor = 'default';

      menu.style.visibility="hidden"
	}
  }
  function MouseClique(src) {
    if(event.srcElement.tagName=='TD'){
	  src.children.tags('A')[0].click();
    }
  }
  
  
  function MouseOverSC(src) {
    if (!src.contains(event.fromElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';
	  src.bgColor = '#000000';
	}
  }
  function MouseOutSC(src) {
	if (!src.contains(event.toElement)) {
      src.style.border = 'solid 0px #000000 ';
	  src.style.cursor = 'hand';
	  src.style.cursor = 'default';
	  src.bgColor = '#000000';
	}
  }

// ENQUETE

window.defaultStatus="Ckless Internet - (51) 3333 9932"



// RECONHECE O BROWSER
var ns4 = (document.layers) ? true : false
var ie4 = (document.all) ? true : false

// FILTRA AS TECLAS PRESSIONADAS
function filtra(obj, padrao) {
	tk    = (ie4) ? event.keyCode : event.which;
	letra = String.fromCharCode(tk);
	
	for (x = 0; x < padrao.length; x++)
		if (padrao.slice(x, x + 1) == letra) return true;
	
	return false;
}

// BLOQUEIA CARACTERES EXCEDENTES EM TEXTAREAS
function maximo(obj, valor) {
	if (obj.value.length >= valor) return false;
}

// ESCREVE DINAMICAMENTE DENTRO DE UM LAYER
function escreve(id, txt) {
	if (ns4) {
		var lyr = document.layers[id].document;
		lyr.write(txt);
		lyr.close();
	} else
		document.getElementById(id).innerHTML = txt;
}

// FUNCOES PARA CONTROLE DE AVANCO EM CAMPOS DE TEXTO
function semTab() {
	checatab = false;
}

function comTab() {
	checatab = true;
} 

checatab = true;

// PULA PARA A CAIXA DE TEXTO DEFINIDA AO ALCANCAR O TAMANHO MAXIMO DE CARACTERES
function pula(origem, tamanho, destino) {
	if ((origem.value.length == tamanho) && checatab)
		destino.focus();
}

// INPEDE A EXECUCAO DE MENUS COM OS BOTOES DO MOUSE
function click() {
	if (event.button == 2 || event.button == 3) oncontextmenu = 'return false';
}

document.onmousedown   = click;
//document.oncontextmenu = new Function('return false;');

/*-----------------------------------------------------------------------
Somente Números e Letras
-----------------------------------------------------------------------*/

function somente_numletras(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 16 && tecla < 19 || tecla > 90 && tecla < 96 || tecla > 105 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}

/*-----------------------------------------------------------------------
Função para Pesquisa
-----------------------------------------------------------------------*/

function pesquisa(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 90 && tecla < 96 || tecla > 105 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}

/*-----------------------------------------------------------------------
Somente Números
-----------------------------------------------------------------------*/

function somente_num(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 48 || tecla > 57 && tecla < 96 || tecla > 105) 
	{
	return false;
	}
}

/*-----------------------------------------------------------------------
Função para E-mail
-----------------------------------------------------------------------*/

function valida_email(string) {
	padraoEmail = /^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*\.{1}[a-zA-Z]{2,4})+$/;
	var reg = new RegExp(padraoEmail);
	var obj = reg.test(string);
	
	if(obj)
		return true;
	else
		return false;		
}

/*-----------------------------------------------------------------------
Função para Validar Login e Senha
-----------------------------------------------------------------------*/

function valida_login(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 16 && tecla < 19 || tecla > 90 && tecla < 96 || tecla > 110 && tecla < 190 || tecla > 190 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}


/*-----------------------------------------------------------------------
Validação para os campos de Seja Um Fornecedor
-----------------------------------------------------------------------*/

function ValidaAtendimentoSejaUmFornecedor()
{
	
	if (document.getElementById("razaosocial").value == "" ) {
		alert('O campo Razao e obrigatorio \n');
		this.document.getElementById("razaosocial").focus();
		return false;
	}
	if (document.getElementById("nomefantasia").value == "" ) {
		alert('O campo Nome Fantasia e obrigatorio \n');
		this.document.getElementById("nomefantasia").focus();
		return false;
	}
	if (document.getElementById("endereco").value == "" ) {
		alert('O campo Endereco e obrigatorio \n');
		this.document.getElementById("endereco").focus();
		return false;
	}
	if (document.getElementById("endereconumero").value == "") {
		alert('O campo Numero e obrigatorio \n');
		this.document.getElementById("endereconumero").focus();
		return false;
	}
//validar numero(verificacao se contem apenas numeros)
	if (isNaN(document.getElementById("endereconumero").value)){
		alert ("O campo Numero deve conter apenas numeros!");
		this.document.getElementById("endereconumero").focus();
	 	return false;
	}
	if (document.getElementById("complemento").value == "" ) {
		alert('O campo Complemento e obrigatorio \n');
		this.document.getElementById("complemento").focus();
		return false;
	}
	if (document.getElementById("bairro").value == "" ) {
		alert('O campo Bairro e obrigatorio \n');
		this.document.getElementById("bairro").focus();
		return false;
	}
	if (document.getElementById("cidade").value == "" ) {
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("estado").value == "" ) {
		alert('O campo Estado e obrigatorio \n');
		this.document.getElementById("estado").focus();
		return false;
	}
	if ((document.getElementById("cep").value == "") && (document.getElementById("cep").value < 8 )) {
		alert('O campo CEP e obrigatorio \n');
		this.document.getElementById("cep").focus();
		return false;
	}
	if (isNaN(document.getElementById("cep").value)){
		alert ("O campo CEP deve conter apenas numeros!");
		this.document.getElementById("cep").focus();
	 	return false;
	}	
	if (document.getElementById("contato").value == "" ) {
		alert('O campo Contato e obrigatorio \n');
		this.document.getElementById("contato").focus();
		return false;
	}
	if (document.getElementById("emailfale").value == "" ) {
		alert('O campo E-mail e obrigatorio \n');
		this.document.getElementById("emailfale").focus();
		return false;
	}
	if (document.getElementById("emailfale").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("emailfale").focus();
		return false;
	}
	if ((document.getElementById("telefoneDDD").value == "") && (document.getElementById("telefoneDDD").value < 2 )) {
		alert('O campo Telefone DDD e obrigatorio \n');
		this.document.getElementById("telefoneDDD").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefoneDDD").value)){
		alert ("O campo Telefone DDD deve conter apenas numeros!");
		this.document.getElementById("telefoneDDD").focus();
		return false;
	}	
	if ((document.getElementById("telefone").value == "") && (document.getElementById("telefone").value < 8 )) {
		alert('O campo Telefone e obrigatorio \n');
		this.document.getElementById("telefone").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefone").value)){
		alert ("O campo Telefone deve conter apenas numeros!");
		this.document.getElementById("telefone").focus();
	 	return false;
	}
	if ((document.getElementById("faxDDD").value == "") && (document.getElementById("faxDDD").value < 2 )) {
		alert('O campo Fax DDD e obrigatorio \n');
		this.document.getElementById("faxDDD").focus();
		return false;
	}
	if (isNaN(document.getElementById("faxDDD").value)){
		alert ("O campo Fax DDD deve conter apenas numeros!");
		this.document.getElementById("faxDDD").focus();
		return false;
	}	
	if ((document.getElementById("fax").value == "") && (document.getElementById("fax").value < 8 )) {
		alert('O campo Fax e obrigatorio \n');
		this.document.getElementById("fax").focus();
		return false;
	}
	if (isNaN(document.getElementById("fax").value)){
		alert ("O campo Fax deve conter apenas numeros!");
		this.document.getElementById("fax").focus();
	 	return false;
	}	
	if (document.getElementById("descricao").value == "" ) {
		alert('O campo Descricao e obrigatorio \n');
		this.document.getElementById("descricao").focus();
		return false;
	}
	if (document.getElementById("preco").value == "" ) {
		alert('O campo Preco e obrigatorio \n');
		this.document.getElementById("preco").focus();
		return false;
	}
	if (isNaN(document.getElementById("preco").value)){
		alert ("O campo Preco deve conter apenas numeros!");
		this.document.getElementById("preco").focus();
	 	return false;
	}	
	if (document.getElementById("captchaVerify").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		document.sejaumfornecedor.submit();
		return true;
	}
}

function carregaCaptcha(val)
{
	xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("captchaVerify").setAttribute("value",xmlhttp.responseText);
		}
	}
	xmlhttp.open("GET","captcha_acao.asp?captchaTxt="+val,true);
	xmlhttp.send();
}

<!--ÍNICIO LIMITAR CARACTERES NO CAMPO OBSERVAÇÃO-->

function TextAreaDescricao(valor)
{
    quant = 500;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('cont').innerHTML = resto;
    }
    else
    {
        document.getElementById('descricao').value = valor.substr(0,quant);
    }
}
<!--FINAL LIMITAR CARACTERES NO CAMPO OBSERVAÇÃO-->
/*-----------------------------------------------------------------------
Validação para os campos de Carrinho
-----------------------------------------------------------------------*/

function ValidaCarrinho()
{
	padraoQuant = /([1-9]+[0-9]*)/;
	quantidade = document.getElementById("Quantidade").value;
	
	var ref = new RegExp(padraoQuant);
	var obj = ref.test(quantidade);

	if (obj)
		return true;
	else {
		alert("Preencha uma quantidade válida!");
		return false;
	}
}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho e Autenticacao e Direita
-----------------------------------------------------------------------*/

function ValidaLogin()
{
	if (document.getElementById("email").value == "")
	{
		alert('O campo Login e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}	
	if (document.getElementById("nome3").value == "")
	{
		alert('O campo Senha e obrigatorio \n');
		this.document.getElementById("nome3").focus();
		return false;
	}
	if (document.getElementById("login").value == "")
	{
		alert('O campo Login e obrigatorio \n');
		this.document.getElementById("login").focus();
		return false;
	}	
	if (document.getElementById("senha").value == "")
	{
		alert('O campo Senha e obrigatorio \n');
		this.document.getElementById("senha").focus();
		return false;
	}	
	else{
		return true;
	}	
}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho, Autenticacao e Direita
-----------------------------------------------------------------------*/

function ValidaDuvidas()
{	
	if (document.getElementById("enviadopor").value == "")
	{
		alert('O campo Nome e obrigatorio \n');
		this.document.getElementById("enviadopor").focus();
		return false;
	}
	if (document.getElementById("email").value == "")
	{
		alert('O campo Email e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("ddd").value == "")
	{
		alert('O campo Telefone DDD e obrigatorio \n');
		this.document.getElementById("ddd").focus();
		return false;
	}
	if (isNaN(document.getElementById("ddd").value))
	{
		alert('O campo Telefone DDD deve conter apenas numeros!');
		this.document.getElementById("ddd").focus();
		return false;
	}	
	if (document.getElementById("telefone").value == "")
	{
		alert('O campo Telefone e obrigatorio \n');
		this.document.getElementById("telefone").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefone").value))
	{
		alert('O campo Telefone deve conter apenas numeros!');
		this.document.getElementById("telefone").focus();
		return false;
	}	
	if (document.getElementById("cidade").value == "")
	{
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("pergunta").value == "")
	{
		alert('O campo Mensagem e obrigatorio \n');
		this.document.getElementById("pergunta").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		return true;
	}	
}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho(Opine)
-----------------------------------------------------------------------*/

function ValidaOpine()
{
	if (document.getElementById("titulo").value == "")
	{
		alert('O campo Titulo e obrigatorio \n');
		this.document.getElementById("titulo").focus();
		return false;
	}
	if (document.getElementById("resenha").value == "")
	{
		alert('O campo Resenha e obrigatorio \n');
		this.document.getElementById("resenha").focus();
		return false;
	}
	if (document.getElementById("nome").value == "")
	{
		alert('O campo Nome e obrigatorio \n');
		this.document.getElementById("nome").focus();
		return false;
	}
	if (document.getElementById("email").value == "")
	{
		alert('O campo E-mail e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("cidade").value == "")
	{
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		return true;
	}	
}	