var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

var toolTipSTYLE="";


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;
};

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);
};

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function confirma_exclusao(area, codigo)
{
  if(confirm("Deseja realmente excluir?"))
  {
   window.location = 'excluir_'+ area +'.asp?codigo='+codigo;
  }
  else
  {
   alert('Exclusão cancelada');
  }
}

function abrir(url) {
	window.open(url, 'S','resizable=yes,scrollbars=no');
}

function mostraPressFunc(obj) {
	var end = "noticias_cadastrar_pressfuncs.asp?empr="+obj;
	ajax_loadContent('nomefuncs',end);
}

function mostraUserSugest(obj) {
	var end = "user_sugest_manager_main.asp?canal="+obj;
	ajax_loadContent('sugestmain',end);
}

function ajustar_data_hora(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(":", "");
		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 < 9) {
				Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,tam);
			}
			if (tam >= 9 && tam < 11) {
				Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4)+ ' ' + vr.substr(8,tam);
			}
			if (tam >= 11 && tam < 12) {
				Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4)+ ' ' + vr.substr(8,8) + ':' + vr.substr(10,tam-1);
			}
		}
	}
	
	return retorno;
}

function ajustar_horario(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);
			}
		}
	}
	
	return retorno;
}


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 ajustar_cep(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("-", "");
		
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8) {
			if (tam > 5 && tam <= 9) {
				Campo.value = vr.substr(0, 5) + '-' + vr.substr(5, tam);
			}
		}
	}
	
	return retorno;
}

function ajustar_tel(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("-", "");
		
		tam = vr.length + 1;
		
		if (tecla != 9 && tecla != 8) {
			if (tam > 4 && tam <= 9) {
				Campo.value = vr.substr(0, 4) + '-' + vr.substr(4, tam);
			}
		}
	}
	
	return retorno;
}

function ampliar_foto(foto) {
	abrir('popup_fotos_produto.asp?foto='+foto);
}

function apaga_valor_campo(destino) {
	destino.value = '';
}

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 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 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 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_telefone(obj){
   if (obj.value.length==4){
	   obj.value = obj.value + "-";
   }
}

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 le_ementa(origem, destino) {
	var form    = origem.form;
	var destino = eval("document."+form.name+"."+destino);
	destino.value = ementas[origem.value];
}

