function chaveOn(varCampo,varChave) {
	if ($("#"+varCampo+"").val() == varChave) {
		$("#"+varCampo+"").val("");
	}
}
function chaveOff(varCampo,varChave) {
	if ($("#"+varCampo+"").val() == "") {
		$("#"+varCampo+"").val(varChave);
	}
}

function alterarTipo(obj){
var newO=document.createElement('input');
newO.setAttribute('type','password');
newO.setAttribute('name',obj.getAttribute('name'));
newO.setAttribute('class','campo_senha cc');
obj.parentNode.replaceChild(newO,obj);
newO.focus();
}




function popup(url, width, height, left, top, scrollbars, toolbar, location, status, menubar, resizable, nome) {
  top = ( (screen.height/2) - (height/2) )
  left = ( (screen.width/2) - (width/2) -10 )
  text = "Você deve desativar o bloqueador de popup.";
  janela = window.open(url,nome,'width='+width+',height='+height+',scrollbars='+scrollbars+',toolbar='+toolbar+',location='+location+',status='+status+',menubar='+menubar+',resizable='+resizable+',left='+left+',top='+top);
  if(janela == null) { alert(text); return; }
  janela.focus();
}

var strGravarLog
strGravarLog = 1
function gravarLog() {
	strGravarLog = strGravarLog+1;
    $.ajax({
    type: "POST",
    url: "includes/asp/acessos.asp",
    dataType: "html",
    timeout: 30000,
    data: strGravarLog,
    success:function(response){
		window.setTimeout('gravarLog();', 30000);
    },
    error: function( objAJAXRequest, strError ){
		gravarLog();
    }
    });
  return false;
}
function executaScripts(texto){
        var ini = 0;
        while (ini!=-1){
                ini = texto.indexOf('<script', ini);
                if (ini >=0){
                        ini = texto.indexOf('>', ini) + 1;
                        var fim = texto.indexOf('</script>', ini);
                        codigo = texto.substring(ini,fim);
                        novo = document.createElement("script");
						$("body").append("<div id='scriptsResponse'></div>")
						$("#scriptsResponse").html("<script>" + eval(codigo) + "</script>");
						$("#scriptsResponse").remove();						
						
                }
        }
}



function emailAlterar() {	
	$("#botaoEnviar").attr("disabled", "true");
    $.ajax({
    type: "POST",
    url: "includes/asp/email_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formEmail").serialize(),
    success:function(response){
		$("#botaoEnviar").removeAttr("disabled");
		executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
		$("#botaoEnviar").removeAttr("disabled");
		alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function senhaAlterar() {	
	$("#botaoEnviar").attr("disabled", "true");
    $.ajax({
    type: "POST",
    url: "includes/asp/senha_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formSenha").serialize(),
    success:function(response){
		$("#botaoEnviar").removeAttr("disabled");
		executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
		$("#botaoEnviar").removeAttr("disabled");
		alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function lembreteEnviar() {	
	$("#botaoEnviar").attr("disabled", "true");
    $.ajax({
    type: "POST",
    url: "includes/asp/lembrete_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formLembrete").serialize(),
    success:function(response){
		$("#botaoEnviar").removeAttr("disabled");
		executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
		$("#botaoEnviar").removeAttr("disabled");
		alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function contatoEnviar() {	
	$("#botaoEnviar").attr("disabled", "true");
    $.ajax({
    type: "POST",
    url: "includes/asp/contato_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formContato").serialize(),
    success:function(response){
		$("#botaoEnviar").removeAttr("disabled");
		executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
		$("#botaoEnviar").removeAttr("disabled");
		alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function contaEncerrar() {	
	$("#botaoEnviar").attr("disabled", "true");
    $.ajax({
    type: "POST",
    url: "includes/asp/encerrar_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formEncerrar").serialize(),
    success:function(response){
		$("#botaoEnviar").removeAttr("disabled");
		executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
		$("#botaoEnviar").removeAttr("disabled");
		alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}





































function GetElement( idElement )
{
if( document.all )
return document.all( idElement );
return document.getElementById( idElement );
}
function changepic(i,code)
{
var loop=0;
if (stat[code])
{
while ((pics[code][i]==0 || i>=(pics[code].length - 1)) && loop<100)
{
if (i>=(pics[code].length - 1)) { i=0; }
else
{
i++;
}
loop++;
}
if (pic[code][i].complete)
{
document.getElementById(code).src=pic[code][i].src;
setTimeout("changepic("+(i+1)+",'"+code+"')",500);
}
else
{
setTimeout("changepic("+i+",'"+code+"')",20);
}
}
}
function loadpic(code,j)
{
if (stat[code]) { pic[code][j].src=pics[code][j]; }
}
function startm(code)
{
stat[code]=1;
var jj, jjj;
var first=1;
for(var j=0;j<(pics[code].length - 1);j++)
{
pic[code][j]=new Image();
if (first) { first=0; loadpic(code,j); }
else { setTimeout("loadpic('"+code+"',"+j+")",j*50); }
}
changepic(0,code);
}
function endm(code)
{
stat[code]=0;
}
var pics=new Array();
var stat=new Array();
var pic=new Array();

