var ie=document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

var toolTipSTYLE="";

	function trata_acentuacao(str)
	{ 
		var str_retorno = str; 
		
		str_retorno = str_retorno.replace('&#33;','!');
		str_retorno = str_retorno.replace('&#34;','"');
		str_retorno = str_retorno.replace('&#35;','#');
		str_retorno = str_retorno.replace('&#36;','$');
		str_retorno = str_retorno.replace('&#37;','%');
		str_retorno = str_retorno.replace('&#38;','&');
		str_retorno = str_retorno.replace('&#39;','\'');
		str_retorno = str_retorno.replace('&#40;','(');
		str_retorno = str_retorno.replace('&#41;',')');
		str_retorno = str_retorno.replace('&#42;','*');
		str_retorno = str_retorno.replace('&#43;','+');
		str_retorno = str_retorno.replace('&#44;',',');
		str_retorno = str_retorno.replace('&#45;','-');
		str_retorno = str_retorno.replace('&#46;','.');
		str_retorno = str_retorno.replace('&#47;','/');
		/*str_retorno = str_retorno.replace('&#48;','0');
		str_retorno = str_retorno.replace('&#49;','1');
		str_retorno = str_retorno.replace('&#50;','2');
		str_retorno = str_retorno.replace('&#51;','3');
		str_retorno = str_retorno.replace('&#52;','4');
		str_retorno = str_retorno.replace('&#53;','5');
		str_retorno = str_retorno.replace('&#54;','6');
		str_retorno = str_retorno.replace('&#55;','7');
		str_retorno = str_retorno.replace('&#56;','8');
		str_retorno = str_retorno.replace('&#57;','9');*/
		str_retorno = str_retorno.replace('&#58;',':');
		str_retorno = str_retorno.replace('&#59;',';');
		str_retorno = str_retorno.replace('&#60;','<');
		str_retorno = str_retorno.replace('&#61;','=');
		str_retorno = str_retorno.replace('&#62;','>');
		str_retorno = str_retorno.replace('&#63;','?');
		str_retorno = str_retorno.replace('&#64;','@');
		/*str_retorno = str_retorno.replace('&#65;','A');
		str_retorno = str_retorno.replace('&#66;','B');
		str_retorno = str_retorno.replace('&#67;','C');
		str_retorno = str_retorno.replace('&#68;','D');
		str_retorno = str_retorno.replace('&#69;','E');
		str_retorno = str_retorno.replace('&#70;','F');
		str_retorno = str_retorno.replace('&#71;','G');
		str_retorno = str_retorno.replace('&#72;','H');
		str_retorno = str_retorno.replace('&#73;','I');
		str_retorno = str_retorno.replace('&#74;','J');
		str_retorno = str_retorno.replace('&#75;','K');
		str_retorno = str_retorno.replace('&#76;','L');
		str_retorno = str_retorno.replace('&#77;','M');
		str_retorno = str_retorno.replace('&#78;','N');
		str_retorno = str_retorno.replace('&#79;','O');
		str_retorno = str_retorno.replace('&#80;','P');
		str_retorno = str_retorno.replace('&#81;','Q');
		str_retorno = str_retorno.replace('&#82;','R');
		str_retorno = str_retorno.replace('&#83;','S');
		str_retorno = str_retorno.replace('&#84;','T');
		str_retorno = str_retorno.replace('&#85;','U');
		str_retorno = str_retorno.replace('&#86;','V');
		str_retorno = str_retorno.replace('&#87;','W');
		str_retorno = str_retorno.replace('&#88;','X');
		str_retorno = str_retorno.replace('&#89;','Y');
		str_retorno = str_retorno.replace('&#90;','Z');*/
		str_retorno = str_retorno.replace('&#91;','[');
		str_retorno = str_retorno.replace('&#92;','\\');
		str_retorno = str_retorno.replace('&#93;',']');
		str_retorno = str_retorno.replace('&#94;','^');
		str_retorno = str_retorno.replace('&#95;','_');
		str_retorno = str_retorno.replace('&#96;','`');
		/*str_retorno = str_retorno.replace('&#97;','a');
		str_retorno = str_retorno.replace('&#98;','b');
		str_retorno = str_retorno.replace('&#99;','c');
		str_retorno = str_retorno.replace('&#100;','d');
		str_retorno = str_retorno.replace('&#101;','e');
		str_retorno = str_retorno.replace('&#102;','f');
		str_retorno = str_retorno.replace('&#103;','g');
		str_retorno = str_retorno.replace('&#104;','h');
		str_retorno = str_retorno.replace('&#105;','i');
		str_retorno = str_retorno.replace('&#106;','j');
		str_retorno = str_retorno.replace('&#107;','k');
		str_retorno = str_retorno.replace('&#108;','l');
		str_retorno = str_retorno.replace('&#109;','m');
		str_retorno = str_retorno.replace('&#110;','n');
		str_retorno = str_retorno.replace('&#111;','o');
		str_retorno = str_retorno.replace('&#112;','p');
		str_retorno = str_retorno.replace('&#113;','q');
		str_retorno = str_retorno.replace('&#114;','r');
		str_retorno = str_retorno.replace('&#115;','s');
		str_retorno = str_retorno.replace('&#116;','t');
		str_retorno = str_retorno.replace('&#117;','u');
		str_retorno = str_retorno.replace('&#118;','v');
		str_retorno = str_retorno.replace('&#119;','w');
		str_retorno = str_retorno.replace('&#120;','x');
		str_retorno = str_retorno.replace('&#121;','y');
		str_retorno = str_retorno.replace('&#122;','z');*/
		str_retorno = str_retorno.replace('&#123;','{');
		str_retorno = str_retorno.replace('&#124;','|');
		str_retorno = str_retorno.replace('&#125;','}');
		str_retorno = str_retorno.replace('&#126;','~');
		str_retorno = str_retorno.replace('&#127;','');
		str_retorno = str_retorno.replace('&#128;','€');
		str_retorno = str_retorno.replace('&#129;','');
		str_retorno = str_retorno.replace('&#130;','‚');
		str_retorno = str_retorno.replace('&#131;','ƒ');
		str_retorno = str_retorno.replace('&#132;','„');
		str_retorno = str_retorno.replace('&#133;','…');
		str_retorno = str_retorno.replace('&#134;','†');
		str_retorno = str_retorno.replace('&#135;','‡');
		str_retorno = str_retorno.replace('&#136;','ˆ');
		str_retorno = str_retorno.replace('&#137;','‰');
		str_retorno = str_retorno.replace('&#138;','Š');
		str_retorno = str_retorno.replace('&#139;','‹');
		str_retorno = str_retorno.replace('&#140;','Œ');
		str_retorno = str_retorno.replace('&#141;','');
		str_retorno = str_retorno.replace('&#142;','Ž');
		str_retorno = str_retorno.replace('&#143;','');
		str_retorno = str_retorno.replace('&#144;','');
		str_retorno = str_retorno.replace('&#145;','‘');
		str_retorno = str_retorno.replace('&#146;','’');
		str_retorno = str_retorno.replace('&#147;','“');
		str_retorno = str_retorno.replace('&#148;','”');
		str_retorno = str_retorno.replace('&#149;','•');
		str_retorno = str_retorno.replace('&#150;','–');
		str_retorno = str_retorno.replace('&#151;','—');
		str_retorno = str_retorno.replace('&#152;','˜');
		str_retorno = str_retorno.replace('&#153;','™');
		str_retorno = str_retorno.replace('&#154;','š');
		str_retorno = str_retorno.replace('&#155;','›');
		str_retorno = str_retorno.replace('&#156;','œ');
		str_retorno = str_retorno.replace('&#157;','');
		str_retorno = str_retorno.replace('&#158;','ž');
		str_retorno = str_retorno.replace('&#159;','Ÿ');
		str_retorno = str_retorno.replace('&#160;',' ');
		str_retorno = str_retorno.replace('&#161;','¡');
		str_retorno = str_retorno.replace('&#162;','¢');
		str_retorno = str_retorno.replace('&#163;','£');
		str_retorno = str_retorno.replace('&#164;','¤');
		str_retorno = str_retorno.replace('&#165;','¥');
		str_retorno = str_retorno.replace('&#166;','¦');
		str_retorno = str_retorno.replace('&#167;','§');
		str_retorno = str_retorno.replace('&#168;','¨');
		str_retorno = str_retorno.replace('&#169;','©');
		str_retorno = str_retorno.replace('&#170;','ª');
		str_retorno = str_retorno.replace('&#171;','«');
		str_retorno = str_retorno.replace('&#172;','¬');
		str_retorno = str_retorno.replace('&#173;','­');
		str_retorno = str_retorno.replace('&#174;','®');
		str_retorno = str_retorno.replace('&#175;','¯');
		str_retorno = str_retorno.replace('&#176;','°');
		str_retorno = str_retorno.replace('&#177;','±');
		str_retorno = str_retorno.replace('&#178;','²');
		str_retorno = str_retorno.replace('&#179;','³');
		str_retorno = str_retorno.replace('&#180;','´');
		str_retorno = str_retorno.replace('&#181;','µ');
		str_retorno = str_retorno.replace('&#182;','¶');
		str_retorno = str_retorno.replace('&#183;','·');
		str_retorno = str_retorno.replace('&#184;','¸');
		str_retorno = str_retorno.replace('&#185;','¹');
		str_retorno = str_retorno.replace('&#186;','º');
		str_retorno = str_retorno.replace('&#187;','»');
		str_retorno = str_retorno.replace('&#188;','¼');
		str_retorno = str_retorno.replace('&#189;','½');
		str_retorno = str_retorno.replace('&#190;','¾');
		str_retorno = str_retorno.replace('&#191;','¿');
		str_retorno = str_retorno.replace('&#192;','À');
		str_retorno = str_retorno.replace('&#193;','Á');
		str_retorno = str_retorno.replace('&#194;','Â');
		str_retorno = str_retorno.replace('&#195;','Ã');
		str_retorno = str_retorno.replace('&#196;','Ä');
		str_retorno = str_retorno.replace('&#197;','Å');
		str_retorno = str_retorno.replace('&#198;','Æ');
		str_retorno = str_retorno.replace('&#199;','Ç');
		str_retorno = str_retorno.replace('&#200;','È');
		str_retorno = str_retorno.replace('&#201;','É');
		str_retorno = str_retorno.replace('&#202;','Ê');
		str_retorno = str_retorno.replace('&#203;','Ë');
		str_retorno = str_retorno.replace('&#204;','Ì');
		str_retorno = str_retorno.replace('&#205;','Í');
		str_retorno = str_retorno.replace('&#206;','Î');
		str_retorno = str_retorno.replace('&#207;','Ï');
		str_retorno = str_retorno.replace('&#208;','Ð');
		str_retorno = str_retorno.replace('&#209;','Ñ');
		str_retorno = str_retorno.replace('&#210;','Ò');
		str_retorno = str_retorno.replace('&#211;','Ó');
		str_retorno = str_retorno.replace('&#212;','Ô');
		str_retorno = str_retorno.replace('&#213;','Õ');
		str_retorno = str_retorno.replace('&#214;','Ö');
		str_retorno = str_retorno.replace('&#215;','×');
		str_retorno = str_retorno.replace('&#216;','Ø');
		str_retorno = str_retorno.replace('&#217;','Ù');
		str_retorno = str_retorno.replace('&#218;','Ú');
		str_retorno = str_retorno.replace('&#219;','Û');
		str_retorno = str_retorno.replace('&#220;','Ü');
		str_retorno = str_retorno.replace('&#221;','Ý');
		str_retorno = str_retorno.replace('&#222;','Þ');
		str_retorno = str_retorno.replace('&#223;','ß');
		str_retorno = str_retorno.replace('&#224;','à');
		str_retorno = str_retorno.replace('&#225;','á');
		str_retorno = str_retorno.replace('&#226;','â');
		str_retorno = str_retorno.replace('&#227;','ã');
		str_retorno = str_retorno.replace('&#228;','ä');
		str_retorno = str_retorno.replace('&#229;','å');
		str_retorno = str_retorno.replace('&#230;','æ');
		str_retorno = str_retorno.replace('&#231;','ç');
		str_retorno = str_retorno.replace('&#232;','è');
		str_retorno = str_retorno.replace('&#233;','é');
		str_retorno = str_retorno.replace('&#234;','ê');
		str_retorno = str_retorno.replace('&#235;','ë');
		str_retorno = str_retorno.replace('&#236;','ì');
		str_retorno = str_retorno.replace('&#237;','í');
		str_retorno = str_retorno.replace('&#238;','î');
		str_retorno = str_retorno.replace('&#239;','ï');
		str_retorno = str_retorno.replace('&#240;','ð');
		str_retorno = str_retorno.replace('&#241;','ñ');
		str_retorno = str_retorno.replace('&#242;','ò');
		str_retorno = str_retorno.replace('&#243;','ó');
		str_retorno = str_retorno.replace('&#244;','ô');
		str_retorno = str_retorno.replace('&#245;','õ');
		str_retorno = str_retorno.replace('&#246;','ö');
		str_retorno = str_retorno.replace('&#247;','÷');
		str_retorno = str_retorno.replace('&#248;','ø');
		str_retorno = str_retorno.replace('&#249;','ù');
		str_retorno = str_retorno.replace('&#250;','ú');
		str_retorno = str_retorno.replace('&#251;','û');
		str_retorno = str_retorno.replace('&#252;','ü');
		str_retorno = str_retorno.replace('&#253;','ý');
		str_retorno = str_retorno.replace('&#254;','þ');
		str_retorno = str_retorno.replace('&#255;','ÿ');
		str_retorno = str_retorno.replace('&#256;','A');
		
		return str_retorno;
	} 

	function limpa_select(id)
	{
		var total_opcoes = document.getElementById(id).length;
	
		for(j=total_opcoes;j>-1;j--)
			document.getElementById(id).remove(j);
	}


