function exibeFlash(swf, width, height, wmode, cache) {
	var monta_swf, noCache;
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	monta_swf = "";
	monta_swf += "<object style=\"z-index:-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"0\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
};

function Escreve(Texto) {
	document.writeln(Texto);
};

function soNumeros(evtKeyPress) {
	var Tecla;
	if(document.all) // Internet Explorer
		Tecla = evtKeyPress.keyCode;
	else
		Tecla = evtKeyPress.which;
	return (((Tecla > 47) && (Tecla < 58)) || (Tecla == 8));
}

function formataNumero(numero, casas) {
	var i, retorno, nCount;
	nCount = 0;
	retorno = "";
	for(i = numero.length - 1; i >= 0; i--) {
		if(!isNaN(numero.charAt(i))) {
			nCount++;
			retorno = numero.charAt(i) + retorno;
			if(nCount == casas) {
				retorno = "," + retorno;
			}
			else {
				if(nCount > casas) {
					if(((nCount - casas) % 3) == 0) {
						retorno = "." + retorno;
					}
				}	
			}
		}
	}
	if(nCount > casas) {
		if(((nCount - casas) % 3) == 0) {
			retorno = retorno.substring(1, retorno.length);
		}	
	}
	return retorno;
}

function formataData(Data) {
	var i, retorno, nCount;
	nCount = 0;
	retorno = "";
	for(i = Data.length - 1; i >= 0; i--) {
		if(!isNaN(Data.charAt(i))) {
			nCount++;
			retorno = Data.charAt(i) + retorno;
			if(nCount == 4) {
				retorno = "/" + retorno;
			}
			if(nCount == 6) {
				retorno = "/" + retorno;
			}
		}
	}
	return retorno;
}

function Imprimir(Idform){
	var meuForm, destino;
	meuForm = document.getElementById(Idform);
	destino = meuForm.action;
	if(meuForm.action.indexOf("?")	== -1){
		meuForm.action = meuForm.action + "?";	
	}
	else{
		meuForm.action = meuForm.action + "&";	
	}
	meuForm.action = meuForm.action + "imprimir=1";
	meuForm.target = "_blank";
	meuForm.submit();
	meuForm.action = destino;
	meuForm.target = "";
}

function Mostra(tagParaMostrar){
	tagParaMostrar.style.visibility = "visible";
}

function Esconde(tagParaEsconder) {
	tagParaEsconder.style.visibility = "hidden";
}


function enviaForm(form) {
	document.getElementById('Preencheu').value = "Sim";
	document.getElementById(form).submit();
	}


function FormataCpf(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
		if (tam == 4)
			campo.value = vr.substr(0, 3) + '.';
		if (tam == 7)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 6) + '.';
		if (tam == 11)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 3) + '.' + vr.substr(7, 3) + '-' + vr.substr(11, 2);
	}
}


function FormataCnpj(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 18)
	{
		if (tam == 3)
			campo.value = vr.substr(0, 2) + '.';
		if (tam == 6)
			campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 5) + '.';
		if (tam == 10)
			campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/';
		if (tam == 15)
			campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/' + vr.substr(9, 4) + '-' + vr.substr(13, 2);
	}
}


function FormataTelefone(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 9)
	{
		if (tam == 5)
			campo.value = vr.substr(0, 5) + '-';
	}
}

function mascara(e,src,mask) {
	if(window.event) { 
	_TXT = e.keyCode; 
	} else 
	if(e.which) { 
	_TXT = e.which; 
	}
	if(_TXT > 47 && _TXT < 58) {
	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); 
	}
	return true; 
	} else { 
	if (_TXT != 8) { 
	return false; 
	} else { 
	return true; 
	}
	}
}

