function writeCookieTela()
{
	var date = new Date();
	date.setTime(date.getTime()+(30*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();

var the_cookie = "AZ_tela="+ screen.width + expires;
document.cookie=the_cookie


}

function limite(campo, countcampo, maxlimit)
{
if (campo.value.length > maxlimit)
{
  campo.value = campo.value.substring(0, maxlimit);
}
else
  countcampo.value = maxlimit - campo.value.length;
}

function mostraEsconde(qual)
{
	if (document.getElementById(qual).style.display == "none") {
		document.getElementById(qual).style.display = "";
	}
	else {
		document.getElementById(qual).style.display = "none";
	}
}

function mostra(qual)
{
	if (document.getElementById(qual).style.display == "none") {
		document.getElementById(qual).style.display = "";
	}
}

function mostrax(qual)
{
	if (document.getElementById(qual).style.display == "none") {
		document.getElementById(qual).style.display = "";
	}
	
	if (qual == "vendas") 
	{
		document.getElementById('linkc').className = "tabh";
		document.getElementById('linkv').className = "tab";
	}
	if (qual == "compras") 
	{
		document.getElementById('linkv').className = "tabh";
		document.getElementById('linkc').className = "tab";
	}
}

function mostray(qual)
{
	if (document.getElementById(qual).style.display == "none") {
		document.getElementById(qual).style.display = "";
	}
	
	if (qual == "perg") 
	{
		document.getElementById('linkp').className = "tabh p";
		document.getElementById('linkc').className = "tab s";
	}
	if (qual == "comentcomp") 
	{
		document.getElementById('linkc').className = "tabh s";
		document.getElementById('linkp').className = "tab p";
	}
}


function Esconde(qual)
{
	document.getElementById(qual).style.display = "none";
}

function troca_imagem(imagem,enderecoimg,imgoriginal)
{
/*	document.getElementById("imagem_zoom").src = "scripts/timthumb.php?src=/"+imagem.rel+"&w=250&h=190&zc=0"; */

	document.getElementById("imagem_zoom").src = enderecoimg;
	document.getElementById('linkz').href = imgoriginal;
/*	document.getElementById('la').innerHTML = enderecoimg;*/


/*	<? echo $diretoriover.$cod.'_1g.jpg'; ?>&w=<? echo $grande_largura; ?>&h=<? echo $grande_altura; ?>&zc=0" */
}

function formatar(src, mask){
  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);
  }
}

function limite(campo, countcampo, maxlimit)
{
if (campo.value.length > maxlimit)
{
  campo.value = campo.value.substring(0, maxlimit);
}
else
  countcampo.value = maxlimit - campo.value.length;
}

function formatar_moeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
//	var whichCode = (window.Event) ? tecla.which : tecla.keyCode;
var whichCode = (window.addEventListener) ? tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux.substr(len - 2, len);
	}

	return false;
}

function desabilita(num) {
		document.getElementById('aqualificacao'+num).checked = false;
		document.getElementById('bqualificacao'+num).checked = false;
		document.getElementById('aqualificacao'+num).disabled = true;
		document.getElementById('bqualificacao'+num).disabled = true;
}
function habilita(num) {
		document.getElementById('aqualificacao'+num).disabled = false;
		document.getElementById('bqualificacao'+num).disabled = false;
}