function aparece_submenu( ids )
{
	var array_de_IDS = ids.split(",");
	var total = array_de_IDS.length;

	for(i=0;i<total;i++)
	{
		if (document.getElementById(array_de_IDS[i]).style.display == 'inline' || document.getElementById(array_de_IDS[i]).style.display == '')
		{
			document.getElementById(array_de_IDS[i]).style.display = 'none';
		}
		else
		{
			document.getElementById(array_de_IDS[i]).style.display = '';
		}
	}
	
	if( ids=='detran1,detran2,detran3')
	{
		document.getElementById('calendario').style.display = 'none';
		document.getElementById('calendario1').style.display = 'none';
		document.getElementById('prazos').style.display = 'none';
		document.getElementById('prazos1').style.display = 'none';
		document.getElementById('multas').style.display = 'none';
		document.getElementById('multas1').style.display = 'none';
		document.getElementById('multas_outro_estado').style.display = 'none';
		document.getElementById('multas_outro_estado1').style.display = 'none';
		document.getElementById('recursos').style.display = 'none';
		document.getElementById('recursos1').style.display = 'none';
	}	
}

function xKey(e) 
{ 
	isNetscape=(document.layers); 
	eventChooser = window.event ? e.keyCode : e.which;
	which = String.fromCharCode(eventChooser); 
	xCode=which.charCodeAt(0); 

	switch(xCode)
	{
		case 27: //Escape
			closepreview();
			break;		
	}

} 

