jQuery.noConflict();  

	(function($) { 	
/* functions() */
		function slideShow(speed) {
			//Set the opacity of all images to 0
			$('#slideshow ul.slideshow li').css({opacity: 0.0});
			//Get the first image and display it (set it to full opacity)
			$('#slideshow ul.slideshow li:first').css({opacity: 1.0});
			//Get the caption of the first image from REL attribute and display it
			$('#slideshow-caption h3').html($('#slideshow ul.slideshow a:first').find('img').attr('title'));
			$('#slideshow-caption p').html($('#slideshow ul.slideshow a:first').find('img').attr('alt'));
			//Display the caption
			$('#slideshow-caption').css({opacity: 0.7, bottom:0});
			setInterval(function(){
				//if no IMGs have the show class, grab the first image
				var current = ($('#slideshow ul.slideshow li.show')?  $('#slideshow ul.slideshow li.show') : $('#ul.slideshow li:first'));
				//Get next image, if it reached the end of the slideshow, rotate it back to the first image
				var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('#slideshow ul.slideshow li:first') :current.next()) : $('#slideshow ul.slideshow li:first'));
				//Set the fade in effect for the next image, show class has higher z-index
				next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
				//Hide the current image
				current.animate({opacity: 0.0}, 1000).removeClass('show');
			},speed);
		}
		function showAlbum(element) { 			
			var thisIndex = $('#portfolio .blogitem img').index(element);			
			//$(element).css("borderColor", "#9CFC5E");			
			$(element).css("borderColor", "#FF6533");			
			$('#portfolio .categoryitem').eq(thisIndex).css("z-index", "99");					
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow", "visible");						
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow-y", "visible");						
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow-x", "visible");						
			if( thisIndex%4 == 9999){				
				if(ie==0){ 
					$('#portfolio .categoryitem').eq(thisIndex).find('.album').css("marginLeft", "-307px");
					$('#portfolio .categoryitem').eq(thisIndex).find('#album').css("marginLeft", "-307px");
				}else{
					$('#portfolio .categoryitem').eq(thisIndex).find('.album').css("marginLeft", "-442px");
					$('#portfolio .categoryitem').eq(thisIndex).find('#album').css("marginLeft", "-442px");
				}
			}					
			$('#portfolio .blogitem img').stop().animate(
				{opacity:"0.1"},
				{duration:500}
			);	
			$('#portfolio .blogitem img').eq(thisIndex).stop().animate(
				{opacity:"1"},
				{duration:500}
			);
		}
		function hideAlbum(element) { 
			$(element).css("borderColor", "#ffffff");			
			var thisIndex = $('#portfolio .blogitem img').index(element);						
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow", "hidden");			
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow-y", "hidden");			
			$('#portfolio .categoryitem').eq(thisIndex).css("overflow-x", "hidden");		
			$('#portfolio .categoryitem').eq(thisIndex).css("z-index", "1");
			$('#portfolio .blogitem img').stop().animate(
				{opacity:"1"},
				{duration:500}
			);
			if(ie==0){
				$('#portfolio .categoryitem').eq(thisIndex).find('.album').css("marginLeft", "132px");	
				$('#portfolio .categoryitem').eq(thisIndex).find('#album').css("marginLeft", "132px");	
			}else{
				$('#portfolio .categoryitem').eq(thisIndex).find('.album').css("marginLeft", "-3px");	
				$('#portfolio .categoryitem').eq(thisIndex).find('#album').css("marginLeft", "-3px");	
			}
		}
		function redirectPage() {
			window.location = linkLocation;
		}
/* ----------------------------------------------------------------------- */
		$(document).ready(function(){	
/* main() */

    slideShow(10000);
 
/* Animation affichage */
	$("body").css("display", "none");
	$("body").fadeIn(500);
/* Ajout _blank si lien vers page externe */
	//initExternalLinks();
/* Fonction de fadeout sur changement de page */
	$("a").click(function(event){
			event.preventDefault();
			//var h = window.location.host.toLowerCase();
			linkLocation = this.href;
			/* Ouverture nouvelle fenetre si fichier pdf ou autre site */
			if (
				(this.href.toString().search(new RegExp(/.pdf/i))>0) 
			||
				(this.href.toString().search(new RegExp(/.zip/i))>0) 
			||
				(this.href.toString().search(new RegExp(/www.nautylusprod.com/i))<1)
			) {
				window.open(this.href);
			}
			else {
				$("body").fadeOut(250, redirectPage);
			}
		});

/* Animation musicale */
	soundManager.url = 'http://www.nautylusprod.com/wp-content/themes/tpl_nautylus/audio/';
	soundManager.flashVersion = 9;
	soundManager.useFlashBlock = false;
	soundManager.debugMode = false;
	soundManager.onload = function() {
		soundManager.createSound('button','http://www.nautylusprod.com/wp-content/themes/tpl_nautylus/audio/button2.mp3');
	};		

/* Animation book */
			$('#portfolio .blogitem img').mouseenter(function(element) { 				
				showAlbum($(this));			
			});
			$('#portfolio .blogitem img').mouseleave(function(element) {
				hideAlbum($(this));
			}); 
/* Animation Menu */
			$('#container_id ul li.menu-item')
			.mouseover(function(){
				soundManager.play('button');
				$(this).stop().animate(
					{backgroundPosition:"0 -39px"}, 
					{duration:700, easing:'easeOutBack'}
				)
			})
			.mouseout(function(){
					$(this).stop().animate(
						{backgroundPosition:"0 0"}, 
						{duration:700, easing:'easeOutBack'}
					)
			})
			$('#container_id ul li.current-menu-item')
			.mouseover(function(){
				$(this).stop().animate(
					{backgroundPosition:"0 -39px"}, 
					{duration:700, easing:'easeOutBack'}
				)
			})
			.mouseout(function(){
					$(this).stop().animate(
						{backgroundPosition:"0 -39px"}, 
						{duration:700, easing:'easeOutBack'}
					)
			})
		})
	})
(jQuery);

