attachRollOverEvent = function(imageId){
	$(imageId).mouseover( function(){ $(this).attr("src", $(this).attr("src").split('_off').join('_on')) } );
	$(imageId).mouseout( function(){ $(this).attr("src", $(this).attr("src").split('_on').join('_off')) } );
};

// jQuery-powered events for this site, activated when doc is finished loading
$(document).ready(function(){

  // Activate nice scroll bars
  $('.scroll-pane').jScrollPane();

  // Add rollover events to navigation
	attachRollOverEvent("a#link_bio img");
	attachRollOverEvent("a#link_contact img");
	attachRollOverEvent("a#link_needmore img");
	attachRollOverEvent("#pretty_menu a#link_desc img");
	attachRollOverEvent("#pretty_menu a#link_events img");
	attachRollOverEvent("#pretty_menu a#link_excerpt img");
	attachRollOverEvent("#pretty_menu a#link_links img");
	attachRollOverEvent("#footer a#link_jessica img");
	attachRollOverEvent("#footer a#link_needmore img");

	// Add pretty menu popup feature
	$("a#link_pretty").mouseover(function() {
	  $('#pretty_menu').fadeIn(200);
  });
  $('#wrap').mousemove(function(e){
    var x = e.pageX - this.offsetLeft;
    var y = e.pageY - this.offsetTop;
    if (x < 154 || x > 471 || y < 194 || y > 484) {
      $('#pretty_menu').fadeOut(200);
    };
  });

  // We also want to preload all images to make the page work better
  var preload = [ 
    '/images/menu_01_on.gif', 
    '/images/menu_02_on.gif', 
    '/images/menu_03_on.gif',
    '/images/menu_04_on.gif',
    '/images/nav_05_on.gif',
    '/images/nav_06_on.png',
    '/images/nav_07_on.png',
    '/images/footer_01_on.gif',
    '/images/footer_02_on.gif'
  ];           
  $(document.createElement('img')).bind('load', function(){ 
    if(preload[0]) this.src = preload.shift(); 
  }).trigger('load');
});
