// JavaScript Document

function writeMainNavi()
{
	var str = "";
	if (document.MAIN_NAVI) {
		for (var i=0;i<document.MAIN_NAVI.length;i++) {
			if (i == document.CURRENT_DIVISION) {
				var btn = new ButtonComponent(document.MAIN_NAVI[i][0],document.MAIN_NAVI[i][2],document.MAIN_NAVI[i][2],"",document.MAIN_NAVI[i][4]);
			} else {
				var btn = new ButtonComponent(document.MAIN_NAVI[i][0],document.MAIN_NAVI[i][1],document.MAIN_NAVI[i][2],document.MAIN_NAVI[i][3],document.MAIN_NAVI[i][4]);
			}
			str += btn.getButton();
			if (document.MAIN_NAVI[i][5])
				str += "<br>";
		}
	}
	writeHTML(findObj("mainNavi"),str);
}


function writeSecondaryNavi()
{
	var str = "";
	if (document.SEC_NAVI) {
		for (var i=0;i<document.SEC_NAVI.length;i++) {
			var btn = new ButtonComponent(document.SEC_NAVI[i][0],document.SEC_NAVI[i][1],document.SEC_NAVI[i][2],document.SEC_NAVI[i][3],document.SEC_NAVI[i][4]);
			str += btn.getButton() + "<img src=\"" + document.DIRPATH["img"] + "spacer.gif\" width=\"1\" height=\"1\">";
		}
	}
	writeHTML(findObj("secondaryNavi"),str);
}


function writeLocalNavi()
{
	var str = "";
	if (document.LOCAL_NAVI) {
		for (var i=0;i<document.LOCAL_NAVI.length;i++) {
			if (document.CURRENT_SECTION == i) {
				var btn = new ButtonComponent(document.LOCAL_NAVI[i][0],document.LOCAL_NAVI[i][2],document.LOCAL_NAVI[i][2],"",document.LOCAL_NAVI[i][4]);
			} else {
				var btn = new ButtonComponent(document.LOCAL_NAVI[i][0],document.LOCAL_NAVI[i][1],document.LOCAL_NAVI[i][2],document.LOCAL_NAVI[i][3],document.LOCAL_NAVI[i][4]);
			}
			str += btn.getButton();
			if (document.LOCAL_NAVI[i][5])
				str += "<br>";
		}
	}
	writeHTML(findObj("localNavi"),str);
}


function writePageNavi()
{
	var str = "";
	var back_str = "";
	var next_str = "";
	
	if (document.PAGE_NAVI) {
		for (var i=0;i<document.PAGE_NAVI.length;i++) {
			if (window.location.pathname == document.PAGE_NAVI[i]) {
				str += "<span class=\"lightgreen\">" + (i+1).toString() + "</span>";
				if (i > 0)
					back_str = "<a href=\"" + document.PAGE_NAVI[i-1] + "\">&lt;&lt;&nbsp;back</a>&nbsp;|&nbsp;";
				if (i!=document.PAGE_NAVI.length-1)
					next_str = "<a href=\"" + document.PAGE_NAVI[i+1] + "\">next&nbsp;&gt;&gt;</a>";
			} else {
				str += "<a href=\"" + document.PAGE_NAVI[i] + "\">" + (i+1).toString() + "</a>";
			}
			str += "&nbsp;|&nbsp;";
		}
	}
	str = back_str + str;
	str += next_str;
	
	writeHTML(findObj("pageNavi"),str);
}


function writeNavigations()
{
	writeMainNavi();
	writeSecondaryNavi();
	writeLocalNavi();
	writePageNavi();
	writeHTML(findObj("CopyRight"),document.COPYRIGHT);
}

//
function WindowOpen(link) {
	NewWin = window.open(link, 'win','status=yes,scrollbars=no,resizable=no,width=420,height=720');
	NewWin.focus();
}