<!--

// Sets a form's focus to the first visible element.
function SetFormFocus(formName)
{
	if(document.forms[formName])
	{
		for(i = 0; i < document.forms[formName].elements.length; i++)
		{
			if(document.forms[formName].elements[i].type != 'hidden')
			{
				document.forms[formName].elements[i].focus();
				return;
			}
		}
	}


}


function CheckLoginForm(frm)
{
	re = new RegExp("^[a-zA-Z0-9\\._-]+@[a-zA-Z0-9\\._-]+\\.[a-zA-Z0-9_-]{2,4}$", 'i'); // Create the regular expression object
	
	// Validate Email.
	field = frm.elements['Email'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		alert('Your email address is not formatted correctly.');  
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}
	
	re = new RegExp("[^ ]", 'i'); // Create the regular expression object
	
	// Validate Password.
	field = frm.elements['Password'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		alert('Please enter your password.');  
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}

	return true;
}


function CheckQuickRegisterForm(frm)
{
	// Category1 and Category2 are required.
	var fld1 = frm.elements['category1'];
	var fld2 = frm.elements['category2'];
	
	if(fld1.selectedIndex <= 0 || fld2.selectedIndex <= 0) {
	
		alert('Please select Category for your search.');
		return false;

	}
	
	re = new RegExp("[^ ]", 'i'); // Create the regular expression object
	
	// Validate First Name.
	field = frm.elements['First_Name'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		alert('Please enter your First Name.');  
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}
	
	// Validate Last Name.
	field = frm.elements['Last_Name'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		alert('Please enter your Last Name.');  
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}
	
	re = new RegExp("^[a-zA-Z0-9\\._-]+@[a-zA-Z0-9\\._-]+\\.[a-zA-Z0-9_-]{2,4}$", 'i'); // Create the regular expression object

	// Validate Email Address.
	field = frm.elements['Email'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		if(field.value == '') {
			alert('Please enter your Email Address.');
		} else {
			alert('Email address format is invalid.');
		}
		
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}
	
	re = new RegExp("[^ ]", 'i'); // Create the regular expression object
	
	// Validate Password.
	field = frm.elements['Password'];
	if ( ! re.test(field.value)) { // Does it match the expression?  If not do this.
	
		alert('Please enter your Password.');  
		field.focus();  // Set the cursor focus for convenience.
		return false;  // No go!

	}
	
	if(! frm.elements['AcceptTerms'].checked)
	{
		alert('Please confirm you have read and accept the Terms & Conditions.');
		return false;
	}
	
	return true;
}

// Post the form to the Terms & Conditions page
// so that the user can read it without losing entered information.
function GoToTermsAndConditions()
{
	document.forms['frmQuickRegister'].action = '/terms_and_conditions.php';
	document.forms['frmQuickRegister'].submit();
}

-->
