﻿xa = new xAnimation(10);
xa1 = new xAnimation(10);

var memo = null;
var memo_aba = null;
//var anunciotxt = "";

//star1 = new Image();
//star1.src = "../siv/imagens/estrela1.gif";
//star2 = new Image();
//star2.src = "../siv/imagens/estrela2.gif";

function Abrir(lugar) {
    open(lugar, "_self");
}

function Voltar() {
    history.back();
}

function MM_openBrWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
}

function InitAnuncio() {
	if (document.aspnetForm) {
		MudouTipo();
	}
}

function MudouAba(qnum) {
	if (memo_aba != null) {
		xGetElementById("Master_link" + memo_aba).className = "menuadminB";
		xGetElementById("TB_Aba" + memo_aba).style.display = "none";
	}
	
	xGetElementById("Master_link" + qnum).className = "menuadminB2";
	xGetElementById("TB_Aba" + qnum).style.display = "";
	
	if (qnum == "11" || qnum == "12" || qnum == "13" || qnum == "14") {
		ifr_vendas.document.location = "about:blank";
		ifr_solicitacoes.document.location = "about:blank";
		ifr_operacoes.document.location = "about:blank";
		ifr_documentos.document.location = "about:blank";
		
		if (qnum == "11") {
			xlocal = ifr_vendas.document.location.toString();
			if (xlocal == "about:blank") {
				open("vendas.aspx?iframe=1&id_cadastro=" + id_cadastro, "ifr_vendas");
			}
		} else if (qnum == "12") {
			xlocal = ifr_solicitacoes.document.location.toString();
			if (xlocal == "about:blank") {
				open("solicitacoes.aspx?iframe=1&id_cadastro=" + id_cadastro, "ifr_solicitacoes");
			}
		} else if (qnum == "13") {
			xlocal = ifr_operacoes.document.location.toString();
			if (xlocal == "about:blank") {
				open("operacoes.aspx?iframe=1&id_cadastro=" + id_cadastro, "ifr_operacoes");
			}
		} else if (qnum == "14") {
			xlocal = ifr_documentos.document.location.toString();
			if (xlocal == "about:blank") {
				open("arquivos.aspx?iframe=1&id_cadastro=" + id_cadastro, "ifr_documentos");
			}
		}
		
		xGetElementById("TR_Espaco1").style.display = "none";
		xGetElementById("TR_Espaco2").style.display = "none";
		xGetElementById("Master_Dados").style.overflowY = "hidden";
		xGetElementById("Master_TD_Linha4").style.display = "none";
		xGetElementById("TR_Botoes").style.display = "none";
	} else {
		xGetElementById("TR_Espaco1").style.display = "";
		xGetElementById("TR_Espaco2").style.display = "";
		xGetElementById("Master_Dados").style.overflowY = "auto";
		xGetElementById("Master_TD_Linha4").style.display = "";
		xGetElementById("TR_Botoes").style.display = "";
	}
	
	memo_aba = qnum;
}

function AddMaisVistos(id_imovel) {
	var cookies = "";
	var grava = false;
	var vistos = Get_Cookie("VistosSabel");
	
	if (vistos == null || vistos == "") {
		cookies = "," + id_imovel + ",";
		grava = true;
	} else {
		if (vistos.indexOf("," + id_imovel + ",") == -1) {
			cookies += vistos + id_imovel + ",";
			grava = true;
		}
	}
	
	if (grava) {
		Set_Cookie("VistosSabel", cookies, 90, "/", null, null);
	}
}

function AddFavorito(id_imovel, imoveis) {
	var cookies = "";
	var grava = false;
	var txtid = "";
	if (imoveis != null) {
		txtid = "_" + id_imovel;
	}
	var favos = Get_Cookie("FavoritosSabel");
	
	if (favos == null || favos == "") {
		cookies = "," + id_imovel + ",";
		grava = true;
	} else {
		if (favos.indexOf("," + id_imovel + ",") == -1) {
			cookies += favos + id_imovel + ",";
			grava = true;
		}
	}
	
	if (grava) {
		document.images["img_favoritos" + txtid].src = eval("favosoff.src");
		document.images["img_favoritos" + txtid].alt = "Excluir dos Favoritos";
		xGetElementById("link_favoritos" + txtid).href = "javascript:DeleteFavorito('" + id_imovel + "')";
		document.images["txtfavos"].src = eval("txtfavoson.src");
		
		Set_Cookie("FavoritosSabel", cookies, 90, "/", null, null);
		NoPopupFundo("1");
		setTimeout("MoveEstrela()", 300);
	}
}

function DeleteFavorito(id_imovel, imoveis) {
	var txtid = "";
	if (imoveis != null) {
		txtid = "_" + id_imovel;
	}
	var favos = Get_Cookie("FavoritosSabel");
	
	favos = favos.replace("," + id_imovel, "");
	
	document.images["img_favoritos" + txtid].src = eval("favoson.src");
	document.images["img_favoritos" + txtid].alt = "Adicionar aos Favoritos";
	xGetElementById("link_favoritos" + txtid).href = "javascript:AddFavorito('" + id_imovel + "')";
	document.images["txtfavos"].src = eval("txtfavosoff.src");
	
	Set_Cookie("FavoritosSabel", favos, null, "/", null, null);
	NoPopupFundo("1");
	setTimeout("MoveEstrela()", 300);
}

function MoveEstrela() {
	altura = parseInt(xClientHeight());
	hscroll = 0; //parseInt(document.body.scrollTop);
	meia_altura = parseInt(altura / 2) + hscroll - 88;
	xGetElementById("DIV_Mensagem").style.display = "";
	
	if (xGetElementById("DIV_Estrela").style.top == "-176px") {
		xa.opacity("DIV_Mensagem", 1, 1000, 2, 0);
		xAnimateCss("DIV_Estrela", 'top', meia_altura, 1000);
		
		tempo = setTimeout("MoveEstrela()", 2000);
	} else {
		xa.opacity("DIV_Mensagem", 0, 1000, 2, 0);
		xAnimateCss("DIV_Estrela", 'top', -176, 1000);
		setTimeout("FinalEstrela()", 1000);
		clearTimeout(tempo);
	}
}

function FinalEstrela() {
	NoPopupFundo();
	xGetElementById("DIV_Mensagem").style.display = "none";
}

function CentralizaMensagem() {
	altura = parseInt(xClientHeight());
	meia_altura = parseInt(altura / 2) - 20;
	
	xGetElementById("DIV_Mensagem").style.top = meia_altura + "px";
	xGetElementById("DIV_Mensagem").style.display = "none";
}

