﻿
function ViewList(t, mini, minit) {
	window.location = "class.asp?top=" + (t + 1) +
		"&mini=" + (mini + 1) +
		"&minititle=" + escape(minit);
}
function _IMG (src) {
	var img = new Image();
	img.src = src;
	return img;
}

var HYMN = [
	{
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_1.gif"),
			alt: "예배 1-72"
		},
		items: [
			{title:"송영", range:"1 - 8"},
			{title:"찬양과 경배", range:"9 - 55"},
			{title:"주일", range:"56 - 58"},
			{title:"폐회", range:"59 - 62"},
			{title:"아침과 저녁", range:"63 - 68"},
			{title:"헌금", range:"69 - 72"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_2.gif"),
			alt: "성부 73-80"
		},
		items: [
			{title:"창조와 섭리", range:"73 - 80"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_3.gif"),
			alt: "성자 81-168"
		},
		items: [
			{title:"예수그리스도", range:"81 - 103"},
			{title:"강림", range:"104 - 107"},
			{title:"탄생", range:"108 - 126"},
			{title:"생애", range:"127 - 133"},
			{title:"고난", range:"134 - 148"},
			{title:"부활", range:"149 - 160"},
			{title:"재림", range:"161 - 168"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_4.gif"),
			alt: "성령 169-181"
		},
		items: [
			{title:"성령", range:"169 - 181"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_5.gif"),
			alt: "구원 182-219"
		},
		items: [
			{title:"속죄", range:"182 - 202"},
			{title:"거듭남", range:"203 - 209"},
			{title:"성결", range:"210 - 219"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_6.gif"),
			alt: "천국 220-233"
		},
		items: [
			{title:"천국", range:"220 - 233"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_7.gif"),
			alt: "성경 234-241"
		},
		items: [
			{title:"성경", range:"234 - 241"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_8.gif"),
			alt: "교회 242-280"
		},
		items: [
			{title:"하나님 나라", range:"242 - 250"},
			{title:"전도와 선교", range:"251 - 277"},
			{title:"친교와 봉사", range:"278 - 280"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_9.gif"),
			alt: "성례와 예식 281-295"
		},
		items: [
			{title:"성찬", range:"281 - 285"},
			{title:"혼례", range:"286 - 288"},
			{title:"장례", range:"289 - 295"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_10.gif"),
			alt: "절기와 성례 296-312"
		},
		items: [
			{title:"신년", range:"296 - 297"},
			{title:"어린이", range:"298 - 301"},
			{title:"청년", range:"302 - 303"},
			{title:"어버이", range:"304 - 304"},
			{title:"가정", range:"305 - 305"},
			{title:"감사절", range:"306 - 312"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_11.gif"),
			alt: "성도의 생애1 313-403"
		},
		items: [
			{title:"부르심과 영접", range:"313 - 329"},
			{title:"회개와 사죄", range:"330 - 339"},
			{title:"신뢰와 확신", range:"340 - 345"},
			{title:"소명과 헌신", range:"346 - 362"},
			{title:"시련과 극복", range:"363 - 367"},
			{title:"봉사와 충성", range:"368 - 383"},
			{title:"분투와 승리", range:"384 - 402"},
			{title:"은혜와 사랑", range:"403 - 418"},
			{title:"인도와 보호", range:"419 - 463"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_12.gif"),
			alt: "성도의 교제2 464-545"
		},
		items: [
			{title:"평안과 위로", range:"464 - 478"},
			{title:"기도와 간구", range:"479 - 487"},
			{title:"축복과 감사", range:"488 - 489"},
			{title:"주와 동행", range:"490 - 504"},
			{title:"주를 본받음", range:"505 - 508"},
			{title:"제자의 길", range:"509 - 522"},
			{title:"성도의 교제", range:"523 - 527"},
			{title:"신유", range:"528 - 530"},
			{title:"소망", range:"531 - 545"}
		]
	}, {
		title: {
			img: _IMG("http://img.cbs.co.kr/cbs/christian/bible/top_13.gif"),
			alt: "송영과 영창 545-558"
		},
		items: [
			{title:"송영과 영창", range:"546 - 558"}
		]
	}
];

function DrawList(tbl, sIdx, eIdx) {
	var oRow, oCell, oImg, oTable, oCol, oColGroup;
	var intRowIndex = 0;

	for (var i = sIdx; i < eIdx; i++) {
		// Header
		oRow = tbl.insertRow(intRowIndex * 3);
		oCell = oRow.insertCell(0);
		oImg = oCell.appendChild(document.createElement("img"));
		oImg.src = HYMN[i].title.img.src;
		oImg.alt = HYMN[i].title.alt;
		
		// Body
		oRow = tbl.insertRow(intRowIndex * 3 + 1);
		oCell = oRow.insertCell(0);
		oCell.align = "center";
		oCell.style.background = "url(http://img.cbs.co.kr/cbs/christian/bible/tb_body.gif)";
		
		oTable = oCell.appendChild(document.createElement("table"));
		oTable.width = "245";
		oTable.cellSpacing = 0;
		oTable.cellPaddnig = 0;
//		oTable.style.border = "solid 1px red";
		
		oColGroup = oTable.appendChild(document.createElement("colgroup"));
		
		oCol = oColGroup.appendChild(document.createElement("col"));
		oCol.width = "20";
		oCol = oColGroup.appendChild(document.createElement("col"));
		oCol.width = "165";
		oCol = oColGroup.appendChild(document.createElement("col"));
//		oCol.width = "60";
		
		for (var j = 0; j < HYMN[i].items.length; j++) {
			oRow = oTable.insertRow(j);
			oRow.style.height = "18px";
			oRow.style.cursor = "pointer";
			oRow.style.background = j % 2 == 0 ? "#efefef" : "White";
			oRow.align = "left";
			oRow.data = i.toString() + "," + j.toString() + "," + HYMN[i].items[j].title;
			
			oRow.onclick = function () {
				var data = this.data.split(",");
				ViewList(
					parseInt(data[0]), 
					parseInt(data[1]),
					HYMN[data[0]].items[data[1]].title
				);
			}
			oCell = oRow.insertCell(0);
			oCell.innerHTML = "&nbsp;";
			
			oCell = oRow.insertCell(1);
			oCell.innerHTML = HYMN[i].items[j].title;

			oCell = oRow.insertCell(2);
			oCell.innerHTML = HYMN[i].items[j].range;
		}
		
		// Footer
		oRow = tbl.insertRow(intRowIndex * 3 + 2);
		oCell = oRow.insertCell(0);
		oImg = oCell.appendChild(document.createElement("img"));
		oImg.src = "http://img.cbs.co.kr/cbs/christian/bible/tb_bottom.gif";
		oImg.alt = "";
		
		oCell.appendChild(document.createElement("br"));
		oCell.appendChild(document.createElement("br"));
		intRowIndex++;
	}
}
