
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, 1, "Lorelai/Luke", 0);
categories[1] = new category(-1, 2, "Lorelai/Other", 0);
categories[2] = new category(-1, 3, "Rory and . . .", 0);
categories[3] = new category(-1, 9, "Other pairings", 0);
categories[4] = new category(-1, 8, "General", 0);
categories[5] = new category(3, 4, "Rory/Dean", 0);
categories[6] = new category(3, 13, "Rory/Finn", 0);
categories[7] = new category(3, 5, "Rory/Jess", 0);
categories[8] = new category(3, 6, "Rory/Logan", 0);
categories[9] = new category(3, 7, "Rory/Marty", 0);
categories[10] = new category(3, 10, "Rory/Tristan", 0);
characters[0] = new character(19, 8, "Babette Dell");
characters[1] = new character(33, 9, "Babette Dell");
characters[2] = new character(4, 2, "Christopher Hayden");
characters[3] = new character(58, 8, "Christopher Hayden");
characters[4] = new character(34, 9, "Christopher Hayden");
characters[5] = new character(17, 8, "Dave Rygalski");
characters[6] = new character(35, 9, "Dave Rygalski");
characters[7] = new character(36, 9, "Dean Forester");
characters[8] = new character(59, 8, "Dean Forester");
characters[9] = new character(11, 4, "Dean Forester");
characters[10] = new character(5, 8, "Emily Gilmore");
characters[11] = new character(37, 9, "Emily Gilmore");
characters[12] = new character(77, -1, "Gypsy");
characters[13] = new character(38, 9, "Jackson Belville");
characters[14] = new character(7, 8, "Jackson Belville");
characters[15] = new character(75, 2, "Jason Stiles");
characters[16] = new character(76, 8, "Jason Stiles");
characters[17] = new character(16, 5, "Jess Mariano");
characters[18] = new character(60, 8, "Jess Mariano");
characters[19] = new character(39, 9, "Jess Mariano");
characters[20] = new character(20, 8, "Kirk Gleason");
characters[21] = new character(40, 9, "Kirk Gleason");
characters[22] = new character(41, 9, "Lane Kim");
characters[23] = new character(8, 8, "Lane Kim");
characters[24] = new character(74, 6, "Logan Huntzberger");
characters[25] = new character(1, 1, "Lorelai Gilmore");
characters[26] = new character(61, 8, "Lorelai Gilmore");
characters[27] = new character(42, 9, "Lorelai Gilmore");
characters[28] = new character(2, 2, "Lorelai Gilmore");
characters[29] = new character(24, 8, "Louise");
characters[30] = new character(43, 9, "Louise");
characters[31] = new character(9, 1, "Luke Danes");
characters[32] = new character(62, 8, "Luke Danes");
characters[33] = new character(44, 9, "Luke Danes");
characters[34] = new character(45, 9, "Lulu");
characters[35] = new character(21, 8, "Lulu");
characters[36] = new character(46, 9, "Madeline");
characters[37] = new character(23, 8, "Madeline");
characters[38] = new character(63, 8, "Marty");
characters[39] = new character(31, 7, "Marty");
characters[40] = new character(47, 9, "Marty");
characters[41] = new character(64, 8, "Max Medina");
characters[42] = new character(26, 2, "Max Medina");
characters[43] = new character(48, 9, "Max Medina");
characters[44] = new character(49, 9, "Michel Gerard");
characters[45] = new character(14, 8, "Michel Gerard");
characters[46] = new character(50, 9, "Miss Patty");
characters[47] = new character(15, 8, "Miss Patty");
characters[48] = new character(67, 9, "Nicole");
characters[49] = new character(71, 8, "Nicole");
characters[50] = new character(68, 9, "Other");
characters[51] = new character(72, 8, "Other");
characters[52] = new character(69, 2, "Other");
characters[53] = new character(70, 3, "Other");
characters[54] = new character(51, 9, "Paris Geller");
characters[55] = new character(12, 8, "Paris Geller");
characters[56] = new character(52, 9, "Rachel");
characters[57] = new character(10, 8, "Rachel");
characters[58] = new character(13, 8, "Richard Gilmore");
characters[59] = new character(53, 9, "Richard Gilmore");
characters[60] = new character(54, 9, "Rory Gilmore");
characters[61] = new character(29, 5, "Rory Gilmore");
characters[62] = new character(3, 3, "Rory Gilmore");
characters[63] = new character(73, 6, "Rory Gilmore");
characters[64] = new character(28, 4, "Rory Gilmore");
characters[65] = new character(30, 7, "Rory Gilmore");
characters[66] = new character(32, 10, "Rory Gilmore");
characters[67] = new character(65, 8, "Rory Gilmore");
characters[68] = new character(55, 9, "Sookie St. James");
characters[69] = new character(6, 8, "Sookie St. James");
characters[70] = new character(56, 9, "Taylor Doose");
characters[71] = new character(18, 8, "Taylor Doose");
characters[72] = new character(22, 10, "Tristan DuGrey");
characters[73] = new character(66, 8, "Tristan DuGrey");
characters[74] = new character(57, 9, "Tristan DuGrey");

