//==============================================================
//  SHOW THAT LOADING IMAGE
//==============================================================

function showLoadingImage() {
	document.getElementById('submitbox1').style.display = 'none';
	document.getElementById('submitbox2').style.display = 'block';
	setTimeout('document.images["loading"].src = "images/loading.gif"', 1);
}

//==============================================================
//  CONTACT FORM VALIDATION
//==============================================================

function contact_urbanEnroll(form)
{
	var form = document.form;
	var valid = true;
	var errors = '';
	// ERROR CHECKING
	if(document.getElementById('enroll_Main-Course').options[document.getElementById('enroll_Main-Course').selectedIndex].value=="") { valid = false; errors = errors + '\n- Choose a course'; }
	if(document.getElementById('enroll_Main-Location').options[document.getElementById('enroll_Main-Location').selectedIndex].value=="") { valid = false; errors = errors + '\n- Choose a location'; }
	if(!document.getElementById('enroll_Main-Ground-Rules').checked) { valid = false; errors = errors + '\n- You need to agree with the Ground Rules'; }
	var email = document.getElementById('enroll_Owner-Email').value;
	if(!checkMail(email)) { valid = false; errors = errors + '\n- Email Address'; }
	if(document.getElementById('enroll_Owner-Home-Phone').value=="") { valid = false; errors = errors + '\n- Phone Number'; }
	// VALID OPTIONS
	if (valid)
		{
		showLoadingImage();
		return true;
		}
	else {
		msg = "Please fill the required fields";
		alert ( msg + errors );
		return false;
		}
}

function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) { return true; }
	else { return false; }
}
