jQuery(document).ready(function($) {
					$(".clientes_historico")
						.click(
							   function() { 
								$(this).addClass("clientes_historico-ativo");
								$(".clientes_hist_sub").animate({width: "350px",opacity: .9, filter:"alpha(opacity=80)"}, 200 );}
								);
						$(".clientes_hist_sub")
							.click(
									function () { 
									$(".clientes_historico").removeClass("clientes_historico-ativo");
									$(this).animate({width: "350px",opacity: 0, filter:"alpha(opacity=0)"}, 200 ).hide('fast');}
								   );
					
					
					$("#c_1 #c-1")
					var onc1 = $("#c_1 #c-1").find("img").attr("src");
					$(this).find("#c_1 #c-1").css({'background' : 'url(' + onc1 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_1 #c-1 span").stop().fadeTo('slow', 0 );
				
					$("#c_2 #c-2")
					var onc2 = $("#c_2 #c-2").find("img").attr("src");
					$(this).find("#c_2 #c-2").css({'background' : 'url(' + onc2 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_2 #c-2 span").stop().fadeTo('slow', 0 );
					
					$("#c_3 #c-3")
					var onc3 = $("#c_3 #c-3").find("img").attr("src");
					$(this).find("#c_3 #c-3").css({'background' : 'url(' + onc3 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_3 #c-3 span").stop().fadeTo('slow', 0 );
					
					$("#c_4 #c-4")
					var onc4 = $("#c_4 #c-4").find("img").attr("src");
					$(this).find("#c_4 #c-4").css({'background' : 'url(' + onc4 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_4 #c-4 span").stop().fadeTo('slow', 0 );
					
					$("#c_5 #c-5")
					var onc5 = $("#c_5 #c-5").find("img").attr("src");
					$(this).find("#c_5 #c-5").css({'background' : 'url(' + onc5 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_5 #c-5 span").stop().fadeTo('slow', 0 );
					
					$("#c_6 #c-6")
					var onc6 = $("#c_6 #c-6").find("img").attr("src");
					$(this).find("#c_6 #c-6").css({'background' : 'url(' + onc6 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_6 #c-6 span").stop().fadeTo('slow', 0 );
					
					$("#c_7 #c-7")
					var onc7 = $("#c_7 #c-7").find("img").attr("src");
					$(this).find("#c_7 #c-7").css({'background' : 'url(' + onc7 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_7 #c-7 span").stop().fadeTo('slow', 0 );
					
					$("#c_8 #c-8")
					var onc8 = $("#c_8 #c-8").find("img").attr("src");
					$(this).find("#c_8 #c-8").css({'background' : 'url(' + onc8 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_8 #c-8 span").stop().fadeTo('slow', 0 );
					
					$("#c_9 #c-9")
					var onc9 = $("#c_9 #c-9").find("img").attr("src");
					$(this).find("#c_9 #c-9").css({'background' : 'url(' + onc9 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_9 #c-9 span").stop().fadeTo('slow', 0 );
					
					$("#c_10 #c-10")
					var onc10 = $("#c_10 #c-10").find("img").attr("src");
					$(this).find("#c_10 #c-10").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_10 #c-10 span").stop().fadeTo('slow', 0 );
					
					$("#c_11 #c-11")
					var onc10 = $("#c_11 #c-11").find("img").attr("src");
					$(this).find("#c_11 #c-11").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_11 #c-11 span").stop().fadeTo('slow', 0 );
					
					$("#c_12 #c-12")
					var onc10 = $("#c_12 #c-12").find("img").attr("src");
					$(this).find("#c_12 #c-12").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_12 #c-12 span").stop().fadeTo('slow', 0 );
					
					$("#c_13 #c-13")
					var onc10 = $("#c_13 #c-13").find("img").attr("src");
					$(this).find("#c_13 #c-13").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_13 #c-13 span").stop().fadeTo('slow', 0 );
					
					$("#c_14 #c-14")
					var onc10 = $("#c_14 #c-14").find("img").attr("src");
					$(this).find("#c_14 #c-14").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_14 #c-14 span").stop().fadeTo('slow', 0 );
					
					$("#c_15 #c-15")
					var onc10 = $("#c_15 #c-15").find("img").attr("src");
					$(this).find("#c_15 #c-15").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_15 #c-15 span").stop().fadeTo('slow', 0 );
					
					$("#c_16 #c-16")
					var onc10 = $("#c_16 #c-16").find("img").attr("src");
					$(this).find("#c_16 #c-16").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_16 #c-16 span").stop().fadeTo('slow', 0 );
					
					$("#c_17 #c-17")
					var onc10 = $("#c_17 #c-17").find("img").attr("src");
					$(this).find("#c_17 #c-17").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_17 #c-17 span").stop().fadeTo('slow', 0 );
					
					$("#c_18 #c-18")
					var onc10 = $("#c_18 #c-18").find("img").attr("src");
					$(this).find("#c_18 #c-18").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_18 #c-18 span").stop().fadeTo('slow', 0 );
					
					$("#c_19 #c-19")
					var onc10 = $("#c_19 #c-19").find("img").attr("src");
					$(this).find("#c_19 #c-19").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_19 #c-19 span").stop().fadeTo('slow', 0 );
					
					$("#c_20 #c-20")
					var onc10 = $("#c_20 #c-20").find("img").attr("src");
					$(this).find("#c_20 #c-20").css({'background' : 'url(' + onc10 + ') no-repeat center bottom','border' : '1px solid #999'});
					$(this).find("#c_20 #c-20 span").stop().fadeTo('slow', 0 );
					
					
					//mais clientes
					$("#mc_abrir")
					.click(function(){
						$(".maisClientes").stop().animate({top:"-15px"},200);
						$(this).stop().hide(200);
						$("#mc_fechar").stop().show(200);
						$(".clientes_marca ul.gallery").stop().animate({height:"148px"},200);
						$("#qd_clientesImagens").stop().animate({top:"67px"},200);
						$("#qd_clientes").stop().animate({top:"60px"},200);
						$("#trab_categorias").stop().animate({top:"67px"},200);
						$("#trab_imagens").stop().animate({top:"67px"},200);
						$("#clientes_nome").stop().animate({top:"5px"},200);
						$("#conteudo-fundo_c").stop().animate({height:"650px"},200);
						})
					$("#mc_fechar")
					.click(function(){
						$(".maisClientes").stop().animate({top:"-90px"},200);
						$("#mc_fechar").stop().hide();
						$("#mc_abrir").stop().show();
						$(".clientes_marca ul.gallery").stop().animate({height:"70px"},200);
						$("#qd_clientesImagens").stop().animate({top:"7px"},200);
						$("#qd_clientes").stop().animate({top:"0px"},200);
						$("#trab_categorias").stop().animate({top:"0px"},200);
						$("#trab_imagens").stop().animate({top:"0px"},200);
						$("#clientes_nome").stop().animate({top:"-55px"},200);
						$("#conteudo-fundo_c").stop().animate({height:"580px"},200);
						})
					$("")
					


					
					$("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});
					});
					
				$(".ic_vejamais").click(function() {
						$(".vejamais_cont").animate({"opacity": .93 }).show('fast');
						$(".ic_vejamaisfechar").show();
						$(this).hide("");
						$(".nav-controls").hide("fast");
					});
				
				$(".ic_vejamaisfechar").click(function() {
						$(".vejamais_cont").hide('fast');
						$(".ic_vejamais").show("");
						$(this).hide("");
						$(".nav-controls").show("fast");
					});
				
				$("ul.thumbs li, .nav-controls a").click(function() {
						$(".vejamais_cont").hide('fast');
						$(".ic_vejamaisfechar").hide("");
						$(".ic_vejamais").show("");
						$(".nav-controls").show("fast");
					});

				// We only want these styles applied when javascript is enabled
				$('div.navigation').css({'width' : '300px', 'float' : 'left'});
				$('div.content').css('display', 'block');

				// Initially set opacity on thumbs and add
				// additional styling for hover effect on thumbs
				var onMouseOutOpacity = 1;
				$('#thumbs ul.thumbs li').opacityrollover({
					mouseOutOpacity:   onMouseOutOpacity,
					mouseOverOpacity:  1.0,
					fadeSpeed:         'fast',
					exemptionSelector: '.selected'
				});

				// Enable toggling of the caption
				var captionOpacity = 1;
				$('#captionToggle a').click(function(e) {
					var link = $(this);
					
					var isOff = link.hasClass('off');
					var removeClass = isOff ? 'off' : 'on';
					var addClass = isOff ? 'on' : 'off';
					var linkText = isOff ? 'Ocultar legendas' : 'Mostrar legendas';
					captionOpacity = isOff ? 1 : 0.0;
					
					link.removeClass(removeClass).addClass(addClass).text(linkText).attr('title', '');
					$('#caption span.image-caption').fadeTo(1000, captionOpacity);
					
					e.preventDefault();
				});
				
				// Initialize Advanced Galleriffic Gallery
				var gallery = $('#thumbs').galleriffic({
					delay:                     2500,
					numThumbs:                 22,
					preloadAhead:              10,
					enableTopPager:            true,
					enableBottomPager:         true,
					maxPagesToShow:            7,
					imageContainerSel:         '#slideshow',
					controlsContainerSel:      '#controls',
					captionContainerSel:       '#caption',
					loadingContainerSel:       '#loading',
					renderSSControls:          true,
					renderNavControls:         true,
					playLinkText:              'Play Slideshow',
					pauseLinkText:             'Pause Slideshow',
					prevLinkText:              'anterior',
					nextLinkText:              'pr&oacute;ximo',
					nextPageLinkText:          '&raquo;',
					prevPageLinkText:          '&laquo;',
					enableHistory:             true,
					autoStart:                 false,
					syncTransitions:           true,
					defaultTransitionDuration: 900,
					onSlideChange:             function(prevIndex, nextIndex) {
						// 'this' refers to the gallery, which is an extension of $('#thumbs')
						this.find('ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
					},
					onTransitionOut:           function(slide, caption, isSync, callback) {
						slide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, callback);
						caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0);
					},
					onTransitionIn:            function(slide, caption, isSync) {
						var duration = this.getDefaultTransitionDuration(isSync);
						slide.fadeTo(duration, 1.0);
						
						// Position the caption at the bottom of the image and set its opacity
						//var slideImage = slide.find('span');
						//caption.width(slideImage.width())
							//.css({
								//'bottom' : Math.floor((slide.height() - slideImage.outerHeight()) / 2),
								//'left' : Math.floor((slide.width() - slideImage.width()) / 2) + slideImage.outerWidth() - slideImage.width()
							//})
					$('span.image-caption').fadeTo(duration, captionOpacity);
					},
					onPageTransitionOut:       function(callback) {
						this.fadeTo('fast', 0.0, callback);
					},
					onPageTransitionIn:        function() {
						this.fadeTo('fast', 1.0);
					},
					onImageAdded:              function(imageData, $li) {
						$li.opacityrollover({
							mouseOutOpacity:   onMouseOutOpacity,
							mouseOverOpacity:  1.0,
							fadeSpeed:         'fast',
							exemptionSelector: '.selected'
						});
					}
				});

				/**** Functions to support integration of galleriffic with the jquery.history plugin ****/

				// PageLoad function
				// This function is called when:
				// 1. after calling $.historyInit();
				// 2. after calling $.historyLoad();
				// 3. after pushing "Go Back" button of a browser
				function pageload(hash) {
					// alert("pageload: " + hash);
					// hash doesn't contain the first # character.
					if(hash) {
						$.galleriffic.gotoImage(hash);
					} else {
						gallery.gotoIndex(0);
					}
				}

				// Initialize history plugin.
				// The callback is called at once by present location.hash. 
				
				$.historyInit(pageload, "");
				$("a[rel='history']").live('click', function() {
					if (e.button != 0) return true;

					var hash = this.href;
					hash = hash.replace(/^.*#/, '');

					// moves to a new page. 
					// pageload is called at once. 
					// hash don't contain "#", "?"
					$.historyLoad(hash);

					return false;
				})
				.click(function(){
					// 
					var hash = this.href;
					hash = hash.replace(/^.*#/, '');
					// moves to a new page. 
					// pageload is called at once. 
					$j.history.load(hash);
					return false;
				});
});


////////////////////////////////////////////////////////////////////

