var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {
	isID = 1;
	isDHTML = 1; }
else {
	if (document.all) {
	isAll = 1;
	isDHTML = 1; }
	else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1 ) && (browserVersion == 4)) {
			isLayers = 1;
			isDHTML = 1; }
	 }
}

function findDOM(objectID) {
	if (isID) {
		return (document.getElementById(objectID)); 
	}
	else if (isAll) {
		return (document.all[objectID]); 
	}
	else if (isLayers) {
			return (document.layers[objectID]); 
	}
}


var x, tagName, idNum, Div;
var child = 1;
var sibling = 1;
var singer = 1;
var pallbearer = 1;
var person = 1;
var emp = 1;
var other = 1;

function show(div) {
	div = findDOM(div);
	div.style.visibility = 'visible';
	div.style.position = 'static';
}

function hide(div) {
	div = findDOM(div);
	div.style.visibility = 'hidden';
	div.style.position = 'absolute';
}

function addObject(tagName, idNum) {
	var removeButton, addButton;
	var Div = tagName + idNum.toString();
	show(Div);
	if ( idNum == 10 ) {
		addButton = 'add' + tagName;
		hide(addButton);
	}
	if ( idNum >= 2 ) {
		removeButton = 'remove' + tagName;
		show(removeButton);
	}
}

function addSinger(tagName, idNum) {
	var removeButton, addButton;
	var Div = tagName + idNum.toString();
	show(Div);
	if ( idNum == 5 ) {
		addButton = 'add' + tagName;
		hide(addButton);
	}
	if ( idNum >= 2 ) {
		removeButton = 'remove' + tagName;
		show(removeButton);
	}
}

function addPerson(tagName, idNum) {
	var removeButton, addButton;
	var Div = tagName + idNum.toString();
	show(Div);
	if ( idNum == 5 ) {
		addButton = 'add' + tagName;
		hide(addButton);
	}
	if ( idNum >= 2 ) {
		removeButton = 'remove' + tagName;
		show(removeButton);
	}
}

function addPB(tagName, idNum) {
	var removeButton, addButton;
	var Div = tagName + idNum.toString();
	show(Div);
	if ( idNum == 8 ) {
		addButton = 'add' + tagName;
		hide(addButton);
	}
	if ( idNum >= 2 ) {
		removeButton = 'remove' + tagName;
		show(removeButton);
	}
}

function addEmp(tagName, idNum) {
	var removeButton, addButton;
	var Div = tagName + idNum.toString();
	show(Div);
	if ( idNum == 5 ) {
		addButton = 'add' + tagName;
		hide(addButton);
	}
	if ( idNum >= 2 ) {
		removeButton = 'remove' + tagName;
		show(removeButton);
	}
}

function add(x) {
	if ( x == 'child' && child < 10 ) {
		child = child + 1;
		addObject(x,child);
	}
	if ( x == 'sibling' && sibling < 10 ) {
		sibling = sibling + 1;
		addObject(x,sibling);
	}
	if ( x == 'singer' && singer < 5 ) {
		singer = singer + 1;
		addSinger(x,singer);
	}
	if ( x == 'pallbearer' && pallbearer < 8 ) {
		pallbearer = pallbearer + 1;
		addPB(x,pallbearer);
	}
	if ( x == 'person' && person < 5 ) {
		person = person + 1;
		addPerson(x,person);
	}
   if ( x == 'emp' && emp < 5 ) {
		emp = emp + 1;
		addEmp(x,emp);
	}
   if ( x == 'other' && other < 10 ) {
		other = other + 1;
		addObject(x,other);
	}
}

function removeObject(tagName,idNum) {
	var Div = tagName + idNum.toString();
	hide(Div);
	if ( idNum == 2 ) {
		var removeButton = 'remove' + tagName;
		hide(removeButton);
	}
	if ( idNum > 2 ) {
		var addButton = 'add' + tagName;
		show(addButton);
	}
}

function removeSinger(tagName,idNum) {
	var Div = tagName + idNum.toString();
	hide(Div);
	if ( idNum == 2 ) {
		var removeButton = 'remove' + tagName;
		hide(removeButton);
	}
	if ( idNum > 2 ) {
		var addButton = 'add' + tagName;
		show(addButton);
	}
}

function removePerson(tagName,idNum) {
	var Div = tagName + idNum.toString();
	hide(Div);
	if ( idNum == 2 ) {
		var removeButton = 'remove' + tagName;
		hide(removeButton);
	}
	if ( idNum > 2 ) {
		var addButton = 'add' + tagName;
		show(addButton);
	}
}

function removePB(tagName,idNum) {
	var Div = tagName + idNum.toString();
	hide(Div);
	if ( idNum == 2 ) {
		var removeButton = 'remove' + tagName;
		hide(removeButton);
	}
	if ( idNum > 2 ) {
		var addButton = 'add' + tagName;
		show(addButton);
	}
}

function removeEmp(tagName,idNum) {
	var Div = tagName + idNum.toString();
	hide(Div);
	if ( idNum == 2 ) {
		var removeButton = 'remove' + tagName;
		hide(removeButton);
	}
	if ( idNum > 2 ) {
		var addButton = 'add' + tagName;
		show(addButton);
	}
}
	
function removeRec(x) {
	if ( x == 'child' && child > 1 ) {
		removeObject(x,child);
		child = child - 1;
	}
	if ( x == 'sibling' && sibling > 1 ) {
		removeObject(x,sibling);
		sibling = sibling - 1;
	}
	if ( x == 'singer' && singer > 1 ) {
		removeSinger(x,singer);
		singer = singer - 1;
	}
	if ( x == 'pallbearer' && pallbearer > 1 ) {
		removePB(x,pallbearer);
		pallbearer = pallbearer - 1;
	}
	if ( x == 'person' && person > 1 ) {
		removePerson(x,person);
		person = person - 1;
	}
   if ( x == 'emp' && emp > 1 ) {
		removeEmp(x,emp);
		emp = emp - 1;
	}
   if ( x == 'other' && other > 1 ) {
		removeObject(x,other);
		other = other - 1;
	}
}
	
function casketInput(x) {
	var domMetal = findDOM('metalDiv');
	var domWood = findDOM('woodDiv');
	if ( x == "wood" ) {
		show('woodDiv');
		hide('metalDiv');
	}
	else {
		hide('woodDiv');
		show('metalDiv');
	}
}
