// jQuery Easing v1.3
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

$(document).ready(function() {
	
	// easingScroll
	$('a[href^="#"]').click(function() {
		$('html:animated, body:animated').queue('fx', []).stop();
		var targetOffset = 0;
		
		var targetId = $(this).attr("href");
		if (targetId != "#") {
			if (targetId.search(/^#tabs/i) == -1) {
				targetOffset = $(targetId).offset().top;
			} else {
				return false;
			}
		}
        $('html,body').animate({ scrollTop: targetOffset }, 500, 'easeOutQuart');
		return false;
	});
	
	
	// rollOver
	
	$('.rollOver img:not([src$=_on.jpg])').rollover('_over');
	$('.rollOver input:image').rollover('_over');
	
	// mouseWheel
	if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
	window.onmousewheel = document.onmousewheel = wheel;


	// fontResize
	
	if ($.cookie('fs') == null) {
		$.cookie('fs', 100);
	} else {
		fontResize($.cookie('fs'));
	}
	
	$(".fs-small a").click(function() {
		fontResize(80);
		return false;
	});
	
	$(".fs-midium a").click(function() {
		fontResize(100);
		return false;
	});
	
	$(".fs-large a").click(function() {
		fontResize(140);
		return false;
	});
});

function wheel()
{
	$('html:animated, body:animated').queue('fx', []).stop();
}

function fontResize(percent)
{
	var fs = parseInt(percent);
	$.cookie('fs', fs);
	$("#contents").css("font-size", fs + "%");
	if (fs == 80) {
		$(".fs-small a").addClass("on");
		$(".fs-midium a").removeClass("on");
		$(".fs-large a").removeClass("on");
	} else if (fs == 100){
		$(".fs-small a").removeClass("on");
		$(".fs-midium a").addClass("on");
		$(".fs-large a").removeClass("on");
	} else if (fs == 140){
		$(".fs-small a").removeClass("on");
		$(".fs-midium a").removeClass("on");
		$(".fs-large a").addClass("on");
	}
}
