function submitForm(form, action) {
	form.action = action;
	form.submit();
}

function submitFormThin(form) {
	form.submit();
}

function fieldFocus(element) {
	document.getElementById(element).focus();
}

function isDefined(variable) {
	if(typeof(variable) !="undefined")
		return true;
	else
		return false;
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 2;
	while(isDefined(theForm[z]) && theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
		if(theForm[z].type == 'checkbox') {
			theForm[z].checked = theElement.checked;
		}
		z++;
	}
}

function cancelForm(action) {
	window.location.href = action;
}

function toggleDiv(id) {
	element = document.getElementById(id);
	element.className = (element.className.toLowerCase() == 'show'?'hide':'show');
}

function showDiv(id) {
	element = document.getElementById(id);
	element.className = 'show';
}

function hideDiv(id) {
	element = document.getElementById(id);
	element.className = 'hide';
}

function copyFromContact() {
	// First name
	document.getElementById('newUserFirstname').value = document.getElementById('firstName').value;
	
	// Last name
	document.getElementById('newUserLastname').value = document.getElementById('lastName').value;
	
	// Username
	document.getElementById('username').value = document.getElementById('firstName').value;
	
	// Password
	document.getElementById('password').value = document.getElementById('idCode').value;
}

function copyBusinessAddress() {
	document.getElementById('address1contact').value = document.getElementById('address1').value;
	document.getElementById('address2contact').value = document.getElementById('address2').value;
	document.getElementById('citycontact').value = document.getElementById('city').value;
	document.getElementById('zipcodecontact').value = document.getElementById('zipcode').value;
	
	document.getElementById('stateIDcontact').selectedIndex = document.getElementById('stateID').selectedIndex;
}