function enlarge(which, e, position, imgwidth, imgheight)
{
	if (ie||ns6)
	{
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if (position=="center")
		{
			pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
			horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
			vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
			if (window.opera && window.innerHeight) //compensate for Opera toolbar
			vertpos=pgyoffset+window.innerHeight/2-imgheight/2
			vertpos=Math.max(pgyoffset, vertpos)
		}
		else
		{
			var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
			var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
		}
		crossobj.style.left=horzpos+"px"
		crossobj.style.top=vertpos+"px"
		
		crossobj.innerHTML='<div align="right" id="dragbar"><span id="closetext" onClick="closepreview()">x </span> </div><img src="'+which+'">'
		crossobj.style.visibility="visible"

		return false
	}
	else //if NOT IE 4+ or NS 6+, simply display image in full browser window
		return true
}

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
}

function closepreview()
{
 crossobj.style.visibility="hidden";
 crossobj.innerHTML="";
 document.onmousemove="";
}

function drag_drop(e)
{
	if (ie&&dragapproved)
	{
		crossobj.style.left=tempx+event.clientX-offsetx+"px";
		crossobj.style.top=tempy+event.clientY-offsety+"px";
	}
	else 
		if (ns6&&dragapproved)
		{
			crossobj.style.left=tempx+e.clientX-offsetx+"px";
			crossobj.style.top=tempy+e.clientY-offsety+"px";
		}
	return false;
}

