/*************************************************************************************
   インフォメーション情報の表示、非表示 関数
   item_spec.html

   注意！protype.jsがver 1.5じゃないとscriptaculousのeffect.toggleが使用できない
   注意！a hrefタグを埋め込んでいるとtargetNode.idを取得できない時がある
   知識！ソースの書き方や構文ミスによって処理速度がかなり異なる（パフォチュ必須）
*************************************************************************************/

var flag_allTables = 0; //全表示、全非表示用フラグ

var month2005Table = $('month2005Table');
var month2006Table = $('month2006Table');
var month2007Table = $('month2007Table');
var month2008Table = $('month2008Table');
var month2009Table = $('month2009Table');
//var month2010Table = $('month2010Table');
//var month2011Table = $('month2011Table');


// インフォメーションテーブルの高さを取得
var getHeight = new Object();
getHeight['month2005Table'] = month2005Table.clientHeight;
getHeight['month2006Table'] = month2006Table.clientHeight;
getHeight['month2007Table'] = month2007Table.clientHeight;
getHeight['month2008Table'] = month2008Table.clientHeight;
getHeight['month2009Table'] = month2009Table.clientHeight;
//getHeight['month2010Table'] = month2010Table.clientHeight;
//getHeight['month2011Table'] = month2011Table.clientHeight;


/*======================*/
/* Load時リスナーセット */
/*======================*/
function setListener(e) {
	Event.observe($('month2005'), 'click', showInfo, false);
	Event.observe($('month2006'), 'click', showInfo, false);
	Event.observe($('month2007'), 'click', showInfo, false);
	Event.observe($('month2008'), 'click', showInfo, false);
	Event.observe($('month2009'), 'click', showInfo, false);
//	Event.observe($('month2010'), 'click', showInfo, false);
//	Event.observe($('month2011'), 'click', showInfo, false);
}

// 全表示、全非表示用 "none" or "block"をセット
function pushAllInfo(display, flag) {
	
	month2005Table.style.display = display;
	month2006Table.style.display = display;
	month2007Table.style.display = display;
	month2008Table.style.display = display;
	month2009Table.style.display = display;
//	month2010Table.style.display = display;
//	month2011Table.style.display = display;

	$('month2005Table').style.height = getHeight['month2005Table'];
		new Effect.toggle('month2005Table', 'slide');

	$('month2006Table').style.height = getHeight['month2006Table'];
		new Effect.toggle('month2006Table', 'slide');

	$('month2007Table').style.height = getHeight['month2007Table'];
		new Effect.toggle('month2007Table', 'slide');

	$('month2008Table').style.height = getHeight['month2008Table'];
		new Effect.toggle('month2008Table', 'slide');

	$('month2009Table').style.height = getHeight['month2009Table'];
		new Effect.toggle('month2009Table', 'slide');

//	$('month2010Table').style.height = getHeight['month2010Table'];
//		new Effect.toggle('month2010Table', 'slide');

//	$('month2011Table').style.height = getHeight['month2011Table'];
//		new Effect.toggle('month2011Table', 'slide');

	flag_allTables = flag;
}

function showInfo(e) {
	var getNode = getTargetNode(e);

	if(getNode.id != 'allTables') {
		// 表示するテーブル
		var pushTables = getNode.id + 'Table';
		$(pushTables).style.height = getHeight[pushTables];
		new Effect.toggle(pushTables, 'slide');
	} else if(flag_allTables == 0) {
		pushAllInfo('none', 1);
	} else if(flag_allTables == 1) {
		pushAllInfo('block', 0);
	}
	return false;
}

// 月別アーカイーブの非表示(デフォルトで"非表示")
month2005Table.style.display = '';
month2006Table.style.display = 'none';
month2007Table.style.display = 'none';
month2008Table.style.display = 'none';
month2009Table.style.display = 'none';
//month2010Table.style.display = 'none';
//month2011Table.style.display = 'none';

/*************************************************************************************
   縦型比較ページのスペック表のテーブル幅を操作する関数
	 スペック表の上のテーブルのサイズをチェックし
	 それと同じ幅にする。
	 if分はアイテムビューでもこの.jsを使っているため
	 縦型比較ページにしかないIDで分岐
*************************************************************************************/
var speconload;
speconload = function(){
	if(document.getElementById('specMain') == undefined){
		
	}else{
		var tableWidth = document.getElementsByTagName('table')[0].offsetWidth;
		document.getElementById('specTables').style.width = tableWidth;
	}
}


var oldonload = window.onload;
if (typeof window.onload != 'function'){
	window.onload = speconload;
} else {
	window.onload = function(){
	oldonload();
	speconload();
	}
}




Event.observe(window, 'load', setListener, false);
