﻿ $(document).ready(function(){
   
/*------------------  Get all JS-Effects-Only styles out - make Page work without Javascript  ---------------------*/ 
 
    $("ul#gallery li").addClass("pics");
/*	$("ul#gallery li p").addClass("imgDesc");    - all <p> with class 'imgDsc'*/
	$("ul#gallery li:not(.projectDesc, .intro) p").addClass("imgDesc"); 
	$("div#maincontent").css("height", "470px");
	$("ul#gallery").css("margin-top", "10px");

	
/*-------------------------------------  Hover Menu - Portfolio  ---------------------------------------
* with HoverIntent-plugin 
* http://cherne.net/brian/resources/jquery.hoverIntent.html

*/

$("ul#portfolio_nav").hide();
	$("li#portfolio_nav")
	$("li#portfolio").hoverIntent({
		sensitivity: 3, // How sensitive the hoverIntent should be
		interval: 200, // How often in milliseconds the onmouseover should be checked
		over: getdown, // Function to call when mouseover is called
		timeout: 200, // How often in milliseconds the onmouseout should be checked
		out: getup // Function to call when mouseout is called
	});					// Activate/deactivate the hover menu
		function getdown() {
			$(this).children("ul").slideDown("slow");
			$("li#portfolio a").addClass("active");	
		}
		function getup() {
			$(this).children("ul").slideUp("slow");	
			$("li#portfolio a").removeClass("active");
		}	
	

$("li#portfolio a:not(ul#portfolio_nav li a)").click(function() {  // Deactivate the link <a>
    return false;
  });


/* -----Toggle Version -----	

	$("ul#portfolio_nav").hide();
	$("li#portfolio a").toggle(
		function() {
			$("ul#portfolio_nav").slideDown("slow");
			$("li#portfolio a").addClass("active");	
		},
		function() {
			$("ul#portfolio_nav").slideUp("slow");
			$("li#portfolio a").removeClass("active");
		}	
	);
*/

/*-------------------------------------  Hover Info - Image Description  ---------------------------------------*/
	
	$(".imgDesc").hide(); 
	
	$("ul#gallery li:has(.imgDesc)").hover(
		function() {
			$(this).find(".imgDesc").fadeIn("slow");
		},
		function() {
			$(this).find(".imgDesc").fadeOut("slow");		
		}		
	);
	$("ul#gallery:has(.intro)").hover(
		function() {
			$(this).find("li.intro p").fadeOut("slow");
		},
		function() {
			$(this).find("li.intro p").fadeIn("slow");		
		}		
	); 	 	

/*  **************************************************************************************
********************************    Cycle Plugin    ******************************************
**************************** - Gallery navigation - *****************************************
*****************************************************************************************
*/	
		$("div#maincontent").append('<p id="caption"></p>');			
		$('ul#gallery').cycle({ 
		    fx:     'fade', 
			speed:  2000, 
			timeout: 0, 
			next:   '#next_a', 
			prev:   '#prev_a',
			pause:   0,
			after:   onAfter	
		});

		function onAfter(curr,next,opts) {
			var caption = (opts.currSlide + 1) + ' / ' + opts.slideCount;
			$('p#caption').html(caption);		
		}
			
 }); /* Close   $(document).ready(function(){  */
 