function initializedrag(e)
{
	if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar")
	{
		offsetx=ie? event.clientX : e.clientX;
		offsety=ie? event.clientY : e.clientY;
		
		tempx=parseInt(crossobj.style.left);
		tempy=parseInt(crossobj.style.top);
		
		dragapproved=true;
		document.onmousemove=drag_drop;
	}
}

document.onmousedown=initializedrag;
document.onmouseup=new Function("dragapproved=false");

function cria_flash( url, width, height, obj ) {
	var str = '';
	str += '<object 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 +'" VIEWASTEXT>';
	str += '  <param name="movie" value="'+ url +'">';
	str += '  <param name="wmode" value="transparent">';
	str += '  <param name="quality" value="high">';
	str += '  <embed src="'+ url +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'" wmode="transparent"></embed>';
	str += '</object>';
	
	obj = document.getElementById(obj);
	
	if(obj) {
		obj.innerHTML = str;
	}
	else {
		document.write(str);
	}
}

function ValidaEmail(email) {
err = 0;
 // Email tem que estar preenchido
if (email.value == " " || email.value.length < 1)
{ err = 1; }
// Arroba tem que existir, nao pode ser primeiro caracter e tem que ser seguido de no minimo 4 caracteres
if (email.value.indexOf("@") < 1 || email.value.indexOf("@") > email.value.length - 5)
{ err = 1; }
// Pelo menos um ponto tem que existir, e nao pode ser primeiro caracter
if (email.value.indexOf(".") < 1)
{ err = 1; }
// Ultimo ponto tem que existir e ser seguido de no minimo 2 caracteres
if (email.value.lastIndexOf(".") > email.value.length - 3)
{ err = 1; }
// Só pode existir um @
if (email.value.indexOf("@") != email.value.lastIndexOf("@"))
{ err = 1; }
// Nao pode existir 
if (email.value.indexOf(",") > 0 || email.value.indexOf(";") > 0 || email.value.indexOf(":") > 0 || email.value.indexOf("/") > 0  || email.value.indexOf("'") > 0 || email.value.indexOf("\"") > 0)
{ err = 1; }
// Nao pode existir
if (email.value.indexOf("|") > 0 || email.value.indexOf(")") > 0 || email.value.indexOf("(") > 0 || email.value.indexOf("^") > 0 || email.value.indexOf("+") > 0 )
{ err = 1; }
// Nao pode existir
if (email.value.indexOf("!") > 0 || email.value.indexOf("*") > 0)
{ err = 1; }
// Nao pode existir
if (email.value.indexOf("$") > 0 || email.value.indexOf("#") > 0 || email.value.indexOf("`") > 0 || email.value.indexOf("~") > 0 )
{ err = 1; }
// Nao pode existir Arroba-Ponto
if (email.value.indexOf("@.") > 0)
{ err = 1; }
// Nao podem existir espacos em branco no email
if (email.value.indexOf(" ") > 0)
{ err = 1; }
if (err == 1)
{ email.focus();
  alert('E-MAIL incorreto! Verifique-o e tente novamente.'); 
  return false; }
else
  return true;
}