function limpa_se_igual(obj, msg) {
	if(obj.value==msg) {
		obj.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;
}

function seleciona_todos(obj_origem, campo) {
	var f = obj_origem.form;
	var campo = eval('document.'+f.name+'.'+campo);

	if(campo) {
		if(campo.length) {
			for(var i=0; i<campo.length; i++) {
				campo[i].checked = obj_origem.checked;
			}
		}
		else {
			campo.checked = obj_origem.checked;
		}
	}
}

function suja_se_vazio(obj, msg) {
	if(obj.value=='') {
		obj.value=msg;
	}
}

function filtrar_busca() {
    var f = document.form_filtro;
    if( !checou(f.secao) ) {
        alert('Selecione ao menos uma seção para filtrar a busca!');
    }
    else {
        f.submit();
    }
}

function verifica_form_newsletter() {
	var f = document.form_newsletter;
	if( (f.nome.value==0) || (f.nome.value=='nome') ) {
		alert('Por favor, informe o nome!');
		f.nome.focus();
		return false;
	}
	if( (f.email.value==0) || (f.email.value=='e-mail') ) {
		alert('Por favor, informe o email!');
		f.email.focus();
		return false;
	}
	return true;
}

function verifica_form_tipo() {
	var f = document.form_tipo;
	if(f.tipo_nome.value==0) {
		alert('Por favor, informe o nome!');
		f.tipo_nome.focus();
		return false;
	}
	if(f.tipo_abreviacao.value==0) {
		alert('Por favor, informe a abreviação!');
		f.tipo_abreviacao.focus();
		return false;
	}
	return true;
}

function verifica_form_cidade() {
	var f = document.form_cidade;
	if(f.estado_codigo.value==0) {
		alert('Por favor, selecione o estado!');
		f.estado_codigo.focus();
		return false;
	}
	if(f.cidade_nome.value==0) {
		alert('Por favor, informe o nome!');
		f.cidade_nome.focus();
		return false;
	}
	if(f.cidade_abreviacao.value==0) {
		alert('Por favor, informe a abreviação!');
		f.cidade_abreviacao.focus();
		return false;
	}
	return true;
}

function verifica_form_empresa() {
	var f = document.form_empresa;
	if(f.razao_social.value==0) {
		alert('Por favor, informe a razão social!');
		f.razao_social.focus();
		return false;
	}
	if(f.nome_fantasia.value==0) {
		alert('Por favor, informe o nome fantasia!');
		f.nome_fantasia.focus();
		return false;
	}
	if(f.cnpj.value==0) {
		alert('Por favor, informe o CNPJ!');
		f.cnpj.focus();
		return false;
	}
	if(f.ddd_telefone.value==0) {
		alert('Por favor, informe o telefone!');
		f.ddd_telefone.focus();
		return false;
	}
	if(f.telefone.value==0) {
		alert('Por favor, informe o telefone!');
		f.telefone.focus();
		return false;
	}
	if(f.email.value==0) {
		alert('Por favor, informe o email!');
		f.email.focus();
		return false;
	}
	if(!checou(f.tipo)) {
		alert('Por favor, selecione o tipo!');	
		return false;
	}
	return true;
}

function verifica_form_area_campo(url, tira_validacao) {
	var f = document.form_area_campo;
	if(!tira_validacao) {
		if(f.area_campo_nome.value==0) {
			alert('Por favor, informe a Área / Campo!');
			f.area_campo_nome.focus();
		}
		else {
			f.action = url;
			f.submit();
		}
	}
	else {
		f.action = url;
		f.submit();
	}
}

function verifica_form_corporativa() {
	var f = document.form_corporativa;
	var competencia = retorna_valor_select(f.competencia_codigo);
	if(f.corporativa_numero.value==0) {
		alert('Por favor, preencha o nº!');
		f.corporativa_numero.focus();
		return false;
	}
	if(f.corporativa_ano.value==0) {
		alert('Por favor, preencha o ano!');
		f.corporativa_ano.focus();
		return false;
	}
	if(f.tipo_codigo.value==0) {
		alert('Por favor, escolha o tipo!');
		f.tipo_codigo.focus();
		return false;
	}
	if(f.area_campo_codigo.value==0) {
		alert('Por favor, escolha a área / campo!');
		f.area_campo_codigo.focus();
		return false;
	}
	if(f.competencia_codigo.value==0) {
		alert('Por favor, escolha a competência!');
		f.competencia_codigo.focus();
		return false;
	}
	if(f.orgao_codigo.value==0) {
		alert('Por favor, escolha o órgão!');
		f.orgao_codigo.focus();
		return false;
	}
	if( competencia!=2 ) {
		if(f.estado_codigo.value==0) {
			alert('Por favor, escolha o estado!');
			f.estado_codigo.focus();
			return false;
		}
		if( competencia==3 ) {
			if(f.cidade_codigo.value==0) {
				alert('Por favor, escolha a cidade!');
				f.cidade_codigo.focus();
				return false;
			}
		}
	}
	if(f.corporativa_requisito.value==0) {
		alert('Por favor, preencha o requisito!');
		f.corporativa_requisito.focus();
		return false;
	}
	if(f.tema_codigo.value==0) {
		alert('Por favor, escolha o tema!');
		f.tema_codigo.focus();
		return false;
	}
	if(f.corporativa_ementa.value==0) {
		alert('Por favor, preencha a ementa!');
		f.corporativa_ementa.focus();
		return false;
	}
	if(f.cd_corporativa.value==0) {
		if(f.arquivo.value==0) {
			alert('Por favor, escolha o arquivo!');
			f.arquivo.focus();
			return false;
		}
	}
	if(f.corporativa_dt_expedicao.value==0) {
		alert('Por favor, preencha a data da expedição!');
		f.corporativa_dt_expedicao.focus();
		return false;
	}
	if(f.corporativa_dt_validade.value==0) {
		alert('Por favor, preencha a data da validade!');
		f.corporativa_dt_validade.focus();
		return false;
	}
	return true;
}

function verifica_form_legislacao() {
	var f = document.form_legislacao;
	var competencia = retorna_valor_select(f.competencia_codigo);
	if(f.legislacao_numero.value==0) {
		alert('Por favor, preencha o nº!');
		f.legislacao_numero.focus();
		return false;
	}
	if(f.legislacao_ano.value==0) {
		alert('Por favor, preencha o ano!');
		f.legislacao_ano.focus();
		return false;
	}
	if(f.tipo_codigo.value==0) {
		alert('Por favor, escolha o tipo!');
		f.tipo_codigo.focus();
		return false;
	}
	if(f.area_campo_codigo.value==0) {
		alert('Por favor, escolha a área / campo!');
		f.area_campo_codigo.focus();
		return false;
	}
	if(f.competencia_codigo.value==0) {
		alert('Por favor, escolha a competência!');
		f.competencia_codigo.focus();
		return false;
	}
	if(f.orgao_codigo.value==0) {
		alert('Por favor, escolha o órgão!');
		f.orgao_codigo.focus();
		return false;
	}
	if( competencia!=2 ) {
		if(f.estado_codigo.value==0) {
			alert('Por favor, escolha o estado!');
			f.estado_codigo.focus();
			return false;
		}
		if( competencia==3 ) {
			if(f.cidade_codigo.value==0) {
				alert('Por favor, escolha a cidade!');
				f.cidade_codigo.focus();
				return false;
			}
		}
	}
	if(f.legislacao_requisito.value==0) {
		alert('Por favor, preencha o requisito!');
		f.legislacao_requisito.focus();
		return false;
	}
	if(f.tema_codigo.value==0) {
		alert('Por favor, escolha o tema!');
		f.tema_codigo.focus();
		return false;
	}
	if(f.legislacao_ementa.value==0) {
		alert('Por favor, preencha a ementa!');
		f.legislacao_ementa.focus();
		return false;
	}
	if(f.cd_legislacao.value==0) {
		if(f.arquivo.value==0) {
			alert('Por favor, escolha o arquivo!');
			f.arquivo.focus();
			return false;
		}
	}
	return true;
}

function verifica_form_usuario() {
	var f = document.form_usuario;	
	if(f.empresa_codigo.value==0) {
		alert('Por favor, escolha a empresa!');
		f.empresa_codigo.focus();
		return false;
	}
	if(f.usuario_nome.value==0) {
		alert('Por favor, informe o nome!');
		f.usuario_nome.focus();
		return false;
	}
	if(f.usuario_email.value==0) {
		alert('Por favor, informe o email!');
		f.usuario_email.focus();
		return false;
	}
	if(f.usuario_login.value==0) {
		alert('Por favor, informe o login!');
		f.usuario_login.focus();
		return false;
	}
	if(f.usuario_senha.value==0) {
		alert('Por favor, informe a senha!');
		f.usuario_senha.focus();
		return false;
	}
	if(f.usuario_senha.value!=f.usuario_senha_confirmacao.value) {
		alert('Por favor, confirme a senha!');
		f.usuario_senha_confirmacao.select();
		return false;
	}
	if(!checou(f.master)) {
		alert('Por favor, informe o nível do usuário!');
		return false;
	}
	return true;
}

function verifica_form_simples() {
	var f = document.frmsimples;	
	if(f.nome.value==0) {
		alert('Por favor, informe seu nome!');
		f.nome.focus();
		return false;
	}
	if(f.email.value==0) {
		alert('Por favor, informe seu e-mail!');
		f.email.focus();
		return false;
	} else {
		prim = f.email.value.indexOf("@")
		if(prim < 2) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("@",prim + 1) != -1) {
			alert("Por favor, corrija o e-mail digitado..");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf(".") < 1) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf(" ") != -1) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("zipmeil.com") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("hotmeil.com") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("yaho.com") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("gmeil.com") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.txtEmail.focus();
			f.txtEmail.select();
			return false;
		}
		if(f.email.value.indexOf(".@") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("@.") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf(".com.br.") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("/") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			f.txtEmail.select();
			return false;
		}
		if(f.email.value.indexOf(";") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("[") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("]") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf("(") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.email.focus();
			return false;
		}
		if(f.email.value.indexOf(")") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			f.txtEmail.focus();
			return false;
		}
		if(f.email.value.indexOf("..") > 0) {
			alert("Por favor, corrija o e-mail digitado.");
			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=='--') {
		alert('Por favor, informe seu Estado!');
		f.estado.focus();
		return false;
	}
	if(f.profissao.value==0) {
		alert('Por favor, informe sua profissão!');
		f.profissao.focus();
		return false;
	}
	return true;
}