function MudouTipo() {
	valor1 = document.aspnetForm["Master$Formulario2$xid_tipo"][0].checked;
	valor2 = document.aspnetForm["Master$Formulario2$xid_tipo"][1].checked;
	valor3 = document.aspnetForm["Master$Formulario2$xid_tipo"][2].checked;
	valor4 = document.aspnetForm["Master$Formulario2$xid_tipo"][3].checked;
	valor5 = document.aspnetForm["Master$Formulario2$xid_tipo"][4].checked;
	
	if (valor1) { // Apartamento
		document.aspnetForm["Master$Formulario2$id_tipo"].value = "3";
		SomeApareceGrupo("TBODY", "TB_Apartamento", "");
		SomeApareceGrupo("TBODY", "TB_Edificio", "");
		SomeApareceGrupo("TBODY", "TB_Bairro", "");
		SomeApareceGrupo("TBODY", "TB_Conjunto", "none");
		SomeApareceGrupo("TBODY", "TB_Villagio", "none");
		SomeApareceGrupo("TBODY", "TB_Unidade", "none");
		SomeApareceGrupo("TBODY", "TB_Quadra", "none");
		SomeApareceGrupo("TBODY", "TB_Lote", "none");
		SomeApareceGrupo("TBODY", "TB_Dormitorios", "");
		SomeApareceGrupo("TBODY", "TB_Vagas", "");
		SomeApareceGrupo("TBODY", "TB_Unidades", "");
		SomeApareceGrupo("TBODY", "TB_AreaTerreno", "");
		SomeApareceGrupo("TBODY", "TB_AreaTotal", "none");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo1", "none");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo2", "none");
		SomeApareceGrupo("TBODY", "TB_ImovelVago", "");
		
		txt = " logradouro != '' && edificio != '' && apartamento != '' && dormitorios != '' && suites != '' && " +
			  " modulo != '' && vagas != '' && pavimentos != '' && unidades != '' && areaterreno != '' && " +
			  " areautil != '' && chaves != '' && valor != '' ";
	} else if (valor2) { // Casa
		document.aspnetForm["Master$Formulario2$id_tipo"].value = "2";
		SomeApareceGrupo("TBODY", "TB_Apartamento", "none");
		SomeApareceGrupo("TBODY", "TB_Edificio", "none");
		SomeApareceGrupo("TBODY", "TB_Villagio", "none");
		SomeApareceGrupo("TBODY", "TB_Unidade", "none");
		SomeApareceGrupo("TBODY", "TB_Bairro", "");
		SomeApareceGrupo("TBODY", "TB_Quadra", "");
		SomeApareceGrupo("TBODY", "TB_Lote", "");
		SomeApareceGrupo("TBODY", "TB_Dormitorios", "");
		SomeApareceGrupo("TBODY", "TB_Vagas", "");
		SomeApareceGrupo("TBODY", "TB_Unidades", "none");
		SomeApareceGrupo("TBODY", "TB_AreaTerreno", "");
		SomeApareceGrupo("TBODY", "TB_AreaTotal", "");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo1", "none");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo2", "none");
		SomeApareceGrupo("TBODY", "TB_ImovelVago", "");
		
		txt = " bairro != '' && quadra != '' && lote != '' && logradouro != '' && dormitorios != '' && suites != '' && " +
			  " modulo != '' && vagas != '' && pavimentos != '' && areaterreno != '' && " +
			  " areautil != '' && areatotal != '' && chaves != '' && valor != '' ";
	} else if (valor3) { // Terreno
		document.aspnetForm["Master$Formulario2$id_tipo"].value = "1";
		SomeApareceGrupo("TBODY", "TB_Apartamento", "none");
		SomeApareceGrupo("TBODY", "TB_Edificio", "none");
		SomeApareceGrupo("TBODY", "TB_Villagio", "none");
		SomeApareceGrupo("TBODY", "TB_Unidade", "none");
		SomeApareceGrupo("TBODY", "TB_Bairro", "");
		SomeApareceGrupo("TBODY", "TB_Quadra", "");
		SomeApareceGrupo("TBODY", "TB_Lote", "");
		SomeApareceGrupo("TBODY", "TB_Dormitorios", "none");
		SomeApareceGrupo("TBODY", "TB_Vagas", "none");
		SomeApareceGrupo("TBODY", "TB_Unidades", "none");
		SomeApareceGrupo("TBODY", "TB_AreaTerreno", "none");
		SomeApareceGrupo("TBODY", "TB_AreaTotal", "");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo1", "");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo2", "");
		SomeApareceGrupo("TBODY", "TB_ImovelVago", "none");
		
		txt = " bairro != '' && quadra != '' && lote != '' && logradouro != '' && modulo != '' && areatotal != '' && " +
			  " limpo != '' && valor != '' ";
	} else if (valor4) { // Villagio
		document.aspnetForm["Master$Formulario2$id_tipo"].value = "4";
		SomeApareceGrupo("TBODY", "TB_Apartamento", "none");
		SomeApareceGrupo("TBODY", "TB_Edificio", "none");
		SomeApareceGrupo("TBODY", "TB_Villagio", "");
		SomeApareceGrupo("TBODY", "TB_Bairro", "");
		SomeApareceGrupo("TBODY", "TB_Unidade", "");
		SomeApareceGrupo("TBODY", "TB_Quadra", "none");
		SomeApareceGrupo("TBODY", "TB_Lote", "none");
		SomeApareceGrupo("TBODY", "TB_Dormitorios", "");
		SomeApareceGrupo("TBODY", "TB_Vagas", "");
		SomeApareceGrupo("TBODY", "TB_Unidades", "none");
		SomeApareceGrupo("TBODY", "TB_AreaTerreno", "");
		SomeApareceGrupo("TBODY", "TB_AreaTotal", "");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo1", "none");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo2", "none");
		SomeApareceGrupo("TBODY", "TB_ImovelVago", "");
		
		txt = " logradouro != '' && villagio != '' && bairro != '' && unidade != '' && dormitorios != '' && " +
			  " suites != '' && modulo != '' && vagas != '' && pavimentos != '' && areaterreno != '' && " +
			  " areautil != '' && areatotal != '' && chaves != '' && valor != '' ";
	} else if (valor5) { // Comercial
		document.aspnetForm["Master$Formulario2$id_tipo"].value = "5";
		SomeApareceGrupo("TBODY", "TB_Apartamento", "none");
		SomeApareceGrupo("TBODY", "TB_Edificio", "");
		SomeApareceGrupo("TBODY", "TB_Villagio", "none");
		SomeApareceGrupo("TBODY", "TB_Unidade", "none");
		SomeApareceGrupo("TBODY", "TB_Bairro", "");
		SomeApareceGrupo("TBODY", "TB_Quadra", "");
		SomeApareceGrupo("TBODY", "TB_Lote", "none");
		SomeApareceGrupo("TBODY", "TB_Dormitorios", "none");
		SomeApareceGrupo("TBODY", "TB_Vagas", "");
		SomeApareceGrupo("TBODY", "TB_Unidades", "none");
		SomeApareceGrupo("TBODY", "TB_AreaTerreno", "");
		SomeApareceGrupo("TBODY", "TB_AreaTotal", "");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo1", "none");
		SomeApareceGrupo("TD", "TD_TerrenoLimpo2", "none");
		SomeApareceGrupo("TBODY", "TB_ImovelVago", "");
		
		txt = " edificio != '' && bairro != '' && quadra != '' && logradouro != '' && " +
			  " modulo != '' && vagas != '' && pavimentos != '' && areaterreno != '' && " +
			  " areautil != '' && areatotal != '' && chaves != '' && valor != '' ";
	}
}

function SomeApareceGrupo(grupo, yid, xdisplay) {
	tbs = document.getElementsByTagName(grupo);
	for (i=0; i < tbs.length; i++) {
		xid = tbs[i].id;
		if (xid == yid) {
			tbs[i].style.display = xdisplay;
		}
	}
}

function Pause(millis) {
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); } 
	while(curDate-date < millis);
}

function EnviarAnuncio() {
	var erro = false;
	var passou2 = false;
	
	lote = document.aspnetForm["Master$Formulario2$controle$lote"].value;
	quadra = document.aspnetForm["Master$Formulario2$controle$quadra"].value;
	villagio = document.aspnetForm["Master$Formulario2$controle$villagio"].value;
	edificio = document.aspnetForm["Master$Formulario2$controle$edificio"].value;
	apartamento = document.aspnetForm["Master$Formulario2$controle$apartamento"].value;
	modulo = document.aspnetForm["Master$Formulario2$controle$modulo"].value;
	logradouro = document.aspnetForm["Master$Formulario2$controle$logradouro"].value;
	dormitorios = document.aspnetForm["Master$Formulario2$controle$dormitorios"][document.aspnetForm["Master$Formulario2$controle$dormitorios"].selectedIndex].value;
	suites = document.aspnetForm["Master$Formulario2$controle$suites"][document.aspnetForm["Master$Formulario2$controle$suites"].selectedIndex].value;
	vagas = document.aspnetForm["Master$Formulario2$controle$vagas"][document.aspnetForm["Master$Formulario2$controle$vagas"].selectedIndex].value;
	pavimentos = document.aspnetForm["Master$Formulario2$controle$pavimentos"][document.aspnetForm["Master$Formulario2$controle$pavimentos"].selectedIndex].value;
	unidades = document.aspnetForm["Master$Formulario2$controle$unidades"][document.aspnetForm["Master$Formulario2$controle$unidades"].selectedIndex].value;
	areatotal = document.aspnetForm["Master$Formulario2$controle$areatotal"].value;
	areaterreno = document.aspnetForm["Master$Formulario2$controle$areaterreno"].value;
	areautil = document.aspnetForm["Master$Formulario2$controle$areautil"].value;
	limpo = document.aspnetForm["Master$Formulario2$controle$limpo"][document.aspnetForm["Master$Formulario2$controle$limpo"].selectedIndex].value;
	chaves = document.aspnetForm["Master$Formulario2$controle$chaves"][document.aspnetForm["Master$Formulario2$controle$chaves"].selectedIndex].value;
	valor = document.aspnetForm["Master$Formulario2$controle$valor"].value;
	
	nome = document.aspnetForm["Master$Formulario2$controle$nome"].value;
	profissao = document.aspnetForm["Master$Formulario2$controle$profissao"].value;
	telefone = document.aspnetForm["Master$Formulario2$controle$telefone"].value;
	email = document.aspnetForm["Master$Formulario2$controle$email"].value;
	var emailvalido = EmailValido(email);
	bairro = document.aspnetForm["Master$Formulario2$controle$bairro"].value;
	cidade = document.aspnetForm["Master$Formulario2$controle$cidade"].value;
	estado = document.aspnetForm["Master$Formulario2$controle$estado"].value;
	
	var passou1 = eval(anunciotxt);
	
	if (nome != "" && profissao != "" && telefone != "" && email != "" && emailvalido == true && 
		bairro != "" && cidade != "" && estado != "") {
		passou2 = true;
	} else {
		passou2 = false;
	}
	
	if (passou1 && passou2) {
		bt_salvar = xGetElementById("Master_Formulario2_controle_bt_salvar");
        bt_salvar.click();
	} else {
		alert("Preencha todos os campos");
	}
}