function verifica_form_atualiza() {
	var f = document.form_atualiza;
	if(f.email.value==0) {
		alert("Preenha o email!");
		f.email.focus();
		return false;
	}
	if(f.senha.value==0) {
		alert("Preencha a senha!");
		f.senha.focus();
		return false;
	}
}

function verifica_form_contato() {
    var f = document.form_contato;
    if(f.nome.value==0) {
        alert('Por favor, preencha o nome!');
        f.nome.focus();
        return false;
    }
    if(f.email.value==0) {
        alert('Por favor, preencha o email!');
        f.email.focus();
        return false;
    }
    if(f.mensagem.value==0) {
        alert('Por favor, preencha a mensagem!');
        f.mensagem.focus();
        return false;
    }
    return true;
}

function verifica_form_newsletter() {
	var f = document.form_newsletter;
	if((f.nome.value==0)||(f.nome.value=="nome")) {
		alert("Preencha o nome!");
		f.nome.focus();
		return false;
	}
	if((f.email.value==0)||(f.email.value=="email")) {
		alert("Preencha o email!");
		f.email.focus();
		return false;
	}
}

function formata_data(input)
{
	if ((event.keyCode<48)||(event.keyCode>57)) {
		event.returnValue = false;
	}
	else {
		if(input.value.length==2||input.value.length==5) {
			input.value = input.value + "/";
		}
	}
}

function formata_cep(obj, e)
{
	var tecla = e.keyCode;
	if (tecla == 8)
	{ 
		return true;
	}
	else
	{ 
		var retorno = apenas_numero(e);
		if (retorno)
		{
			if (obj.value.length==5)
			{
				obj.value = obj.value + "-";
			}
		}
		return retorno;
	}
}

function ajustar_cnpj(Campo, teclapres)
{
	var retorno = apenas_numero(teclapres);

	if (retorno) {
		if(window.event) {
			var tecla = teclapres.keyCode;
		}
		else {
			var tecla = teclapres.which;
		}
	
		var vr = new String(Campo.value);
		vr = vr.replace(".", "");
		vr = vr.replace(".", "");
		vr = vr.replace("/", "");
		vr = vr.replace("-", "");
		
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8) {
			if (tam > 2 && tam < 6) {
				Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
			}
			if (tam >= 6 && tam < 9) {
				Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
			}
			if (tam >= 9 && tam < 13) {
				Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
			}
			if (tam >= 13 && tam < 15) {
				Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
			}
		}
	}
	
	return retorno;
}

function ajustar_cpf(Campo, teclapres)
{
	var retorno = apenas_numero(teclapres);

	if (retorno) {
		if(window.event) {
			var tecla = teclapres.keyCode;
		}
		else {
			var tecla = teclapres.which;
		}
	
		var vr = new String(Campo.value);
		vr = vr.replace(".", "");
		vr = vr.replace(".", "");
		vr = vr.replace("-", "");
		
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8) {
			if (tam > 3 && tam < 7) {
				Campo.value = vr.substr(0,3) + '.' + vr.substr(3, tam);
			}
			if (tam >= 7 && tam < 10) {
				Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
			}
			if (tam >= 10 && tam < 15) {
				Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-7);
			}
		}
	}
	
	return retorno;
}

function apenas_numero(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	if ((key == 0) || (key == 8)) {
		return true
	}
	else {
		reg = /\d/;
		return reg.test(keychar);
	}  
}

