// JavaScript Document

try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}


atual=0
function carrega(n){
    //Exibe o texto carregando no div conteúdo
    var conteudo=document.getElementById("texto_onde_comprar")
    conteudo.innerHTML='carregando...'

    //Guarda a página escolhida na variável atual
    atual=n

    //Abre a url
    xmlhttp.open("GET", "representantes.php?estado="+n,true);

    //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {

        if (xmlhttp.readyState==4){

            //Lê o texto
            var texto=xmlhttp.responseText

            //Desfaz o urlencode
            texto=texto.replace(/\+/g," ")
            texto=unescape(texto)

            //Exibe o texto no div conteúdo
            var conteudo=document.getElementById("texto_onde_comprar")
            conteudo.innerHTML=texto

            //Obtém os links do menu
            var menu=document.getElementById("menu")
            var links=menu.getElementsByTagName("a")

            //Limpa as classes do menu
            for(var i=0;i<links.length;i++)
                links[i].className=""

            //Marca o selecionado
            links[atual-1].className="selected"
        }
    }
    xmlhttp.send(null)
}


function limpa_tf(obj, valor){
	if(obj.value==valor){
		obj.value = "";
	}
}

function reseta_tf(obj, valor){
	if(obj.value==""){
		obj.value = valor;
	}
}

function act_acesse(){
	if($("#box_acesse").css('display')=="none"){
		$("#box_acesse").slideDown("slow");
	} else {
		$("#box_acesse").slideUp("slow");
	}
}

function abre_produto(div){
	$("#"+div).slideToggle();
}