// JavaScript Document

//イージングの挙動追加

jQuery.easing.quart = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
};  



//ポップアップウィンドウ制御
$(document).ready(function(){
	$('a.window,area.window').click(function(){
		window.open(this.href,'new','scrollbars=yes,width=680,height=600').focus();
		return false;
	});
});














//ヘッダナビのプルダウンメニュー制御

function pluralMenu(){
$("ul#plural ul").css({display:"none"}); // Opera Fix
$("ul#plural li").hover(function(){
		$(this).find('ul:first').css({visibility:"visible",display:"none"}).show(200);
		},function(){
		$(this).find('ul:first').css({visibility:"hidden"});
		});
}

$(document).ready(function(){
	pluralMenu();
});




//ヘッダナビの現在地制御

$(document).ready( function() {
    $(".event-rollover a").each( function() {
        var url = document.URL.split('#');
		var currentpathcount = url[0].lastIndexOf('/');
		var currentpath = url[0].substr(0,currentpathcount+1);
		if ( this == currentpath || this == currentpath + 'index.html') {
		$(this).parent().addClass("current");
        }
    });
	var image_cache = new Object();
    $(".event-rollover .current img").each( function() {
		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.src = imgsrc_on;
		//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.src = imgsrc_on;
//		);
//        }
    });
});

//ヘッダナビロールオーバーの制御

function eventRollover() {
	var image_cache = new Object();
	$(".event-rollover a img").not("[@src*='_on.']").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; }
		);
	});
}

$(document).ready(function(){
	eventRollover();
});


//ページ先頭へ
//$(document).ready(function(){
//	$('div#main div#c001').each( function() {
//		$(this).after('<span class="to_top"><a href="#page" title="ページ先頭へ">ページ先頭へ</a></span>');
//		return false;
//	});
//});


//ページ内リンク
$(document).ready(function(){
  $('a[href*=#]:not([href^="#c-service"]),area[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}, 1000,'quart');
    return false;
   }
 }
  });
});



 

//外部リンク別ウィンドウ
$(document).ready(function(){
$('a[href^="http://"]:not([href^="http://www.tochoji.com/"]),a[href^="https://"]:not([href^="https://www.mmjp.or.jp/"])').click(function(){
	//window.open(this.href,'new','scrollbars=yes,width=480,height=500').focus();
	window.open(this.href, '_blank').focus();
	return false;
});
});

