function mapa(estado){
	$("#lista").html("<p>Carregando...</p>");
	$.get("contato/lista.php", {estado: estado}, function(dados){
		$("#lista").html(dados);
		$('#lista .scroll').jScrollPane();
	});
}

function modoMiniatura(){
	MM_swapImage("imgMiniaturas", "", "imgs/produtos/lista/miniaturas.png", 1);
	MM_swapImage("imgModoLista", "", "imgs/produtos/lista/modo-lista-off.png", 1);
	
	$(".modoMiniaturas").show();
	$(".modoLista").hide();
	$(".modoMiniaturas .helvetica").textfill({maxFontPixels: 16, innerTag: "a"});
}

function modoLista(){
	MM_swapImage("imgModoLista", "", "imgs/produtos/lista/modo-lista.png", 1);
	MM_swapImage("imgMiniaturas", "", "imgs/produtos/lista/miniaturas-off.png", 1);
	
	$(".modoLista").show();
	$(".modoMiniaturas").hide();
	$(".modoLista .helvetica").textfill({maxFontPixels: 16, innerTag: "a"});
}

var pos = 0;

function anteiror(){
	pos--;
	var lista = $(".imgDestaque .fotos").hide();
	pos = ((pos < 0) ? (lista.length - 1) : pos);
	lista.eq(pos).fadeIn();
}

function proximo(){
	pos++;
	var lista = $(".imgDestaque .fotos").hide();
	pos = ((pos >= lista.length) ? 0 : pos);
	lista.eq(pos).fadeIn();
}

var mover = {
		
	o: null,
	
	holder: null,

	active: null,
	
	pageX: null,
	
	scale: false,
	
	init: function(){
		
		mover.o = $(".scroll");
		mover.holder = $(">table", mover.o);
		
		setInterval(mover.update, 1);
		
		mover.o.hover(function(){
			mover.active = true;
		}, function(){
			mover.active = false;
		}).mousemove(function(e){
			mover.pageX = e.pageX - this.offsetLeft;
		});
	},
	
	update: function(){
		if(mover.scale){
			mover.o.css("width", 994 + ($(".topo").offset().left - 4));
		}
		
		if(mover.holder.width() > mover.o.width()){
			$(".txtDeslize").show();
		}else{
			$(".txtDeslize").hide();
		}
		
		if(mover.active && mover.holder.width() > mover.o.width()){
			var speed = 120;
			var half = mover.o.width() / 2;
			var min = 0;
			var max = -(mover.holder.width() - mover.o.width());
			var x = parseInt(mover.holder.css("marginLeft").replace("px", ""));
			x = ((isNaN(x)) ? 0 : x);
			var diff = ((mover.pageX > half) ? (mover.pageX - half) / speed : (half - mover.pageX) / speed);
			if(mover.pageX < half) x += diff;
			if(mover.pageX > half) x -= diff;
			if(x > min) x = min;
			if(x < max) x = max;
			mover.holder.css({marginLeft:x});
		}
	}
}

function menu(){
	var holder = $(".listaProdutos");
	 $("li:last-child", holder).addClass('ultimoItem');
	
	holder.hover(function(){
		$(".bloco", this).css({height: '', marginTop: ''}).stop().slideDown(200,function(){$(this).css("height","")});
	},function(){
		$(".bloco", this).css({height: '', marginTop: ''}).stop().slideUp(200,function(){$(this).hide();});
	});

	$("li", holder).hover(function(){
		$(".normal", this).hide();
		$(".over", this).css('height','58px').stop().slideDown(200);
	},function(){
		$(".over", holder).css({marginTop:'0px', height:''}).hide();
		$(".normal", holder).show();
	});
}
