// Andrew, if you read that code, go easy on me ^^.



//MENU SCRIPT BY MATTHIEU DUFOUR
//OPACITY ON HOVER / TOGGLE RIGHT MENU / AJAX PAGE LOAD / ACCORDION MENU

$(function(){ 



			//AJAX PAGE LOAD
/*
     var hash = window.location.hash.substr(1);
	 if(window.location.href.indexOf('#') > 0 && window.location.hash != '')
	 {
		 window.location.href = hash;
		 return false;
	 }
	
    $('#header li a.lin').click(function(event){
		event.preventDefault();
		// Not to follow the link
		
		var toLoad = $(this).attr('href');
		var ref = $(this).attr('href');
		//get the name of the page and the id of the container the data are loaded from
		$('#cont').fadeOut('slow',loadContent);
		$('#load').remove();
		//if not removed, every page load adds a loader on the page
		window.location.hash = $(this).attr('href');
		//-4 used for my .php pages instead of -5 for .html extensions
		$('#loader').append('<span id="load"></span>');
		$('#load').fadeIn('normal');
		function loadContent() { 
			$('#content').load(toLoad,{ 'ajax': 1 },showNewContent);
		}
		function showNewContent() {
			$('#cont').show(1500,hideLoader);
		}
		function hideLoader() {  
			$('#load').fadeOut('normal');  
		}
    });

*/		
		

//Pulsating
	$("div#red").pulse({
		opacity: [0.3,1]
	}, {
		duration: 1400, // duration of EACH individual animation
		times: 99999, // Will go three times through the pulse array [0,1]
		easing: 'linear', // easing function for each individual animation
		});
		
	


//.scrambledWriter()
		   
//OPACITY ON HOVER NAV LINKS
	//$('ul#nav li').animate({ "opacity": .6 },'slow');
			$('h3').hover(function() {
						$(this).animate({ "opacity": 0 },50);
						$(this).animate({ "opacity": 1 },50);
						$(this).animate({ "opacity": 0 },50);
						$(this).animate({ "opacity": 1 },30);
					}, function() {
						$(this).stop().animate({ "opacity": 1 },200);
					});
					
			$('#cont li a').hover(function() {
						$(this).animate({ "opacity": 0 },50);
						$(this).animate({ "opacity": 1 },50);
						$(this).animate({ "opacity": 0 },50);
						$(this).animate({ "opacity": 1 },30);
					}, function() {
						$(this).stop().animate({ "opacity": 1 },200);
					});
			

			$('h6').hover(function() {
						$(this).stop().animate({ paddingLeft: "8px" }, 200);
					}, function() {
						$(this).stop().animate({ paddingLeft: "0px" }, 200);
					});
					
			
			$('h3').click(function() {
						$(this).scrambledWriter();
					});
			$('#banner div.op').animate({ "opacity": 0 },1800);		
			$('#banner').hover(function() {
							$('#banner img.op').stop().animate({ "opacity": 0.2 },800);
							$('#banner div.op').stop().animate({ "opacity": 1 },800);
						}, function() {
							$('#banner img.op').stop().animate({ "opacity": 1 },400);
							$('#banner div.op').stop().animate({ "opacity": 0 },800);
						});
			$('#cont a img.tn').hover(function() {
							$(this).stop().animate({ "opacity": 0.1 },500);
						}, function() {
							$(this).stop().animate({ "opacity": 1 },400);
						});
			$('div.for img').animate({ "opacity": 0 },1);			
			$('div.for a').hover(function() {
							$('div.for img').stop().animate({ "opacity": 1 },500);
						}, function() {
							$('div.for img').stop().animate({ "opacity": 0 },400);
						});
						
			$('img.soch').animate({ "opacity": 0 },1);			
			$('ul#socicons img').hover(function() {
							$(this).closest('img').stop().animate({ "opacity": 1 },400);
						}, function() {
							$(this).closest('img').stop().animate({ "opacity": 0 },400);
						});
						
			
			
		
			
			
						

/*					
	$('ul#nav2 ul').hover(function() {
						$(this).scrambledWriter();
					}, function() {
						$(this).stop();
					});
					*/
			
//OPACITY ON HOVER HOME THUMBNAILS
	
	
			
			
	
//TOGGLE SUB MENU
		$("#global_wrapper ul#nav2").hide();
		// hide by default.
		// click event on the #works
		$("#global_wrapper ul#nav li#works").click( function () {
			if ($("ul#nav2:visible").length != 0) {						 
			// if show, then hide remove the .open class and add the .closed class
				$("#global_wrapper ul#nav2.open").slideUp(1400, function () { $(this).removeClass("open") }, function () { $(this).addClass("closed") });
				$('h5').scrambledWriter();
			}else {
			// if hidden, then show..
				$("#global_wrapper ul#nav2.closed").slideDown(1400, function () { $(this).addClass("open") });
				$('h5').scrambledWriter();
			}
			return false;
			// Not to follow the link
		}); 
		
		$("#line").hide();
		// hide by default.
		// click event on the #works
		$("#global_wrapper ul#nav li").click( function () {
			
				$("#line.closed").show(1000);
				$("#line.closed").animate({ "opacity": 0 },400);
				$("#line.closed").hide(1);
				$("#line.closed").animate({ "opacity": 1 },1);
			
		}); 



		$('#slideshow').nivoSlider({
        effect:'sliceDown', //Specify sets like: 'fold,fade,sliceDown'
        slices:10,
        animSpeed:400, //Slide transition speed
        pauseTime:7500,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //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:false, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:1, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });

	

});
//End of document ready...