function Solicitar(nome, email, ddd, telefone, periodo, mensagem, info) {
	//alert(nome + " - " + email);
	if (nome != "" && email != "" && mensagem != "") {
		var txt = "act=solicitar&nome=" + escape(nome) + "&email=" + escape(email) + 
				  "&ddd=" + escape(ddd) + "&telefone=" + escape(telefone) + 
				  "&periodo=" + escape(periodo) + "&mensagem=" + escape(mensagem) + 
				  "&info=" + escape(info);
		
		ajax = criaAJAX();
		ajax.open("POST", "exec.aspx", true);
		ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("Content-length", 2);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.responseText == "1") {
					alert("Enviado com sucesso!");
				} else {
					alert("Erro! Tente novamente.\n" + ajax.responseText.substring(1000, 5000));
				}
			};
		};
		ajax.send(txt);
	} else {
		alert("Preencha os campos");
	}
}

function Amigo(nome, email, nome2, email2, mensagem) {
	//alert(nome2 + " - " + email2);
	if (nome != "" && email != "" && mensagem != "") {
		var txt = "act=amigo&nome=" + escape(nome) + "&email=" + escape(email) + 
				  "&nome2=" + escape(nome2) + "&email2=" + escape(email2) + 
				  "&mensagem=" + escape(mensagem);
		
		ajax = criaAJAX();
		ajax.open("POST", "exec.aspx", true);
		ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("Content-length", 2);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.responseText == "1") {
					alert("Enviado com sucesso!");
				} else {
					alert("Erro! Tente novamente.\n" + ajax.responseText);
				}
			};
		};
		ajax.send(txt);
	} else {
		alert("Preencha os campos");
	}
}

function xtractFile(data) {
	var filename = data.replace(/^.*\\/, '');
	return filename;
}

function openLBox(img){
    obj = xGetElementById("BGFundo");
    if (!obj) {
        obj = parent.xGetElementById("BGFundo");
    }
    
    document.body.scrollTop = "0";
	obj.style.display = "";
	
    var flashvars = {
        alvo: img
    };
    var params = {
        menu: "false",
        wmode: "transparent"
    };
    swfobject.embedSWF("flash/box.swf", "DIV_SWFBox", "100%", "100%", "9.0.0", "flash/expressInstall.swf", flashvars, params);    
}

function closeBox() {
    xGetElementById("BGFundo").style.display = "none";
}

function TecladoLogin() {
	if (window.event.keyCode == 13) {
		LogarNoSite();
	}
}

function Busca() {
    id_localidade = document.dadosBusca.id_localidade[document.dadosBusca.id_localidade.selectedIndex].value;
    //id_bairro = document.dadosBusca.id_bairro[document.dadosBusca.id_bairro.selectedIndex].value;
    id_tipo = document.dadosBusca.id_tipo[document.dadosBusca.id_tipo.selectedIndex].value;
    id_situacao = document.dadosBusca.id_situacao[document.dadosBusca.id_situacao.selectedIndex].value;
    id_faixa = document.dadosBusca.id_faixa[document.dadosBusca.id_faixa.selectedIndex].value;
    busca = document.dadosBusca.busca.value;
    
    if (id_localidade != "" || id_tipo != "" || id_situacao != "" || id_faixa != "" || busca != "") {
        document.dadosBusca.submit();
    } else {
        alert("Selecione algum filtro");
    }
}

function alteraMenu() { }

function MudouCombo(obj) {
    if (obj.value != "") {
        open("area-," + obj.value + ".html", "_self");
    }
}

