// This is used by eNT.htm and iNT.htm.
// It does two things:
//	- Displays specific "family" NT's
//	- From a language and family page, display the NT's
/*
    To add an addtion to the NT list:
	- add the NT to the bottom of the table
	- add 'id' number to the bottom of the table of the NT list to tr (id="nt...")
	- in the family (or subfamily) page add, i.e.: "<a href="../ilv/eNT.htm?Family=Maya">Nuevos Testamentos</a>"
			("text" name is: Language or Family)
	- in SpecLang.js add 1 to the 'indx'
	- in SpecLang.js add the record number of the list of the NT to the list of 'indivlang' according to the langauge
	- in SpecLang.js add the record number of the list of the NT to the list of 'familylang' according to the langauge
*/
// 5/24/2004 created by -> Scott Starker
// 6/10/2004 added Family and Stock -> Scott Starker
// 9/8/2004 delete Stock -> Scott Starker

var indx = 120;
var displ = new Array(indx);
var speclang = new Array();

var indivlang = new Array();
indivlang[0]="-1";			// All
indivlang[1]="27,88";		// Amuzgo
indivlang[2]="58,87";		// Chatino
indivlang[3]="100,30,55,10,103,26,66,70,90,67";		// Chinantec
indivlang[4]="37,4";		// Chol
indivlang[5]="85";			// Chontal Oaxaca
indivlang[6]="41";			// Chontal Tabasco
indivlang[7]="96,114";		// Cora
indivlang[8]="29,22";		// Cuicatec
indivlang[9]="18,108";		// Huastec
indivlang[10]="20";			// Huave
indivlang[11]="7";			// Huichol
indivlang[12]="44";			// Lacandon
indivlang[13]="0";			// Maya
indivlang[14]="13";			// Mazahua
indivlang[15]="84,5,116";	// Mazatec
indivlang[16]="0";			// Mexican Sign Language
indivlang[17]="36,80,54,76,83,107";		// Mixe
indivlang[18]="25,49,104,99,65,39,46,53,89,1,94,45,79,111";		// Mixtec
indivlang[19]="75,48,69,72,93,47,52,109,110";	// Nahuatl
indivlang[20]="28,32,14,105,34";	// Otomi
indivlang[21]="0";			// Pame
indivlang[22]="0";			// Pima
indivlang[23]="61,64";		// Popoloca
indivlang[24]="12,38";		// Popoluca
indivlang[25]="11";			// Purepecha
indivlang[26]="62";			// Seri
indivlang[27]="21,115";		// Tarahumara
indivlang[28]="35,106";		// Tepehua
indivlang[29]="59,112";		// Tepehuan
indivlang[30]="31";			// Tlapanec
indivlang[31]="24";			// Tojolabal
indivlang[32]="73,3,51,95,42";	// Totonac
indivlang[33]="9,78";		// Triqui
indivlang[34]="6,2";		// Tzeltal
indivlang[35]="50,60,33,68,74";	// Tzotzil
indivlang[36]="40";			// Yaqui
indivlang[37]="101,82,71,23,19,56,92,63,97,17,91,15,86,57,81,98,102,16,77,113,117,118,119,120";	// Zapotec
indivlang[38]="8,43";		// Zoque
indivlang[indivlang.length]="-1";		// nothing (last index of the array)

var familylang = new Array();
familylang[0]="-1";				// All
familylang[1]="27,88";			// amuzga, familia
familylang[2]="100,30,55,10,103,26,66,70,90,67";	// chinanteca, familia
familylang[3]="96,7,114";		// corachol, familia
familylang[4]="20";				// huave, familia
familylang[5]="37,4,41,6,2,50,60,33,68,74,24,18,44,108";	// maya, familia
familylang[6]="36,80,54,76,83,12,38,8,43,107";	// mixe-zoqueana, familia
familylang[7]="25,49,104,99,65,39,46,53,89,1,94,45,79,22,29,9,78,111";	// mixteca, familia
familylang[8]="75,48,69,72,93,47,52,109,110";	// nahuatl, familia
familylang[9]="13,28,32,14,105,34";		// otopame, familia
familylang[10]="59";			// pimana, familia [Tepiman family]
familylang[11]="61,64,5,84,116";	// popoloca, familia
familylang[12]="62";			// seri
familylang[13]="21,40,115";			// taracahita, familia
familylang[14]="11";			// tarasca, familia
familylang[15]="59,112";		// tepiman family [familia pimana]
familylang[16]="85";			// tequistlateca, familia
familylang[17]="31";			// tlapanecan, familia
familylang[18]="35,73,3,51,95,42,106";	// totonaca, familia
familylang[19]="101,82,71,23,19,56,92,63,97,17,91,15,86,57,81,98,102,16,77,58,87,113,117,118,119,120";	// zapoteca, familia
familylang[familylang.length]="-1";	// nothing (last index of the array)

