/**
 * [関数名] IncludeFiles
 * [機　能] 外部HTMLインクルード
 * [説　明] 外部HTMLファイルを<DIV>タグ部にインクルードする
 *          
 *
 * @param  integer elements    DIVタグのID
 * @param  integer FileNames   外部ファイルHTML
*/
function IncludeFiles(elements,FileNames) {
	new Ajax.Request(FileNames , {
	method: 'get', onComplete: displayData });
	function displayData(responseHttpObj){
		var InSource = responseHttpObj.responseText;
		$(elements).innerHTML = InSource;
	}
}
/**
 * [関数名] ZeroFormat
 * [機　能] ゼロ埋め
 * [説　明] 数値が指定した桁数になるまで数値の先頭をゼロで埋める
 *          例：document.write(ZeroFormat(1,4)); //0001
 *
 * @param  integer num    数値
 * @param  integer max    桁数
 * @return integer tmpS   ゼロ埋め後の数値
*/
function ZeroFormat(num,max){
    var tmp=""+num;
    while(tmp.length<max){
        tmp="0"+tmp;
    }
    return tmp;
}

/* Young Guitar用 */
function makeImageTagYoungGuitar(divId) {
	return "<TABLE><TR><TD style='background-image : url(data/YG"+divId+".jpg); background-repeat : no-repeat;background-position : center center'><IMG height='300' hspace='75' src='images/spacer.gif'></TR></TABLE>";
}


/* Young Guitar用 */
function makeDivTagYoungGuitar(divId) {
	if (document.getElementById(divId) != null){
		document.getElementById(divId).oncontextmenu = function(){ return false; }
		document.getElementById(divId).innerHTML =makeImageTagYoungGuitar(divId);
	}
}



/* 汎用 */
function makeImageTag(divId) {
	return "<TABLE><TR><TD style='background-image : url(data/"+divId+".jpg); background-repeat : no-repeat;background-position : center center'><IMG height='300' hspace='75' src='images/spacer.gif'></TR></TABLE>";
}


/* 汎用 */
function makeDivTag(divId) {
	if (document.getElementById(divId) != null){
		document.getElementById(divId).oncontextmenu = function(){ return false; }
		document.getElementById(divId).innerHTML =makeImageTag(divId);
	}
}


window.onload = function(){
	IncludeFiles("HEADER","Header.html");
	IncludeFiles("HEADERJIGOKU","HeaderJigoku.html");
	IncludeFiles("HEADER100YG","Header100YG.html");
	IncludeFiles("HEADEROKEMETAL","HeaderOkemetal.html");

	IncludeFiles("LEFT","Left.html");
	IncludeFiles("RIGHT","Right.html");
	IncludeFiles("FOOTER","Footer.html");
	IncludeFiles("RIGHT2008","Right2008.html");
	IncludeFiles("RIGHT2007","Right2007.html");
	IncludeFiles("RIGHT2006","Right2006.html");
	IncludeFiles("RIGHTJIGOKU","RightJigoku.html");


	/* Young Guitar用 */
	for (i = 2010; i >= 1978 ; i--){
		for (j = 12; j >= 1 ; j--){
			divId = i + '_' + ZeroFormat(j,2);
			makeDivTagYoungGuitar(divId);
		}
	}

	/*100%用*/
	for (i = 1; i <= 21 ; i++){
			divId = ZeroFormat(i,2);
			//document.write(divId);
			makeDivTag('YG100_'+divId);
	}

	/*地獄用*/
	for (i = 1; i <= 6 ; i++){
			divId = ZeroFormat(i,2);
			//document.write(divId);
			makeDivTag('JIGOKU_'+divId);
	}

	/*オケメタル用*/
	for (i = 1; i <= 12 ; i++){
			divId = ZeroFormat(i,2);
			//document.write(divId);
			makeDivTag('OKEMETAL_'+divId);
	}

	/*EXTRA用*/
	for (i = 0; i <= 30 ; i++){
			divId = ZeroFormat(i,2);
			//document.write(divId);
			makeDivTag('EXTRA_'+divId);
	}

	/*ULTRA EXTRA用*/
	for (i = 1; i <= 12 ; i++){
			divId = ZeroFormat(i,2);
			//document.write(divId);
			makeDivTag('ULTRAEXTRA_'+divId);
	}


}