/* Mouse Over Image Change */
function initRollOverImages() {
  var image_cache = new Object();
  $("img.swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_o' + 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; });
  });
}
/* Drop Dowm Menu */
function mainmenu(){
	$(" #gloval_navi ul ").css({display: "none"}); // Opera Fix
	$(" #gloval_navi li").hover(
	function(){
		$(this).find('ul:first').css({visibility:"visible",display:"none"}).show(400);
	},function(){
		$(this).find('ul:first').css({visibility:"hidden"});
	});
}
$(function() {
	mainmenu();
});
/* Page Scrool */
 jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
jQuery(document).ready(function(){
    jQuery('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 300, 'quart');
                return false;
            }
        }
    });
});
/* 現在地表示 */
function CurrentNavi() {
	$('body').each(function(){
		if ( $(this).attr("id") ){	// body に id がついている場合のみ
			var bodyIdName = $(this).attr("id");		//bodyのidを取得
			$('.side_navi li a').each(function(){
				var imgIdName = $(this).attr("id");	//a のid取得
				if ( bodyIdName == imgIdName ){
					$(this).addClass("active");
				}
			});
			$('.side_navi02 li a').each(function(){
				var imgIdName = $(this).attr("id");	//a のid取得
				if ( bodyIdName == imgIdName ){
					$(this).addClass("active");
				}
			});
			$('#lnavi_news_month li a').each(function(){
				var imgIdName = $(this).attr("id");	//a のid取得
				if ( bodyIdName == imgIdName ){
					$(this).addClass("active");
				}
			});
		}
	});
}
/* Window Close */
function win_close(){
	window.close();
	return false;
}
/* PopUp */
$(document).ready( function () {
    $('.popup').click(function(){
		return winOpen(this.href, this.rel)
		return false;
    });
});
function winOpen(url, rel) {
	var split = rel.split(',') ;
	var win = window.open(
		url,'popup',
		'width='+ split[0] +',height='+ split[1] +',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	win.focus();
	return false;
};
/* tatget="_blank" */
$(document).ready( function () {
    $('.blank').click(function(){
        window.open(this.href, '_blank');
        return false;
    });
});
/* back button */
function HistoryBack(){ history.back(); return false; }

/* TopFlashLoad */
function TopFlashLoad() { document.write('<embed src="top.swf" loop=true quality=high bgcolor=#ffffffff width="100%" height="420" name="hoehoe" align="middle" type="application/x-shockwave-flash" wmode="transparent"></embed>'); }

$(document).ready(initRollOverImages);
$(document).ready(CurrentNavi);