var specificlang = new Array();
specificlang[0]="-1";					// All
specificlang[1]="";						// The specific language
specificlang[specificlang.length]="-1";	// nothing (last index of the array)

//var stocklang = new Array();
//stocklang[0]="-1";			// All
//stocklang[1]="62,85";		    // hokano
//stocklang[2]="27,88,100,30,55,10,103,26,66,70,90,67,29,22,25,49,104,99,65,39,46,53,89,1,94,45,79,9,78,13,28,32,14,105,34,84,5,61,64,31,58,87,101,82,71,23,19,56,92,63,97,17,91,15,86,57,81,98,102,16,77";			// otomangue [Otomanguean]
//stocklang[3]="96,7,75,48,69,72,93,47,52,59,21,40";	// yutonahua [Uto-Aztecan]
//stocklang[4]="20,37,4,50,60,33,68,74,18,36,80,54,76,83,73,3,51,95,42,6,2,8,43,11,24,35,41,44,12,38,106";		// none
//stocklang[stocklang.length]="-1";		// nothing (last index of the array)

function languag(lang, langfamsto) {
//	var obj = document.all["nt" + i];
//	obj.style.display = "none";							works with IE
//	var obj = document.getElementById("nt" + i);
//	obj.style.display = "none";							works with Netscape
//	...display: "block" wont quite work on NS 7.1
//	Try display: table-row for NS6.

	if (original == "English") {
		iIndivVar();
	}
	else if (original == "Spanish") {
		eIndivVar();
	}
    
    if (document.all) {											// IE 6
    // familylang.length = last index of the array, etc.
    	if (langfamsto == "indivlang") {
    		document.forms['Family'].familyname.selectedIndex = familylang.length;		// make dropdown box = passed language
    //		document.forms['Stock'].stockname.selectedIndex = stocklang.length;
    	}
    	else if (langfamsto == "familylang") {
    		document.forms['Language'].selectname.selectedIndex = indivlang.length;		// make dropdown box = passed language
    //		document.forms['Stock'].stockname.selectedIndex = stocklang.length;
    	}
    //	else if (langfamsto == "stocklang") {
    //		document.forms['Family'].familyname.selectedIndex = familylang.length;		// make dropdown box = passed language
    //		document.forms['Language'].selectname.selectedIndex = indivlang.length;
    //	}
    }
    else if (document.getElementById && document.getElementById("nt1")) { // NS 7.1
    	if (langfamsto == "indivlang") {
    		document.forms["Family"].familyname.selectedIndex = familylang.length-1;
    	}
    	else if (langfamsto == "familylang") {
    		document.forms["Language"].selectname.selectedIndex = indivlang.length-1;
    	}
    }
    else if (document.layers) {                                     	 // NS 4
    	if (langfamsto == "indivlang") {
   		    document.forms[1].familyname.selectedIndex = familylang.length-1;
    	}
    	else if (langfamsto == "familylang") {
    		document.forms[0].selectname.selectedIndex = indivlang.length-1;
    	}
    }

	displ[0] = 1;														// "block"ed i.e., make all of the NTs visible
	if (document.all) {													// IE 6
		for (var i = 1; i <= indx; i++) {
			displ[i] = 1;
			document.all["nt"+i].style.display = '';
		}
	}
	else if (document.getElementById && document.getElementById("nt1")) {	// NS 7.1
		for (var i = 1; i <= indx; i++) {
			displ[i] = 1;
			document.getElementById("nt"+i).style.display = '';
		}
	}
	else if (document.layers) {                                          // NS 4--doesn't work
		if (original == "English") {
			alert("This version of the browser doesn't work. Upgrade to the current version.");
		}
		else if (original == "Spanish") {
			alert("Esta versión del navegador no funciona. Actualícelo a la versión más reciente.");
		}
	    document.forms[1].familyname.selectedIndex = familylang.length-1;
   		document.forms[0].selectname.selectedIndex = indivlang.length-1;
		return;
    }
//		for (var i = 1; i <= indx; i++) {
//			displ[i] = 1;
//			document.layers["nt"+i].display = '';
//		}

	if (eval(langfamsto)[lang] == '0') {								// place displ[] = 0 with any NT's that should be displayed
		if (original == "English") {
			alert("There are no New Trestaments currently available in this language.");
		}
		else if (original == "Spanish") {
			alert("No hay ninguna traducción del Nuevo Testamento a este idioma realizada.");
		}
        if (document.all) {											          // IE 6
    		document.forms['Family'].familyname.selectedIndex = familylang.length;
            document.forms['Language'].selectname.selectedIndex = indivlang.length;
        }
        else if (document.getElementById && document.getElementById("nt1")) { // NS 7.1
    		document.forms["Family"].familyname.selectedIndex = familylang.length-1;
    		document.forms["Language"].selectname.selectedIndex = indivlang.length-1;
        }
        else if (document.layers) {                                     	  // NS 4
   		    document.forms[1].familyname.selectedIndex = familylang.length-1;
    		document.forms[0].selectname.selectedIndex = indivlang.length-1;
        }
		return;
	}

	if (eval(langfamsto)[lang] == '-1') {								// "All"
		for (var i = 1; i <= indx; i++) {
			displ[i] = 0;
		}		
	}
	else if (eval(langfamsto)[lang].indexOf(',') == -1) {				// one NT [NS 4 wont work]
		displ[eval(langfamsto)[lang]] = 0;
	}
	else {																// more than one NT [NS 4 wont work]
		var temp = new Array();
		temp = eval(langfamsto)[lang].split(',');
		for (var i = 0; i < temp.length; i++) {
			displ[temp[i]] = 0;
		}
	}

	for (var i = 1; i <= indx; i++) {									// "hide" all but the selected NTs
		if (displ[i]) {
			if (document.all) 											// IE 6
				document.all["nt"+i].style.display = 'none'; 
			else if (document.getElementById && document.getElementById("nt1")) // NS 7.1
				document.getElementById("nt"+i).style.display='none'; 
			else if (document.layers)                                   // NS 4?
				document.layers["nt"+i].display = 'none'; 
		}
	}
}