function LogarNoSite() {
    usuario = document.dadosLogin.usuario.value;
    senha = document.dadosLogin.senha.value;

    if (usuario != "" && senha != "") {
        document.dadosLogin.submit();
    } else {
        alert("Preencha os campos obrigatórios");
    }
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function NoPopup(div, tabela, largura, altura, pagina, target) {
    obj = xGetElementById(div);
    if (!obj) {
        obj = parent.xGetElementById(div);
    }
    
    if (obj.style.display == "none") {
		if (largura != null) {
			if (largura.toString().indexOf("%") != -1) {
				xGetElementById(tabela).style.width = largura;
			} else {
				xGetElementById(tabela).style.width = largura + "px";
			}
		}
		if (altura != null) {
			if (altura.toString().indexOf("%") != -1) {
				xGetElementById(tabela).style.height = altura;
			} else {
				xGetElementById(tabela).style.height = altura + "px";
			}
		}
		
		obj.style.width = "100%";
		obj.style.height = "100%";
		
        obj.style.display = "";
		NoPopupFundo("1");

		if (pagina != null) {
			open(pagina, target);
		}
    } else {
        obj.style.display = "none";
		NoPopupFundo();
    }
}

function NoPopupFundo(num) {
	obj = xGetElementById("DIV_Fundo");
    if (!obj) {
        obj = parent.xGetElementById("DIV_Fundo");
	}

	if (num == "1") {
		xOpacity("DIV_Fundo", 0);

		obj.style.width = "100%";
		obj.style.height = getDocHeight().toString() + "px";

		obj.style.display = "";
		xa1.opacity(obj.id, 0.7, 300, 1, 0, "");
	} else {
		xa1.opacity(obj.id, 0, 300, 1, 0, "VoltaFundoOriginal()");
	}
}

function VoltaFundoOriginal() {
	obj = xGetElementById("DIV_Fundo");
    if (!obj) {
        obj = parent.xGetElementById("DIV_Fundo");
	}

	obj.style.display = "none";
	xOpacity("DIV_Fundo", 0);
}

function NoPopup2(div, largura, altura) {
    obj = xGetElementById("DIV_Fundo");
	obj2 = xGetElementById(div);
    if (!obj) {
        obj = parent.xGetElementById("DIV_Fundo");
		obj2 = parent.xGetElementById(div);
    }
    
    if (obj.style.display == "none") {
		if (largura != null) {
			if (largura.toString().indexOf("%") != -1) {
				xGetElementById("TABLE_NoPopup").style.width = largura;
			} else {
				xGetElementById("TABLE_NoPopup").style.width = largura + "px";
			}
		}
		if (altura != null) {
			if (altura.toString().indexOf("%") != -1) {
				xGetElementById("TABLE_NoPopup").style.height = altura;
			} else {
				xGetElementById("TABLE_NoPopup").style.height = altura + "px";
			}
		}
		
		obj.style.width = "100%";
		obj.style.height = getDocHeight().toString() + "px";
		
        obj.style.display = "";
        xa.opacity(obj.id, 0.7, 300, 1, 0, "obj2.style.display = ''");
    } else {
        obj2.style.display = "none";
		xa.opacity(obj.id, 0, 300, 1, 0, "obj.style.display = 'none'");
    }
}

function NoPopup3(largura, altura, pagina) {
    obj = xGetElementById("BGFundo3");
    if (!obj) {
        obj = parent.xGetElementById("BGFundo3");
    }
    
    if (obj.style.display == "none") {
		if (largura != null) {
			if (largura.toString().indexOf("%") != -1) {
				xGetElementById("TABLE3_NoPopup").style.width = largura;
			} else {
				xGetElementById("TABLE3_NoPopup").style.width = largura + "px";
			}
		}
		if (altura != null) {
			if (altura.toString().indexOf("%") != -1) {
				xGetElementById("TABLE3_NoPopup").style.height = altura;
			} else {
				xGetElementById("TABLE3_NoPopup").style.height = altura + "px";
			}
		}
		
        obj.style.display = "";
        //if (!IsIE()) {
        //	TiraFlashs();
        //}
        //document.body.scrollTop = "0";
        //document.body.style.overflowY = "hidden";
        //document.images["IMG_Grafico"].src = img;
        open(pagina, "ifr_nopopup");
    } else {
        obj.style.display = "none";
        //if (!IsIE()) {
        //	PoeFlashs();
        //}
        //document.body.style.scrollTop = "0";
        //document.body.style.overflowY = "";
    }
}

function TiraFlashs() {
    xGetElementById("SoblocoFlash").style.display = "none";
    xGetElementById("menuFlash2").style.display = "none";
}

function PoeFlashs() {
    xGetElementById("SoblocoFlash").style.display = "";
    xGetElementById("menuFlash2").style.display = "";
}

function Editor(id_area, pai) {
    //obj = xGetElementById("BGFundo");
    //if (!obj) {
    //    obj = parent.xGetElementById("BGFundo");
    //}
    
    var area = "";
    if (id_area != null) {
        area = "&id_area=" + id_area;
    }
    var xpai = "";
    if (pai != null) {
        xpai = "&pai=" + pai;
    }

	NoPopup("BGFundo", null, null, null, "edit/?x=1" + area + xpai, "ifr_editor");
    
	/*
    if (obj.style.display == "none") {
        open("edit/?x=1" + area + xpai, "ifr_editor");
        obj.style.display = "";
    } else {
        //open("about:blank", "ifr_editor");
        obj.style.display = "none";
    }
	*/
}

function Imprimir(fram, tipo) {
    if (fram != null) {
        if (tipo == null) {
            top.document.frames[fram].focus();
        } else {
            parent.document.frames[fram].focus();
        }
    }
    window.print();
}

function apagaLayer(layer) {
    document.getElementById(layer).style.visibility = 'hidden';
}

function acendeLayer(layer) {
    document.getElementById(layer).style.visibility = 'visible';
}

function apagaAcende(apaga, acende) {
    document.getElementById(apaga).style.visibility = 'hidden';
    document.getElementById(acende).style.visibility = 'visible';
}

function Modal(pagina, largura, altura) {
    window.showModalDialog(pagina, window, "status: no; dialogWidth: " + largura + "px; dialogHeight: " + altura + "px; help: no; resizable: no; scroll: no;");
}

function PopProduto(id_produto) {
    w = 300; h = 650;
    x = (screen.availWidth - w) / 2;
    y = (screen.availHeight - h) / 2;
    pagina = "popup.aspx?id_produto=" + id_produto;
    JP = window.open(pagina, "janela1", "toolbar=0, status=0, width=" + w + ", height=" + h + ", left=" + x + ", top=" + y + ", menubar=0, resizable=0, fullscreen=0, scrollbars=0");
    JP.focus();
}

function Checando(obj, func) {
    if (obj.checked == true) {
        var check = true;
        obj.title = "Desmarcar Todos";
    } else {
        var check = false;
        obj.title = "Marcar Todos";
    }
    x = document.getElementsByTagName("input");

    for (i = 0; i < x.length; i++) {
        nome = x[i].name;
        if (x[i].type == "checkbox" && nome.indexOf("CHK_") != -1) {
            if (x[i].checked != check) {
                x[i].checked = check;
                if (func != null) {
                    eval(func);
                }
            }
        }
    }
}

function EscolherSelecionados(vars) {
    var erro = true;
    var uniqkey = "";
    var valuniq = "";
    var xval = "";
    elementos = document.getElementsByTagName("input");

    if (vars != null) {
        xvars = vars.split(";");
        uniqkey = xvars[0];
    }

    for (i = 0; i < elementos.length; i++) {
        nome = elementos[i].name;
        if (elementos[i].type == "radio") {
            if (elementos[i].checked == true) {
                erro = false;
                valuniq = elementos[i].value;
                valuniq = valuniq.replace("CHK_", "");
            }
        }
    }

    if (erro == true) {
        alert("Selecione ao menos um cadastro");
    } else {
        if (opener.document.forms.length > 0) {
            if (opener.document.forms[0][uniqkey]) {
                opener.document.forms[0][uniqkey].value = valuniq;
                if (vars != null) {
                    xvars = vars.split(";");
                    for (i = 1; i < xvars.length; i++) {
                        xval = document.forms[1][xvars[i] + "_" + valuniq].value;
                        opener.document.forms[0][xvars[i]].value = xval;
                    }
                }
            } else if (opener.document.forms[0]["Master$Formulario2$" + uniqkey]) {
                opener.document.forms[0]["Master$Formulario2$" + uniqkey].value = valuniq;
                if (vars != null) {
                    xvars = vars.split(";");
                    for (i = 1; i < xvars.length; i++) {
                        xval = document.forms[1][xvars[i] + "_" + valuniq].value;
                        opener.document.forms[0]["Master$Formulario2$" + xvars[i]].value = xval;
                    }
                }
            }
        } else {
            if (vars != null) {
                xvars = vars.split(";");
                for (i = 1; i < xvars.length; i++) {
                    xval = document.forms[1][xvars[i] + "_" + valuniq].value;
                    if (opener.document.getElementById("inpImgURL")) {
                        opener.document.getElementById("inpImgURL").value = "/content/" + xval;
                    } else if (opener.document.getElementById("inpSwfURL")) {
                        opener.document.getElementById("inpSwfURL").value = "/content/" + xval;
                    }
                }
            }
        }

        top.close();
    }
}

function Apagar(pagina, uniqkey, valuniq, vars, redirect) {
    if (vars == null || vars == "") {
        vars = "";
    }
    if (confirm("Tem certeza de que deseja excluir este cadastro?")) {
        open(pagina + "?act=delete&" + uniqkey + "=" + valuniq + vars + "&redirect=" + escape(redirect), "_self");
    }
}

function ApagarSelecionados(pagina, uniqkey, vars, redirect) {
    if (vars == null || vars == "") {
        vars = "";
    }
    var str = "";
    x = document.getElementsByTagName("input");

    for (i = 0; i < x.length; i++) {
        nome = x[i].name;
        if (x[i].type == "checkbox" && nome.indexOf("CHK_") != -1 && x[i].checked == true) {
            str += "&" + uniqkey + "=" + nome.replace("CHK_", "");
        }
    }

    // Rotina para não trazer duas vezes dois valores
    if (redirect.indexOf(vars) != -1) {
        redirect = redirect.replace(vars, null);
    }

    if (str == "") {
        alert("Selecione ao menos um registro");
    } else {
        if (confirm("Tem certeza de que deseja excluir este(s) cadastro(s)?")) {
            open(pagina + "?act=del" + str + vars + "&redirect=" + redirect, "_self");
        }
    }
}

function ApagarSelecionados2(xnome) {
    var str = "";
    x = document.getElementsByTagName("input");
    
    for (i = 0; i < x.length; i++) {
        nome = x[i].name;
        if (x[i].type == "checkbox" && nome.indexOf("CHK_") != -1 && x[i].checked == true) {
            str += "&" + xnome + "=" + nome.replace("CHK_", "");
        }
    }
    
    if (str == "") {
        alert("Selecione ao menos um registro");
    } else {
        if (confirm("Tem certeza de que deseja excluir este(s) cadastro(s)?")) {
            open("[thispage1]?act=del" + str + "&redirect=[thispage]", "_self");
        }
    }
}

function adjustRatio(largura, altura, largura_img, altura_img, img) {
	var ratio = 0;

	if (largura_img == null) {
		largura_img = img.width;
	}
	if (altura_img == null) {
		altura_img = img.height;
	}
	
	if (largura_img > largura){
		ratio = largura / largura_img;
		img.style.width = largura + "px";
		img.style.height = parseInt(altura_img * ratio) + "px";
		altura_img = altura_img * ratio;
		largura_img = largura_img * ratio;
	}
	
	if (altura_img > altura){
		ratio = altura / altura_img;
		img.style.height = altura + "px";
		img.style.width = parseInt(largura_img * ratio) + "px";
		largura_img = largura_img * ratio;
	}
}

function SelectInputs(nome, num) {
    obj = xGetElementById(nome);
    len = xGetElementById(nome).length;
    //alert(obj.checked);
}

function Loading(xnum) {
    if (xnum != null) {
        Tamanho(xnum);
    }
    Init();
}

function Tamanho(numero) {
	var cont = 1;
	var qlinhas = 0;
	
	if (xGetElementById("TR_Linha")) {
		obj = document.getElementsByTagName("tr");
		
		for (i=0; i<obj.length; i++) {
			if (obj[i].id == "TR_Linha") {
				qlinhas++;
			}
		}
	} else {
		qlinhas = 1;
	}
	
	if (xGetElementById("V1")) {
	    for (i = 1; i <= numero * qlinhas; i++) {
	        xGetElementById("V" + i).width = xGetElementById("T" + cont).clientWidth;
	        
	        if (cont % numero == 0) {
	            cont = 1;
	        } else {
	            cont++;
	        }
	    }
	}
}

function AbreGrupo(nome) {
    if (document.all["TBH_" + nome].style.display == "none") {
        document.all["TBH_" + nome].style.display = "";
        document.images["IMG_" + nome].src = eval("menos.src");
    } else {
        document.all["TBH_" + nome].style.display = "none";
        document.images["IMG_" + nome].src = eval("mais.src");
    }
}

function doLink(lugar, targ) {
    open(lugar, targ);
}

function xGetElementById(e) {
	if (typeof(e) != 'string') return e;
	if (document.getElementById) e = document.getElementById(e);
	else if (document.all) e = document.all[e];
	else e = null;
	return e;
}

function isURL(s) {
    var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
    return regexp.test(s);
}

function EmailValido(email) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)) {
        return true;
    } else {
        return false;
    }
}

