
categories = new Array( );
characters = new Array( );

function category(pid, catid, name, locked) {
	this.pid = pid
	this.catid = catid
	this.name = name
	this.locked = locked
}

function character(charid, catid, charname) { 
	this.charid = charid
	this.catid = catid
	this.charname = charname
}

function setCategories( chosen ) {
	var category = chosen.options[chosen.selectedIndex].value; 

	var count = 0;
	for(x = 0; x < categories.length; x++) 
	{ 
		if(categories[x].pid == category) count++; 
	}
	if(count) {
		chosen.options.length = 0;
		for(x = 0; x < categories.length; x++) {
			if(categories[x].pid == category || categories[x].catid == category) { 
				chosen.options[chosen.options.length] = new Option(categories[x].name, categories[x].catid); 
			}
		}
		if(category != -1) { 
			chosen.options[chosen.options.length] = new Option(lang['Back2Cat'], '-1');
			chosen.options.selectedIndex = 0;
		}
		else { 
			chosen.options[chosen.options.length] = new Option(lang['ChooseCat'], '-1');
			chosen.options.selectedIndex = chosen.options.length - 1;
			
		}
	}
}

function clearSelectedCategory( chosen ) {
	chosen.options.length = 0;
}

function setSelectedCategory( chosen ) {
	newList = new Array(  );
	var category = chosen.options[chosen.selectedIndex].value; 
	var len = document.form.catid.options.length;

	for(x = 0; x < categories.length; x++) {
		if(categories[x].catid != category) continue;
		locked = categories[x].locked;
		break;
	}
	if(locked && document.form.formname.value == "stories") alert(lang['Locked']);
	else {
		document.form.catid[len] = new Option(chosen.options[chosen.selectedIndex].text, chosen.options[chosen.selectedIndex].value, chosen.options[chosen.selectedIndex].defaultSelected, true);

		if(document.form.formname.value != "admins") {
			var charname = document.form.charname;

			for(x = 0; x < characters.length; x++) {
				if(characters[x].catid == category) { 
					charname.options[charname.options.length] = new Option(characters[x].charname, characters[x].charname); 
				}
			}
		}
	}		
}
categories[0] = new category(-1, 4, "Preludes", 0);
categories[1] = new category(-1, 5, "Interludes", 0);
categories[2] = new category(-1, 6, "Postludes", 0);
categories[3] = new category(-1, 7, "Etudes", 0);
characters[0] = new character(9, 4, "Armand Moncharmin/Giles André");
characters[1] = new character(79, 4, "Ayesha");
characters[2] = new character(14, 4, "Carolus Fonta");
characters[3] = new character(100, -1, "Carolus Fonta");
characters[4] = new character(110, -1, "César");
characters[5] = new character(75, 6, "Charles de Chagny");
characters[6] = new character(74, 4, "Charles, Erik's Father");
characters[7] = new character(15, 4, "Christine Daaé");
characters[8] = new character(81, -1, "Christine Daaé");
characters[9] = new character(53, 4, "Darius");
characters[10] = new character(80, -1, "Erik - The Phantom");
characters[11] = new character(16, 4, "Erik, The Phantom");
characters[12] = new character(17, 4, "Firmin Richard/Richard Firmin");
characters[13] = new character(77, 4, "Fr. Erik Mansart");
characters[14] = new character(114, -1, "Inspector Ledoux");
characters[15] = new character(50, 4, "Jammes");
characters[16] = new character(99, -1, "Jammes");
characters[17] = new character(58, 4, "Joseph Buquet");
characters[18] = new character(98, -1, "Joseph Buquet");
characters[19] = new character(57, 4, "Jules Giry");
characters[20] = new character(85, -1, "Jules Giry");
characters[21] = new character(89, -1, "La Carlotta");
characters[22] = new character(13, 4, "La Carlotta/Carlotta Giudicelli");
characters[23] = new character(46, 4, "La Sorelli");
characters[24] = new character(88, -1, "La Sorelli");
characters[25] = new character(95, -1, "M. Armand Moncharmin/M. André");
characters[26] = new character(71, 4, "M. Daaé");
characters[27] = new character(103, -1, "M. Daaé");
characters[28] = new character(68, 4, "M. Debienne");
characters[29] = new character(91, -1, "M. Debienne");
characters[30] = new character(70, 4, "M. Faure");
characters[31] = new character(112, -1, "M. Faure");
characters[32] = new character(96, -1, "M. Firmin Richard/M. Firmin");
characters[33] = new character(62, 4, "M. Gabriel");
characters[34] = new character(113, -1, "M. Gabriel");
characters[35] = new character(97, -1, "M. Gerard Carriere");
characters[36] = new character(105, -1, "M. Isidore Saack");
characters[37] = new character(109, -1, "M. Lachcnel");
characters[38] = new character(69, 4, "M. Lachenal");
characters[39] = new character(63, 4, "M. Lefévre");
characters[40] = new character(93, -1, "M. Lefevre");
characters[41] = new character(107, -1, "M. Maniera");
characters[42] = new character(64, 4, "M. Mercier");
characters[43] = new character(111, -1, "M. Mercier");
characters[44] = new character(61, 4, "M. Mifroid");
characters[45] = new character(108, -1, "M. Mifroid");
characters[46] = new character(67, 4, "M. Poligny");
characters[47] = new character(92, -1, "M. Poligny");
characters[48] = new character(60, 4, "M. Rémy");
characters[49] = new character(104, -1, "M. Rémy");
characters[50] = new character(59, 4, "M. Reyer");
characters[51] = new character(94, -1, "M. Reyer");
characters[52] = new character(73, 4, "Madeleine, Erik's Mother");
characters[53] = new character(76, 4, "Marie Perrault");
characters[54] = new character(18, 4, "Meg Giry");
characters[55] = new character(83, -1, "Meg Giry");
characters[56] = new character(19, 4, "Mme. Giry");
characters[57] = new character(84, -1, "Mme. Giry");
characters[58] = new character(106, -1, "Mme. Julie Maniera");
characters[59] = new character(65, 4, "Mme. Valérius");
characters[60] = new character(101, -1, "Mme. Valérius");
characters[61] = new character(87, -1, "Philippe - Comte de Chagny");
characters[62] = new character(21, 4, "Philippe, The Comte de Chagny");
characters[63] = new character(66, 4, "Prof. Valérius");
characters[64] = new character(102, -1, "Prof. Valérius");
characters[65] = new character(82, -1, "Raoul - Vicomte de Changy");
characters[66] = new character(22, 4, "Raoul, The Vicomte de Chagny");
characters[67] = new character(78, 4, "Sasha");
characters[68] = new character(86, -1, "The Persian - Nadir Khan");
characters[69] = new character(20, 4, "The Persian, Nadir Khan");
characters[70] = new character(72, 4, "The Sultana/Khanum");
characters[71] = new character(48, 4, "Ubaldo Piangi");
characters[72] = new character(90, -1, "Ubaldo Piangi");

