
	document.observe('dom:loaded', function(){
		if ($('error_summary')) $('error_summary').hide();
	});
	
	var errors = [];
	var account_errors = '';

	function validateSignup() {

	// hide the error summary
		$('error_summary').hide();
		
		// reset all the fields prior to re-validation
		account_errors = '';
		errors = [];
		
		// reset the fields
		resetErrorField(['signup_email', 'signup_country']);
		
		
		if ($F('fld_email') == '' || $F('fld_email').indexOf('@') < 0 || $F('fld_email').indexOf('.') < 0) {
			$('signup_email_error').addClassName('error');
			$('signup_email_error').insert({top: '<p id="signup_email_message" class="errorOn">'+snippet('validationemail')+'</p>'});
			errors[1] = snippet('validationemail');
		}
		// check the country field
		if ($('fld_country').selectedIndex==0) {
			$('signup_country_error').addClassName('error');
			$('signup_country_error').insert({top: '<p id="signup_country_message" class="errorOn">'+snippet('validationcountry')+'</p>'});
			errors[2] = snippet('validationcountry');
		}
		
		// highlight the errors at the top of the page
			if (errors.length > 0) {
				$('error_summary').show();
				account_errors = '<h3>'+snippet('validationfields')+'</h3>';
				account_errors += '<ul>';
				for (i = 0; i < errors.length; i++ ){
					if (errors[i] != null) {
						account_errors += '<li id="errorFields">' + errors[i] + '</li>';
					}
				}
				account_errors += '</ul>';
				$('error_summary').innerHTML = account_errors;
				return false;
			} else return true;
	}
	
	function resetErrorField(arr) {
		for (var i=0;i<arr.length;i++) {
			if ($(arr[i]+'_message') != null) $(arr[i]+'_message').remove();
			$(arr[i]+'_error').removeClassName('error');
		}
	}

	function validateContactform() {
			
		// hide the error summary
		$('error_summary').hide();
		
		// reset all the fields prior to re-validation
		account_errors = '';
		errors = [];
		
		// reset the fields
		resetErrorField(['contact_title', 'contact_firstname', 'contact_lastname', 'contact_message', 'contact_country', 'contact_email']);
		
		// check the title field
		if ($F('fld_title') == '') {
			$('contact_title_error').addClassName('error');
			$('contact_title_error').insert({top: '<p id="contact_title_message" class="errorOn">'+snippet('validationtitle')+'</p>'});
			errors[1] = snippet('validationtitle');
		}	
		
		// check the firstname field
		if ($F('fld_firstname') == '') {
			$('contact_firstname_error').addClassName('error');
			$('contact_firstname_error').insert({top: '<p id="contact_firstname_message" class="errorOn">'+snippet('validationfirstname')+'</p>'});
			errors[2] = snippet('validationfirstname');
		}
		
		
		// check the lastname field
		if ($F('fld_lastname') == '') {
			$('contact_lastname_error').addClassName('error');
			$('contact_lastname_error').insert({top: '<p id="contact_lastname_message" class="errorOn">'+snippet('validationlastname')+'</p>'});
			errors[3] = snippet('validationlastname');
		}
		
		// check the message field
		if ($F('fld_message') == '' || $F('fld_message').length>1000) {
			$('contact_message_error').addClassName('error');
			$('contact_message_error').insert({top: '<p id="contact_message_message" class="errorOn">'+snippet('validationmessage')+'</p>'});
			errors[4] = snippet('validationmessage');
		}
		
		// check the country field
		if ($('fld_country').selectedIndex==0) {
			$('contact_country_error').addClassName('error');
			$('contact_country_error').insert({top: '<p id="contact_country_message" class="errorOn">'+snippet('validationcountry')+'</p>'});
			errors[5] = snippet('validationcountry');
		}	


		if ($F('fld_email') == '' || $F('fld_email').indexOf('@') < 0 || $F('fld_email').indexOf('.') < 0) {
			$('contact_email_error').addClassName('error');
			$('contact_email_error').insert({top: '<p id="contact_email_message" class="errorOn">'+snippet('validationemail')+'</p>'});
			errors[6] = snippet('validationemail');
		}
		

	
	// highlight the errors at the top of the page
		if (errors.length > 0) {
			$('error_summary').show(); 
			account_errors = '<h3>'+snippet('validationfields')+'</h3>';
			account_errors += '<ul>';
			for (i = 0; i < errors.length; i++ ){
				if (errors[i] != null) {
					account_errors += '<li id="errorFields">' + errors[i] + '</li>';
				}
			}
			account_errors += '</ul>';
			$('error_summary').innerHTML = account_errors;
			return false;
		}
		else
		{
			return true; 
		}
	}
