	/** 

* Função do menu 

* @author Ana Galuppo Mendes <anagaluppo@gmail.com> 

* @modified Luiz Celso <celsodesign@gmail.com> 

**/



$(function() {

	$('#list-pics li a').lightBox({fixedNavigation:true});

	$('a.lightbox').lightBox({fixedNavigation:true});	

});



$(function(){

	$("#menu ul li.produtos").hover(

		

		function(){

			$(this).parent().find("ul#submenu").fadeIn();

			$("#menu ul li.produtos a").addClass("active");

			$("#menu ul li.produtos a span").addClass("active");	

		},

		function(){

			$(this).parent().find("ul#submenu").fadeOut();

		}

	);

	/**

	* Função quando o mouse tiver com o hover no sub menu

	* o item do menu selecionado fica ativado

	**/

	$("ul#submenu li a").hover(function() {

		$("#menu ul li.produtos a").addClass("active");

		$("#menu ul li.produtos a span").addClass("active");

	});

	/**

	* Quando eu passar o mouse nos links do menu menos no

	* link PRODUTOS

	**/

	$(".rest-menu").hover(function() {

		$("#menu ul li.produtos a").removeClass("active");

		$("#menu ul li.produtos a span").removeClass("active");	

	});

	/**

	* Quando ocorrer o mouseout no submenu ele remove a 

	* class active do Menu.

	**/

	$("ul#submenu li a").mouseout(function() {

		$("#menu ul li.produtos a").removeClass("active");

		$("#menu ul li.produtos a span").removeClass("active");

	});          		

		

  });



/** 

* Função do Carousel lateral 

* @author Luiz Celso <celsodesign@gmail.com> 

* @modified Nome <email> 

**/

(function () {

		$.fn.infiniteCarousel = function () {

			function repeat(str, n) {

				return new Array( n + 1 ).join(str);

			}

			

			return this.each(function () {

				// magic!

				var $wrapper = $('> div', this).css('overflow', 'hidden'),

					$slider = $wrapper.find('> ul').width(9999),

					$items = $slider.find('> li'),

					$single = $items.filter(':first')

					

					singleWidth = $single.outerWidth(),

					visible = Math.ceil($wrapper.innerWidth() / singleWidth),

					currentPage = 1,

					pages = Math.ceil($items.length / visible);

					

				/* TASKS */

				

				// 1. pad the pages with empty element if required

				if ($items.length % visible != 0) {

					// pad

					$slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));

					$items = $slider.find('> li');

				}

				

				// 2. create the carousel padding on left and right (cloned)

				$items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));

				$items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));

				$items = $slider.find('> li');

				

				// 3. reset scroll

				$wrapper.scrollLeft(singleWidth * visible);

				

				// 4. paging function

				function gotoPage(page) {

					var dir = page < currentPage ? -1 : 1,

						n = Math.abs(currentPage - page),

						left = singleWidth * dir * visible * n;

					

					$wrapper.filter(':not(:animated)').animate({

						scrollLeft : '+=' + left

					}, 2000, function () {

						// if page == last page - then reset position

						if (page > pages) {

							$wrapper.scrollLeft(singleWidth * visible);

							page = 1;

						} else if (page == 0) {

							page = pages;

							$wrapper.scrollLeft(singleWidth * visible * pages);

						}

						

						currentPage = page;

					});

				}

				

				// 5. insert the back and forward link

				$wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');

				

				// 6. bind the back and forward links

				$('a.back', this).click(function () {

					gotoPage(currentPage - 1);

					return false;

				});

				

				$('a.forward', this).click(function () {

					gotoPage(currentPage + 1);

					return false;

				});

				

				$(this).bind('goto', function (event, page) {

					gotoPage(page);

				});

				

				// THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL

				$(this).bind('next', function () {

					gotoPage(currentPage + 1);

				});

			});		

		};

})(jQuery);



/** 

* inicializa as funções abaixo

* @author Luiz Celso <celsodesign@gmail.com> 

* @modified Nome <email> 

**/

