
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, 9, "Action Adventure", 0);
categories[1] = new category(-1, 12, "Alternate Universe", 0);
categories[2] = new category(-1, 14, "Angst", 0);
categories[3] = new category(-1, 6, "Challenge", 0);
categories[4] = new category(-1, 2, "Crossover", 0);
categories[5] = new category(-1, 3, "Drama", 0);
categories[6] = new category(-1, 8, "Episode Related", 0);
categories[7] = new category(-1, 17, "Fluff", 0);
categories[8] = new category(-1, 1, "General", 0);
categories[9] = new category(-1, 15, "Horror/Dark", 0);
categories[10] = new category(-1, 11, "Humor", 0);
categories[11] = new category(-1, 16, "Mystery/Suspense", 0);
categories[12] = new category(-1, 7, "Poetry", 0);
categories[13] = new category(-1, 18, "PWP", 0);
categories[14] = new category(-1, 27, "Romance", 0);
characters[0] = new character(16, -1, "Adam Baylin");
characters[1] = new character(2, -1, "Amanda Bloom");
characters[2] = new character(15, -1, "Andy Jensen");
characters[3] = new character(27, -1, "Bradford Hooper");
characters[4] = new character(17, -1, "Brian Taylor");
characters[5] = new character(21, -1, "Carol Bloom");
characters[6] = new character(12, -1, "Charlie");
characters[7] = new character(24, -1, "Cyrus Reynolds");
characters[8] = new character(23, -1, "David Peterson");
characters[9] = new character(8, -1, "Declan McDonough");
characters[10] = new character(13, -1, "Deichman");
characters[11] = new character(18, -1, "Emily Hollander");
characters[12] = new character(11, -1, "Hillary");
characters[13] = new character(14, -1, "Jessie XX");
characters[14] = new character(4, -1, "Josh Trager");
characters[15] = new character(22, -1, "Julia Peterson");
characters[16] = new character(20, -1, "Julian Ballantine");
characters[17] = new character(1, -1, "Kyle");
characters[18] = new character(3, -1, "Lori Trager");
characters[19] = new character(25, -1, "Ms. Thatcher");
characters[20] = new character(6, -1, "Nicole Trager");
characters[21] = new character(28, -1, "Original Female Character");
characters[22] = new character(29, -1, "Original Male Character");
characters[23] = new character(9, -1, "Other Character");
characters[24] = new character(19, -1, "Paige Hollander");
characters[25] = new character(26, -1, "Professor Kern");
characters[26] = new character(7, -1, "Stephen Trager");
characters[27] = new character(10, -1, "Tom Foss");

