<!--
window.addEvent('domready', function() {
	$('companyname').getParent().adopt( new Element('div', {'id':'er-companyname', 'class':'error-message'}) );
	$('contactperson').getParent().adopt( new Element('div', {'id':'er-contactperson', 'class':'error-message'}) );
	$('telephoneno').getParent().adopt( new Element('div', {'id':'er-telephoneno', 'class':'error-message'}) );
	$('emailaddress').getParent().adopt( new Element('div', {'id':'er-emailaddress', 'class':'error-message'}) );
	$('address').getParent().adopt( new Element('div', {'id':'er-address', 'class':'error-message'}) );
	$('city').getParent().adopt( new Element('div', {'id':'er-city', 'class':'error-message'}) );
	$('country').getParent().adopt( new Element('div', {'id':'er-country', 'class':'error-message'}) );
///	$('accepttnc').getParent().adopt( new Element('div', {'id':'er-accepttnc', 'class':'error-message'}) );
	
	$('becomeADealerForm').addEvent('submit', function() {
		var isSubmit = true;
		$('er-companyname').innerHTML = "";
		$('er-contactperson').innerHTML = "";
		$('er-telephoneno').innerHTML = "";
		$('er-emailaddress').innerHTML = "";
		$('er-address').innerHTML = "";
		$('er-city').innerHTML = "";
		$('er-country').innerHTML = "";
//		alert(document.getElementById('er-accepttnc'));
//		document.getElementById('er-accepttnc').innerHTML = "";
		
		if ( $('companyname').value == "" ) {
			$('er-companyname').innerHTML = "Please enter a name of company";
			isSubmit = false;
		}
		if ( $('contactperson').value == "" ) {
			$('er-contactperson').innerHTML = "Please enter contact person";
			isSubmit = false;
		}
		
		if ( $('telephoneno').value == "" ) {
			$('er-telephoneno').innerHTML = "Please enter telephone no.";
			isSubmit = false;
		}
		
		if ( $('emailaddress').value == "" ) {
			$('er-emailaddress').innerHTML = "Please enter the email address";
			isSubmit = false;
		}
		if ( $('emailaddress').value != "" ) {
			if (!isValidEmailFormat( $('emailaddress').value )) {
				$('er-emailaddress').innerHTML = "Please enter a valid email address";
				isSubmit = false;
			}
		}
		
		if ( $('address').value == "" ) {
			$('er-address').innerHTML = "Please enter address";
			isSubmit = false;
		}
		
		if ( $('city').value == "" ) {
			$('er-city').innerHTML = "Please enter city";
			isSubmit = false;
		}
		
		if ( $('country').value == "" ) {
			$('er-country').innerHTML = "Please enter country";
			isSubmit = false;
		}
/*		
		if ( !$('accepttnc').get('checked') ) {
			if (document.all) {
				$('er-accepttnc').innerText = "Please tick the terms and conditions.";
			} else {
				$('er-accepttnc').textContent = "Please tick the terms and conditions.";
			}
			isSubmit = false;
		}
*/		
		return isSubmit;
	});
});

function isValidEmailFormat(str) {
		
	var re = /^\S+\@\S+\.\S+$/;	
	return re.test(str);
}
//-->