function ajustar_data(Campo, teclapres)
{
	var retorno = apenas_numero(teclapres);

	if (retorno) {
		if(window.event) {
			var tecla = teclapres.keyCode;
		}
		else {
			var tecla = teclapres.which;
		}
	
		var vr = new String(Campo.value);
		vr = vr.replace("/", "");
		vr = vr.replace("/", "");
		
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8) {
			if (tam > 2 && tam < 5) {
				Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, tam);
			}
			if (tam >= 5 && tam <= 10) {
				Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,tam-4);
			}
		}
	}
	
	return retorno;
}

function checou(campo) {
	if(campo) {
		if(campo.length) {
			for (var i=0; i<campo.length; i++) {
				if( campo[i].checked ) return true;
			}
			return false;
		}
		else {
			if(campo.checked) return true;
			return false;
		}
	}
	else {
		return false;
	}
}

function conta_checado(campo) {
	var acum = 0;
	if(campo) {
		if(campo.length) {
			for (var i=0; i<campo.length; i++) {
				if( campo[i].checked ) acum++;
			}
		}
		else {
			if(campo.checked) acum++;
		}
	}
	return acum;
}

function excluir(form, campo) {
	var campo= eval('document.'+form+'.'+campo);
	var form = eval('document.'+form);
	
	if(checou(campo)) {
		if(confirm("Deseja realmente excluir?")) {
			form.submit();
		}
	}
	else {
		alert('Selecione primeiro o que deseja excluir');
	}
}


function verifica_form_trabalhe() {
    var f = document.form_trabalhe;
	if(f.nome.value==0)
	{
		alert("Por favor, informe seu nome!");
		f.nome.focus();
		return false;
	}
	if(f.ddd_telefone.value==0)
	{
		alert("Por favor, informe o DDD de seu telefone!");
		f.ddd_telefone.focus();
		return false;
	}
	if(f.telefone.value==0)
	{
		alert("Por favor, informe seu telefone!");
		f.telefone.focus();
		return false;
	}
	if(f.email.value==0)
	{
		alert("Por favor, informe seu e-mail!");
		f.email.focus();
		return false;
	}
	if(f.cidade.value==0)
	{
		alert("Por favor, informe sua cidade!");
		f.cidade.focus();
		return false;
	}
	if(f.estado.value==0)
	{
		alert("Por favor, informe seu estado!");
		f.estado.focus();
		return false;
	}
	if(!checou(f.nivel_ingles))
	{
		alert("Por favor, informe seu nível de inglês!");
		return false;
	}
	if(f.area.value==0)
	{
		alert("Por favor, selecione a sua área de atuação!");
		f.area.focus();
		return false;
	}
	if(f.curriculo_antigo) {
		if(f.curriculo_antigo.value=="") {
			if(f.arquivo.value==0)
			{
				alert("Por favor, selecione o arquivo do seu currículo!");
				return false;
			}
		}
	}
	else {
		if(f.arquivo.value==0)
		{
			alert("Por favor, selecione o arquivo do seu currículo!");
			return false;
		}
	}
	if(f.senha.value==0)
	{
		alert("Por favor, informe uma senha para atualizações futuras!");
		f.senha.focus();
		return false;
	}
	if(f.senha.value!=f.confirmacao_senha.value)
	{
		alert("As senhas informadas estão incorretas!!");
		return false;
	}
	
	return true;
}

function isDate(data) {

	if(!data) return false;
	
	var data_separada = data.split('/'); //separa as datas
	if(data_separada.length < 3) return false; //deve possuir a estrutura dd:mm:aaaa
	
	var dia = data_separada[0];
	var mes = data_separada[1];
	var ano = data_separada[2];
	
	//verificando se o dia, o mês e o ano são numéricos
	if( isNaN(dia) ) return false;
	if( isNaN(mes) ) return false;
	if( isNaN(ano) ) return false;
	
	//verificando se a faixa do mês está correta
	if( (mes<0)||(mes>12) ) return false;

	//verificando se o ano possui 4 dígitos
	if( ano.length!=4 ) return false;

	var dia_max;
	
	switch (mes)
	{
		case '1':
		case '01':
		case '3':
		case '03':
		case '5':
		case '05':
		case '7':
		case '07':
		case '8':
		case '08':
		case '10':
		case '12':
		{
			dia_max=31;
			break;
		}
		case '4':
		case '04':
		case '6':
		case '06':
		case '9':
		case '09':
		case '11':
		{
			dia_max=30;
			break;
		}
		case '2':
		case '02':
		{

			if (ano%4==0) {
			//Ano bissexto
				dia_max=29;
			}
			else {
			//Ano não bissexto
				dia_max=28;
			}
			break;
		}
	}
	if( parseInt(dia) > parseInt(dia_max) ) return false;
	
	return true;
}

