	// funcao de pre-carregamento das imagens
	(function($) {	
		//We define a cache array to store our preloaded images	
		var cache = [];	
		//Our anonymous function will be called preLoadImages
		$.preLoadImages = function() {		
			//We assign the number of images to preload	to the imageCount variable	
			var imageCount = arguments.length;    	
			//And loop through each image
			for (var i = imageCount; i--;) {    		
				//For each image we create a DOM element
				var cacheImage = document.createElement('img');      		
				//Assign the image path
				cacheImage.src = arguments[i];      		
				//And add it to the cache array
				cache.push(cacheImage);    
			}    
		}  	
	})(jQuery)
	
	function mycarousel_initCallback(carousel){
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});			
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
		
		/*
		$('#menu_cardapio_page a').bind('click', function(){					
			var itemCarousel = $(this).attr('href');
			//
			itemCarousel = Number(itemCarousel.charAt(itemCarousel.length-1))

			//var valor = jQuery.jcarousel.intval(jQuery(this).text());
			carousel.scroll(itemCarousel);					
			return false;
		});
		*/
	};
	
	$(document).ready(function() {
		$.preLoadImages(
			"img/menu.png",
			"menu_sub_cardapio.png"
		);
					
		$album = $('#album');
		$album.jcarousel({
			wrap: 'circular',
			scroll: 1
		});
		$album.find('a').fancybox({
			'opacity'			: true,
			'titlePosition'		: 'outside',
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'none',
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.9
		});
		$('.li_delivery a, #carousel_cardapio a').fancybox({
			'opacity'			: true,
			'titlePosition'		: 'outside',
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'none',
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.9
		});
		$('#mapa').fancybox({
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'			: false,
			'titlePosition'		: 'outside',
			'transitionIn'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.9
		});
		
		$('#carousel').jcarousel({
			wrap: 'circular',
			scroll: 1,
			auto: 20,
			initCallback: mycarousel_initCallback
		});
		
		/*
		$('.menu_cardapio').find('li').hover(
			function(){
				$(this).children('.sub-item').fadeIn(200);
			},
			function(){
				$(this).children('.sub-item').hide();
			}
		);
		*/
		
	});
