
function fillCategory(){ 
 // this function is used to fill the category list on load
addOption(document.narniabook.Category, "Education: Teacher", "Education: Teacher", "");
addOption(document.narniabook.Category, "Education: Administrative", "Education: Administrative", "");
addOption(document.narniabook.Category, "Entertainment", "Entertainment", "");
addOption(document.narniabook.Category, "Faith & Outreach", "Faith & Outreach", "");
addOption(document.narniabook.Category, "Family", "Family", "");
addOption(document.narniabook.Category, "Other", "Other", "");

document.narniabook.SubCat.style.display = "none";
document.narniabook.SubCatOther.style.display = "none";
}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.narniabook.SubCat);
addOption(document.narniabook.SubCat, "", "Please Specify", "");

if(document.narniabook.Category.value == 'Education: Teacher'){
addOption(document.narniabook.SubCat,"Elementary", "Elementary");
addOption(document.narniabook.SubCat,"Middle School", "Middle School");
addOption(document.narniabook.SubCat,"High School", "High School");
addOption(document.narniabook.SubCat,"Higher Education", "Higher Education");
addOption(document.narniabook.SubCat,"Librarian", "Librarian");
document.narniabook.SubCat.style.display = "block";
document.narniabook.SubCatOther.style.display = "none";
}
if(document.narniabook.Category.value == 'Education: Administrative'){
addOption(document.narniabook.SubCat,"Elementary", "Elementary");
addOption(document.narniabook.SubCat,"Middle School", "Middle School");
addOption(document.narniabook.SubCat,"High School", "High School");
addOption(document.narniabook.SubCat,"Higher Education", "Higher Education");
document.narniabook.SubCat.style.display = "block";
document.narniabook.SubCatOther.style.display = "none";
}
if(document.narniabook.Category.value == 'Entertainment'){
document.narniabook.SubCat.style.display = "none";
document.narniabook.SubCatOther.style.display = "none";
}
if(document.narniabook.Category.value == 'Faith & Outreach'){
addOption(document.narniabook.SubCat,"Pastor", "Pastor");
addOption(document.narniabook.SubCat,"Youth Pastor", "Youth Pastor");
addOption(document.narniabook.SubCat,"Community Organizer", "Community Organizer");
addOption(document.narniabook.SubCat,"Other Faith & Outreach", "Other Faith & Outreach");
document.narniabook.SubCat.style.display = "block";
document.narniabook.SubCatOther.style.display = "none";
}

if(document.narniabook.Category.value == 'Family'){
document.narniabook.SubCat.style.display = "none";
document.narniabook.SubCatOther.style.display = "none";
}

if(document.narniabook.Category.value == 'Other'){
document.narniabook.SubCat.style.display = "none";
document.narniabook.SubCatOther.style.display = "block";
}

}
////////////////// 

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}