function formata_telefone(obj, e){

    var tecla = e.keyCode;
    if (tecla == 8) {
	    return true;
    }
    else {
	    var retorno = apenas_numero(e);
	    if (retorno) {
		    if (obj.value.length==1) {
			    obj.value = "(" + obj.value;
		    }
		    if (obj.value.length==3) {
			    obj.value = obj.value + ") ";
		    }
		    if (obj.value.length==9) {
			    obj.value = obj.value + "-";
		    }
	    }
	return retorno;
    }
}

function formata_cpf(obj) {
	if ((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue = false;
		}
	else{
		if((obj.value.length==3)||(obj.value.length==7)){
			obj.value = obj.value + ".";
		}
		else{
			if(obj.value.length==11){
				obj.value = obj.value + "-";
			}
		}
	}
}

function limpa_se_igual(obj, msg) {
	if(obj.value==msg) {
		obj.value='';
	}
}

function suja_se_vazio(obj, msg) {
	if(obj.value=='') {
		obj.value=msg;
	}
}

function formatPrice(campo,tammax,teclapres)
{
	if(apenas_numero(teclapres))
	{
		var key = window.event ? teclapres.keyCode : teclapres.which;
		if (key == 44 || key == 46 || key < 48 || key > 57) key = 0;
		var tecla = key;
		vr = document.getElementById(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.getElementById(campo).value = 'R$ ' + vr;
			}
			if ( (tam > 2) && (tam <= 8) ) {
				document.getElementById(campo).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam );
			}
			if ( (tam >= 9) && (tam <= 11) ) {
				document.getElementById(campo).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
			}
			if ( (tam >= 12) && (tam <= 14) ) {
				document.getElementById(campo).value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
			}
			if ( (tam >= 15) && (tam <= 17) ) {
				document.getElementById(campo).value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
			}
			if ( (tam >= 18) && (tam <= 20) ) {
				document.getElementById(campo).value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); 
			}
		}
	}
	else
	{
		return false;
	}
}

function redimensiona(width, height) {
 var width_tela   = self.screen.width;
 var height_tela  = self.screen.height;
 var pos_esquerda  = (width_tela - width)/2;
 var pos_direita  = (height_tela - height)/2;
 
 self.moveTo(pos_esquerda,pos_direita); //centraliza
 self.resizeTo(width, height); //redimensiona
 
}


function abrir(url) {
	window.open(url, 'S','resizable=no,scrollbars=yes,width=620,height=990');
}

