<!--
function EmailVerificaNome(VerificarEmail, EmailPassado, NomePassado)
{
	var Nome = document.getElementById(NomePassado).value;
	var Email = document.getElementById(EmailPassado).value;
	
	if(Nome != "" && Email != "")
	{
		if(document.getElementById(VerificarEmail).value == "True")
		{
			document.getElementById("frmCampos").action = "Index.asp?Ir=Newsletter_Grava";		
			document.getElementById("frmCampos").submit();
		}
		else
		{
			alert("Verifique o e-mail, ele pode estar indisponível\nou ser inválido.");
		}
	}
	else
	{
		var erro = "Erro(s):\n";
		var campos = "";
		if(Nome == "")
		{
			campos += " - Nome é Obrigatório.\n";
		}
		if(Email == "")
		{
			campos += " - E-mail é Obrigatório.\n";
		}
		
		alert(erro + campos);
	}
}


function MM_validateForm() {
	if (document.getElementById){
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		for (i=0; i<(args.length-2); i+=3) { 
			test=args[i+2]; val=document.getElementById(args[i]);
			if (val) { 
				nm=val.name; 
				if ((val=val.value)!="") {
					if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
			if (p<1 || p==(val.length-1)){
				errors+='- '+nm+' nao é válido.\n';
			}
		} 
	else if (test!='R') { num = parseFloat(val);
	if (isNaN(val)) errors+='- '+nm+' nao é válido.\n';
	if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
	min=test.substring(8,p); max=test.substring(p+1);
	if (num<min || max<num) errors+='- '+nm+' Tem que ser número entre '+min+' and '+max+'.\n';
	} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é obrigatório.\n'; }
	} if (errors) alert('Ocorreu(ram) o(s) seguinte(s) erro(s):\n'+errors);
	document.MM_returnValue = (errors == '');
	} 
}

//onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"     NO TEXT AREA

function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;

	if((tecla > 47 && tecla < 58)){
		return true;
	}
	else if (tecla != 8){
		return false;
	}
	else{
		return true;
    }
}

function FormataData(objeto,e){
	var tecla=(window.event)?event.keyCode:e.which;
	if(tecla != 8){
		if (objeto.value.length == 2 || objeto.value.length == 5){
			objeto.value = objeto.value + "/";
		}
	}
}

function FormataTelefone(campo){
	if (campo.value.length == 2){
		campo.value = "(" + campo.value + ")";
	}
	else if(campo.value.length == 8){
		campo.value = campo.value + "-";
	}
}

function FormataCEP(objeto){
	if (objeto.value.length == 5){
		objeto.value = objeto.value + "-";
	}
}

function FormataHora(objeto, e){
	var tecla = (window.event)?event.keyCode:e.which;
	if(tecla != 8){
		if (objeto.value.length == 2){
			objeto.value = objeto.value + ":";
		}
	}
}

function formataMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;    
    // 13=enter, 8=backspace as demais retornam 0(zero)
    // whichCode==0 faz com que seja possivel usar todas as teclas como delete, setas, etc    
    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8))
    	return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
 
 
    if (strCheck.indexOf(key) == -1) 
    	return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) 
        	break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) 
        	aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) 
    	objTextBox.value = '';
    if (len == 1) 
    	objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) 
    	objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        	objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}

function TempoEsconder(){
	tout = setTimeout('fadeOut("mensagem", 0.1)', 5000);
}

function TempoErro(){
	tout = setTimeout('EsconderErro()', 1000);
}

function EsconderErro(){
//	document.getElementById("mensagem").style.display = "none";
	document.getElementById("mensagem").innerHTML = "";
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/25;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
		TempoErro();
}

