document.write("<link rel=\"shortcut icon\" href=\"\/cbbc\/images\/favicon.ico\" type=\"image\/x-icon\" \/>");

/* menu fns */

var numOfItems = 5;

function toggleItems(myNum) {
  closeAllItems(myNum);
  if (document.getElementById("item"+myNum).style.display != 'block') {
     document.getElementById("groupimg"+myNum).src = '/cbbc/images/arw_nw_brown.gif';
     document.getElementById("group"+myNum).className = 'groupon';
     document.getElementById("item"+myNum).style.display = 'block'; 
  } else {
     document.getElementById("groupimg"+myNum).src = '/cbbc/images/arw_se_brown.gif';
     document.getElementById("group"+myNum).className = 'groupoff';
     document.getElementById("item"+myNum).style.display = 'none' 
  }
}

function closeAllItems(myNum) {
  for (var i=1; i<=numOfItems; i++) {
    num = getNum(i);
    if (myNum != num) {
        document.getElementById("groupimg"+num).src = '/cbbc/images/arw_se_brown.gif';
        document.getElementById("group"+num).className = 'groupoff';
        document.getElementById("item"+num).style.display = 'none';
    }
  }
}

function hoverItem(myNum) {
  if (document.getElementById("item"+myNum).className != 'itemhover') {
    document.getElementById("item"+myNum).className = 'itemhover'
  } else {
    document.getElementById("item"+myNum).className = 'itemoff'
  }
}

function getNum(i) {
  if (i < 10) {
      return "0"+i
    } else {
      return "" +i
    }
}

/* banner fns */

function togglePoster(myPoster) {
  if (document.getElementById("bigpic").style.visibility != 'visible') {
    document.getElementById("expcolbutton").src='/cbbc/images/colbutton.gif';
    document.getElementById("bigpic").style.visibility='visible';
  } else {
    document.getElementById("expcolbutton").src='/cbbc/images/expbutton.gif';
    document.getElementById("bigpic").style.visibility='hidden';
  }
}

/* std fns */

function toggleDisplay(me) {
  if (document.getElementById(me).style.display != 'none') {
    document.getElementById(me).style.display = 'none';
  } else {
    document.getElementById(me).style.display = 'block';
  }
}

function toggleDisplayInline(me) {
  if (document.getElementById(me).style.display != 'none') {
    document.getElementById(me).style.display = 'none';
  } else {
    document.getElementById(me).style.display = 'inline';
  }
}

/* printer version */

function togglePrinter() {
  if (document.getElementById("onleft").style.display != 'none') {
    document.getElementById("onleft").style.display='none';
    document.getElementById("onright").style.left='0%';
    document.getElementById("onright").style.width='100%';
    document.getElementById("headerright").style.display='none';
    document.getElementById("bigpic").style.visibility='hidden';
    document.getElementById("printinginfo").style.display='block';
  } else {
    document.getElementById("onleft").style.display='block';
    document.getElementById("onright").style.left='20%';
    document.getElementById("onright").style.width='80%';
    document.getElementById("headerright").style.display='block';
    document.getElementById("printinginfo").style.display='none';
  }
}

