
//現在地ナビ
jQuery(function($) {
	var href = location.href.split('#')[0];
	$('.localMenu 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);


//PopWindow Open
function openwin (url,name,w,h) {
w = window.open(url,name,"width="+w+",height="+h+",left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,favorites=no,resizable=yes");w.focus();
}

//スムーズスクロール
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;
		}
	});
});


//スタイル制御
$(document).ready(function(){
  $(".link:odd").addClass("even");
  $("#sitemapBox ul.list li:last-child").addClass("end");
  $(".link:even").addClass("odd");
  $(".newsMenu ul li:last-child").addClass("last");
  $(".columnMenu ul li:last-child").addClass("last");
  $("#productList ul li:last-child").addClass("last");
  $(".news_body ul li:even").addClass("odd");
  $("#faqPage .pagetop:last-child").css("display", "none");
  $("#researchIndex .pagetop:last-child").css("display", "none");
});

//faq
$(function(){
    $('.faqList dd').css('display','none');
});

$(document).ready(function(){
  $('.faqList > 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' />");
}
