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

$(function () {
	$('.pageTop a')
		.removeAttr('href')
		.css('cursor','pointer')
		.click(function () {
			$('html,body').animate({ scrollTop: 0 }, 300, 'quart');
		 });
	$('a.blank')
		.css('cursor','pointer')
		.click(function(){
			window.open(this.href,"","");
			return false;
		});
	
	//#global
	$('.pagePath li:last').css('background','none');
	$('#home #topics dl:nth-child(2n) , #topics div.contentsBody dl:nth-child(2n) , #maintenance div#index div#worktop ul li:even , #maintenance div#index div#range ul li:even , #maintenance div#index div#strage ul li:even').addClass('even');
	$('#maintenance div#index div#worktop ul li:last , #maintenance div#index div#range ul li:last , #maintenance div#index div#strage ul li:last').addClass('last');
	$('#home #topics dl:last , #topics div.contentsBody dl:last').parent().parent().after('<span class="last"></span>');
	
	
	//#topics
	//$('#topics div.contentsBody , #topics div.utility').flatHeights();
	$('#topics #datebased_archive p.back a , #topics #detail p.back a')
		.css('cursor','pointer')
		.click(function(){
			history.back();
			return false;
		});
	
	/*
	$('#topics #index div.utility a').each(function(){
		var sourceYear = $(this).html().slice(0,4);
		$(this)
			.click(function(){
				$('#topics div.contentsBody dl dt.published').each(function(){
					var publishedYear = $(this).html().slice(0,4);
					if(sourceYear != publishedYear){
						$(this).parent().fadeOut('fast');
					}else{
						$(this).parent().fadeIn('fast');
					};
				});
				return false;
			});
	});
	*/
	
	
	//#faq
	$('#faq div.contentsHeader li a[href*=#] , #maintenance div#index div.contentsHeader dl a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
					.animate({scrollTop: targetOffset}, 500, 'quart');
					return false;
			}
		}
	});
	
	$('#faq div.section p.pageTop a')
		.removeAttr('href')
		.css('cursor','pointer')
		.click(function () {
			$('html,body').animate({ scrollTop: 0 }, 500, 'quart');
		 });
		
	//#maintenance
	$('#maintenance div#index div.contentsHeader dl').each(function (){
		var eHref = $(this).find('a').attr('href');
		$(this)
			.hover(
				function (){
					$(this).addClass('hover');
				},
				function (){
					$(this).removeClass('hover');
				}
			)
			.css('cursor','pointer')
	});
	
	$('#maintenance div#detail div.section dl dt').each(function (){
		var imgWidth = $(this).find('img').attr('width') + 2;
		var imgHeight = $(this).find('img').attr('height') + 2;
		$(this).append('<span></span>');
		$(this).find('span').css({'width':imgWidth,'height':imgHeight});
	});
	
	$('#maintenance div#detail div.section dl ol li').each(function (){
		var str = $(this).html();
		$(this)
			.css('color','#79ba00')
			.empty()
			.append('<span>' + str +'</span>')
	});
});