function fadeIn(id, time) {
//	document.getElementById("mensagem").style.display = "block";
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
	TempoEsconder();
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

function ValidaForm(){
	Senha = document.getElementById("Senha").value;
	Login = document.getElementById("Login").value;

	if(Login != "" && Senha != ""){
		return true;
	}
	else{
		alert("Campos obrigatórios:\n - Login \n - Senha");
		return false;
	}
}

function TempoEsconder(){
	tout = setTimeout('fadeOut("Mensagem", 0.1)', 5000);
}

function TempoErro(){
	tout = setTimeout('EsconderErro()', 1000);
}

function EsconderErro(){
//	document.getElementById("Mensagem").style.display = "none";
	document.getElementById("Mensagem").innerHTML = "";
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/25;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
		TempoErro();
}

function fadeIn(id, time) {
	document.getElementById("Mensagem").style.display = "block";
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
	TempoEsconder();
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

function TrocarCorOver(Campo,Color) {
	Campo.bgColor = Color;
}

function TrocarCorOut(Campo,Color) {
	Campo.bgColor = Color;
}

function ApagarVarios(Nome, Pagina){
	var mensagem = "Deseja excluir " + Nome + " selecionados?";
	if(confirm(mensagem)){
		document.getElementById("frmExcluir").action = "Index.asp?Ir=" + Pagina + "_Grava&Acao=3&NomePagina=Excluir " + Nome;
		document.getElementById("frmExcluir").submit();
	}
	else{
		document.getElementById("frmExcluir").action = "";
	}
}

function SelecionarTodos(Contador){
	var Todos = document.getElementById("Todos").value;
	
	for(var i=0;i < Contador;i++){
		if(Todos == "Todos"){
			document.getElementById("Selecionar" + i).checked = true;
		}
		else{
			document.getElementById("Selecionar" + i).checked = false;
		}
	}

	if(Todos == "Nenhum"){
		document.getElementById("Todos").value = "Todos";
	}
	else{
		document.getElementById("Todos").value = "Nenhum";
	}
}

function abrir(URL, Width, Height, Left, Top){
	var width = Width;
	var height = Height;
	var left = Left;
	var top = Top;

	window.open(URL,'janela', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function MostrarEsconder(Mostrar,Esconder)
{
	DivMostrar = document.getElementById(Mostrar);
	DivEsconder = document.getElementById(Esconder);
	
	if(DivMostrar.style.display == "none")
	{
		DivEsconder.style.display	= "none";
		DivMostrar.style.display 	= "";
	}
	else
	{
		DivEsconder.style.display	= "";
		DivMostrar.style.display	= "none";
	}
}

function MudarPosicoes(Campo){
	var Valor = Campo.value;
	
	if(Valor == "1")
	{
		document.getElementById("BanPosicaoEsquerdo").style.display = "";
		document.getElementById("BanPosicaoDireito").style.display = "none";
	}
	else
	{
		document.getElementById("BanPosicaoEsquerdo").style.display = "none";
		document.getElementById("BanPosicaoDireito").style.display = "";
	}	
}

function LimparBanner(Posicao)
{
	document.getElementById("BanNome" + Posicao).value = "";
	document.getElementById("ConfBanner" + Posicao).value = "";
}

function LimparProduto(Posicao)
{
	document.getElementById("ProNome" + Posicao).value = "";
	document.getElementById("ConfProduto" + Posicao).value = "";
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function LimparTextoBusca(campo){
	var ValorCampo = campo.value;
	var AltCampo = campo.alt;
//	alert(ValorCampo + " - " + AltCampo);

	if(AltCampo == "BUSCAR"){
		campo.alt = "";
		campo.value = "";
	}
	else if(ValorCampo == ""){
		campo.alt = "BUSCAR";
		campo.value = "Digite aqui";
	}
}

function AlterarLink(CodigoPassado, Contador){
	var Codigo = document.getElementById(CodigoPassado);
	
	for(var i=0;i < Contador;i++){
		if(CodigoPassado == i){
			Codigo.style.color = "#FFFF00";
		}
		else{
			document.getElementById(i).style.color = "#FFFFFF";
		}
	}
}

function TrocarMenu(Menu){
	if(document.getElementById(Menu).name == "N"){
		document.getElementById(Menu).src = "imagens/menu_" + Menu + "_hover.png";
		document.getElementById(Menu).name = "H";
	}
	else{
		document.getElementById(Menu).src = "imagens/menu_" + Menu + ".png";
		document.getElementById(Menu).name = "N";
	}
}
