<!--

var chaptercount = new Array(0, 50, 40, 27, 36, 34, 24, 21, 4, 31, 24, 22, 25, 29, 36, 10, 13, 10, 42, 150, 31, 12, 8, 66, 52, 5, 48, 12, 14, 3, 9, 1, 4, 7, 3, 3, 3, 2, 14, 4, 28, 16, 24, 21, 28, 16, 16, 13, 6, 6, 4, 4, 5, 3, 6, 4, 3, 1, 13, 5, 5, 3, 5, 1, 1, 1, 22)

var ua = navigator.userAgent
var ps = navigator.productSub
var dom = (document.getElementById)? 1:0
var ie4 = (document.all&&!dom)? 1:0
var ie5 = (document.all&&dom)? 1:0
var doc_root = ((ie5&&ua.indexOf("Opera")<0||ie4||ua.indexOf("Firefox")>0)&&document.compatMode=="CSS1Compat")? "document.documentElement":"document.body"

if(ie4||ie5||ps>=20020823) {
    var ww = "eval(doc_root).clientWidth"
    var wh = "eval(doc_root).clientHeight"
}
else {
    var ww = "window.innerWidth"
    var wh = "window.innerHeight"
}

function setSize() {
	var winH = eval(wh)
    var h = winH - Element.getHeight('header') - Element.getHeight('footer')
    var hh = h - Element.getHeight('slider') - 1
    $('upper').style.height = (hh * 3 / 4) + 'px'
    $('lower').style.height = (hh / 4) + 'px'
    $('left').style.height = h + 'px'
}

var is_slide = 0

function startSlide() {
    is_slide = 1
}

function goSlide(event) {
    if (is_slide) {
        var winH = eval(wh)
        var tx_height = event.clientY - Element.getHeight('header') - Element.getHeight('slider') / 2
        var nt_height = winH - event.clientY - Element.getHeight('footer') - Element.getHeight('slider') / 2
        $('upper').style.height = tx_height + 'px'
        $('lower').style.height = nt_height + 'px'
	}
}

function stopSlide() {
    is_slide = 0
}

function jumpTo(a) {
    window.location = "#" + a
}

function selectBook(b, c, s) {
    s.options.length = 0
    for (i = 0; i < chaptercount[b]; i++) {
        o = new Option(i + 1, i + 1)
        s.options[i] = o
    }
    s.options[c-1].selected = true
}

function jumpSearch(page) {
    if (parseInt(navigator.appVersion) >= 4) {
        if (navigator.userAgent.indexOf("MSIE") > 0) { //IE 4+
            var sel = document.selection.createRange()
            sel.expand("word")
            word = sel.text
            if (word != '') {
				page = page + escape(word)
				window.location = page
            }
        }
        else { // NS4+
            word = window.getSelection()
            if (word != '') {
				page = page + escape(word)
				window.location = page
            }
        }
    }
}

refs_list = new Array()

function refs(id, url) {
    if (refs_list[id])
        overlib('<div id="' + id + '">' + refs_list[id] + '</div>', STICKY, ABOVE)
    else {
        overlib('<div id="' + id + '"><p class="wait">Please wait while your request is being processed.</p></div>', STICKY, ABOVE)
        new Ajax.Request(url, {onComplete: showRefs})
    }
}

function showRefs(originalRequest) {
    t = originalRequest.responseText
    m = t.match('<!-- (.+) -->')
    if (m) {
        refs_list[m[1]] = t
        $(m[1]).innerHTML = t
    }
}

function preloadRefs(id) {
    if (!refs_list[id])
        new Ajax.Request(preload_list[id], {onComplete: loadRefs})
    else
        preloadRefs(id+1)
}

function loadRefs(originalRequest) {
    t = originalRequest.responseText
    m = t.match('<!-- (.+) -->')
    if (m) {
        refs_list[m[1]] = t
// below is for testing purpose only
// delete when development is done
        $('test').innerHTML = m[1]
        if (m[1] < preload_list.length)
            preloadRefs(m[1]*1+1, preload_list[m[1]*1+1])
    }
}

function lightUp(id, dir) {
    strong = id.id.substring(4);
    if (dir == "in") {
        for (i = 1; i < 10; i++) {
            if ($("n_" + i + "_" + strong))
                $("n_" + i + "_" + strong).addClassName("strong");
            if ($("k_" + i + "_" + strong))
                $("k_" + i + "_" + strong).addClassName("strong");
            if ($("s_" + i + "_" + strong))
                $("s_" + i + "_" + strong).addClassName("strong");
            if ($("h_" + i + "_" + strong))
                $("h_" + i + "_" + strong).addClassName("strong");
            if ($("g_" + i + "_" + strong))
                $("g_" + i + "_" + strong).addClassName("strong");
        }
    }
    else {
        for (i = 1; i < 10; i++) {
            if ($("n_" + i + "_" + strong))
                $("n_" + i + "_" + strong).removeClassName("strong");
            if ($("k_" + i + "_" + strong))
                $("k_" + i + "_" + strong).removeClassName("strong");
            if ($("s_" + i + "_" + strong))
                $("s_" + i + "_" + strong).removeClassName("strong");
            if ($("h_" + i + "_" + strong))
                $("h_" + i + "_" + strong).removeClassName("strong");
            if ($("g_" + i + "_" + strong))
                $("g_" + i + "_" + strong).removeClassName("strong");
        }
    }
}

//-->