function iIndivVar() {
	indivlang[13]="0";			// Maya
	indivlang[14]="13";			// Mazahua
	indivlang[15]="84,5,116";	// Mazatec
	indivlang[16]="0";			// Mexican Sign Language
}

function eIndivVar() {
	indivlang[13]="0";			// Lenguaje-de-Signos
	indivlang[14]="0";			// Maya
	indivlang[15]="13";			// Mazahua
	indivlang[16]="84,5,116";	// Mazateco
}

function family() {
	var str = window.location.search;									// returns '?text=language' from the URL
	if (str != "") {
		var temp = str.split('=');
		if (temp[0] == '?Language') {
			lng();
		}
		else if (temp[0] == '?Family') {
			fam();
		}
		else if (temp[0] == '?SpecificLanguage') {
			specificlang[1] = temp[1];
		}
//		else if (temp[0] == '?Stock') {
//			sto();
//		}

		if (temp[0] != '?SpecificLanguage') {
			for (i = 0; i <= speclang.length; i++) {						// goes through whole language array
				if (temp[1] == speclang[i]) break;							// found the language
			}
		
			if (i > speclang.length) {										// didn't find the language
				if (original == "English") {
					alert("'" + temp[1] + "' was not found in the Mexican language list.");
				}
				else if (original == "Spanish") {
					alert("'" + temp[1] + "' no se encontró en la lista de idiomas de México.");
				}	
				return;
			}
		}
		
		if (temp[0] == "?Language") {
			document.forms['Language'].selectname.selectedIndex = i;	// make dropdown box = passed language
			languag(i, 'indivlang');									// update to specific language
		}
		else if (temp[0] == "?Family") {
			document.forms['Family'].familyname.selectedIndex = i;		// make dropdown box = passed language
			languag(i, 'familylang');									// update to specific language
		}
		else if (temp[0] == "?SpecificLanguage") {
//			document.forms['Family'].familyname.selectedIndex = i;		// make dropdown box = passed language
			languag(1, 'specificlang');									// update to specific language
		}
		//		else if (temp[0] == "?Stock") {
//			document.forms['Stock'].stockname.selectedIndex = i;		// make dropdown box = passed language
//			languag(i, 'stocklang');									// update to specific language
//		}
	}
}

