$(document).ready(function(){
	

// FUNCTION 1 - for topNav

	$("#topNav li").mouseenter(function(){	  // Used for animating side nave arrow
		if ( $(this).hasClass("current-cat") ) {
			return;
		} else {
			var anchorLink = $(this).children();
			anchorLink.stop(true,false).animate({ 'paddingRight' : '15px' }, 400);
		}
		}).mouseleave(function(){	
		if ( $(this).hasClass("current-cat") ) {
			return;
		} else {
			var anchorLink = $(this).children();
			anchorLink.stop(true,false).animate({ 'paddingRight' : '0px' }, 400);
		}
	});	
	
	
// FUNCTION 2 - for animating expanding div

    $(".expDIV").click(function() {
    
        var expEle = $(this).attr("expTar");
        
        $("." + expEle).slideToggle("normal");
        
        if ( $(this).hasClass("ON") ) {
        
            $(this).removeClass("ON");
        } else {
            $(this).addClass("ON");
        }
    });
    
// FUNCTION 3  --------  Used for slideshow

	function testSlider() { // begin test slider function
	
		var thumbCount = $("#slider li").length; // count the amount of pics in the list
		
		var w = 450; // same width as li width declared in css for li
		var currentPos = 0; // to hold the position (in increments of 450)
		var slideW = (w*thumbCount); // to calculate the width of the entire slide gallery
		var maxslide = (-1*w*thumbCount) + w; // to judge positive value; are there pics to the right?
		var minslide = 0; // base value for judging positve/negative slide value
		
		
		$("#slider ul").css("width",slideW + "px"); // give unordered list a pixel width based on all the images
		$("#caption ul").css("width",slideW + "px"); // give unordered list a pixel width based on all the images
		
		$("#sliderPrevBtn").addClass("OFF"); // turn previous button off (on page load the list starts at first list item...so no need to hit previous
		
		$("#sliderNextBtn").click(function() { //clicking the next button
			if (currentPos > maxslide) { // if current position is a negative number; there are pics still to the right
				var nextLI = (currentPos - 450); // increment pixel width of next line item (negative to go left)
				$("#slider ul").animate({"left" : nextLI + "px"}, 600); // .animate (properties, duration)  so... left: (nextLineItem)px, 600 ...this will be a negative number
				$("#caption ul").animate({"left" : nextLI + "px"},600);
				currentPos = nextLI; // change current position variable to value of next Line Item
				$("#sliderPrevBtn").removeClass("OFF"); // since the gallery is no longer on the first picture, turn on the previous button
				
			if (currentPos <= maxslide) { // // if at the last picture; current position is currently equal to (or less than...somehow?) the maxSlide number
					$("#sliderNextBtn").addClass("OFF"); // turn the next button off...don't need it because there are no more pictures to the right
				} 
			} 
		}); // end next button click function
		
		
		$("#sliderPrevBtn").click(function(){  // clicking the previous button
			if (currentPos < minslide) { // if minslide is not zero, then there are still pictures to the left 
				var prevLI = (currentPos + 450); // increment pixel width of previous line item (positive to go right)		
				$("#slider ul").animate({"left" : prevLI + "px"},600); //.animate (properties, duration)  so...left: (previousLineItem)px, 600 ...this will be a positive number
				$("#caption ul").animate({"left" : prevLI + "px"},600);
				currentPos = prevLI; // change current position variable to value of previous Line Item
				$("#sliderNextBtn").removeClass("OFF"); // since the gallery now has pictures to the right, turn on the next button
				
				if (currentPos > -w) { // if current Position greater than -w (in this case current Posistion should be zero), we are at the first picture again
					$("#sliderPrevBtn").addClass("OFF"); // turn off the previous button...we don't need it becaue there are no more pictures to the left
				
				} else { // there are pictures to the left
					$("#sliderPrevBtn").removeClass("OFF"); // turn on the previous button
				}
			} 
			
		}); // end previous button click function
		
		animate("prev"); // don't know what this does yet...
	};
	
	testSlider();  // run test slider function
	

});





