var $$ = $.fn;

$$.extend({
  SplitID : function()
  {
    return this.attr('id').split('-').pop();
  },

  Slideshow : {
    Ready : function()
    {
      $('div.tmpelement_servicos')
        .hover(
          function() {
            $(this).addClass('tmpSlideshowControlOn');
          },
          function() {
            $(this).removeClass('tmpSlideshowControlOn');
          },
		  function() {
            $$.Slideshow.Interrupted = true;

            $('div.tmpSlide').hide();
            $('div.tmpelement_servicos').removeClass('tmpelement_servicosActive');

            $('div#tmpSlide-' + $(this).SplitID()).show()
            $(this).addClass('tmpelement_servicosActive');
          }
		  
        )
		
        .hover(
			   function() {
				   $$.Slideshow.Interrupted = true;
				   $('div.tmpSlide').hide();
				   $('div.tmpelement_servicos').removeClass('tmpelement_servicosActive');
				   $('div#tmpSlide-' + $(this).SplitID()).show()
				   $(this).addClass('tmpelement_servicosActive');
				   
				   }
				   );

      this.Counter = 1;
      this.Interrupted = false;

      this.Transition();
    },

    Transition : function()
    {
      if (this.Interrupted) {
        return;
      }

      this.Last = this.Counter - 1;

      if (this.Last < 1) {
        this.Last = 5;
      }

      $('div#tmpSlide-' + this.Last).fadeOut(1000, function() {
          $('div#tmpSlideshowControl-' + $$.Slideshow.Last).removeClass('tmpelement_servicosActive');
          $('div#tmpSlideshowControl-' + $$.Slideshow.Counter).addClass('tmpelement_servicosActive');
          $('div#tmpSlide-' + $$.Slideshow.Counter).fadeIn(1000);

          $$.Slideshow.Counter++;

          if ($$.Slideshow.Counter > 5) {
            $$.Slideshow.Counter = 1;
          }
		  

          setTimeout('$$.Slideshow.Transition();', 1000);
        }
      );
    }
  }
});

$(document).ready(
  function() {
    $$.Slideshow.Ready();
  }
);



$(document).ready(function(){
   $(".clientes_historico")
	.click(
		   function() { 
			$(this).addClass("clientes_historico-ativo");
			$(".clientes_hist_sub").animate({width: "350px",opacity: .9, filter:"alpha(opacity=80)"}, 700 );}
			);
	$(".clientes_hist_sub")
		.click(
				function () { 
				$(".clientes_historico").removeClass("clientes_historico-ativo");
				$(this).animate({width: "350px",opacity: 0, filter:"alpha(opacity=0)"}, 700 ).hide('slow');}
			   );
	
	$("#carregando").hide();
	//
	$(".cliente1").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente1/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente2").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente2/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente3").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente3/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente4").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente4/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente5").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente5/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente6").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente6/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente7").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente7/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente8").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente8/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente9").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente9/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
	//
	$(".cliente10").click(function() {
		$("#carregando").ajaxStart(function(){
			$(this).show();
			$(".alvo").hide();
		});
		$("#carregando").ajaxStop(function(){
			$(this).hide();
			$(".alvo").show();
		});
		$.get("clientes/cliente10/categoria1.php",function(data) {
				$(".alvo").empty().html(data);
			});
		return false;
	});
});
$(document).ready(
	function() {
		$("#cliente_on")
		var on = $(this).find("img").attr("src");
		$(this).find("#cliente_on").css({'background' : 'url(' + on + ') no-repeat center bottom'});
		$(this).find("#cliente_on span").stop().fadeTo('slow', 0 );
		
		$("ul.gallery li")
		.click(function() {
			var on = $(this).find("img").attr("src");
			$("a.thumb").find("span").stop().fadeTo('slow', 1 ); 
			$(this).find("a.thumb").css({'background' : 'url(' + on + ') no-repeat center bottom'});
			$(this).find("span").stop().fadeTo('slow', 0 );});
		
		$("ul.gallery li")
		.hover(
			function() {
				$(this).stop().animate({top: "-3px"}, {duration:200});
				},
			function() {
				$(this).stop().animate({top: "0px"}, {duration:200});
				}
				);
	})



