<!--
window.addEvent('domready', function() {
	$('fullname').getParent().adopt( new Element('div', {'id':'er-fullname', 'class':'error-message'}) );
	$('email_address').getParent().adopt( new Element('div', {'id':'er-email_address', 'class':'error-message'}) );
	$('street_address_2').getParent().adopt( new Element('div', {'id':'er-street_address', 'class':'error-message'}) );
	$('zipcode_city').getParent().adopt( new Element('div', {'id':'er-zipcode_city', 'class':'error-message'}) );
	$('country').getParent().adopt( new Element('div', {'id':'er-country', 'class':'error-message'}) );
	$('your_model').getParent().adopt( new Element('div', {'id':'er-your_model', 'class':'error-message'}) );
	$('frame_serial_number').getParent().adopt( new Element('div', {'id':'er-frame_serial_number', 'class':'error-message'}) );
	$('date_of_purchase_year').getParent().adopt( new Element('div', {'id':'er-date_of_purchase', 'class':'error-message'}) );
	$('place_of_purchase').getParent().adopt( new Element('div', {'id':'er-place_of_purchase', 'class':'error-message'}) );
	$('accepttnc').getParent().adopt( new Element('div', {'id':'er-accepttnc', 'class':'error-message'}) );
	
	$('onlineWarrantyForm').addEvent('submit', function() {
		var isSubmit = true;
		$('er-fullname').innerHTML = "";
		$('er-email_address').innerHTML = "";
		$('er-street_address').innerHTML = "";	
		$('er-zipcode_city').innerHTML = "";	
		$('er-country').innerHTML = "";	
		$('er-your_model').innerHTML = "";	
		$('er-frame_serial_number').innerHTML = "";	
		$('er-date_of_purchase').innerHTML = "";	
		$('er-place_of_purchase').innerHTML = "";	
		$('er-accepttnc').innerHTML = "";	
		
		if ( $('fullname').value == "" ) {
			$('er-fullname').innerHTML = "Please enter the full name";
			isSubmit = false;
		}
		if ( $('email_address').value == "" ) {
			$('er-email_address').innerHTML = "Please enter the email address";
			isSubmit = false;
		}
		if ( $('email_address').value != "" ) {
			if (!isValidEmailFormat( $('email_address').value )) {
				$('er-email_address').innerHTML = "Please enter a valid email address";
				isSubmit = false;
			}
		}
		if ( $('street_address_1').value == "" || $('street_address_2').value == "" ) {
			$('er-street_address').innerHTML = "Please enter the street address ";
			isSubmit = false;
		}
		if ( $('zipcode_city').value == "" ) {
			$('er-zipcode_city').innerHTML = "Please enter the zip code, city";
			isSubmit = false;
		}
		if ( $('country').value == "" ) {
			$('er-country').innerHTML = "Please select the country";
			isSubmit = false;
		}
		if ( $('your_model').value == "" ) {
			$('er-your_model').innerHTML = "Please select your model";
			isSubmit = false;
		}
		if ( $('frame_serial_number').value == "" ) {
			$('er-frame_serial_number').innerHTML = "Please enter the frame serial number";
			isSubmit = false;
		}
		if ( $('date_of_purchase_day').value == "" || $('date_of_purchase_month').value == "" || $('date_of_purchase_year').value == "") {
			$('er-date_of_purchase').innerHTML = "Please select the date of purchase";
			isSubmit = false;
		}
		if ( $('place_of_purchase').value == "" ) {
			$('er-place_of_purchase').innerHTML = "Please enter the place of purchase";
			isSubmit = false;
		}
		if ( !$('accepttnc').get('checked') ) {
			$('er-accepttnc').innerHTML = "Please tick the terms and conditions. ";
			isSubmit = false;
		}
		
		return isSubmit;
	});
});

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