function FormatCPF(cpf) {
    if (cpf != "") {
        cpf = cpf.substring(0, 3) + "." + cpf.substring(3, 6) + "." + cpf.substring(6, 9) + "-" + cpf.substring(9, 11);
        return (cpf);
    } else {
        return ("");
    }
}

function FormatRG(rg) {
    if (rg != "") {
        rg = rg.substring(0, 2) + "." + rg.substring(2, 5) + "." + rg.substring(5, 8) + "-" + rg.substring(8, 9);
        return (rg);
    } else {
        return ("");
    }
}

function Set_Cookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie(name, path, domain) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Get_Cookie(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function TecladoFF(e) {
	if (!IsIE()) {
		evt.stopPropagation();
		evt.preventDefault();
	}
}

function Submitando(evt) {
	if (IsIE()) {
		event.cancelBubble = true;
		event.returnValue = false;
	} else {
		if (evt.stopPropagation) {
			evt.stopPropagation();
			evt.preventDefault();
		}
	}
}

function Limpar() {
    document.dados.reset();
}

function LimparCampo(formulario, campo) {
    document[formulario][campo].value = "";
}

function img_on(nome) {
    if (memo != null) {
        document.images[memo].src = eval(memo + "off.src");
    }
    document.images[nome].src = eval(nome + "on.src");
}

function img_off(nome) {
    if (memo != null) {
        document.images[memo].src = eval(memo + "on.src");
    }
    document.images[nome].src = eval(nome + "off.src");
}

function Lupinha(pagina, largura, altura, filtros, filtros2, filtros3, filtros4, targt) {
    var plus, plus1, plus2;

    pagina = pagina.toString();
    if (filtros != null) {
        filtros = filtros.toString();
    } else {
        filtros = "";
    }
    if (filtros2 != null) {
        filtros2 = filtros2.toString();
        if (filtros != "") {
            plus = "&";
        } else {
            plus = "";
        }
    }
    if (filtros3 != null) {
        xfiltros3 = eval(filtros3);
        plus1 = xfiltros3.toString();
    } else {
        plus1 = "";
    }
    if (filtros4 != null) {
        xfiltros4 = eval(filtros4);
        if (xfiltros4 != false) {
            plus2 = xfiltros4;
        } else {
            plus2 = "";
            return;
        }
    } else {
        plus2 = "";
    }
    page = pagina + "?" + filtros + plus + filtros2 + plus1 + plus2;
    w = altura; h = altura;
    x = (screen.availWidth - w) / 2;
    y = (screen.availHeight - h) / 2;
    if (targt == null) {
        JP = window.open(page, "janela1", "toolbar=0, status=1, width=" + w + ", height=" + h + ", left=" + x + ", top=" + y + ", menubar=0, resizable=0, fullscreen=0, scrollbars=0");
        JP.focus();
    } else {
        open(page, targt);
    }
}

function ColocaArea(id_area, area) {
    if (document.aspnetForm["Master$id_area"]) {
        document.aspnetForm["Master$id_area"].value = id_area;
    } else if (document.aspnetForm["Master$Formulario2$id_area"]) {
        document.aspnetForm["Master$Formulario2$id_area"].value = id_area;
    }
    xGetElementById("Master_Formulario2_TD_Area").innerHTML = area;
}

function LimparCampos(campos) {
    campos = campos.split(",");
    for (i = 0; i < campos.length; i++) {
        document.dados[campos[i]].value = "";
    }
}

function CPF(campo, e) {
	nome = campo.name;
    if (IsIE()) {
		codigo = window.event.keyCode;
    } else {
		codigo = e.which;
    }
	
    if ((codigo < 48 || codigo >= 58) &&
		(codigo < 96 || codigo >= 106) && codigo != 46 &&
		codigo != 45 && codigo != 35 && codigo != 36 &&
		codigo != 37 && codigo != 39 && codigo != 8 &&
		codigo != 9) {
		if (IsIE()) {
			e.cancelBubble = true;
			e.returnValue = false;
		} else {
			e.preventDefault();
		}
    }
	
    if (codigo != 46 && codigo != 8) {
        cpf = document.aspnetForm[nome].value;
        tamanho = cpf.length;
        if (tamanho == 3) {
            document.aspnetForm[nome].value += ".";
        } else if (tamanho == 7) {
            document.aspnetForm[nome].value += ".";
        } else if (tamanho == 11) {
            document.aspnetForm[nome].value += "-";
        }
    }
}

function SoNumeros(e) {
    if (IsIE()) {
        var e = window.event;
        code = e.keyCode;
    } else {
        code = e.which;
    }

    if (!e.shiftKey) {
        if ((code < 48 || code > 57) && (code < 96 || code > 105) &&
			(code != 8 && code != 9 && code != 35 && code != 36 && code != 37 &&
			code != 38 && code != 39 && code != 40 && code != 46 && code != 13)) {
            if (IsIE()) {
                e.cancelBubble = true;
                e.returnValue = false;
            } else {
                e.preventDefault();
            }
        }
    } else {
        if (IsIE()) {
            e.cancelBubble = true;
            e.returnValue = false;
        } else {
            e.preventDefault();
        }
    }
}

function CampoDinheiro(e) {
    if (IsIE()) {
        var e = window.event;
        code = e.keyCode;
    } else {
        code = e.which;
    }

    if (!e.shiftKey) {
        if ((code < 48 || code > 57) && (code < 96 || code > 105) &&
			(code != 8 && code != 9 && code != 35 && code != 36 && code != 37 &&
			code != 38 && code != 39 && code != 40 && code != 46 && code != 188)) {
            if (IsIE()) {
                e.cancelBubble = true;
                e.returnValue = false;
            } else {
                e.preventDefault();
            }
        }
    } else {
        if (IsIE()) {
            e.cancelBubble = true;
            e.returnValue = false;
        } else {
            e.preventDefault();
        }
    }
}

function Pula(campo, proximo) {
    if (campo.value.length == campo.maxLength) {
        document.dados[proximo].focus();
    }
}

function CampoData() {
    code = event.keyCode;
    if (!event.shiftKey) {
        if ((code < 48 || code > 57) && (code < 96 || code > 105) &&
			(code != 8 && code != 9 && code != 35 && code != 36 && code != 37 &&
			code != 38 && code != 39 && code != 40 && code != 46 && code != 191 &&
			code != 111)) {
            event.cancelBubble = true;
            event.returnValue = false;
        }
    } else {
        event.cancelBubble = true;
        event.returnValue = false;
    }
}

function SemCaractere(caracs) {
    code = event.keyCode;
    if (caracs != null) {
        caracs = caracs.split(",");
        for (i = 0; i < caracs.length; i++) {
            if (code == caracs[i]) {
                event.cancelBubble = true;
                event.returnValue = false;
            }
        }
    }
}

function FormatHora(campo) {
    var formu;
    nome = campo.name;
    codigo = event.keyCode;
    if (!event.shiftKey) {
        if ((codigo < 48 || codigo >= 58) &&
			(codigo < 96 || codigo >= 106) && codigo != 46 &&
			codigo != 45 && codigo != 35 && codigo != 36 &&
			codigo != 37 && codigo != 39 && codigo != 8 &&
			codigo != 9) {
            event.cancelBubble = true;
            event.returnValue = false;
        }
    } else {
        event.cancelBubble = true;
        event.returnValue = false;
    }

    if (codigo != 46 && codigo != 8) {
        if (document.forms[0][nome]) {
            obj = document.forms[0][nome].value;
            formu = 0;
        } else if (document.forms[1][nome]) {
            obj = document.forms[1][nome].value;
            formu = 1;
        } else {
            alert("Erro! Nenhum formulário encontrado");
        }

        if (obj) {
            tamanho = obj.length;
            if (tamanho == 2) {
                document.forms[formu][nome].value += ":";
            }
        }
    }
}

function FormatNota(campo) {
    nome = campo.name;
    codigo = event.keyCode;
    if (!event.shiftKey) {
        if ((codigo < 48 || codigo >= 58) &&
			(codigo < 96 || codigo >= 106) && codigo != 46 &&
			codigo != 45 && codigo != 35 && codigo != 36 &&
			codigo != 37 && codigo != 39 && codigo != 8 &&
			codigo != 9) {
            event.cancelBubble = true;
            event.returnValue = false;
        }
    } else {
        event.cancelBubble = true;
        event.returnValue = false;
    }

    if (codigo != 46 && codigo != 8) {
        obj = document.dados[nome].value;
        tamanho = obj.length;
        if (tamanho == 2) {
            document.dados[nome].value += ",";
        }
    }
}

function CNPJ(campo) {
    nome = campo.name;
    codigo = window.event.keyCode;
    if ((codigo < 48 || codigo >= 58) &&
		(codigo < 96 || codigo >= 106) && codigo != 46 &&
		codigo != 45 && codigo != 35 && codigo != 36 &&
		codigo != 37 && codigo != 39 && codigo != 8 &&
		codigo != 9) {
        window.event.returnValue = false;
        window.event.keyCode = 0;
    }

    if (codigo != 46 && codigo != 8) {
        cnpj = document.dados[nome].value;
        tamanho = cnpj.length;
        if (tamanho == 3) {
            document.dados[nome].value += ".";
        } else if (tamanho == 7) {
            document.dados[nome].value += ".";
        } else if (tamanho == 11) {
            document.dados[nome].value += "/";
        } else if (tamanho == 16) {
            document.dados[nome].value += "-";
        }
    }
}

function Ocorrencias(campo, txt) {
    var contador = 0;
    if (campo != "") {
        tam = campo.length;
        tam2 = txt.length;
        for (i = 0; i < tam; i++) {
            if (campo.substring(i, tam2 + i) == txt) {
                contador++;
            }
        }
    }
    return contador;
}

function IsNumeric(strString) {
    if (strString.toString() != "") {
        var strValidChars = "0123456789.";
        var strChar;
        var blnResult = true;

        for (i = 0; i < strString.length && blnResult == true; i++) {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1) {
                blnResult = false;
            }
        }
        return blnResult;
    } else {
        return false;
    }
}