function lng() {
    speclang[0]="All";
	speclang[1]="Amuzgo";
	speclang[2]="Chatino";
	speclang[3]="Chinantec";
	speclang[4]="Chol";
	speclang[5]="Chontal+Oaxaca";
	speclang[6]="Chontal+Tabasco";
	speclang[7]="Cora";
	speclang[8]="Cuicatec";
	speclang[9]="Huastec";
	speclang[10]="Huave";
	speclang[11]="Huichol";
	speclang[12]="Lacandon";
	speclang[13]="Maya";
	speclang[14]="Mazahua";
	speclang[15]="Mazatec";
	speclang[16]="Mexican+Sign+Language";
	speclang[17]="Mixe";
	speclang[18]="Mixtec";
	speclang[19]="Nahuatl";
	speclang[20]="Otomi";
	speclang[21]="Pame";
	speclang[22]="Pima";
	speclang[23]="Popoloca";
	speclang[24]="Popoluca";
	speclang[25]="Purepecha";
	speclang[26]="Seri";
	speclang[27]="Tarahumara";
	speclang[28]="Tepehua";
	speclang[29]="Tepehuan";
	speclang[30]="Tlapanec";
	speclang[31]="Tojolabal";
	speclang[32]="Totonac";
	speclang[33]="Triqui";
	speclang[34]="Tzeltal";
	speclang[35]="Tzotzil";
	speclang[36]="Yaqui";
	speclang[37]="Zapotec";
	speclang[38]="Zoque";
	speclang[speclang.length]="";
		
	if (original == "English") {
		iSpecVar();
	}
	else if (original == "Spanish") {
		eSpecVar();
	}
}

function iSpecVar() {
	speclang[13]="Maya";
	speclang[14]="Mazahua";
	speclang[15]="Mazatec";
	speclang[16]="Mexican+Sign+Language";
}

function eSpecVar() {
	speclang[13]="Mexican+Sign+Language";
	speclang[14]="Maya";
	speclang[15]="Mazahua";
	speclang[16]="Mazatec";
}

function fam() {
    speclang[0]="All";
	speclang[1]="Amuzgo";
	speclang[2]="Chinanteca";
	speclang[3]="Corachol";
	speclang[4]="Huave";
	speclang[5]="Maya";
	speclang[6]="Mixe-zoque";
	speclang[7]="Mixteca";
	speclang[8]="Nahuatl";
	speclang[9]="Otopame";
	speclang[10]="Pimana+[Tepiman]";
	speclang[11]="Popoloca";
	speclang[12]="Seri";
	speclang[13]="Taracahita";
	speclang[14]="Tarasca";
	speclang[15]="Tepiman+[pimana]";
	speclang[16]="Tequistlateca";
	speclang[17]="Tlapanecan";
	speclang[18]="Totonaca";
	speclang[19]="Zapoteca";
	speclang[speclang.length]="";
}

// function sto() {
//	speclang[1]="Hokano";
//	speclang[2]="Otomangue+[Otomanguean]";
//	speclang[3]="Yutonahua+[Uto-Aztecan]";
//	speclang[4]="None";
//	speclang[speclang.length]="";
// }
