// JavaScript Document

$(function() {

	//swap images button
		var postfix = '_o';
		$('.swap').not('[src*="'+ postfix +'."]').each(function() {
			var img = $(this);
			var src = img.attr('src');
			var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
			$('<img>').attr('src', src_on);
			img.hover(function() {img.attr('src', src_on);},function() {img.attr('src', src);
			});
		});

	// easeOutExpo
	jQuery.easing.expo = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};

	//smooth scroll
	$('a.scroll').click(
		function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
			var target = $(this.hash);
			target = target.length && target;
			if (target.length)
				var sclpos = 30;
				var scldurat = 900;
				var targetOffset = target.offset().top - sclpos;
				$('html,body').animate({scrollTop: targetOffset}, {duration: scldurat, easing: "expo"});
				return false;
			}
		);
	$('input').keypress(function (e) {
		if((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
			return false;
		}
	});


});
