function carregaSite(){
	setTimeout(function (){
        
		$('#from').jForms({listSize:5, imagePath:'img/'});
		$.swapImage(".swapImage");
		$('a.lightBox').lightBox();

		$("dd:not(:first)").hide();
		$("dt a").click(function(){
			$("dd:visible").slideUp("3000");
			$(this).parent().next().slideDown("4000");
			return false;
		});

		if(document.getElementById("troca_subestacoes")){
			$('#troca_subestacoes').cycle({
				fx:     'scrollHorz',
				prev:   '#prev',
				next:   '#next',
				nowrap:  1,
				timeout: 0
			});
		}

        //$(".linha_tempo ul, .linha_tempo div.representantes_exportacao").addClass(" none");

        $(".linha_tempo h3").mouseover(function(){
            $(this).find("img").css("border-bottom","2px solid #E87717");
        }).mouseout(function(){
            $(this).find("img").css("border-bottom","2px solid #FFF");
        });

        $(".linha_tempo h3").click(function(){
            $(this).next("ul, div.representantes_exportacao").slideToggle("slow")
            .siblings("ul:visible, div.representantes_exportacao:visible").slideUp("slow");
            $(this).toggleClass("corrente");
            $(this).siblings(".linha_tempo h3").removeClass("corrente");
            return false;
        });

		$('.itens_linha_do_tempo').hide();

	},1);
}

function carregaSiteHome(){
	setTimeout(function (){
		$.swapImage(".swapImage");
		$('a.lightBox').lightBox();
	},1);
}

var cont = 1;

function troca_topo(x) {
	
    var aux;
	var num_elementos = document.getElementById("num_elementos").value;
	
	if( x == "up" ) {
		
	    aux = cont + 1;
	    
		if( aux > num_elementos ) {
			aux  = 1;
			cont = 1;
		} else {
			cont++;
		}
		
	}
	
	if( x == "down" ) {
		
	    aux = cont - 1;
	    
		if( aux == 0 ) {
			aux = num_elementos;
			cont = num_elementos;
		} else {
			cont--;
		}
		
	}
	
	for( i = 1 ; i <= num_elementos; i++ ) {
		document.getElementById("produto"+i).style.display = "none";
		document.getElementById("legenda"+i).style.display = "none";
	}
	
	document.getElementById("produto"+aux).style.display = "block";
	document.getElementById("legenda"+aux).style.display = "block";
	
}

function mostraEstado(uf) {
    
    $.ajax({
        type: "POST",
        url: document.getElementById("url_mapa").value + "ajax_mapa/nacional/"+uf+"/0",
        success: function(msg) {
            $('.local_internacional').html(msg);
        }
    })
    
}

function ajaxAssunto(obj){

    dep = obj.value;
    carregando = document.getElementById("carregando").value;
    selecione = document.getElementById("selecione").value;

    if(dep != -1){

        document.getElementById("ajax_assunto").innerHTML = '<select class="select_option"><option value="-1">'+carregando+'</option></select>';

        $.ajax({
            type: "GET",
            url: document.getElementById("url_fale").value + "index.php/contato/ajaxAssunto/"+dep,
            success: function(msg) {
                document.getElementById("ajax_assunto").innerHTML = msg;
            }
        })
        
    } else {
        document.getElementById("ajax_assunto").innerHTML = '<select class="select_option"><option value="-1">'+selecione+'</option></select>';
    }

}

window.onload = function() {
    dropdown();
}