$(document).ready(function(){ 
	rolloverImage();
	fadeImages();
	flip();
	replaceHomeNav();
});


function rolloverImage() {
	var image_cache = new Object();
	$("img.rollover, .content-navi img").each(function(i) {
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var imgsrc_on = this.src.substr(0, dot) + '-ovr' + this.src.substr(dot, 4);
	image_cache[this.src] = new Image();
	image_cache[this.src].src = imgsrc_on;
	$(this).hover(
		function() { this.src = imgsrc_on; },
		function() { this.src = imgsrc; });
	});
}

function fadeImages() {
	$("img.rollover, #information a, #sidebar ul li, .content-navi li a").each(function() {
		$(this).hover(
			function() {
				$(this).queue([]).stop();
				$(this).fadeTo(400, 0.6);
			},
			function() {
				$(this).queue([]).stop();
				$(this).fadeTo(500, 1);
			});
		}
	);
}

$(function(){
  $(".blank").click(function(){
    this.target = "_blank";
  });
});

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(300);
    return false;
  });
//  if ($("div#content").is(":hidden")) {
//    $("div#content").slideDown(800);

//  } else {
//    $("div#content").hide();
//  }

//  $("div#footer-nav:hidden:first").fadeIn(1000);

	$("table#option tr:even, div#news div:even, body#feature ul.links li:even").addClass("even");
	//$("div#sidebar:hidden").slideDown("slow");
	$('body.one #sidebar ul#sub-navi li:nth-child(1), body.two #sidebar ul#sub-navi li:nth-child(2), body.three #sidebar ul#sub-navi li:nth-child(3), body.four #sidebar ul#sub-navi li:nth-child(4), body.five #sidebar ul#sub-navi li:nth-child(5), body.six #sidebar ul#sub-navi li:nth-child(6), body.seven #sidebar ul#sub-navi li:nth-child(7), body.eight #sidebar ul#sub-navi li:nth-child(8), body.nine #sidebar ul#sub-navi li:nth-child(9)').addClass("current");
	$('#sidebar ul#sub-navi li:last').prev('li').addClass("ending");
	$('#sidebar ul#sub-navi li:last').addClass("end");


});

function replaceHomeNav() {
	$('body#home #navi li > a, body#home #footer-nav li > a').each(function(){
		var newurl = $(this).attr('href').replace(/\.\.\//ig, '');
	$(this).attr('href', newurl);
	});
}

function flip() {
	$('#nav-home a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:200})
		});
	$('#nav-system a')
		.css( {backgroundPosition: "-98px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-98px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-98px 0)"}, {duration:200})
		});
	$('#nav-market a')
		.css( {backgroundPosition: "-196px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-196px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-196px 0)"}, {duration:200})
		});
	$('#nav-highgrade a')
		.css( {backgroundPosition: "-294px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-294px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-294px 0)"}, {duration:200})
		});
	$('#nav-feature a')
		.css( {backgroundPosition: "-392px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-392px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-392px 0)"}, {duration:200})
		});
	$('#nav-event a')
		.css( {backgroundPosition: "-490px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-490px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-490px 0)"}, {duration:200})
		});
	$('#nav-useful a')
		.css( {backgroundPosition: "-588px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-588px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-588px 0)"}, {duration:200})
		});
	$('#nav-about a')
		.css( {backgroundPosition: "-686px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-686px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-686px 0)"}, {duration:200})
		});
	$('#nav-dobetter a')
		.css( {backgroundPosition: "-784px 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-784px -55px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-784px 0)"}, {duration:200})
		});

}

var addthis_language = "ja"; 
var addthis_options = 'email, print, favorites, yahoobkm, google, live, twitter, evernote, yahoobkm,  more';

