//******************************************************
	function exibe_relatorio(pagina, largura, altura, nome)
//******************************************************
{
		window.open(pagina, nome, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=' + largura + ',height=' + altura);
}

//*******************************
function abre_foto(galeria, foto)
//*******************************
{
		localizacao = "/visualiza_foto.php?id_galeria=" + galeria + "&id_foto=" + foto;
		window.open(localizacao, "abre_foto", "toolbar=0,location=0,directories=0,status=0,menubar=0,width=600,height=570");
}

//**********************
function confirma_item()
//**********************
{
		if (confirm("Deseja excluir este item?"))
				{	document.form1.submit();	}
		else
				{	return false;	}
}

//************************
function confirma_figura()
//************************
{
		if (confirm("Deseja excluir esta figura?"))
				{	document.form1.submit();	}
		else
				{	return false;	}
}

//**************************
function MM_reloadPage(init) 
//**************************
{
		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 nova_janela(pagina, largura, altura, nome)
//********************************************************
	{
			window.open(pagina, nome, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=' + largura + ',height=' + altura);
	}

//********************************************************
	function mostra_tabela(pagina, largura, altura)
//********************************************************
	{
			window.open(pagina, '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=' + largura + ',height=' + altura);
	}

//********************************************************
function mostra_arquivo(arquivo, largura, altura)
//********************************************************
{
		localizacao = "/visualiza_arquivo.php?arquivo=" + arquivo + "&altura=" + altura + "&largura=" + largura;
		window.open(localizacao, "", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=" + largura + ",height=" + altura);
}

//********************************************************
function mostra_video(video, largura, altura, descricao)
//********************************************************
{
		localizacao = "/visualiza_video.php?video=" + video + "&altura=" + altura + "&largura=" + largura;
		window.open(localizacao, "Visualiza", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=" + largura + ",height=" + altura);
}

//********************************************************
function mostra_pedido(arquivo, largura, altura)
//********************************************************
{
		localizacao = "/imprime_pedido.php?arquivo=" + arquivo + "&altura=" + altura + "&largura=" + largura;
		window.open(localizacao, "", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=" + largura + ",height=" + altura);
}

//**************************************************************
function mostra_figura(figura, largura, altura, descricao, nome)
//**************************************************************
{
		localizacao = "/visualiza.php?figura=" + figura + "&altura=" + altura + "&largura=" + largura + "&descricao=" + descricao;
		window.open(localizacao, nome, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=" + largura + ",height=" + altura);
}

//*******************************
function mostra_wallpaper(papel)
//*******************************
{
		localizacao = "/visualiza_wallpaper.php?papel=" + papel;
		window.open(localizacao, "", "toolbar=0,location=0,directories=0,status=0,menubar=0,width=720,height=545");
}

//*******************************
function mostra_copa(localizacao)
//*******************************
{
		window.open(localizacao, "", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=540,height=545");
}

//****************************
function valida_data(dia, mes)
//****************************
{
		var erro = 0;
		var retorno = true;
		var ArrMes30 = new Array(7);
		ArrMes30[0] = 2;
		ArrMes30[1] = 4;
		ArrMes30[2] = 6;
		ArrMes30[3] = 9;
		ArrMes30[4] = 11;
		if (dia == "" || mes == "")
				{ erro++; }
		if (mes == 2 && dia > 29)
				{ erro++; }
		for (x = 0; x <= 4; x++)
		{
				if (mes == ArrMes30[x])
				{
						if (dia == 31)
								{ erro++; }
				}
		}
		if (erro > 0)
				{ retorno = false; }
		return (retorno);
}

//*************************
function valida_email(mail)
//*************************
{
		var c_error = 0;
		var ponto = 0;
		if (mail.indexOf("@") < 1)   { c_error++; }
		if (mail.indexOf(".") < 1)   { c_error++; }
		if (mail.indexOf("á") != -1) { c_error++; }
		if (mail.indexOf("é") != -1) { c_error++; }
		if (mail.indexOf("í") != -1) { c_error++; }
		if (mail.indexOf("ó") != -1) { c_error++; }
		if (mail.indexOf("ú") != -1) { c_error++; }
		if (mail.indexOf(" ") != -1) { c_error++; }
		for ( i = mail.indexOf('@') + 1; i <= mail.length; i++ )
		{
				if (mail.charAt(i) == '.')
					{ ponto = 1; break; }
		}
		if (ponto == 0) 
				{ c_error++; }
		if (c_error > 0) 
				{ return (false); } 
		else 
				{ return (true); }
}
	
//*********************************
function verifica_numero(caractere)
//*********************************
{ 
		var strValidos = "0123456789";
		if (strValidos.indexOf(caractere) == -1) 
				{ return false; }
		return true; 
} 
		
//*********************************
function valida_tecla(campo, event) 
//*********************************
{ 
		var BACKSPACE = 8; 
		var key; 
		var tecla; 
		CheckTAB = true; 

		if(navigator.appName.indexOf("Netscape") != -1) 
				{ tecla = event.which; }
		else 
				{ tecla = event.keyCode; }
		
		key = String.fromCharCode(tecla); 
		//alert( 'key: ' + tecla + ' -> campo: ' + campo.value); 
		
		if (tecla == 13) 
				{ return false; }
		
		if (tecla == BACKSPACE) 
				{ return true; }
		
		return (verifica_numero(key)); 
} 

//**********************************************************
function txtBoxFormat(objForm, strField, sMask, evtKeyPress) 
//**********************************************************
{ 
		/*** 
		* Descrição.: formata um campo do formulário de acordo com a máscara informada... 
		* Parâmetros: - objForm     (o Objeto Form) 
		*             - strField    (string contendo o nome do textbox) 
		*             - sMask       (mascara que define o formato que o dado será apresentado, usando o 
		*                            algarismo "9" para definir números e o símbolo "!" para qualquer caracter
		*             - evtKeyPress (evento) 
		* 
		* Uso.......: <input type="textbox" name="xxx" onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);"> 
		* Observação: As máscaras podem ser representadas como os exemplos abaixo: 
		* CEP -> 99999-999 
		* CPF -> 999.999.999-99 
		* CNPJ -> 99.999.999/9999-99 
		* C/C -> 999999-! 
		* Tel -> (99) 9999-9999 
		***/ 

		var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 

		if(document.all) // Internet Explorer 
				nTecla = evtKeyPress.keyCode;
		else if(document.layers) // Nestcape 
				nTecla = evtKeyPress.which; 

		sValue = objForm[strField].value; 

		// Limpa todos os caracteres de formatação que 
		// já estiverem no campo. 
		sValue = sValue.toString().replace( "-", "" ); 
		sValue = sValue.toString().replace( "-", "" ); 
		sValue = sValue.toString().replace( ".", "" ); 
		sValue = sValue.toString().replace( ".", "" ); 
		sValue = sValue.toString().replace( "/", "" ); 
		sValue = sValue.toString().replace( "/", "" ); 
		sValue = sValue.toString().replace( "(", "" ); 
		sValue = sValue.toString().replace( "(", "" ); 
		sValue = sValue.toString().replace( ")", "" ); 
		sValue = sValue.toString().replace( ")", "" ); 
		sValue = sValue.toString().replace( " ", "" ); 
		sValue = sValue.toString().replace( " ", "" ); 
		fldLen = sValue.length; 
		mskLen = sMask.length; 

		i = 0; 
		nCount = 0; 
		sCod = ""; 
		mskLen = fldLen; 

		while (i <= mskLen) 
		{ 
				bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")) 
				bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) 

				if (bolMask) 
				{ 
						sCod += sMask.charAt(i); 
						mskLen++; 
				} 
				else 
				{ 
						sCod += sValue.charAt(nCount); 
						nCount++; 
				} 

				i++; 
		} 

		objForm[strField].value = sCod; 

		if (nTecla != 8) // backspace 
		{ 
				if (sMask.charAt(i-1) == "9") // apenas números de 0 a 9
						return ((nTecla > 47) && (nTecla < 58)); 
				else // qualquer caracter
						return true; 
		} 
		else 
				return true; 
} 

//*******************************************
function FormataValor(campo,tammax,teclapres) 
//*******************************************
{
		var tecla = teclapres.keyCode ? teclapres.keyCode : teclapres.which ? teclapres.which : teclapres.charCode;
		
		vr = document.oform[campo].value;
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ",", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		tam = vr.length;
		if (tam < tammax && tecla != 8)
				{ tam = vr.length + 1; }
		if (tecla == 8 )
				{ tam = tam - 1; }
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
				if ( tam <= 2 )
						{	document.oform[campo].value = vr; }
//				if ( (tam >= 3) && (tam <= 5) )
//						{	document.oform[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
//				if ( (tam >= 6) && (tam <= 8) )
//						{	document.oform[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
//				if ( (tam >= 9) && (tam <= 12) )
//						{	document.oform[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
    else
						{	document.oform[campo].value = vr.substr( 0, tam - 2 ) + '.' + vr.substr( tam - 2, tam ); }
		}
}

