

//現在地ナビ
jQuery(function($) {
	var href = location.href.split('#')[0];
	$('#localNavi a').each(function() {
		if (href == this.href){
			$(this).addClass("active");
		}
	});
});

//フォントサイズ変更
$(document).ready(function() {
	if($.cookie('TEXT_SIZE')) {
		$('body').addClass($.cookie('TEXT_SIZE'));
	}
	$('#switch a').click(function() {
		var textSize = $(this).parent().attr('class');
		$('body').removeClass('sizeS sizeM sizeL').addClass(textSize);
		$.cookie('TEXT_SIZE',textSize, { path: '/', expires: 10000 });
		return false;
	});
});

//ロールオーバー
function initRollOverImages() {
  var image_cache = new Object();
  $("img.swap,input.swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + 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; });
  });
  $("a.swap img").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).parent().hover(
      function() { $(this).find("img").attr("src",imgsrc_on); },
      function() { $(this).find("img").attr("src",imgsrc); });
  });
}

$(document).ready(initRollOverImages);




//スムーズスクロール
var span = 1000;
var effect = 'easeOutQuint';

$(function() {
	var ua = $.browser;
	$("a.scroll, .pagetop a").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			$(this).blur();
			var t = navigator.appName.match(/Opera/) ? "html" : "html,body";
			$(t).queue([]).stop();
			var $targetElement = $(this.hash);
			var scrollTo = $targetElement.offset().top;
			if (window.scrollMaxY) {
				var maxScroll = window.scrollMaxY;
			} else {
				var maxScroll = document.documentElement.scrollHeight - document.documentElement.clientHeight;
			}
			if (scrollTo > maxScroll){
				scrollTo = maxScroll;
			}
			$(t).animate({ scrollTop: scrollTo }, span, effect);
			return false;
		}
	});
});

// jquery Self
jQuery(function($) {
var href = location.href.split('#')[0];
$('a').each(function() {
  if (href == this.href)
    $(this)
     .addClass("self");
});
});

// jquery Even

$(document).ready(function(){
  $(".lastClass:last-child").addClass("last");

  $(".oddClass:odd").addClass("even");
  $(".evenClass:even").addClass("odd");
  $(".oddBlock:nth-child(odd)").addClass("even");
  $(".evenBlock:nth-child(even)").addClass("odd");
});


//faq
$(function(){
    $('.qaList dd').css('display','none');
});

$(document).ready(function(){
  $('.qaList dt').click(function(){
    $(this).next().slideToggle('normal');
  });
});


// Blog New
function newM(y,m,d)
{
newday=new Date(y+"/"+m+"/"+d);
oldday= new Date();
n=(oldday-newday)/(1000*60*60*24);
if (n <=7)document.write(" <img src='img/blog_new.gif' />");
}