function replace2(str, valor1, valor2) {
    var str2 = "";
    for (q = 0; q < str.length; q = q + valor1.length) {
        if (str.substring(q, q + valor1.length) == valor1) {
            str2 += valor2;
        } else {
            str2 += str.substring(q, q + valor1.length);
        }
    }
    return str2;
}

function TiraHTML(txt) {
    var novo_txt = "";
    var sinal_maior = false;
    var quebra = new RegExp("\n", "gi");

    if (txt != "") {
        sinal_maior = false;

        for (i = 0; i < txt.length; i++) {
            if (txt.substring(i, i + 1) != "<" && sinal_maior == false) {
                novo_txt += txt.substring(i, i + 1);
            } else if (txt.substring(i, i + 1) == "<") {
                sinal_maior = true;
            } else if (txt.substring(i, i + 1) == ">") {
                sinal_maior = false;
            }
        }
        novo_txt = novo_txt.replace(quebra, "<br>");

        return novo_txt;
    }
}

function IsIE() {
    if (document.all) {
        return true;
    } else {
        return false;
    }
}

function Calendar2(nome, xform, xobj, xdiv, func) {
    if (xGetElementById("calendario").style.display != "") {
        formu = xform.name;
        
        if (document[formu][xobj]) {
            obj = document[formu][xobj].name;
        } else if (document[formu]["Master$Formulario2$" + xobj]) {
            obj = document[formu]["Master$Formulario2$" + xobj].name;
        }
        
        if (xGetElementById(xdiv)) {
            div = xdiv;
        } else {
            div = "Master_" + xdiv;
        }
        
        if (document[formu][obj].value != "") {
            data = document[formu][obj].value;
            dia = data.substring(0, data.indexOf("/"));
            mes = data.substring(data.indexOf("/") + 1, data.lastIndexOf("/"));
            ano = data.substring(data.lastIndexOf("/") + 1, data.length);
            //document.calendario.document.location = "inc_calendario.asp?dia=" + dia + "&mes=" + mes + "&ano=" + ano + "&objeto=" + obj + "&formulario=" + formu;
        } else {
            //document.calendario.document.location = "inc_calendario.asp?objeto=" + obj + "&formulario=" + formu;
        }

        DesapareceSels();
        
        if (div != null) {
            scrolltop = xGetElementById(div).scrollTop;
            scrollleft = xGetElementById(div).scrollLeft;
            altura = xGetElementById(div).scrollHeight;
            largura = xGetElementById(div).scrollWidth;
        } else {
            scrolltop = document.body.scrollTop;
            scrollleft = document.body.scrollLeft;
            altura = document.body.scrollHeight;
            largura = document.body.scrollWidth;
        }
        eval(nome).style.position = "absolute";
        if (eval(nome).offsetLeft + 201 > largura) {
            x = eval(nome).offsetLeft - (scrollleft + (eval(nome).offsetLeft + 201 - largura));
        } else {
            x = eval(nome).offsetLeft - scrollleft;
        }
        //y = eval(nome).offsetTop + 20;
        if (eval(nome).offsetTop + 214 > altura) {
            y = eval(nome).offsetTop - (scrolltop + (eval(nome).offsetTop + 214 - altura));
        } else {
            y = eval(nome).offsetTop - scrolltop;
        }
        if (div != null) {
            xGetElementById(div).style.position = "absolute";
            if (IsIE()) {
                posdiv = parseInt(xGetElementById(div).offsetTop);
            } else {
                posdiv = 0;
            }
            xGetElementById(div).style.position = "static";
            y = y + posdiv + 19;
        }
        //y = y - scrolltop;
        eval(nome).style.position = "static";
        xGetElementById("calendario").style.visibility = "visible";
        xGetElementById("calendario").style.left = x;
        xGetElementById("calendario").style.top = y;
        xGetElementById("calendario").style.display = "";
        
        if (IsIE()) {
            //document.Form1.objeto.value = obj;
            document.calendario.document.Form1.form.value = formu
            document.calendario.document.Form1.objeto.value = obj;
        } else {
            xGetElementById("calendario").contentWindow.document.Form1.form.value = obj;
            xGetElementById("calendario").contentWindow.document.Form1.objeto.value = obj;
            //xGetElementById("calendario").contentWindow.document.cal.objeto.value = document[formu][obj].name;
        }
        if (func != null) {
            if (IsIE()) {
                //xGetElementById("calendario").document.cal.func.value = func;
            } else {
                //xGetElementById("calendario").contentWindow.document.cal.func.value = func;
            }
        }
    } else {
        xGetElementById("calendario").style.display = "none";
        ApereceSels();
    }
}

function DesapareceCalendario() {
    xGetElementById("calendario").style.display = "none";
    ApereceSels();
}

function DesapareceSels() {
    elem = document.getElementsByTagName("select");
    total = document.getElementsByTagName("select").length;
    for (i = 0; i < total; i++) {
        eval(elem[i]).style.visibility = "hidden";
    }

    iframes = document.getElementsByTagName("iframe");
    for (i = 0; i < iframes.length; i++) {
        eval(iframes[i]).style.visibility = "hidden";
    }
}

function ApereceSels() {
    elem = document.getElementsByTagName("select");
    for (i = 0; i < elem.length; i++) {
        eval(elem[i]).style.visibility = "visible";
    }

    iframes = document.getElementsByTagName("iframe");
    for (i = 0; i < iframes.length; i++) {
        eval(iframes[i]).style.visibility = "visible";
    }
}

function Trim(txt) {
    var i = 0;
    while (txt.charAt(i) == " ") {
        i = i + 1;
    }
    var j = txt.length - 1
    while (txt.charAt(j) == " ") {
        j = j - 1;
    }
    return txt.substr(i, j - i + 1)
}

