function popUp(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}	
function displayFlash(largura, altura, arquivo){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" />');
	document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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 validaCPF() {	
	//alert(document.frmVotoDigital.nmCPF.value);
	stCPF = document.frmVotoDigital.nmCPF.value;
	stCPF = stCPF.replace("CPF", "");
	stCPF = stCPF.replace(".", "");
	stCPF = stCPF.replace(".", "");
	stCPF = stCPF.replace("-", "");
	valor = true;
	erro = new String;
	if (stCPF.length < 11) erro = "Número de CPF Inválido."; 
	var nonNumbers = /\D/;
	if (nonNumbers.test(stCPF)) erro = "Número de CPF Inválido.";	
	if (stCPF == "00000000000" || stCPF == "11111111111" || stCPF == "22222222222" || stCPF == "33333333333" || stCPF == "44444444444" || stCPF == "55555555555" || stCPF == "66666666666" || stCPF == "77777777777" || stCPF == "88888888888" || stCPF == "99999999999"){
		  erro = "Número de CPF Inválido."
	}
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		a[i] = stCPF.charAt(i);
		if (i < 9) b += (a[i] *  --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] *  c--); 
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	if ((stCPF.charAt(9) != a[9]) || (stCPF.charAt(10) != a[10])){
			//erro = "";
			erro = "Número de CPF Inválido.";
	}
	if (erro.length > 0){
		aviso.innerHTML = erro;
		//document.getElementById('mensagem').style.display = "";
	}
    else
    {
		//alert(stCPF);
		//document.getElementById('mensagem').style.display = "none";
    	document.frmVotoDigital.stCPFVerificado.value='Verificado';
    	document.frmVotoDigital.nmCPF.value=""+stCPF+"";
		document.frmVotoDigital.submit();    	
    }
}
/***
* AUTO TAB - ao prencher o campo, automaticamente manda o foco para o próximo!
* insere isso na tag onKeyUp="return autoTab(this, 80, event);" maxlength="80"
***/

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
    }

function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
        found = true;
    else
        index++;
        return found;
    }

function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
    }
    return true;
}

function MM_OnFocus(obj, sFieldValue){
	if (eval(obj).value == sFieldValue){
		eval(obj).value = "";
	}
}
function MM_OnBlur(obj, sFieldValue){
	if (eval(obj).value == ""){
		eval(obj).value = sFieldValue;
	}
}
function Tecla(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}