function verifica_form_completo() {
	var f = document.frmcompleto;	
	//validar data de nascimento
	erro=0;
	hoje = new Date();
	anoAtual = hoje.getFullYear();
	barras = f.niver.value.split("/");
	if (barras.length == 3){
    	dia = barras[0];
    	mes = barras[1];
    	ano = barras[2];
    	resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual && ano >= 1900));
        if (!resultado) {
        	alert("Corrija a data de nascimento!");
            f.niver.focus();
            return false;
        }
    } else {
    	alert("Corrija a data de nascimento!");
    	f.niver.focus();
    	return false;
    }
	if(f.senha1.value==0) {
		alert('Por favor, informe sua senha!');
		f.senha1.focus();
		return false;
	}
	if(f.senha1.value!=f.senha2.value) {
		alert('Por favor, confirme sua senha!');
		f.senha2.select();
		return false;
	}
	return true;
}

function ValidaForm(form){
  for (i=0;i<form.length;i++){
    var obg = form[i].name.indexOf("x");
    if (obg!=-1){
      if (form[i].value == ""){
        var nome = form[i].name.substring(3,form[i].name.length);
        alert("O campo " + nome + " é obrigatório.")
        form[i].focus();
        return false
      }
    }
  } 
  
	if (form.txtEmail.value == "") {
		alert("Informe seu e-mail.");
		form.txtEmail.focus();
		return false;
	} else {
		prim = form.txtEmail.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("yaho.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("gmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			form.txtEmail.select();
			return false;
		}
		if(form.txtEmail.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			form.txtEmail.select();
			return false;
		}
		if(form.txtEmail.value.indexOf(";") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
		if(form.txtEmail.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			form.txtEmail.focus();
			return false;
		}
	}
  return true;
}

function verifica_form_orgao(url, tira_validacao) {
	var f = document.form_orgao;
	if(!tira_validacao) {
		if(f.orgao_nome.value==0) {
			alert('Por favor, informe o Órgão!');
			f.orgao_nome.focus();
		}
		else {
			f.action = url;
			f.submit();
		}
	}
	else {
		f.action = url;
		f.submit();
	}
}

function verifica_form_busca() {
    var f = document.form_busca;
    if(f.palavra.value==0) {
        alert('Por favor, preencha a palavra que deseja buscar!');
        f.palavra.focus();
        return false;
    }
    return true;
}

function verifica_form_tema(url, tira_validacao) {
	var f = document.form_tema;
	if(!tira_validacao) {
		if(f.tema_nome.value==0) {
			alert('Por favor, informe o Tema!');
			f.tema_nome.focus();
		}
		else {
			f.action = url;
			f.submit();
		}
	}
	else {
		f.action = url;
		f.submit();
	}
}

function verifica_upload_sansouth(lang) {
	var f = document.form_upload_sansouth;
	if(lang=='en') {
		var msg = 'Please, select the file!';
	}
	else {
		var msg = 'Por favor, selecione o arquivo!';
	}
	if(f.arquivo.value==0) {
		alert(msg);
		f.arquivo.focus();
		return false;
	}
	return true;
}

	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 verifica_motoboy(obj) {
	var f = eval('document.'+obj.form.name);
	var iframe = document.getElementById('iframe_verifica_motoboy');
	verificou_motoboy = false;
	
	if( (f.cep1.value.length<5)||(f.cep2.value.length<3) ) {
		alert('Preencha corretamente o CEP!');
		f.cep1.focus();
		obj.checked = false;
	}
	else {
		iframe.src = 'iframe_verifica_motoboy.asp?cep1='+f.cep1.value+'&cep2='+f.cep2.value;		
	}
	
}

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;
}
function moveSelectedOptions(from,to) {
	
	// Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			unSelectMatchingOptions(from,regex);
			}
		}
	// Move them over
	if (!hasOptions(from)) { return; }
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			to.options[index] = new Option( o.text, o.value, false, false);
			}
		}
	// Delete them from original
	for (var i=(from.options.length-1); i>=0; i--) {
		var o = from.options[i];
		if (o.selected) {
			from.options[i] = null;
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		sortSelect(from);
		sortSelect(to);
		}
	
	// testa se acrescenta o valor do combo no campo texto
	if (arguments.length>4) {
		var origem = from;
		var campo_destino = arguments[4];
		var acao = arguments[5];
		if (!acao) acao = "I";
		if (acao=='I') {
			origem = to;
		}
		if (campo_destino != "") {
			move_do_combo_para_text(origem, campo_destino, acao);
		}
	}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
}

function ContaCharComent(){ 
    var frm = document.Coment;
    numChar = frm.txtComent.value.length;
    if (numChar > 255) {
	   frm.txtComent.value = frm.txtComent.value.substring(0,255);
			numChar = numChar - 1;
			}
    frm.txtChar.value = 255 -numChar;
} 

function ContaCharIndique(){ 
    var frm = document.Indique;
    numChar = frm.txtComent.value.length;
    if (numChar > 255) {
	   frm.txtComent.value = frm.txtComent.value.substring(0,255);
			numChar = numChar - 1;
			}
    frm.txtChar.value = 255 -numChar;
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// Para link em combobox
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}