jQuery(document).ready(function($) {
//ロールオーバー
	var postfix = '_on';
	$('.over').not('[src*="'+ postfix +'."]').each(function() {

		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});


//スムーズスクロール
/*	$('a[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}, 800);
				return false;
			}
		}
	});
*/


//ファンクションの起動
	js_window_open();

});

/*	//	PAGE PRINT
-----------------------------------------------------------------------------------------------------------------*/
function js_page_print(){
	window.print();
	return false
}
/*	//	ウィンドウを閉じる - a要素にclass="js_window_close"でウィンドウを閉じる
-----------------------------------------------------------------------------------------------------------------*/
function js_window_close(){
	window.close();
	return false;
}
/*	//	ポップアップ - a要素にclass="js_window_open-width-height"でポップアップ
-----------------------------------------------------------------------------------------------------------------*/
function js_window_open(){
	var js_para = null;
	// js_para[0] = width
	// js_para[1] = height
	// js_para[2] = window.name
	$('a[class^="js_window_open"], area[class^="js_window_open"]').each(function(index){
		$(this).click(function(){
			var wo = null;
			// get window width & height
			js_para = $(this).attr('class').match(/[0-9]+/g);
			// get window.name
			window.name ? js_para[2] = window.name+'_' : js_para[2] = ('');
			wo = window.open(this.href, js_para[2]+'popup'+index,'width='+js_para[0]+',height='+js_para[1]+',scrollbars=yes');
			wo.focus();
			return false;
		});
	});
}
/*	//	js accordion
-----------------------------------------------------------------------------------------------------------------*/

window.onload = function() {
	var maxh = $('#theColdDisc').innerHeight();
	maxh = (maxh < $('#pastAward').innerHeight())? $('#pastAward').innerHeight() : maxh;
	maxh = (maxh < $('#jgda').innerHeight())? $('#jgda').innerHeight() : maxh;
	$("dt#acNav01, dt#acNav02, dt#acNav03, #theColdDisc, #pastAward, #jgda").css("height",maxh);

	var flag = true;
    $("#theColdDisc, #pastAward").css({"width":"0px","display":"none"})
    $("dt#acNav03 span").addClass("selected");
    $("dt#acNav01, dt#acNav02, dt#acNav03").click(function(){
		if(flag){
			if($("+dd",this).css("width")=="0px"){
				flag = false;
				$("dt:has(.selected) +dd").animate({"width":"0px"},600);
				$("+dd",this).animate({"width":"925px"},600,function(){flag = true});
				$("dt  span").removeClass("selected");
				$("span",this).addClass("selected");
			}
		}
    }).mouseover(function(){
        $(this).addClass("hover");
    }).mouseout(function(){
        $(this).removeClass("hover");
    });
    $(".header > ul li:not(.noSlide) a, .headerTop > ul a").click(function(event){
    	event.preventDefault();
    	var targetid = $(this).attr('href');
    	var targetelm = $(targetid);
    	// console.log(targetelm);
		if(flag){
			if($(targetelm).css("width")=="0px"){
				flag = false;
				$("dt:has(.selected) +dd").animate({"width":"0px"},600);
				$(targetelm).animate({"width":"925px"},600,function(){flag = true});
				$("dt  span").removeClass("selected");
				$(targetelm).prev().find("span").addClass("selected");
			}
		}
   	});
};

/*	//	Firefox用CSSを呼び出し（ルート相対パスなのでサーバー上でのみ）
-----------------------------------------------------------------------------------------------------------------*/
var firefox = (navigator.userAgent.indexOf("Firefox") != -1)? true : false; 
if(firefox) document.write('<link rel="stylesheet" type="text/css" media="print" href="/common/css/fx_print.css" />');