$(document).ready(function () {



		/* Função da pagina Novidades

		*

		* Ao clicar no link o mesmo percorre procurando

		* todos os links (a) com a class (active) e 

		* remove a classe de onde estiver e add

		* no link no qual foi clicado

		*************************************************/

		$('#menu-accordion dl dt a').click(function(){

			$('#menu-accordion dl').find('a.active').removeClass('active');	

			$(this).addClass('active');

		});



		//Definimos que todos as tags dd terão display:none menos o primeiro filho

		$('dd:not(:first)').hide();

		//Ao clicar no link, executamos a funcao

		$('dt a').click(function(){

			//As tags dd's visíveis agora ficam com display:none

			$("dd:visible").slideUp("slow");

			//Apos, a funcao é transferida para seu pai, que procura o proximo irmao no codigo o tonando visível

			$(this).parent().next().slideDown("slow");

			

			return false;

		});





	/** 

	* inicializa a funçõão do Carousel lateral

	**/

	var autoscrolling = true;

	

	$('.infiniteCarousel').infiniteCarousel().mouseover(function () {

		autoscrolling = false;

	}).mouseout(function () {

		autoscrolling = true;

	});

	

	setInterval(function () {

		if (autoscrolling) {

			$('.infiniteCarousel').trigger('next');

		}

	}, 5000);





	/**

	* Abrir todos os links em outra pagina quando o rel 

	* estiver como externo

	**/

		$('a[rel=externo]').attr('target', '_blank');	



	/**

	* Função para limpar os inputs que estiver com algum valor em seu 

	* value basta adicionar a class INPUT-VALUE

	**/

	swapValue = [];

	$("input.clean-value").each(function(i){

	   swapValue[i] = $(this).val();

	   $(this).focus(function(){

		  if ($(this).val() == swapValue[i]) {

			 $(this).val("");

		  }

	   }).blur(function(){

		  if ($.trim($(this).val()) == "") {

			 $(this).val(swapValue[i]);

		  }

	   });

	});



	

});





/** 

* Função do Banner na Home 

* @author Luiz Celso <celsodesign@gmail.com> 

* @modified Nome <email> 

**/

$(window).load(function() {

	$('#slider').nivoSlider({

        effect:'sliceUpDown', //Specify sets like: 'fold,fade,sliceDown'

        slices:15,

        animSpeed:1000, /* Aqui muda a velocidade do slider lateral */

        pauseTime:5000,

		startSlide:0, //Set starting Slide (0 index)

		directionNav:false, //Next & Prev

		directionNavHide:false, //Only show on hover

		controlNav:false, //1,2,3...

		controlNavThumbs:false, //Use thumbnails for Control Nav

		controlNavThumbsFromRel:false, //Use image rel for thumbs

		controlNavThumbsSearch: '.jpg', //Replace this with...

		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src

		keyboardNav:true, //Use left & right arrows

		pauseOnHover:true, //Stop animation while hovering

		manualAdvance:false, //Force manual transitions

		captionOpacity:0.8, //Universal caption opacity

		beforeChange: function(){},

		afterChange: function(){},

		slideshowEnd: function(){} //Triggers after all slides have been shown

	});

});



jQuery(document).ready(function($) {

				// We only want these styles applied when javascript is enabled

				$('div.navigation').css({'width' : '115px', 'float' : 'right'});

				$('div.content').css('display', 'block');



				// Initially set opacity on thumbs and add

				// additional styling for hover effect on thumbs

				var onMouseOutOpacity = 0.67;

				$('#thumbs ul.thumbs li').opacityrollover({

					mouseOutOpacity:   onMouseOutOpacity,

					mouseOverOpacity:  1.0,

					fadeSpeed:         'fast',

					exemptionSelector: '.selected'

				});

				

				// Initialize Advanced Galleriffic Gallery

				var gallery = $('#thumbs').galleriffic({

					delay:                     2500,

					numThumbs:                 5,

					preloadAhead:              10,

					enableTopPager:            true,

					enableBottomPager:         true,

					maxPagesToShow:            4,

					imageContainerSel:         '#slideshow',

					controlsContainerSel:      '#controls',

					captionContainerSel:       '#caption',

					loadingContainerSel:       '#loading',

					renderSSControls:          true,

					renderNavControls:         true,

					playLinkText:              '<span class="icon-play"></span><span class="txtalign-pause">Play Slideshow</span>',

					pauseLinkText:             '<span class="icon-pause"></span><span class="txtalign-pause">Pause Slideshow<span>',

					prevLinkText:              '<span>&lsaquo;</span> Anterior', /*   &lsaquo; Anterior  '&lsaquo; Anterior   */

					nextLinkText:              'Próxima <span>&rsaquo;</span>',

					nextPageLinkText:          '',

					prevPageLinkText:          '',

					enableHistory:             false,

					autoStart:                 true,

					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);

					},

					onPageTransitionOut:       function(callback) {

						this.fadeTo('fast', 0.0, callback);

					},

					onPageTransitionIn:        function() {

						this.fadeTo('fast', 1.0);

					}

				});



				/**** 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, "advanced.html");



				// set onlick event for buttons using the jQuery 1.3 live method

				$("a[rel='history']").live('click', function(e) {

					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;

				});



				/****************************************************************************************/

			});