function FormataCampo(campo) {
    if (campo) {
        vax = campo.value;
        vax = Formata2(vax);
        vax = parseFloat(vax);
        if (isNaN(vax) == false) {
            campo.value = Formata(vax, '');
        } else {
            campo.value = "0,00";
        }
    }
}

function Formata(numero, tipo) {
    if (numero != "") {
        numero = numero.toString();
        numero = replace2(numero, " ", "");
        numero = Trim(numero);

        num = ""; num2 = ""; sinal = "";
        count = 0; jafoi = false;
        if (numero < 0) {
            sinal = "-";
            numero = numero.toString();
            numero = numero.replace("-", "");
        } else {
            numero = numero.toString();
        }
        tamanho = numero.length;
        //		if (numero.indexOf(",") != -1 && (numero.indexOf(".") == -1)) {
        //			numero = replace2(numero, ".", "");
        //			numero = replace2(numero, ",", ".");
        //			numero = parseFloat(numero);
        //			numero = numero.toString();
        //		}

        if (numero.indexOf(".") != -1) {
            for (j = tamanho; j > 0; j--) {
                if (jafoi == true) {
                    if (count % 3 == 0) {
                        if (count != 0) {
                            num += ".";
                        } else {
                            num += ":";
                        }
                    }
                    count++;
                }
                if (numero.substring(j, j - 1) == ".") {
                    jafoi = true;
                } else {
                    num += numero.substring(j, j - 1);
                }
            }
            if (num.indexOf(":") == 1) {
                num = "0" + num;
            }
        } else {
            for (j = tamanho; j > 0; j--) {
                num += numero.substring(j, j - 1);
                count++;
                if (count % 3 == 0 && j != 1) {
                    if (count != 0) {
                        num += ".";
                    } else {
                        num += ":";
                    }
                }
            }

            //			if (num.substring(0, 1) == ".") {
            //				num = num.replace(".", "");
            //			}
            num = "00," + num;
        }

        for (j = num.length; j > 0; j--) {
            num2 += num.substring(j, j - 1);
        }
        num2 = num2.replace(":", ",");

        if (num2.indexOf(",") != -1) {
            diferenca = num2.length - (num2.indexOf(",") + 1);
            if (diferenca > 2) {
                num2 = num2.substring(0, num2.indexOf(",") + 3);
            }
        }

        if (tipo == "P") {
            num2 = sinal + num2 + "%";
        } else if (tipo == "R") {
            num2 = "R$ " + sinal + num2;
        } else {
            num2 = sinal + num2;
        }
        return num2;
    } else {
        if (tipo == "P") {
            num2 = "0,00%";
        } else if (tipo == "R") {
            num2 = "R$0,00";
        } else {
            num2 = "0,00";
        }
        return num2;
    }
}

function Formata2(valor) {
    if (valor != "" && valor != null) {
        if (valor.indexOf(",") != -1) {
            valor = replace2(valor, ".", "");
            valor = replace2(valor, ",", ".");
        }
        return valor;
    } else {
        return "";
    }
}

function criaAJAX() {
    var xmlhttp = false;
    try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
        try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch (E) { xmlhttp = false; }
    }
    if (!xmlhttp) xmlhttp = new XMLHttpRequest();
    return xmlhttp;
}

function XMLParser() {
    var xmlDoc, ie;
    
    this.create = function() {
        var pser = null;
        if (window.ActiveXObject) {
            pser = new ActiveXObject("Microsoft.XMLDOM");
            pser.async = false;
            this.ie = true;
        } else if (document.implementation && document.implementation.createDocument) {
            pser = document.implementation.createDocument("", "", null);
            this.ie = false;
        }
        return pser;
    }
    
    this.load = function(file) {
        this.xmlDoc.load(file);
        if (this.ie)
            this.callback();
        else
            this.xmlDoc.onload = this.callback;
    }
    
    this.xmlDoc = this.create();
    
    this.callback = function() {
        alert("Funçao de callback não definida");
    };
}

function basicAJAX(page, data) {
    var i, retorno, data_qtt = 0;
    if (data != undefined && data.length > 0) {
        data_qtt++;
        for (i = 0; i < data.length; i++) if (data.substr(i, 1) == '&') data_qtt++;
    }
    ajax.open("POST", page, true);
    ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    ajax.setRequestHeader("Content-length", data_qtt);
    ajax.onreadystatechange = function() { if (ajax.readyState == 4) return (ajax.responseText); }
    ajax.send(data);
}

function xOpacity(e, o) {
  var set = xDef(o);
  //  if (set && o == 1) o = .9999; // FF1.0.2 but not needed in 1.5
  if(!(e=xGetElementById(e))) return 2; // error
  if (xStr(e.style.opacity)) { // CSS3
    if (set) e.style.opacity = o + '';
    else o = parseFloat(e.style.opacity);
  }
  else if (xStr(e.style.filter)) { // IE5.5+
    if (set) e.style.filter = 'alpha(opacity=' + (100 * o) + ')';
    else if (e.filters && e.filters.alpha) { o = e.filters.alpha.opacity / 100; }
  }
  else if (xStr(e.style.MozOpacity)) { // Gecko before CSS3 support
    if (set) e.style.MozOpacity = o + '';
    else o = parseFloat(e.style.MozOpacity);
  }
  else if (xStr(e.style.KhtmlOpacity)) { // Konquerer and Safari
    if (set) e.style.KhtmlOpacity = o + '';
    else o = parseFloat(e.style.KhtmlOpacity);
  }
  return isNaN(o) ? 1 : o; // if NaN, should this return an error instead of 1?
}

function xDocSize(xdoc) {
  var b=xdoc.document.body, e=xdoc.document.documentElement;
  var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
  if (e) {
    esw = e.scrollWidth;
    eow = e.offsetWidth;
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsw = b.scrollWidth;
    bow = b.offsetWidth;
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
//  alert('compatMode: ' + document.compatMode + '\n\ndocumentElement.scrollHeight: ' + esh + '\ndocumentElement.offsetHeight: ' + eoh + '\nbody.scrollHeight: ' + bsh + '\nbody.offsetHeight: ' + boh + '\n\ndocumentElement.scrollWidth: ' + esw + '\ndocumentElement.offsetWidth: ' + eow + '\nbody.scrollWidth: ' + bsw + '\nbody.offsetWidth: ' + bow);
  return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh)};
}

function xStr(s) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

function xNum() {
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xCamelize(cssPropStr) {
  var i, c, a, s;
  a = cssPropStr.split('-');
  s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}

function xGetComputedStyle(e, p, i) {
  if(!(e=xGetElementById(e))) return null;
  var s, v = 'undefined', dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(e,'');
    if (s) v = s.getPropertyValue(p);
  }
  else if(e.currentStyle) {
    v = e.currentStyle[xCamelize(p)];
  }
  else return null;
  return i ? (parseInt(v) || 0) : v;
}

function xLeft(e, iX) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xStr(e.style.left)) {
    if(xNum(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=xGetComputedStyle(e,'left',1);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(xNum(iX)) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  return iX;
}

function xAniWH(e, w, h, t) {
  if (!(e=xGetElementById(e))) return;
  var w0 = xWidth(e), h0 = xHeight(e); // start positions
  var dw = w - w0, dh = h - h0; // displacements
  var fq = 1 / t; // frequench
  var t0 = new Date().getTime(); // start time
  var tmr = setInterval(
    function() {
      var wi = w, hi = h;
      var et = new Date().getTime() - t0; // elapsed time
      if (et < t) {
        var f = et * fq; // constant velocity
        wi = f * dw + w0; // instantaneous positions
        hi = f * dh + h0;
      }
      else { clearInterval(tmr); }
      e.style.width = Math.round(wi) + 'px';
      e.style.height = Math.round(hi) + 'px';
    }, 20 // timer resolution
  );
}

function xWidth(e,w) {
  var css, pl=0, pr=0, bl=0, br=0, gcs;
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(w)) {
    if (w<0) w = 0;
    else w=Math.round(w);
  }
  else w=-1;
  css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = xClientWidth();
  }
  else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(w>=0) {
      if (document.compatMode=='CSS1Compat') {
        gcs = xGetComputedStyle;
        pl=gcs(e,'padding-left',1);
        if (pl !== null) {
          pr=gcs(e,'padding-right',1);
          bl=gcs(e,'border-left-width',1);
          br=gcs(e,'border-right-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetWidth,e.style.width)){
          e.style.width=w+'px';
          pl=e.offsetWidth-w;
        }
      }
      w-=(pl+pr+bl+br);
      if(isNaN(w)||w<0) return;
      else e.style.width=w+'px';
    }
    w=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(w>=0) e.style.pixelWidth=w;
    w=e.style.pixelWidth;
  }
  return w;
}

