var scriptureWindow;
var mstrBook = "";
var mstrChapter = "";
var mstrVerse = "";
// new vars for foreign languages
var gstrLanguage = '';
var gstrLanguageURL = '/';
var gstrBible = 'bible';
var gstrForeignURLIdentifier = ('/');

// vars for jw-media
var gstrMedia = 'jw-media-dev';
var gstrMediaorg = 'jw-media-dev';
var gstrWTOrg = 'http://www.watchtower.org';
var gstrRussia = 'jw-russia.org';
var gstrRussiaorg = 'www.jw-russia.org';

<!------------------------------------------------------------------------->
/* function showCitedScripture(strBook, strChapter, strVerse)
	Purpose:	  		 Opens scripture links in a separate window.	
	Parameters:	  		 none
	Called Function(s):  Scripture links from within the Require(rq) and 
	                     Jehovah's Witnesses (JT) brochures

 	HISTORY:
   	Date      	Who  	Description
	========================================================================
 	07/19/2004 	RP  	Created
*/
<!------------------------------------------------------------------------->
function showCitedScripture(strBook, strChapter, strVerse) {
	var strURL;
	checkLanguage();

	var strFileName = gstrLanguageURL + gstrBible + "/" + strBook.toLowerCase() + "/chapter_";
	var blnNewScripture = false;
	var intHyphenPos;
	var strBk;
	
	strHost = parent.location.hostname;
    if(strChapter<10) {
        strFileName += "00" + strChapter;
    } else if(strChapter<100){
        strFileName += "0" + strChapter;
    } else {
        strFileName += strChapter;
    }

    if (mstrBook != strBook || mstrChapter != strChapter || mstrVerse != strVerse) {
       blnNewScripture = true;
    }

	//retrieve first verse for bookmark
	intHyphenPos = parseInt(strVerse.indexOf('-'));
	if (intHyphenPos > -1) {
		strBk = strVerse.substr(0, intHyphenPos);
	} else {
		strBk = strVerse;
	}

// IE4 on Windows 95 does not seem to handle bookmarks correctly; remove bookmark from URL for IE4
	if((document.all) && (!document.getElementById)) {
	    strURL = strFileName + ".htm?bk=" + strBook + ";chp=" + strChapter + ";vs=" + strVerse + ";citation";
	} else {
	    strURL = strFileName + ".htm?bk=" + strBook + ";chp=" + strChapter + ";vs=" + strVerse + ";citation#bk" + strBk;
	}
   //make sure it isn't already open or whether a new scripture was selected
   if (!scriptureWindow || scriptureWindow.closed || blnNewScripture) {
	if (strHost == gstrMedia || strHost == gstrMediaorg || strHost == gstrRussia || strHost == gstrRussiaorg ) {
		strURL = gstrWTOrg + strURL;
		} 

	  scriptureWindow = window.open(strURL,"subWindow","top=120,left=180,height=450,width=640,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	  mstrBook = strBook;
	  mstrChapter = strChapter;
	  mstrVerse = strVerse;
   }
	if (scriptureWindow.focus || window.focus) {
		scriptureWindow.focus();
	}
}

<!------------------------------------------------------------------------->
/* function checkLanguage()
	Purpose:	  		 Opens scripture links in a separate window.	
	Parameters:	  		 none
	Called from Function(s):  showCitedScripture
	
 	HISTORY:
   	Date      	Who  	Description
	========================================================================
 	04/30/2005 	MJM  	Created
*/
<!------------------------------------------------------------------------->
function checkLanguage() {
// based on the URL, decide if we are working with a non-English 
// if so, get the language and string for Bible
	strURL = parent.location.pathname;

	strHost = parent.location.hostname;
	var isFgn = strURL.match("translations"); //for languages inside ISO folder
	var isRussian = strURL.match("/u/"); // for Russian section
	//added for linking from jw-media (all languages
	if (strHost == gstrMedia || strHost == gstrMediaorg) {
		if (isFgn != null) {
			strURL = strURL.split("/");
			var strFile = strURL[strURL.length-1];
			var strEnd = strFile.indexOf(".htm");
			var strBegin = strFile.indexOf("_");
			var gstrLanguage = strFile.substring(strBegin + 1,strEnd);
		} else if  (isRussian != null) { 
			gstrLanguage = "u";
		} else {
			gstrLanguage = "e";
		}
			
			gstrLanguageURL = "/" + gstrLanguage + "/";
			getForeignNavString(gstrLanguage);

	//added for linking from jw-russia (Russian Bible only)	
	} else if (strHost == gstrRussia || strHost == gstrRussiaorg) {
		gstrLanguage = "u";
		gstrLanguageURL = "/" + gstrLanguage + "/";
		getForeignNavString(gstrLanguage);

	//linking from wt.org (all languages)
	} else {
	var intLang = strURL.indexOf(gstrForeignURLIdentifier);
		if (intLang != -1) {
			intLang = intLang + gstrForeignURLIdentifier.length;
			var intSlashPos = strURL.indexOf('/', intLang + 1);
			gstrLanguage = strURL.substring(intLang, intSlashPos);
			gstrLanguageURL = gstrForeignURLIdentifier + gstrLanguage + "/";
			getForeignNavString(gstrLanguage);
		}
	}
}

<!------------------------------------------------------------------------->
/* function getForeignNavString(strLang)
	Purpose:	  		 gets appropriate string to build URL for foreign Bible
	Parameters:	  strLang
	Called from Function(s):  checkLanguage()

 	HISTORY:
   	Date      	Who  	Description
	========================================================================
 	04/30/2005 	MJM  	Created
*/
<!------------------------------------------------------------------------->
function getForeignNavString(strLang) {

	switch (strLang) {
		case "e":
		case "a":
		case "b":
		case "ch":
		case "chs":
		case "f":
		case "g":
		case "j":
		case "ko":
		case "rea":
		case "u":
			gstrBible = "bible";	//lowercase-string is word for Bible to be used in the path
			break;
		case "d":
		case "n":
			gstrBible = "bibelen";
			break;
		case "o":
			gstrBible = "bijbel";
			break;
		case "fi":
			gstrBible = "raamattu";
			break;
		case "x":
			gstrBible = "bibel";	
			break;
		case "i":
			gstrBible = "bibbia";	
			break;
		case "p":
		case "t":
		case "s":
			gstrBible = "biblia";
			break;
		case "z":
			gstrBible = "bibeln";
			break;

// international bibles
		case "af":
			gstrBible = "bybel";
			break;
		case "al":
		case "bl":
		case "ef":
		case "ge":
		case "oss":
		case "sb":
			gstrBible = "bible";
			break;
		case "cn":
			gstrBible = "baibulo";
			break;
		case "cw":
			gstrBible = "baibolo";
			break;
		case "c":
			gstrBible = "biblija";
			break;
		case "h":
		case "li":
		case "m":
		case "sw":
		case "v":
			gstrBible = "biblia";
			break;
		case "in":
			gstrBible = "alkitab";
			break;
		case "mg":
			gstrBible = "baiboly";
			break;
		case "mt":
			gstrBible = "bibbja";
			break;
		case "sr":
			gstrBible = "bijbel";
			break;
		case "su":
			gstrBible = "bibele";
			break;
		case "sv":
			gstrBible = "svetopismo";
			break;
		case "tn":
			gstrBible = "baebele";
			break;
		case "tk":
			gstrBible = "kutsalkitap";
			break;
		case "xo":
			gstrBible = "ibhayibhile";
			break;
		case "zu":
			gstrBible = "ibhayibheli";
			break;
		case "tg":
			gstrBible = "bibliya";
			break;
		case "yr":
			gstrBible = "bibeli";
			break;
		}	
}
