$(function() {
	
	// fadeout flash messages on click
	$('.cancel').click(function() {
		$(this).parent().fadeOut();
		return false;
	});

	// fade out good flash messages after 5 seconds
	$('.flash_good').animate({opacity: 1.0}, 5000).fadeOut();

	// projects
	$(".screenshot").hover(
		function() { $(this).css('border', '2px solid #000'); },
		function() { $(this).css('border', '2px solid #165f1d'); }
	);
	$(".website_view .details a[rel='colorbox']").colorbox();
	$(".website_index").hover(
		function() { $(this).css('border', '1px dashed #165f1d'); },
		function() { $(this).css('border', '1px solid #fefcd7'); }
	);

	// resumes
	$(".jobname img a").colorbox();
	
	// load images/bind behaviors for menu rollover
	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]+)$/) ) + '_on' + src.match(/(\.[a-z]+)$/)[0];
   },

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