/* bible books array */
function getBibleBook(versionFrom, versionTo, versionIn) {
  var bookNumber;
  var engListFull = new Array();
  engListFull[0] = 'Genesis';
  engListFull[1] = 'Exodus';
  engListFull[2] = 'Leviticus';
  engListFull[3] = 'Numbers';
  engListFull[4] = 'Deuteronomy';
  engListFull[5] = 'Joshua';
  engListFull[6] = 'Judges';
  engListFull[7] = 'Ruth';
  engListFull[8] = '1 Samuel';
  engListFull[9] = '2 Samuel';
  engListFull[10] = '1 Kings';
  engListFull[11] = '2 Kings';
  engListFull[12] = '1 Chronicles';
  engListFull[13] = '2 Chronicles';
  engListFull[14] = 'Ezra';
  engListFull[15] = 'Nehemiah';
  engListFull[16] = 'Esther';
  engListFull[17] = 'Job';
  engListFull[18] = 'Psalms';
  engListFull[19] = 'Proverbs';
  engListFull[20] = 'Ecclesiastes';
  engListFull[21] = 'Song of Solomon';
  engListFull[22] = 'Isaiah';
  engListFull[23] = 'Jeremiah';
  engListFull[24] = 'Lamentations';
  engListFull[25] = 'Ezekiel';
  engListFull[26] = 'Daniel';
  engListFull[27] = 'Hosea';
  engListFull[28] = 'Joel';
  engListFull[29] = 'Amos';
  engListFull[30] = 'Obadiah';
  engListFull[31] = 'Jonah';
  engListFull[32] = 'Micah';
  engListFull[33] = 'Nahum';
  engListFull[34] = 'Habakkuk';
  engListFull[35] = 'Zephaniah';
  engListFull[36] = 'Haggai';
  engListFull[37] = 'Zechariah';
  engListFull[38] = 'Malachi';
  engListFull[39] = 'Matthew';
  engListFull[40] = 'Mark';
  engListFull[41] = 'Luke';
  engListFull[42] = 'John';
  engListFull[43] = 'Acts';
  engListFull[44] = 'Romans';
  engListFull[45] = '1 Corinthians';
  engListFull[46] = '2 Corinthians';
  engListFull[47] = 'Galatians';
  engListFull[48] = 'Ephesians';
  engListFull[49] = 'Philippians';
  engListFull[50] = 'Colossians';
  engListFull[51] = '1 Thessalonians';
  engListFull[52] = '2 Thessalonians';
  engListFull[53] = '1 Timothy';
  engListFull[54] = '2 Timothy';
  engListFull[55] = 'Titus';
  engListFull[56] = 'Philemon';
  engListFull[57] = 'Hebrews';
  engListFull[58] = 'James';
  engListFull[59] = '1 Peter';
  engListFull[60] = '2 Peter';
  engListFull[61] = '1 John';
  engListFull[62] = '2 John';
  engListFull[63] = '3 John';
  engListFull[64] = 'Jude';
  engListFull[65] = 'Revelation';
                                         
  var engListShort = new Array();
  engListShort[0] = 'Ge';
  engListShort[1] = 'Ex';
  engListShort[2] = 'Le';
  engListShort[3] = 'Nu';
  engListShort[4] = 'De';
  engListShort[5] = 'Jos';
  engListShort[6] = 'Jud';
  engListShort[7] = 'Ru';
  engListShort[8] = '1Sa';
  engListShort[9] = '2Sa';
  engListShort[10] = '1Ki';
  engListShort[11] = '2Ki';
  engListShort[12] = '1Ch';
  engListShort[13] = '2Ch';
  engListShort[14] = 'Ezr';
  engListShort[15] = 'Ne';
  engListShort[16] = 'Es';
  engListShort[17] = 'Job';
  engListShort[18] = 'Ps';
  engListShort[19] = 'Pr';
  engListShort[20] = 'Ec';
  engListShort[21] = 'So';
  engListShort[22] = 'Isa';
  engListShort[23] = 'Jer';
  engListShort[24] = 'La';
  engListShort[25] = 'Eze';
  engListShort[26] = 'Da';
  engListShort[27] = 'Ho';
  engListShort[28] = 'Joe';
  engListShort[29] = 'Am';
  engListShort[30] = 'Ob';
  engListShort[31] = 'Jon';
  engListShort[32] = 'Mic';
  engListShort[33] = 'Na';
  engListShort[34] = 'Hab';
  engListShort[35] = 'Zep';
  engListShort[36] = 'Hag';
  engListShort[37] = 'Zec';
  engListShort[38] = 'Mal';
  engListShort[39] = 'Mt';
  engListShort[40] = 'Mr';
  engListShort[41] = 'Lu';
  engListShort[42] = 'Joh';
  engListShort[43] = 'Ac';
  engListShort[44] = 'Ro';
  engListShort[45] = '1Co';
  engListShort[46] = '2Co';
  engListShort[47] = 'Ga';
  engListShort[48] = 'Eph';
  engListShort[49] = 'Php';
  engListShort[50] = 'Col';
  engListShort[51] = '1Th';
  engListShort[52] = '2Th';
  engListShort[53] = '1Ti';
  engListShort[54] = '2Ti';
  engListShort[55] = 'Tit';
  engListShort[56] = 'Phm';
  engListShort[57] = 'Heb';
  engListShort[58] = 'Jas';
  engListShort[59] = '1Pe';
  engListShort[60] = '2Pe';
  engListShort[61] = '1Jo';
  engListShort[62] = '2Jo';
  engListShort[63] = '3Jo';
  engListShort[64] = 'Jude';
  engListShort[65] = 'Re';
  
  if (versionFrom == '1') { for (var i = 0; i < engListFull.length; i++)  { if (engListFull[i] ==versionIn) { bookNumber = i; } } }
  if (versionFrom == '2') { for (var i = 0; i < engListShort.length; i++) { if (engListShort[i]==versionIn) { bookNumber = i; } } }

  if (versionTo   == '1') { return engListFull[bookNumber] }
  if (versionTo   == '2') { return engListShort[bookNumber]}
}

/* BibleGateway Passage Lookup  */
function bgpl(passage, version) {
  if (version == null) {
    version = 22; // 22 = Traditional Union Version
  }
  // 20100306: biblegateway now stopped
  // self.location = 'http://www.biblegateway.com/passage/?search=' + passage + ';&version=' + version + ';';
  alert("抱歉，聖經連結尚未更新。");
}

/* CBOL passage lookup */
function CBOL(chineses, chap, sec, chap2, sec2, version1) {
  var url;
  var tabflag = '1';
  if (version1 == null) {
    version1 = 'unv'; // unv = Union Version
  }
  // convert full english book to short english book
  chineses = getBibleBook('1', '2', chineses);
  url = 'http://bible.fhl.net/new/read.php?TABFLAG=1&chineses=' + chineses + '&chap=' + chap + '&sec=' + sec + '&version1=' + version1;
  if ((chap2 != null) && (sec2 != null)) {
    url = url + '&chap2=' + chap2 + '&sec2=' + sec2;
  }
  window.open(url,'scripture');
  //alert("抱歉，聖經連結正在更新。");
}