var Header = {
  // Let's write in JSON to make it more modular
  addFade : function(selector){
    $("<span class=\"fake-hover\"></span>").css("display",
      "none").prependTo($(selector));
      // Safari dislikes hide() for some reason
      $(selector+" a").bind("mouseenter",function(){
      $(selector+" .fake-hover").fadeIn("slow");
    });
    $(selector+" a").bind("mouseleave",function(){
      $(selector+" .fake-hover").fadeOut("slow");
    });
  }
};
$(function(){
  Header.addFade("#content-menu-logo");
// This makes sure our function executes when the pages load
// It will add a fake hove to the #header element
});

/* 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\./, '.');
   }
};

/* JScrollPane */
$(function()
{
	$('.scroll-pane').jScrollPane();
	$('.form-scroll-pane').jScrollPane();
});

/* Image Scroller */
$(function() {         
         
    // initialize scrollable  
    $("div.scrollable").scrollable();     
     
}); 

/* Facebox */
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox() 
}) 

/* Show Hide */
$(document).ready(function(){

	$("ul.article").each(function(){

		var thisArticle = this;

		// Initially, hide the "Show" link
		$("a.hide, ul.articleBody", thisArticle).hide();	

		// The show and hide links both toggle themselves and the article body
		$("a.show, a.hide", thisArticle).click(function(){
			$("a.show, a.hide, ul.articleBody", thisArticle).toggle();
			return false;
		});

	});

});
