;(function($, window) {
	/** Settings **/
	
	var raiz = 'http://luxcel.tempsite.ws';
	
	// List of background images to use, the default image will be the first one in the list
	var backgrounds = [
	   '/img/backgrounds/bg-azul.jpg','/img/backgrounds/bg-vermelho.jpg','/img/backgrounds/bg-laranja.jpg'
	],
	
	
	// The speed of the fade transition between backgrounds in milliseconds (1000 = 1 second)
	//speed = 1250,
	speed = 0,
	
	// The speed of the fade transition to hide the website
	//fadeOutSpeed = 1000,
	fadeOutSpeed = 0,
	
	// The speed of the fade transition to show the website
	//fadeInSpeed = 1000,
	fadeInSpeed = 0,
	
	// Should the current background be saved across pages in a cookie?
	save = false,
	
	// Should the cache be used for faster image loading?
	preload = false,
	
	// Twitter username
	twitterUsername = 'sabrewebdesign',
		
	// Number tweets to show, set to 0 to disable
	tweetCount = 2;
	
	/** End settings **/
	
	Cufon.replace('h1, h2, h3, h4, h5');
	
	$('html').addClass('js-enabled');
		
	$(document).ready(function() {
		
		inicializaBg(backgrounds);
		
		/* ---------- CAROUSEL DA PÁGINA INICIAL ---------- */
		var theInt = null;
		var theInt2 = null;
		var curclicked = 0;
		var curclicked2 = 0;
		
		theInterval = function()
		{
			clearInterval(theInt);
			theInterval2();
			theInt = setInterval(function(){
						
						$(".stripNav ul li a").eq(curclicked).trigger('click');
						curclicked++;
						if( 4 == curclicked ) curclicked = 0;
						
					}, 3000);
		};
		
		theInterval2 = function()
		{
			clearInterval(theInt2);
			
			theInt2 = setInterval(function(){
						
						$(".stripNav ul li a").eq(curclicked2).trigger('click');
						curclicked2++;
						if( 16 == curclicked2 ) curclicked2 = 0;
						
					}, 3500);
		};
		
		
		$(function(){
			
			$("#nossasMarcas").codaSlider();
			$("#marcasLicenciadas").codaSlider();
			
			theInterval();
			
		});	
		
		
		
		// Initialise the full screen backgrounds
		
		
		// Initialise the menu
		$('ul.sf-menu').superfish({ speed: 0 });		
		
		// Bind the search button to show/hide the search field
		$('#search-button').click(function() {
			$('.search-container').fadeToggle();
			return false;
		});
				
		// Bind the social button to show/hide the social icons box
		$('#social-pop-out-trigger').click(function() {
			var $allBoxes = $('.footer-pop-out-box');
			if ($allBoxes.is(':animated')) {
				return false;
			}
					
			var $thisBox = $('.social-pop-out-box');
			if ($thisBox.is(':visible')) {
				$thisBox.slideUp();
			} else {
				if ($allBoxes.is(':visible')) {
					$allBoxes.filter(':visible').slideUp(function() {
						$thisBox.slideDown();
					});
				} else {
					$thisBox.slideDown();
				}
			}
			
			return false;
		});
		
		// Bind the Twitter button to show/hide the Twitter feed box
		$('#twitter-pop-out-trigger').click(function() {
			var $allBoxes = $('.footer-pop-out-box');
			if ($allBoxes.is(':animated')) {
				return false;
			}
					
			var $thisBox = $('.twitter-pop-out-box');		
			if ($thisBox.is(':visible')) {
				$thisBox.slideUp();
			} else {
				if ($allBoxes.is(':visible')) {
					$allBoxes.filter(':visible').slideUp(function() {
						$thisBox.slideDown();
					});
				} else {
					$thisBox.slideDown();
				}
			}
			
			return false;
		});
		
		// Bind the view map button to slide down / up the map
		var $viewMapButton = $('.view-map'),
		$mapImg = $('.hidden-map'),
		$contactInfoWrap = $('.contact-info-wrap'),
		viewMapButtonText = $('.view-map').text();
		
		$viewMapButton.click(function() {
			if (!$mapImg.add($contactInfoWrap).is(':animated')) {
				if (!$mapImg.hasClass('map-visible')) {
					$contactInfoWrap.slideUp(600, function() {
						$mapImg.slideDown(600, function() {
							$mapImg.addClass('map-visible');
							$viewMapButton.text('Esconder mapa');
						});
					});
				} else {
					$mapImg.removeClass('map-visible').slideUp(600, function() {
						$contactInfoWrap.slideDown(600, function() {
							$viewMapButton.text(viewMapButtonText);
						});
					});
				}
			}
			return false;
		});
		
		// Bind any links with the class 'scroll-top' to animate the scroll to the top
		$('a.scroll-top'). click(function() {
			if ($('html,body').scrollTop() > 0) {
				$('html,body').animate({ scrollTop: 0 }, 1000);
			}
			return false;
		});
		
		// Make the form inputs and search fields clear value when focused
		$('#search-input').toggleVal({ populateFrom: 'custom', text: 'Search' });
		$('#name, #email, #phone, #message, #endereco, #cidade, #estado').toggleVal({ populateFrom: 'label', removeLabels: true });
		
		// Create the gallery rollover effect
		$('li.one-portfolio-item a').append(
			$('<div class="portfolio-hover"></div>').css({ opacity: 0, display: 'block' })
		).hover(function() {
			$(this).find('.portfolio-hover').stop().fadeTo(400, 0.6);
		}, function() {
			$(this).find('.portfolio-hover').stop().fadeTo(400, 0.0);
		});
		
		
	}); // End (document).ready
	
	/*$(window).load(function() {
		 Load the Twitter feed
		if (twitterUsername && tweetCount > 0) {
			(function() {
				var t = document.createElement('script'); t.type = 'text/javascript'; t.src = 'http://twitter.com/statuses/user_timeline/' + twitterUsername + '.json?callback=twitterCallback2&count=' + tweetCount;
				var h = document.getElementsByTagName('head')[0]; h.appendChild(t);
			})();
		}
	}); // End (window).load*/
	
	// Global image preloader
	window.preloadedImages = [];
	window.preload = function(images) {
		for (var i in images) {
			var elem = document.createElement('img');
			elem.src = images[i];
			window.preloadedImages.push(elem);
		}
	};
	
		// Preloader rula (menos no IE)!
		window.preload([
        /*raiz+'/img/home-1.jpg',raiz+'/img/home-2.jpg',raiz+'/img/home-3.jpg',raiz+'/img/home-4.jpg',raiz+'/img/home-5.jpg',
		raiz+'/img/home-1-masc.jpg',raiz+'/img/home-2-masc.jpg',raiz+'/img/home-3-masc.jpg',raiz+'/img/home-4-masc.jpg',raiz+'/img/home-5-masc.jpg',
		raiz+'/img/home-logo-1.jpg',raiz+'/img/home-logo-2.jpg',raiz+'/img/home-logo-3.jpg',raiz+'/img/home-logo-4.jpg',raiz+'/img/home-logo-5.jpg',
		raiz+'/img/home-logo-1-masc.jpg',raiz+'/img/home-logo-2-masc.jpg',raiz+'/img/home-logo-3-masc.jpg',raiz+'/img/home-logo-4-masc.jpg',raiz+'/img/home-logo-5-masc.jpg'*/
		
	]);

})(jQuery, window);

