function montaFlash(swf, width, height, id, wmode, cache) {
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"0\" />";
	monta_swf += "<param name=\"volume\" value=\"1\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" volume=\"100\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}

function popWin(URL,NAME,WIDTH,HEIGHT,RESIZE,SCROLL) {
   winId = window.open(URL,NAME,'width='+WIDTH+',height='+HEIGHT+',resizable='+RESIZE+',scrollbars='+SCROLL+',menubar=no,toolbar=no,location=no,directories=no,status=no');
	var clientWidth = screen.availWidth;
	var clientHeight = screen.availHeight;
	var xPos = (clientWidth - WIDTH)/2;
	var yPos = (clientHeight - HEIGHT)/2;
	winId.moveTo(xPos,yPos);
}

function CheckMail(str){
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=false
	else { 
		testresults=true
	     }
	return (testresults)
}

function getKey(e) {
	return (window.event) ? event.keyCode : e.which
}

function formatar(src, maska, e) {
	var scan	= getKey(e);
	var i = src.value.length;
	var saida = maska.substring(0,1);
	var texto = maska.substring(i);
	var tecla	= String.fromCharCode(scan);
	var mask	= "0123456789"
	if (scan == 13 || scan == 8 || scan == 0) return true;
	if (mask.indexOf(tecla) == -1) {
		return false;
	}
	if (texto.substring(0,1) != saida && scan != 8) {
		src.value += texto.substring(0,1);
	}
	return true;
}
function numeral(e, obj){
           	if (e.keyCode < 48 || e.keyCode > 57) {
	           			if(e.keyCode != 44 || document.getElementById(obj).value.indexOf(",") != -1){
           				e.returnValue = false;
           				return;
           			}
           		}      		
}
function apenasNumero(objCampo,e) {
	var scan	= getKey(e);
	var tecla	= String.fromCharCode(scan);
	var mask	= "0123456789"
	if (scan == 13 || scan == 8 || scan == 0) return true;
	if (mask.indexOf(tecla) == -1) {
		return false;
	}
	return true;
}

function toMais(txt) {
	document.getElementById(txt).value.toUpperCase();
}

function ChecaCPF(strCPF) {
  	if (strCPF.length != 11 || strCPF == "00000000000" || strCPF == "11111111111" || strCPF == "22222222222" ||	strCPF == "33333333333" || strCPF == "44444444444" || strCPF == "55555555555" || strCPF == "66666666666" || strCPF == "77777777777" || strCPF == "88888888888" || strCPF == "99999999999")
		return false;
	soma = 0;
	for (i=0; i < 9; i ++)
		{soma += parseInt(strCPF.charAt(i)) * (10 - i);}
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		{resto = 0;}
	if (resto != parseInt(strCPF.charAt(9)))
		{return false;}
	soma = 0;
	for (i = 0; i < 10; i ++)
		{soma += parseInt(strCPF.charAt(i)) * (11 - i);}
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		{resto = 0;}
	if (resto != parseInt(strCPF.charAt(10)))
		{return false;}
	return true;
}

function ChecaCNPJ(strCGC) {
	var NewCGC = "";
	var DV = "";
	var DVCGC;
	var s1 = 0;
	var s2 = 0;
	var NewDV;
	
	//Verifica tamanho do CGC
	if ((strCGC.length != 14) || (isNaN(strCGC)))
		return false;
	
	//Calcula os dígitos verificadores
	//Guarda os 12 primeiros digitos
	DVCGC = strCGC.substring(0,12);
	
	//calcula o primeiro digito verificador
	for (i=1;i<=4;i++)
		s1 = s1 + (parseInt(DVCGC.charAt(i-1))*(6-i));

	for (i=5;i<=12;i++)
		s1 = s1 + (parseInt(DVCGC.charAt(i-1))*(14-i));
		r1 = s1 % 11;
	if (r1 < 2)
		dv1 = 0;
	else 
		dv1 = 11 - r1;
	//calcula o segundo digito verificador
	s2 = dv1 * 2;
	for (i=1;i<=5;i++)
		s2 = s2 + (parseInt(DVCGC.charAt(i-1))*(7-i));
	for (i=6;i<=12;i++)
		s2 = s2 + (parseInt(DVCGC.charAt(i-1))*(15-i));
	r2 = s2 % 11;
	if (r2 < 2)
		dv2 = 0;
	else
		dv2 = 11 - r2;
	//junta os digitos verificadores
	DV = DV + dv1 + dv2;
	//guarda os digitos verificadores do CGC digitado (últimas duas posições no string)
	NewDV = strCGC.substring(12,14)
	if (NewDV == DV) //se o DV calculado for igual ao digitado, retorna true
		return true
	else
		return false;
}