$(function (){
	
	// HOME WORK BOX
	$('#box_work .text').hide(); // hide text on default
	$('#box_work .content').hover(function() { // swap image and text 
	    $(this).find(".image").hide();
		$(this).find(".text").show();
	}, function() {
	    $(this).find(".text").hide();
		$(this).find(".image").show();
	});
	
	// EQUAL HEIGHTS
	function equalHeight(group) {
		tallest = 0;
		group.each(function() {
			thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	equalHeight($("#content .subcat .text"));
	
	// ROLLOVER IMAGES (1/2)
	IMAGE.rollover.init();
	
});


// ROLLOVER IMAGES (2/2)
IMAGE = {};
IMAGE.rollover = {
   init: function() {
      this.preload();
      $(".rollover").hover(
         function () { $(this).attr( 'src', IMAGE.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', IMAGE.rollover.oldimage($(this).attr('src')) ); }
      );
   },
   preload: function() {
      $(window).bind('load', function() {
         $('.rollover').each( function( key, elm ) { $('<img>').attr( 'src', IMAGE.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/, '');
   }
};