
/*
* jQuery Timer Plugin
* http://www.evanbot.com/article/jquery-timer-plugin/23
*
* @version      1.0
* @copyright    2009 Evan Byrne (http://www.evanbot.com)
*/ 

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

$(document).ready(function(){
	 var myTimer = {};
	var count = 0;

	for(i=1; i!=100; i++){
		myTimer = $.timer(15000*(i+count),function(){
				$('.especial p').hide();
				count++;
				if(count==4){
					count=0;
				}
				
				$('.especial li').css('background-color', '#F0F0F0');
				$('.especial li a').css('color', '#000099');
				
				if(count==3){
					$('.especial li.esp'+count).css('background-color', '#000000');
					$('.especial li.esp'+count+' a').css('color', '#FFF');
				}
				
				$('.especial p.esp'+count).show();
			});
	}
});
/*************************************************************/
/* 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($('#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;
 	});
});