/* Roll Over scripts */
$(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\./, '.');
   }
};

/* Content Slider */
$(window).load(function() {
	$('#featured').orbit({          
		 animation: 'fade', //fade, horizontal-slide, vertical-slide
		 animationSpeed: 800, //how fast animations are
		 advanceSpeed: 5000, //if timer advance is enabled, time between transitions 
		 startClockOnMouseOut: true, //if timer should restart on MouseOut
		 startClockOnMouseOutAfter: 3000, //how long after mouseout timer should start again
		 directionalNav: true, //manual advancing directional navs
		 captions: true, //if has a title, will be placed at bottom
		 captionAnimationSpeed: 800, //how quickly to animate in caption on load and between captioned and uncaptioned photos
		 timer: true, //if the circular timer is wanted
		 bullets: false //true or false to activate the bullet navigation
	});
});

/* Pikachoose */
$(document).ready(
function (){
	var a = function(self){
      self.anchor.fancybox();
    };

	$("#pikame").PikaChoose({auto_play:false,show_prev_next: false,buildFinished:a});

	$("#pikame").jcarousel({scroll:4,					
		initCallback: function(carousel) 
		{
			$(carousel.list).find('img').click(function() {
				//console.log($(this).parents('.jcarousel-item').attr('jcarouselindex'));
				carousel.scroll(parseInt($(this).parents('.jcarousel-item').attr('jcarouselindex')));
			});
		}
	});

});


