
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, 25, "Reference Material", 0);
categories[1] = new category(-1, 5, "Geoffrey Chaucer/Wat", 0);
categories[2] = new category(-1, 23, "Geoffrey Chaucer/Prince Edward", 0);
categories[3] = new category(-1, 21, "Geoffrey Chaucer/other", 0);
categories[4] = new category(-1, 4, "William/Count Adhemar", 0);
categories[5] = new category(-1, 1, "William/Geoffrey Chaucer", 0);
categories[6] = new category(-1, 3, "William/Wat", 0);
categories[7] = new category(-1, 2, "William/Prince Edward", 0);
categories[8] = new category(-1, 8, "William/other", 0);
categories[9] = new category(-1, 18, "Roland/other", 0);
categories[10] = new category(-1, 6, "threesomes", 0);
categories[11] = new category(-1, 17, "other/other", 0);
categories[12] = new category(-1, 7, "William/OC", 0);
categories[13] = new category(-1, 14, "Crossovers", 0);
categories[14] = new category(-1, 16, "AU - Present Day Setting", 0);
categories[15] = new category(-1, 13, "Fem Slash", 0);
categories[16] = new category(-1, 12, "Gen & Het fiction", 0);
categories[17] = new category(-1, 22, "No Pairing", 0);
categories[18] = new category(-1, 26, "Artwork", 0);
categories[19] = new category(-1, 27, "Poetry", 0);
categories[20] = new category(12, 24, "Geoffrey Chaucer/Phillipa", 0);
categories[21] = new category(13, 20, "Kate/Phillipa", 0);
categories[22] = new category(12, 9, "William/Jocelyn", 0);
categories[23] = new category(12, 10, "William/Kate", 0);
categories[24] = new category(13, 11, "Jocelyn/Kate", 0);
categories[25] = new category(13, 19, "Jocelyn/Christiana", 0);
categories[26] = new category(14, 15, "Lord of The Rings", 0);
characters[0] = new character(9, -1, "Christiana the maid");
characters[1] = new character(7, -1, "Count Adhemar");
characters[2] = new character(14, -1, "crossover character");
characters[3] = new character(2, -1, "Geoffrey Chaucer");
characters[4] = new character(11, -1, "Germain, Adhemar's Squire");
characters[5] = new character(5, -1, "Kate the Smithee");
characters[6] = new character(6, -1, "Lady Jocelyn");
characters[7] = new character(12, -1, "OC - female");
characters[8] = new character(13, -1, "OC - male");
characters[9] = new character(10, -1, "Phillipa, Chaucer's wife");
characters[10] = new character(8, -1, "Prince Edward");
characters[11] = new character(4, -1, "Roland the Squire");
characters[12] = new character(3, -1, "Wat the Squire");
characters[13] = new character(1, -1, "William Thatcher");