function proximoBg() 
{ 
	$('.fullscreen-next').trigger('click'); 
}

var interval = "";

function inicializaBg(bg)
{
	
	/** Settings **/
	
	var raiz = 'http://luxcel.tempsite.ws';
			
	// List of background images to use, the default image will be the first one in the list	
	if (bg == 'penelope-bls')
	{
		
		var backgrounds = [raiz+'/img/produto/penelope-bls/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'nos')
	{
		
		var backgrounds = [raiz+'/img/produto/nos/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'bang')
	{
		
		var backgrounds = [raiz+'/img/produto/bang/bg.png'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'charuca')
	{
		
		var backgrounds = [raiz+'/img/produto/charuca/bg.png'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'dragao')
	{
		
		var backgrounds = [raiz+'/img/produto/dragao/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'hummer')
	{
		var backgrounds = [raiz+'/img/produto/hummer/bg.jpg'];
		window.clearInterval(interval);
	}
	else if (bg == 'hardcore')
	{
		
		var backgrounds = [raiz+'/img/produto/hardcore/bg.png'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'pinguins')
	{
		
		var backgrounds = [raiz+'/img/produto/pinguins/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'shrek')
	{
		
		var backgrounds = [raiz+'/img/produto/shrek/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'snoopy')
	{
		
		var backgrounds = [raiz+'/img/produto/snoopy/bg.png'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'fabric')
	{
		
		var backgrounds = [raiz+'/img/produto/fabric/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'princess')
	{
		
		var backgrounds = [raiz+'/img/produto/princess/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'penelope-esc')
	{
		
		var backgrounds = [raiz+'/img/produto/penelope-esc/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else if (bg == 'fiorucci')
	{
		
		var backgrounds = [raiz+'/img/produto/fiorucci/bg.jpg'];
		window.clearInterval(interval);
		
	}
	else
	{
		
		//var backgrounds = [raiz+'/img/backgrounds/bg-azul.jpg',raiz+'/img/backgrounds/bg-vermelho.jpg',raiz+'/img/backgrounds/bg-laranja.jpg'];
		var backgrounds = [raiz+'/img/backgrounds/bg-laranja.jpg'];
		//interval = window.setInterval(proximoBg,10000);
		
	}
	
	
	
	// The speed of the fade transition between backgrounds in milliseconds (1000 = 1 second)
	var speed = 0,
	
	// The speed of the fade transition to hide the website
	fadeOutSpeed = 0,
	
	// The speed of the fade transition to show the website
	fadeInSpeed = 0,
	
	// Should the current background be saved across pages in a cookie?
	save = false,
	
	// Should the cache be used for faster image loading?
	preload = false
	
	$.fullscreen({
		backgrounds: backgrounds,
		speed: speed,
		fadeOutSpeed: fadeOutSpeed,
		fadeInSpeed: fadeInSpeed,
		save: save,
		preload: preload
	});
	
}
