// JQUERY CUSTOM COMMANDS
$(document).ready( function() {  // start javascript when document is loaded
	
	// MENU HOVER
	$('#menu li').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	// INPUT FOCUS & BLUR
	$('input.textfield, textarea.textarea, select.select').focus(function() {
	    $(this).addClass("focus");
	});
	$('input.textfield, textarea.textarea, select.select').blur(function() {
	    $(this).removeClass("focus");
	});
	
	/* CYCLE */
	$('.slide').cycle({
	    fx:     'fade',
	    speed:   1000,
	    timeout: 4000
	});
	
	
	// ROLLOVER IMAGES (1/2)
	IMAGE.rollover.init();
   
}); // end ready function




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


