function centraliza(largura,altura){
	window.moveTo((window.screen.width-largura)/2,(window.screen.height-altura)/2);
}
function abreJanela(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){
	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" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<embed menu="false" src="swf/'+ arquivo +'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}

function atualizar(n,i) {
    doRequest('server.aspx?query=atualizar&idcarrinho=' + i + '&quantidade=' + n,resposta);
}

function remover(i) {
    doRequest('server.aspx?query=remover&idcarrinho=' + i,resposta);
}

function resposta(f) {
    window.location.href='carrinho.aspx';
}

var ie =(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns =(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);
function ajustar_cep(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if ((tecla == 8)||(tecla == 46)||(tecla == 39)||(tecla == 37)||(tecla == 36)||(tecla == 35)||(tecla == 9)) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    return true;
}

function ajustar_cpf(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 3 || input.value.length == 7) {
            input.value += ".";
        }
        if (input.value.length == 11) {
            input.value += "-";
        }
    }
}

function ajustar_telefone(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 4) {
            input.value += "-";
        }
    }
}

function autodromo(c) {
    if (c) {
        document.forms[0].txtAutodromo.disabled = "";
        document.forms[0].txtAutodromo.focus();
    }
    else {
        document.forms[0].txtAutodromo.disabled = "disabled";
        document.forms[0].txtAutodromo.value = "";
    }
}

function fecharPedido() {
    if (document.forms[0].txtAutodromo.disabled == "" && document.forms[0].txtAutodromo.value == "") {
        alert(unescape('Digite o nome do Aut%F3dromo onde deseja receber o pedido.'));
        return false;
    }
}

function autotab(original,destination) {
    if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
        destination.focus();
}