//barras com setas laterais
function animarLista(el) {
	$(el).find('.lista').each(function(){
		$(this).find('ul').html($(this).find('li').sort(function() {return 0.5 - Math.random()}));
	});
	$(el).find('.esq').click(function(){
		$(el).find('li:last').prependTo($(el).find('ul'));
		return false;
	});
	$(el).find('.dir').click(function(){
		$(el).find('li:first').appendTo($(el).find('ul'));
		return false;
	});
}
$(function(){
	animarLista($('#guias, #marcas'));
})

/*marcas*/
var marcasL, tdWidth, windowSize, i, tbl, tableWidth, leftLimit, right;
function initMarcas() {
	marcasL    = 0; // "position left" inicial
	tdWidth    = 130; //largura de cada TD: 88 pixels da logo + 36 pixels de padding;
	windowSize = 630; //124 x 5 (visualização a cada clique)
	i = 1;			 //iterarador do numero de cliques para a esquerda
	tbl		   = document.getElementById("marcas");
	tableWidth = document.getElementsByTagName("td").length * tdWidth;	
	leftLimit  = tableWidth - windowSize;	
	right = false;
}
function moveLeft(r) {						
	if(r!=null) right = false;
	if(marcasL > -leftLimit && !right) {
		var tblL = marcasL - 20;		
		tbl.style.left = tblL + "px";
		if(tblL > -leftLimit) marcasL = marcasL - 20;	
		if( marcasL > -(i*windowSize) ) window.setTimeout("moveLeft()",10);	
			else {i++;}						
	}	
}
function movR(n) {	
	var n1 = Number(n);
	if(n1 < 0 && right) {	
		var tblR = n1 + 20;
		tbl.style.left = tblR + "px";
		if(tblR < 0) n1 += 20;
		window.setTimeout("movR(" + n1 + ")",10);
	}
}
function moveRight() {
	right = true;
	i = 1;
	marcasL = 0;			
	var mRight = tbl.style.left.substring(0, tbl.style.left.indexOf("p"));	
	movR(mRight);		
}
/* Lateral de Categorias-Home Abas*/
function menu_prod(){
	var mp = document.getElementById("categorias");
	var ms = document.getElementById("servicos");
	if(mp.style.display == "none"){
	mp.style.display = "block";
	ms.style.display = "none";
}
	else{
		mp.style.display = "none";
		ms.style.display = "block";
	}
}
	 
$(function(){
	$('.especial li a').click(
		function(){
			$('.especial li').css('background-color', 'F0F0F0');
 			$('.especial li').find('a').css('color', '#000099');
 			$('.especial p').hide();
 			$('.especial p.' + $(this).parent().attr('class')).show();
 			if ($(this).parent().hasClass('esp0')){
 				$(this).parent().css('background-color', '#F0F0F0');
 				$(this).css('color', '#000099');
 			}else{
 				if ($(this).parent().hasClass('esp1')){
 					$(this).parent().css('background-color', '#F0F0F0');
 					$(this).css('color', '#000099');
 				}

 				if ($(this).parent().hasClass('esp3')){
 					$('.especial li.esp0').find('a').css('color', '#000099');
 					$('.especial li.esp2').find('a').css('color', '#000099');
 				}
 			}
 			return false;
 	})
})
//Sub-Menu Seleção de País no Header
$(function(){
	$(".submenu-hover a").mouseover(function(){
		$(".submenu-hide").slideDown("fast");
		$(".submenu-hover").addClass("submenu-hoverb");
	});
	$("#submenu").mouseleave(function(){
		$(".submenu-hide").hide();
		$(".submenu-hover").removeClass("submenu-hoverb");
	})
});