function visualiza_dados_patrocinador( CI )
{
	  var open = window.open('popup_usuario.asp?CI='+CI,'dados','status=no,scrollbars=no,height=370,width=600,resizable=no');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ampliar_foto(foto) {
	abrir('popup_fotos_produto.asp?foto='+foto);
}

function esqueceu_senha_trabalhe_conosco() {
	abrir('popup_trabalhe_conosco_form_senha.asp');
}

function apaga_valor_campo(destino) {
	destino.value = '';
}

function apenasNumero(input) {
	if ((event.keyCode<46)||(event.keyCode>57)||(event.keyCode==47)) {
		event.returnValue = false;
	}
}

function carrega() {
	document.getElementById("carrega_mensagem").style.display = 'none';
	document.getElementById("corpo").style.display = 'inline';
}

function carrega_define_posicao() {
  var x,y;
  if (self.innerHeight)
  {// all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
  }
  else 
  if (document.documentElement && document.documentElement.clientHeight)
  {// Explorer 6 Strict Mode
   x = document.documentElement.clientWidth;
   y = document.documentElement.clientHeight;
  }
  else
  if (document.body)
  {// other Explorers
   x = document.body.clientWidth;
   y = document.body.clientHeight;
  }
	var el=document.getElementById('carrega_mensagem');
	if(null!=el)
	{
		var top = (y/2) - 50;
		var left = (x/2) - 200;
		if( left<=0 ) left = 10;

		el.style.left = left + "px"
		el.style.top = top + "px";
		el.style.zIndex = 2;
	}
}

function centraliza_janela(width, height) {
	var width_janela	= eval(width);
	var height_janela	= eval(height);
	var width_tela 		= self.screen.width;
	var height_tela 	= self.screen.height;
	var pos_esquerda 	= (width_tela - width_janela)/2;
	var pos_direita 	= (height_tela - height_janela)/2;

	self.moveTo(pos_esquerda,pos_direita); //centraliza
	self.resizeTo(width_janela, height_janela); //redimensiona
}

function valida_campos() {
	var f = document.formulario;
	if (isDate(f.data.value)) {
		return true;
	}
	else {
		alert('Data inválida');
		return false;
	}
}

function isDate(data) {

	if(!data) return false;
	
	var data_separada = data.split('/'); //separa as datas
	if(data_separada.length < 3) return false; //deve possuir a estrutura dd:mm:aaaa
	
	var dia = data_separada[0];
	var mes = data_separada[1];
	var ano = data_separada[2];
	
	//verificando se o dia, o mês e o ano são numéricos
	if( isNaN(dia) ) return false;
	if( isNaN(mes) ) return false;
	if( isNaN(ano) ) return false;
	
	//verificando se a faixa do mês está correta
	if( (mes<0)||(mes>12) ) return false;

	//verificando se o ano possui 4 dígitos
	if( ano.length!=4 ) return false;

	var dia_max;
	
	switch (mes)
	{
		case '1':
		case '01':
		case '3':
		case '03':
		case '5':
		case '05':
		case '7':
		case '07':
		case '8':
		case '08':
		case '10':
		case '12':
		{
			dia_max=31;
			break;
		}
		case '4':
		case '04':
		case '6':
		case '06':
		case '9':
		case '09':
		case '11':
		{
			dia_max=30;
			break;
		}
		case '2':
		case '02':
		{

			if (ano%4==0) {
			//Ano bissexto
				dia_max=29;
			}
			else {
			//Ano não bissexto
				dia_max=28;
			}
			break;
		}
	}
	if( parseInt(dia) > parseInt(dia_max) ) return false;
	
	return true;
}

function aparece()
{
	document.getElementById('foto').style.display='';
}

function some() 
{
	document.getElementById('foto').style.display='none';
}

/*function confirma_exclusao(area, codigo)
{
  if(confirm("Deseja realmente excluir?"))
  {
   window.location = 'excluir_'+ area +'.asp?codigo='+codigo;
  }
  else
  {
   alert('Exclusão cancelada');
  }
}*/

function le_ementa(origem, destino) {
	var form    = origem.form;
	var destino = eval("document."+form.name+"."+destino);
	destino.value = ementas[origem.value];
}

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 move(index,to) {
	var list = document.form_ordenar.list;
	var total = list.options.length-1;
	if (index == -1) return false;
	if (to == +1 && index == total) return false;
	if (to == -1 && index == 0) return false;
	var items = new Array;
	var values = new Array;
	for (i = total; i >= 0; i--) {
		items[i] = list.options[i].text;
		values[i] = list.options[i].value;
	}
	for (i = total; i >= 0; i--) {
		if (index == i) {
			list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
			list.options[i] = new Option(items[i + to], values[i]);
			i--;
		}
		else {
			list.options[i] = new Option(items[i], values[i]);
		}
	}
	list.focus();
}


function move_submit() {
	var list = document.form_ordenar.list;
	var theList = "?";
	// start with a "?" to make it look like a real query-string
	for (i = 0; i <= list.options.length-1; i++) { 
		cod = list.options[i].text.split(',');
		theList += "tL" + "=" + parseInt(cod[0]);
		// a "&" only BETWEEN the items, so not at the end
		if (i != list.options.length-1) theList += "&";
	}
	//alert(theList);
	//alert(theList.length);
	location.href = document.form_ordenar.action + theList;
}

function muda_estilo(destino, estilo) {
	var obj = document.getElementById(destino);
	obj.className = estilo;
}
	
function MudaFilho(formulario, Pai, Filho, Vetor)	{
	var f=formulario.elements;
	var N=Vetor.length-1;
	var indice=f[Pai].options[f[Pai].selectedIndex].value;
	f[Filho].length=1;
	f[Filho].options[0].text='Selecione';
	f[Filho].options[0].value='';
	if (indice!=0) {  
	  for (var i = 0; i<=N; i++) {
	    if (Vetor[i][0]==indice){
				f[Filho].length=f[Filho].length+1;
				f[Filho].options[f[Filho].length-1] = new Option(Vetor[i][2],Vetor[i][1]);
	    }
	  }
	}
}

function retorna_valor_select(campo) {
	var retorno = "";
	if(campo) {
		if(campo.length) {
			for (var i=0; i<campo.length; i++) {
				if( campo[i].selected ) retorno = campo[i].value;
			}
		}
		else {
			if(campo.selected) retorno = campo.checked;
		}
	}
	else {
		retorno = "";
	}
	return retorno;
}

	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 initToolTips()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }
}
function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#204373";
    if(!bg) bg = "#D7DBE7";
    var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
    '"><td align="center" style="font-family:Verdana; font-size:9px;"><font color="' + fg +
    '">&nbsp\;' + msg +
    '&nbsp\;</font></td></table></td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
  }
}
function moveToMouseLoc(e)
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  return true;
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

MaskInput = function(f, m){
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask);
};

addEvent = function(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
};

removeEvent = function(o, e, f, s){
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
};