var pages = new Array(
'sitem01'
)

var sections = new Array(
'int',
'abo',
'sit',
'faq'
)

var subSections = new Array(
'1 sitem01'
)

var subThemes_c = new Array(
'ºô¯¸¦a¹Ï'
)

var subThemes_e = new Array(
'Site map'
)

var currPage
var currSection      //current section
var fullCurrPage = document.location.toString()
var lang = (fullCurrPage.indexOf('_e.html') == -1)? 0 : 1
var fileExt = (lang == 0)? '_c.html' : '_e.html'
var imageExt = (lang == 0)? '_c.jpg' : '_e.jpg'
var currPageNo = findCurrPageNo()
var currSectionNo = findCurrSection()

function findCurrPageNo() {
	var bi = fullCurrPage.lastIndexOf('/')
	var ei = fullCurrPage.indexOf(fileExt)
	currPage = fullCurrPage.substring(bi+1, ei)
	for (var i = 0; i < pages.length; i++) {
		if (currPage == pages[i]) break
	}
	return i
}

function findCurrSection() {
	var ci = fullCurrPage.lastIndexOf('/')
	currSection= fullCurrPage.substring(ci-3, ci)   //example: abo folder
	for (var j = 0; j < sections.length; j++) {
		if (currSection == sections[j]) break
	}
	return j
}

function goFirstPage() {
	document.location = pages[0] + fileExt
}

function goLastPage() {
	document.location = pages[pages.length-1] + fileExt
}

function goPrevPage() {
	var prevPageNo = currPageNo - 1
	if (prevPageNo < 0) prevPageNo = pages.length - 1
	document.location =  pages[prevPageNo] + fileExt
}

function goNextPage() {
	var nextPageNo = currPageNo + 1
	if (nextPageNo > pages.length - 1) nextPageNo = 0
	document.location = pages[nextPageNo] + fileExt
}

function goUpPage() {
	document.location = '../index' + fileExt
}

function writePageLink() {
	var subTheme, linkName
	document.writeln('<SPAN CLASS="DES">')
	for (var i = 0; i < subSections.length; i++) {
		if (i != 0) document.writeln('<B>&nbsp;|&nbsp;</B>')
		var str = pages[currPageNo]
		 if (subSections[i].match(str)) {
		 		subTheme = (lang == 0) ? subThemes_c[i] : subThemes_e[i]
		 		document.writeln('<SPAN CLASS="COLORHEAD">' + subTheme  + '</SPAN>' )
		 		var sno = subSections[i].substr(0, 1)
		 		var no = parseFloat(sno) + 1
		 		 for ( k = 1; k < no; k++) {
		 		   var b = k.toString()
		 		   if (str.match(b)) {
		 		   document.writeln('<SPAN CLASS="COLORHEAD">[' + b  + ']</SPAN>' )
		 		   } else {
		 		      linkName = subSections[i].substr(2, 6) + k + fileExt
		 		      document.writeln('<A HREF="' + linkName + '">' + k + '</A>')
		 		      }}
		 } else {		
		 		for (var j=0; j < pages.length; j++) {
					var str2 = pages[j]
					var str3 = subSections[i].substr(2, 7)
					if (str2.match(str3)) {
						linkName = pages[j] + fileExt
						subTheme = (lang == 0) ? subThemes_c[i] : subThemes_e[i]
						document.writeln('<A HREF="' + linkName + '">' + subTheme + '</A>')
					} 
				}	   		   
			    }
	}
		
	
	document.writeln('</SPAN>')
}

function writeSectionLink() {    //display section images and highlight present section
	var linkName
	var mainImage = '../images/main' + imageExt
	document.writeln('<SPAN><IMG SRC="'+ mainImage +'">')
	for (var i = 0; i < sections.length; i++) {
		if (i != 0) document.writeln('&nbsp;')
		if (currSectionNo == i) {
			var imageLoc = '../images/' + sections[i] + '2' + imageExt
			document.writeln('<IMG SRC="' + imageLoc + '" BORDER="0">')
		} //else {
			//var imageLink = '../images/' + sections[i] + imageExt
			//linkName = '../' + sections[i] + '/' + sections[i] + '1' + fileExt
			//document.writeln('<A HREF="' + linkName + '"><IMG SRC="' + imageLink + '" BORDER="0"></A>')
		//}
	}
	document.writeln('</SPAN>')
}

function writeTitle() {
	document.write(document.title)
}

var mediaWindow

function openMediaWindow(fileName, w, h) {
	closeMediaWindow()
	w += 20
	h += 80
	var dim = 'HEIGHT=' + h + ',WIDTH=' + w
	mediaWindow = window.open(fileName, 'mediaWin', dim)
}

function closeMediaWindow() {
	if (mediaWindow && !mediaWindow.closed) mediaWindow.close()
}
