//GALLERY SLIDESHOW//



function mycarousel_initCallback(carousel)
		{
		    // Disable autoscrolling if the user clicks the prev or next button.
		    carousel.buttonNext.bind('click', function() {
		        carousel.startAuto(0);
		    });
		
		    carousel.buttonPrev.bind('click', function() {
		        carousel.startAuto(0);
		    });
		
		    // Pause autoscrolling if the user moves with the cursor over the clip.
		    carousel.clip.hover(function() {
		        carousel.stopAuto();
		    }, function() {
		        carousel.startAuto();
		    });
		};
		
		jQuery(document).ready(function() {
		    jQuery('#mycarousel').jcarousel({
		        auto: 2,
		        wrap: 'last',
		        initCallback: mycarousel_initCallback
		    });
		});
		
/*ROTATION*/

var rotationDown = function () {
	$("#arrowRotate").rotate(90);
}

var rotationSide = function() {
	$("#arrowRotate").rotate(0);
}




/* 
Simple JQuery menu.
HTML structure to use:

Copyright 2007-2010 by Marco van Hylckama Vlieg

web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl

Free to use any way you like.
*/


jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand  > .acitem', this).show();
        $('li.expand  > .acitem', this).prev().addClass('active');
        $('li a', this).click(
            function(e) {
                e.stopImmediatePropagation();
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if($(parent).hasClass('noaccordion')) {
                    if(theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal', function() {
                        if ($(this).is(':visible')) {
                            rotationDown(),
                            $(this).prev().addClass('active');
                        }
                        else {
                            rotationSide(),
                            $(this).prev().removeClass('active');
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal',
                            function() {
                                rotationSide(),
                                $(this).prev().removeClass('active');
                            }
                        );
                        return false;  
                    }
                    return false;
                }
                if(theElement.hasClass('acitem') && !theElement.is(':visible')) {         
                    $('.acitem:visible', parent).first().slideUp('normal', function() {
                        rotationSide(),
                        $(this).prev().removeClass('active');
                    });
                    theElement.slideDown('normal', function() {
                        rotationDown(),
                        $(this).prev().addClass('active');
                    });
                    return false;
                }
                
/*
                if(theElement.hasClass('active') && theElement.is(':visible')) {
                	rotationDown();
                }
                else {
                	rotationSide();
                }
*/
            }
        }
    );
});
};

$(document).ready(function() {$('.sidemenu').initMenu();});

/*

Main Javascript for jQuery Realistic Hover Effect
Created by Adrian Pelletier
http://www.adrianpelletier.com

*/

/* =Realistic Navigation
============================================================================== */

	// Begin jQuery
	
	$(document).ready(function() {

	/* =move Nav
	-------------------------------------------------------------------------- */	
		
		// Append span to each LI to add move
		
		$("#nav-move li").append("<span></span>");	
		
		// Animate buttons, move move and fade
		
		$("#nav-move a").hover(function() {
		    $(this).stop().animate({ marginLeft: "10px" }, 200);
		    //$(this).parent().find("span").stop().animate({ marginTop: "18px", opacity: 0.25 }, 200);
		},function(){
		    $(this).stop().animate({ marginLeft: "0px" }, 300);
		    //$(this).parent().find("span").stop().animate({ marginTop: "1px", opacity: 1 }, 300);
		});
				
	
						
	// End jQuery
	
	});
	


//rollover via peps.ca


	$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }
};


///////////////////
//// ROTATION  ////
//////////////////


/*
var rotation = function (){
   $("#arrowRotate").rotate({
      angle:0, 
      animateTo:90, 
      callback: rotation
   });
}
*/

/* $("#arrowRotate").rotate(45); */



