function centraliza(largura,altura){
	window.moveTo((window.screen.width-largura)/2,(window.screen.height-altura)/2);
}

function abreJanelax(arquivo,nome,barra,largura,altura) {
	window.open(arquivo,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+barra+",width="+largura+",height="+altura);
}

function redimenciona(){
	var i=0;
	function resize() {
		if (navigator.appName == 'Netscape') i=40;
		if (document.images[0]) window.resizeTo(document.images[0].width +50, document.images[0].height+80-i);
		if (window.moveTo((window.screen.width-document.images[0].width)/2,(window.screen.height-document.images[0].height)/2));
	}
}

function montaSWF(arquivo,largura,altura,action){
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="swf/'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="FlashVars" value="'+ action +'&clearCache='+ data +'" />');
	document.write('<embed FlashVars="'+ action +'&clearCache='+ data +'" wmode="transparent" menu="false" src="swf/'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}

function login(radio) {
    var valor = radio.value;
    if (valor == "1") {
        document.getElementById("divLogin").style.display = '';
        document.forms[0].txtEmail.focus();
    }
    else {
        document.getElementById("divLogin").style.display = 'none';
    }
}

function cepCadastro(i) {
    if (parseInt(i) == 1)
        document.getElementById("trCep").style.display = '';
    else
        document.getElementById("trCep").style.display = 'none';
}

function autotab(original, destination) {
    if (original.getAttribute && original.value.length == original.getAttribute("maxlength"))
        destination.focus();
}

function cepi(cep) {
    if (cep.value) {
        document.getElementById("labCep").innerHTML = unescape("aguarde, carregando endere%E7o.");
        doRequest('cep.asp?cep=' + cep.value, resposta1);
    }
}

function resposta1(f) {
    var n = eval('(' + f + ')');
    document.forms[0].ctl00$ContentPlaceHolder2$txtEndereco.value = unescape(n.foo[0].endereco);
    document.forms[0].ctl00$ContentPlaceHolder2$txtNumero.value = '';
    document.forms[0].ctl00$ContentPlaceHolder2$txtCompl.value = '';
    document.forms[0].ctl00$ContentPlaceHolder2$txtBairro.value = n.foo[0].bairro;
    document.forms[0].ctl00$ContentPlaceHolder2$txtCidade.value = n.foo[0].cidade;
    document.forms[0].ctl00$ContentPlaceHolder2$txtUF.value = n.foo[0].estado;
    document.getElementById("labCep").innerHTML = "";
    document.forms[0].ctl00$ContentPlaceHolder2$txtNumero.focus();
}

function cepi1(cep) {
    if (cep.value) {
        document.getElementById("labCep").innerHTML = unescape("aguarde, carregando endere%E7o.");
        doRequest('cep.asp?cep=' + cep.value, resposta11);
    }
}

function resposta11(f) {
    var n = eval('(' + f + ')');
    document.forms[0].ctl00$ContentPlaceHolder2$txtEndereco.value = unescape(n.foo[0].endereco);
    document.forms[0].ctl00$ContentPlaceHolder2$txtNumero.value = '';
    document.forms[0].ctl00$ContentPlaceHolder2$txtCompl.value = '';
    document.forms[0].ctl00$ContentPlaceHolder2$txtBairro.value = n.foo[0].bairro;
    document.forms[0].ctl00$ContentPlaceHolder2$txtCidade.value = n.foo[0].cidade;
    document.forms[0].ctl00$ContentPlaceHolder2$txtUF.value = n.foo[0].estado;
    document.getElementById("labCep").innerHTML = "";
    document.forms[0].ctl00$ContentPlaceHolder2$txtNumero.focus();

    if (parseFloat(n.foo[0].cep.replace("-", "")) > 5999999 || n.foo[0].endereco == "Endere%E7o n%E3o localizado") {
        document.getElementById("labCep").innerHTML = "Localidade n&atilde;o atendida. Servi&ccedil;o dispon&iacute;vel por enquanto somente para a cidade de S&atilde;o Paulo";
        document.getElementById("ctl00_ContentPlaceHolder2_btnContinuar").style.display = 'none';
    }
    else {
        document.getElementById("ctl00_ContentPlaceHolder2_btnContinuar").style.display = '';
    }
}

function langu(i) {
    if (i == 1) {
        document.getElementById("trBra").style.display = '';
        document.getElementById("trUsa").style.display = 'none';
    }
    else {
        document.getElementById("trBra").style.display = 'none';
        document.getElementById("trUsa").style.display = '';
    }
}

function alerta(msg,url) {
    alert(msg);
    window.location.href = url;
}

function inout(img, imagem) {
    img.src = 'img/listas/' + imagem;
}