
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;

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 == 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 add(x) {
	if ( x == 'child' && child < 5 ) {
		child = child + 1;
		addObject(x,child);
	}
	if ( x == 'sibling' && sibling < 5 ) {
		sibling = sibling + 1;
		addObject(x,sibling);
	}
	if ( x == 'singer' && singer < 5 ) {
		singer = singer + 1;
		addObject(x,singer);
	}
	if ( x == 'pallbearer' && pallbearer < 8 ) {
		pallbearer = pallbearer + 1;
		addPB(x,pallbearer);
	}
	if ( x == 'person' && person < 5 ) {
		person = person + 1;
		addObject(x,person);
	}
}

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 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 remove(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 ) {
		removeObject(x,singer);
		singer = singer - 1;
	}
	if ( x == 'pallbearer' && pallbearer > 1 ) {
		removePB(x,pallbearer);
		pallbearer = pallbearer - 1;
	}
	if ( x == 'person' && person > 1 ) {
		removeObject(x,person);
		person = person - 1;
	}
}
	
function casketInput(x) {
	var domMetal = findDOM('metalDiv');
	var domWood = findDOM('woodDiv');
	if ( x == "wood" ) {
		show('woodDiv');
		hide('metalDiv');
	}
	else {
		hide('woodDiv');
		show('metalDiv');
	}
}

function check() {
	var form = document.form1;
	if ( !form.location.value ) {
		if ( form.location.selectedIndex == 0 ) {
			alert("Please select a location you would like to submit this form to");
			return false;
		}
	}
	if ( !form.fName.value ) {
		alert("Please enter a first name in personal information")
		return false;
	}
	if ( !form.lName.value ) {
		alert("Please enter a last name in personal information");
		return false;
	}
	if ( !form.personalAddress1.value ) {
		alert("Please enter an address in personal information" );
		return false;
	}
	if ( !form.personalCity.value ) {
		alert( "Please enter a city in personal information" );
		return false;
	}
	if ( !form.personalState.value ) {
		alert( "Please enter a state/province in personal information" );
		return false;
	}
	if ( !form.personalZip.value ) {
		alert( "Please enter a zip/postal code in personal information" );
		return false;
	}
	if ( form.personalZip.value ) {
		for ( i=0; i < form.personalZip.value.length; i++ ) {
			var x = form.personalZip.value;
			x = x.charAt(i);
			if ( isNaN(x) ) {
				alert("Please enter numeric values in the zip/postal code in personal information");
				return false;
			 }
		}
	}
	if ( !form.personalPhone.value ) {
		alert( "Please enter a phone number" );
		return false;
	}
	if ( !form.personalEmail.value ) {
		alert("Please enter an email address");
		return false;
	}

	else {
		return true;
	}
}