function clearForm(form) { document.getElementById(form).reset(); }
function clearForms(formName) {
    var arr = new Array();
    arr = document.getElementsByName(formName);
    for (var i = 0; i < arr.length; i++)
    {
        var form = arr.item(i);
        form.reset();
    }
}

function handleForm(form,id) {
	var possibles = new Array(); 
	
	/////////////////
	// IMPORTANT: You'll need to set up more of these based on the values in the dropdown menus in each lightbox
	/////////////////

	// Check form name
	// FORMS FOR OVERVIEW PAGE
	if (form == 'edit-info-form') 
	{
		// Load all possible sub-divs so you can hide them when the selection changes
		possibles = ['edit-dob','edit-pob','edit-dod','edit-pod','edit-ethnicity','edit-gender', 'edit-bio'];
		
		// Perform the transformation
		for (i=0;i<possibles.length;i++) 
		{
			var hide = possibles[i] +'-div';
			document.getElementById(hide).style.display='none';
		}				
				
		// Verify id is populated (not the default/blank) and show the selected div
		if (id != '') 
		{
			// Show new div
			var show = id +'-div';
			document.getElementById(show).style.display='block';
		}
	} else if (form == 'person-selected') 
	{
		/////// THIS ONE IS DIFFERENT. It shows a random div based on click.
		
		// Show new div
		var show = id +'-div';
		document.getElementById(show).style.display='block';
		
	} else if (form == 'reply-to-comment') 
	{
		
		// Fill in hidden input field with comment ID
		var formEl = document.getElementById(form+'-id').value = id;
	
	} 
}

function activateInput(id) 
{
	var e = document.getElementById(id);
	e.value = '';
	e.style.color='#000000';
}

function deactivateInput(id,val) 
{
	var e = document.getElementById(id);
	if (e.value == '') 
	{ 
		e.value = val;
		e.style.color='#999999';
	}
}

function checkPasswordUpdate() {
	var p1 = document.getElementById('pword').value;
	var p2 = document.getElementById('pword2').value;
	
	if (p1 == '') alert('Password field must not be blank.');
	else if (p2 == '') alert('You must confirm the password you\'ve entered.');
	else if (p1 != '' && p2 != '') {
		if (p1 != p2) 
		{
			 alert('Passwords provided do not match.');
			 return false;
		} else return true;
	}
}

function notify(which,val) {
	var c1 = document.getElementById(which+'-email');
	var c2 = document.getElementById(which+'-notify');	
	
	if (val == 'n') {
		c1.disabled = true;
		c2.disabled = true;
		c1.checked = false;
		c2.checked = false;
	} else {
		c1.disabled = false;
		c2.disabled = false;	
	}
}

function checkAll(formName) {
	var boxes = document.getElementById(formName+'-form').messages;
	var iMax = boxes.length;
	if (document.getElementById('check-all-'+formName).checked == false) {
		for (i=0;i<iMax;i++) { boxes[i].checked = false; }
	} else {
		for (i=0;i<iMax;i++) { boxes[i].checked = true; }
	}
}
