$(document).ready(function(){
	
	// TARGET _blank
	$('a[rel=blank]').click(function(){
		window.open(this.href);
		return false;
	});
	
	// BUSCA E ACESSO RÁPIDO
	var buscaVal = $('#busca').val();
	$('#busca').focusin(function(){
		if ($(this).val() == buscaVal){
			$(this).val('');
		}
	}).focusout(function(){
		if ($(this).val() == ''){
			$(this).val(buscaVal);
		}
	});
	var acessoVal = $('#acesso').val();
	$('#acesso').focusin(function(){
		$(this).val('');
		$(this).next().slideDown(500);
	}).focusout(function(){
		setTimeout("$('#acesso').next().slideUp(250);",500);
		if ($(this).val() == ''){
			$(this).val(acessoVal);
		}
	}).css('cursor', 'pointer');
	$('#acesso').next().hide().find('li').click(function(){
		var linkHtml = $(this).find('a').attr('rel');
			//linkHtml = linkHtml.substr(2,linkHtml.length);
			document.location = linkHtml.toLowerCase();
	}).css('cursor', 'pointer');
	$('.acesso li a').each(function(){
		if ($(this).attr('class') != 'acesso-titulo'){
			$(this).html('&minus; '+$(this).html()).css('padding-left','10px');
		}
		else {
			$(this).html('&raquo; '+$(this).html()).css('margin-top','5px');
		}
	});

	// ANIMAÇÃO DO MENU
	$('#menu a').mouseover(function(){
		$(this).find('span.hover').stop().animate({'left':'0px'}, {duration:250});
	}).mouseout(function(){
		$(this).find('span.hover').stop().animate({'left':'-128px'}, {duration:500});
	});
	
	
	// SLIDER DE MARCAS
	var marcas = [
		"bematech",
		"brother",
		"canon",
		"citizen",
		"epson",
		"filizola",
		"fujitsu",
		"hp",
		"ibm",
		"itautec",
		"okidata",
		"olivetti",
		"ricoh",
		"rima",
		"samsung",
		"schalter",
		"sweda",
		"toledo",
		"urmet",
		"xerox",
		"yanco"
	];
	for (x=0; x<marcas.length; x++){
		$('#marcas #holder').append('<div class="marca" style="background-image:url(../img/marcas/'+marcas[x]+'.png)"><span></span></div>');
	}
	$('#marcas #holder').html($('#marcas #holder').html()+$('#marcas #holder').html());
	//$('#marcas #holder').width(($('.marca').width()+20)*marcas.length*2);
	$('#marcas #holder').width(123*marcas.length*2);
	var animateMarcas = function(){$('#marcas #holder').css('margin-left', 0);$('#marcas #holder').animate({'margin-left': '-'+$('#marcas #holder').width()/2}, 2500*marcas.length, 'linear');};
		animateMarcas = function(){$('#marcas #holder').css('margin-left', 0);$('#marcas #holder').animate({'margin-left': '-'+$('#marcas #holder').width()/2}, 2500*marcas.length, 'linear', animateMarcas);};
	$('#marcas #holder').animate({'margin-left': '-'+$('#marcas #holder').width()/2}, 2500*marcas.length, 'linear', animateMarcas);
	
	// SLIDER TELEFONES
	$("#telefones").easySlider({
		controlsBefore:	'<div id="controles">',
		controlsAfter:	'</div>',
		prevId: 'tel-voltar',
		nextId: 'tel-avancar',
		auto: true,
		speed: 1500,
		pause: 5000,
		continuous: true
	});	
	
}); //end document.ready
