// Image RollOver action
$(document).ready(function() {
	PEPS.rollover.init();
});

PEPS = {};
PEPS.rollover = {
	init: function() {
		this.preload();
		$(".hover").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() {
			$('.hover').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\./, '.');
	}
};


//Smooth Scroll
jQuery.fn.extend({
	scrollTo : function(speed, easing) {
		if(!$(this)[0].hash || $(this)[0].hash == "#") {
			return false;
		}
		return this.each(function(){
			var targetOffset = $($(this)[0].hash).offset().top;
			$('html,body').animate({scrollTop: targetOffset}, speed, easing);
		});
	}
});
$(document).ready(function() {
	$('a[href*=#]').click(function() {
		$(this).scrollTo(1000);
		return false;
	});
});