/* Author: Mark Luetke

*/

/* SIMPLE SLIDESHOW BY Jon Rausch */
function slideSwitch() {
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow div:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


/* JCAROUSEL */



jQuery(document).ready(function() {

    jQuery('#mycarousel').jcarousel({
    	wrap: 'circular',
    	scroll: 1,
    	start: 1,
    	
    	
    	itemFirstInCallback: {
		  onBeforeAnimation: lmj_itemFirstInBeforeAnimation
		},
    	
    	itemFirstOutCallback: {
		  onBeforeAnimation: lmj_itemFirstOutBeforeAnimation
		}    	
    });


function lmj_itemFirstInBeforeAnimation(carousel, item, idx, state) {
    jQuery('img', item).fadeTo('slow', 1.0);
};

function lmj_itemFirstOutBeforeAnimation(carousel, item, idx, state) {
    jQuery('img', item).fadeTo('slow', 0.25);
};   

 	jQuery('#mycarousel img').css({ opacity: 0.25 });
});



/* Gallery Page Hovers */

$('.gallery-item-area td').css('display','none');

/*
$('.gallery-item-area').hover(
	
	function(){
		$(this).find('p').fadeIn('fast');
		$(this).find('.wp-post-image').fadeOut('fast');
	},
    function(){
       $(this).find('p').fadeOut('fast');
       $(this).find('.wp-post-image').fadeIn('fast');
	});
*/
	
	
	
	$(".gallery-item-area").mouseenter(function(){
      	$(this).find('td').css('display','table-cell');
		$(this).find('.wp-post-image').fadeOut('fast');
    }).mouseleave(function(){
      	$(this).find('td').css('display','none');
       	$(this).find('.wp-post-image').fadeIn('fast');
    });





/* Press Page Hovers */

$('.press-item').hover(
	
	function(){
		$(this).find('.thumb').fadeIn('fast');
	},
    function(){
       	$(this).find('.thumb').fadeOut('fast');
	});



/* About pic hovers */
$('.aboutpic').hover(
	function(){
		$(this).find('img').fadeTo('fast', 0.75);
	},
	function(){
		$(this).find('img').fadeTo('fast', 1.0);
	});



/* SIDEBAR BRACKETS */
$('aside ul.menu li a').width();
/*
$('<span class="left-small">{</span>').prependTo('aside ul.menu li.current-menu-item');
$('<span class="right-small"></span>').appendTo('aside ul.menu li.current-menu-item');
*/






/* ACCORDION */
/***********************************************************************************************************************
DOCUMENT: includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 3/26/2009
UPDATED: 3/25/2010
DESCRIPTION: This is the JavaScript required to create the accordion style menu.  Requires jQuery library
NOTE: Because of a bug in jQuery with IE8 we had to add an IE stylesheet hack to get the system to work in all browsers. I hate hacks but had no choice :(.
************************************************************************************************************************/
$(document).ready(function() {
	 
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.accordionButton').click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.accordionButton').removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.accordionContent').slideUp('normal');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next().is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('on');
			  
			//OPEN THE SLIDE
			$(this).next().slideDown('normal');
		 } 
		  
	 });
	  
	
	/*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	//ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
	$('.accordionButton').mouseover(function() {
		$(this).addClass('over');
		
	//ON MOUSEOUT REMOVE THE OVER CLASS
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	
	/*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	
	/********************************************************************************************************************
	CLOSES ALL S ON PAGE LOAD
	********************************************************************************************************************/	
	$('.accordionContent').hide();

});




