
$(function(){
	/* ============================================================
	前のページへ戻る
	============================================================ */
	$('div#left_linkback')
		.click(function(event){
			history.back();
			return false;
		})
	$('div#linkback')
		.click(function(event){
			history.back();
			return false;
		})
	
	
	/* ============================================================
	画像リンクとテキストリンクを同期させる
	============================================================ */
	$('div.rollover_imgtext')
		.each(function(event){
			$(this).find('img.rollover_imgtext')
				.mouseover(function(event){
					$(this).css('cursor','pointer');
					var parentDiv = $(this).parents('div.rollover_imgtext');
					var childImg = $(parentDiv[0]).find('img.rollover_imgtext');
					$(childImg)
						.each(function(event){
							$(this)
								.css('opacity', '0.5')
								.css('filter', 'Alpha(opacity=50)');
						})
					var childLink = $(parentDiv[0]).find('a.rollover_imgtext');
					$(childLink[0])
						.css('text-decoration', 'none');
				})
				.mouseout(function(event){
					$(this).css('cursor','auto');
					var parentDiv = $(this).parents('div.rollover_imgtext');
					var childImg = $(parentDiv[0]).find('img.rollover_imgtext');
					$(childImg)
						.each(function(event){
							$(this)
								.css('opacity', '1')
								.css('filter', 'Alpha(opacity=100)');
						})
					var childLink = $(parentDiv[0]).find('a.rollover_imgtext');
					$(childLink[0])
						.css('text-decoration', 'underline');
				})
				.click(function(event){
					var parentDiv = $(this).parents('div.rollover_imgtext');
					var childLink = $(parentDiv[0]).find('a.rollover_imgtext');
					location = $(childLink[0]).attr('href');
				})
			$(this).find('a.rollover_imgtext')
				.mouseover(function(event){
					$(this)
						.css('text-decoration', 'none');
					var parentDiv = $(this).parents('div.rollover_imgtext');
					var childImg = $(parentDiv[0]).find('img.rollover_imgtext');
					$(childImg)
						.each(function(event){
							$(this)
								.css('opacity', '0.5')
								.css('filter', 'Alpha(opacity=50)');
						})
				})
				.mouseout(function(event){
					$(this)
						.css('text-decoration', 'underline');
					var parentDiv = $(this).parents('div.rollover_imgtext');
					var childImg = $(parentDiv[0]).find('img.rollover_imgtext');
					$(childImg)
						.each(function(event){
							$(this)
								.css('opacity', '1')
								.css('filter', 'Alpha(opacity=100)');
						})
				})
		})
	
	
});

/*------------------------------------------------------------
 *						POPUP OF CODE
/*-----------------------------------------------------------*/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



/*------------------------------------------------------------
 *						acordion
/*-----------------------------------------------------------*/

window.onload = defaultClass;


function expand(t) {
    for (var i=0; i<5; i++) {
        var t = t.parentNode

        if (t.className=='hide') {
            t.className = 'show';
            break;
        } else if (t.className=='show') {
            t.className = 'hide';
            break;
        }
    }
}

function defaultClass() {
    var e = document.getElementsByTagName('*');

    for(var i=0; i<e.length; i++) {
        if(e[i].getAttribute('class') == 'show' || e[i].getAttribute('className') == 'show') {
            e[i].className = 'hide';
        }
    }
}


/* ---------------------------------------------------------------
 * jquery-auto-height.js
 * Copyright (c) 2010 Tomohiro Okuwaki (http://www.tinybeans.net/blog/)
 * Licensed under MIT Lisence:
 * http://www.opensource.org/licenses/mit-license.php
--------------------------------------------------------------- */
//BLOCK HEIGHT
$(document).ready(function() {
	$.fn.autoHeight = function(options){
		var op = $.extend({
		
			column  : 0,
			clear   : 0,
			height  : 'minHeight',
			reset   : '',
			descend : function descend (a,b){ return b-a; }
		
		},options || {}); // optionsに値があれば上書きする

		var self = $(this);
		var n = 0,
			hMax,
			hList = new Array(),
			hListLine = new Array();
			hListLine[n] = 0;

		// 要素の高さを取得
		self.each(function(i){
			if (op.reset == 'reset') {
				$(this).removeAttr('style');
			}
			var h = $(this).height();
			hList[i] = h;
			if (op.column > 1) {
				// op.columnごとの最大値を格納していく
				if (h > hListLine[n]) {
					hListLine[n] = h;
				}
				if ( (i > 0) && (((i+1) % op.column) == 0) ) {
					n++;
					hListLine[n] = 0;
				};
			}
		});
		// 取得した高さの数値を降順に並べ替え
		hList = hList.sort(op.descend);
		hMax = hList[0];
		
		// 高さの最大値を要素に適用
		var browser = $.browser.version;
		if (op.column > 1) {
			for (var j=0; j<hListLine.length; j++) {
				for (var k=0; k<op.column; k++) {
					if (browser == '6.0') {
						self.eq(j*op.column+k).height(hListLine[j]);
						if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
					} else {
						self.eq(j*op.column+k).css(op.height,hListLine[j]);
						if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
					}
				}
			}
		} else {
			if (browser == '6.0') {
				self.height(hMax);
			} else {
				self.css(op.height,hMax);
			}
		}
	};
});

$(window).load(function(){
	$(".goo_contents02_inner > div > div").autoHeight({column: 4});
});


/*------------------------------------------------------------
 *						pagetop
/*-----------------------------------------------------------*/
$(document).ready(function() {
	$("#pagetop a").click(function() {
		var speed = 1200;
		var href= $(this).attr('href');
		var target = $(href == '#' || href == '' ? 'html' : href);
		var position = target.offset().top;
		$($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'easeOutQuint');
		return false;
	});
});



/*------------------------------------------------------------
 *						fs_contents
/*-----------------------------------------------------------*/
$(window).load(function() {
	var fsFlg = 1;
	//$('div#fs_contents').css('display', 'none');
	
	$('p#footer_btn_sitemap a')
		.click(function(event){
			if( fsFlg ){
				$('div#fs_contents').css('display', 'block');
				fsFlg = 0;
			} else{
				$('div#fs_contents').css('display', 'none');
				fsFlg = 1;
			}
		})
});

/*------------------------------------------------------------
 *						layerd navi
/*-----------------------------------------------------------*/
$(document).ready(function() {
	
	//---init
	var lay = $('#layerd_navi');
	var layBody = $('#layerd_navi .body');
	var layBtn = $('#lay-btn');
	var layBtnImg = $('#lay-btn img');
	//layBody.css('height', 0);
	
	
	//---toggle
	$(layBtn).toggle(
		function(){
			layBody.animate({height: '438px'}, 600, 'easeOutCubic');
			$(layBtnImg).attr('src', '/common/images/layer/lay-head_menu-close.gif');
			return false;
		},
		function(){
			layBody.animate({height: '0'}, 600, 'easeOutCubic');
			$(layBtnImg).attr('src', '/common/images/layer/lay-head_menu-open.gif');
			return false;
		}
	);
});
$(window).load(function() {
	var lay = $('#layerd_navi');
	setTimeout(function(){
		lay.animate({marginBottom: '0px'}, 600, 'easeOutCubic');
	}, 500)
});
