function initRollovers(){
	var image_cache = new Object();
	$( '.rollover' ).each( function(){
		var imgsrc = this.src;
		var ftype = imgsrc.substring( imgsrc.lastIndexOf('.'), imgsrc.length );
		var imgsrc_ov = imgsrc.replace( ftype, '_over' + ftype );
		image_cache[ this.src ] = new Image();
		image_cache[ this.src ].src = imgsrc_ov;
		
		$( this ).hover(
			function(){
				this.src = imgsrc_ov;
			},
			function(){
				this.src = imgsrc;
			}	
		);
	} );
}

function filterPath( string ) {
	return string
		.replace(/^\//,'')
		.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		.replace(/\/$/,'');
}
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
	{
	def: 'easeOutCubic',
	swing: function (x, t, b, c, d) {
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	}
});
function initSmoothScroll(){
	var locationPath = filterPath( location.pathname );
	$( 'a[ href *= # ]' ).each( function(){
		var thisPath = filterPath( this.pathname ) || locationPath;
		if ( locationPath == thisPath
		&& ( location.hostname == this.hostname || !this.hostname )
		&& this.hash.replace( /#/,'' ) ){
			var $target = $( this.hash ), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click( function( event ){
					event.preventDefault();
					$( 'html, body' ).animate( { scrollTop: targetOffset }, 900, function(){
						location.hash = target;
					});
				});
			}
		}
	});
}

$( document ).ready( function(){
	initRollovers();
	initSmoothScroll();
} );

