function showHide(elementID) {
//used for showing or hiding a section of code
	var theelement = document.getElementById(elementID);
	if (theelement.style.display == 'none') {
		theelement.style.display = '';
	} else {
		theelement.style.display = 'none';
	}
}

function multishowhide(container,baseid,index){
	var contained;
	if(document.all){ //ie5 - allows me to have other div tags inside the ones im hiding
		contained = document.all(container).childNodes;
	} else { //ns - lame browser and doesnt support the DOM (treeview stuff)
		contained = document.getElementById(container).getElementsByTagName('div');
	}
	for(i = 0; i < contained.length; i++){
		contained[i].style.display = 'none';
	}
	var showobject = document.getElementById(baseid+index);
	showobject.style.display = '';
}

function checkBox(elementID){
//used for text next to checkboxes - click the text and the box is 'clicked' too
	var checkBox = document.getElementById(elementID);
	checkBox.click();
}
//controls for javascript checkbox delete/select etc
var boxCounter = 0;
function clickBox(elementID){ //passed in as 'this'
	var boxid = elementID
	if(boxid.checked){
		boxCounter++;
	} else {
		boxCounter--;
	}
	var optionsdiv = document.getElementById("selectOptions");
	if(optionsdiv.style.display == 'none' && boxCounter > 0){
		optionsdiv.style.display = '';
	} else if(boxCounter == 0){
		optionsdiv.style.display = 'none';
		if(document.getElementById("fileOptions")){ //only on ui_postlist.asp - hides the filegen options
			document.getElementById("fileOptions").style.display = 'none';
		}
	}
}

function confirmDelete(){
	if(confirm('Delete is irreversible - are you sure you wish to delete?')){
		document.forms.form1.action = "DBdelete.asp";
		document.forms.form1.submit();
	}
}

function setsubcats(){
	var catbox = document.getElementById('catselect');
	var subcatbox = document.getElementById('subcatselect');
	for(i = subcatbox.options.length - 1; i > -1; i--){ //removes current options
		subcatbox.options[i] = null;
	}
	var optionvalue,optiontext,commafound;
	var selected = catbox.selectedIndex;
	for(i = 0; i < arrSubCat[selected].length; i++){
		commafound = arrSubCat[selected][i].indexOf(", ");
		optionvalue = arrSubCat[selected][i].substring(0,commafound);
		optiontext = arrSubCat[selected][i].substring(commafound + 2,arrSubCat[selected][i].length);
		subcatbox.options[i] = new Option(optiontext,optionvalue);
	}
	if(arrSubCat[selected].length == 1){
		subcatbox.disabled = true;
	} else {
		subcatbox.disabled = false;
	}
	// fix for browser not sending the form value properly if dynamic generated..
	subcatbox.options[0].selected = true;
	setsubcats_pt2();
}

function setsubcats_pt2(){
	var subcatbox = document.getElementById('subcatselect');
	var hiddenfield = document.getElementById('subcathid');
	// sets the value of the hidden field to be whatever the dropdown is.. fix for browser thingy
	hiddenfield.value = subcatbox[subcatbox.selectedIndex].value;
}