function xHeight(e,h) {
  var css, pt=0, pb=0, bt=0, bb=0, gcs;
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(h>=0) {
      if (document.compatMode=='CSS1Compat') {
        gcs = xGetComputedStyle;
        pt=gcs(e,'padding-top',1);
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

function animate4(sEleId, iTargetX, uTotalTime) {
	//memorias = iTargetX;
  var ele = xGetElementById(sEleId);
  var startX = xLeft(ele);
  var disp = iTargetX - startX; // total displacement
  var freq = Math.PI / (2 * uTotalTime); // frequency
  var startTime = new Date().getTime();
  var tmr = setInterval(
    function() {
      var elapsedTime = new Date().getTime() - startTime;
      if (elapsedTime < uTotalTime) {
        var f = Math.abs(Math.sin(elapsedTime * freq));
        xLeft(ele, Math.round(f * disp + startX));
      }
      else {
        clearInterval(tmr);
        xLeft(ele, iTargetX);
      }
    }, 10
  );
}

xAnimation.prototype.scroll = function(e,x,y,t,a,b,oe) {
  var i = this;
  i.init(e);
  i.win = i.e.nodeType==1 ? false:true;
  i.x1 = xScrollLeft(i.e, i.win); i.y1 = xScrollTop(i.e, i.win); // start position
  i.x2 = Math.round(x); i.y2 = Math.round(y); // target position
  i.init(e,t,h,h,oe,a,b);
  i.run();
  function h(i) { // onRun and onTarget
    var x = Math.round(i.x), y = Math.round(i.y);
    if (i.win) i.e.scrollTo(x, y);
    else { i.e.scrollLeft = x; i.e.scrollTop = y; }
  }
};

function xAnimation(r)
{
  this.res = r || 10;
}
xAnimation.prototype.init = function(e,t,or,ot,oe,a,b) {
  var i = this;
  i.e = xGetElementById(e);
  i.t = t;
  i.or = or; // onRun
  i.ot = ot; // onTarget
  i.oe = oe; // onEnd
  i.a = a || 0; // acceleration type
  i.v = xAnimation.vf[i.a];
  i.qc = 1 + (b || 0); // quarter-cycles
  i.fq = 1 / i.t; // frequency
//  if (i.a) {              // r4
  if (i.a > 0 && i.a < 4) { // r4
    i.fq *= i.qc * Math.PI;
    if (i.a == 1 || i.a == 2) { i.fq /= 2; }
  }
//  else { i.qc = 1; } // r4
  // displacements
  i.xd = i.x2 - i.x1;
  i.yd = i.y2 - i.y1;
  i.zd = i.z2 - i.z1;
};
xAnimation.prototype.run = function(r) {
  var i = this;
  if (!r) { i.t1 = new Date().getTime(); }
  if (!i.tmr) i.tmr = setInterval(
    function() {
      i.et = new Date().getTime() - i.t1;
      if (i.et < i.t) {
        i.f = i.v(i.et * i.fq);
        i.x = i.xd * i.f + i.x1;
        i.y = i.yd * i.f + i.y1;
        i.z = i.zd * i.f + i.z1;
        i.or(i);
      }
      else { // target time reached
        clearInterval(i.tmr);
        i.tmr = null;
        if (i.qc % 2) {
          i.x = i.x2;
          i.y = i.y2;
          i.z = i.z2;
        }
        else {
          i.x = i.x1;
          i.y = i.y1;
          i.z = i.z1;
        }
        i.ot(i);
        var rep = false;
        if (typeof i.oe == 'function') { rep = i.oe(i); }
        else if (typeof i.oe == 'string') { rep = eval(i.oe); }
        if (rep) { i.resume(1); }
      }
    }, i.res
  );
};
xAnimation.vf = [
  function(r){return r;},
  function(r){return Math.abs(Math.sin(r));},
  function(r){return 1-Math.abs(Math.cos(r));},
  function(r){return (1-Math.cos(r))/2;},
  function(r) {return (1.0 - Math.exp(-r * 6));} // r4
];
xAnimation.prototype.pause = function() {
  clearInterval(this.tmr);
  this.tmr = null;
};
xAnimation.prototype.resume = function(fs) {
  if (typeof this.tmr != 'undefined' && !this.tmr) {
    this.t1 = new Date().getTime();
    if (!fs) {this.t1 -= this.et;}
    this.run(!fs);
  }
};
xAnimation.prototype.opacity = function(e,o,t,a,b,oe) {
  var i = this;
  i.x1 = xOpacity(e); i.x2 = o; // start and target opacity
  i.init(e,t,h,h,oe,a,b);
  i.run();
  function h(i) {xOpacity(i.e, i.x);} // onRun and onTarget
};

function xAnimateCss(sEleId, sCssProp, iTarget, uTotalTime) {
  units = 'px'; // only supports integer pixel values for now
  var ele = xGetElementById(sEleId);
  var startValue = parseInt(xGetComputedStyle(ele, sCssProp)) || 0;
  var disp = iTarget - startValue; // total displacement
  var freq = Math.PI / (2 * uTotalTime); // frequency
  var startTime = new Date().getTime();
  var tmr = setInterval(
    function() {
      var elapsedTime = new Date().getTime() - startTime;
      if (elapsedTime < uTotalTime) {
        var f = Math.abs(Math.sin(elapsedTime * freq));
        ele.style[xCamelize(sCssProp)] = Math.round(f * disp + startValue) + units;
      }
      else {
        clearInterval(tmr);
        ele.style[xCamelize(sCssProp)] = iTarget + units;
      }
    }, 10
  );
}
 
function xCamelize(cssPropStr) {
  var i, c, a, s;
  a = cssPropStr.split('-');
  s = a[0];
  for (i=1; i<a.length; ++i) {
    c = a[i].charAt(0);
    s += a[i].replace(c, c.toUpperCase());
  }
  return s;
}
 
function xGetComputedStyle(e, p, i) {
  if(!(e=xGetElementById(e))) return null;
  var s, v = 'undefined', dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(e,'');
    if (s) v = s.getPropertyValue(p);
  }
  else if(e.currentStyle) {
    v = e.currentStyle[xCamelize(p)];
  }
  else return null;
  return i ? (parseInt(v) || 0) : v;
}

function xScrollLeft(e, bWin) {
  var w, offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}

function xScrollTop(e, bWin) {
  var w, offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}

function xClientHeight() {
  var v=0,d=document,w=window;
  if((!d.compatMode || d.compatMode == 'CSS1Compat') /* && !w.opera */ && d.documentElement && d.documentElement.clientHeight)
    {v=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
    {v=d.body.clientHeight;}
  else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
    v=w.innerHeight;
    if(d.width>w.innerWidth) v-=16;
  }
  return v;
}

var xWinScrollWin = null;
function xWinScrollTo(win,x,y,uTime) {
  var e = win;
  if (!e.timeout) e.timeout = 15;
  var st = xScrollTop(e, 1);
  var sl = xScrollLeft(e, 1);
  e.xTarget = x; 
  e.yTarget = y; e.slideTime = uTime; e.stop = false;
  e.yA = e.yTarget - st;
  e.xA = e.xTarget - sl; // A = distance
  e.B = Math.PI / (2 * e.slideTime); // B = period
  e.yD = st;
  e.xD = sl; // D = initial position
  var d = new Date(); e.C = d.getTime();
  if (!e.moving) {
    xWinScrollWin = e;
    _xWinScrollTo();
  }
}

function _xWinScrollTo() {
  var e = xWinScrollWin || window;
  var now, s, t, newY, newX;
  now = new Date();
  t = now.getTime() - e.C;
  if (e.stop) { e.moving = false; }
  else if (t < e.slideTime) {
    setTimeout("_xWinScrollTo()", e.timeout);
    s = Math.sin(e.B * t);
    newX = Math.round(e.xA * s + e.xD);
    newY = Math.round(e.yA * s + e.yD);
    e.scrollTo(newX, newY);
    e.moving = true;
  }  else {
    e.scrollTo(e.xTarget, e.yTarget);
    xWinScrollWin = null;
    e.moving = false;
  }  
}
