	/**
	* this jsscript can be used for checking forms
	*
	* @author     Verkoyen Tys <tys@crsolutions.be>
	* @copyright  2005 CR Solutions
	* @version    0.1
	*/
	
	/**
	* checks if value is shorter then length
	*
	* @param	string	value	the value to check
	* @param	int		length	the maximum length
	*
	* @returns	boolean	if value is shorter then length the boolean will be true, otherwise it will be false
	*/	
	function isEmpty(value, length) {
		if(value.length < length) {
			return true;	
		} else {
			return false;
		}
	}
	
	/**
	* checks if emailaddress is a valid emailaddress
	*
	* @param	string	email	the emailaddress to check
	*
	* @returns	boolean	if email is a valid emailaddress the boolean will be true, otherwise it will be false
	*/	
	function isValidEmail(email) {
		var regex = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
	    
		if(regex.test(email)) {
			return true;
		} else {
			return false;	
		}
	}
	
	/**
	* same as in_array for PHP
	*
	* @returns	boolean	
	*/	
	function in_array(needle, haystack){
        var hay = haystack.toString();
        if(hay == ''){
            return false;
        }
        var pattern = new RegExp(needle, 'g');
        var matched = pattern.test(haystack);
        return matched;
    }
		
	/**
	* checks the information specific for contacting.
	*
	* @returns	string	the string contains the errors
	*/	
	function validateContact() {
		var form = document.getElementById("form");
		var contact = document.getElementById("contact");
		var err_contact = document.getElementById("err_contact");
		var email = document.getElementById("email");
		var err_email = document.getElementById("err_email");
		var mesg = document.getElementById("mesg");
		var err_mesg = document.getElementById("err_mesg");
		var error = document.getElementById("error");
				
		var control = new Array();
		
		if (isEmpty(contact.value, 4)) {
			err_contact.style.color = '#FF0000';
			control[0] = false;
		} else {
			err_contact.style.color = '#FFFFFF';
			control[0] = true;
		}
		if (isEmpty(email.value, 4)) {
			err_email.style.color = '#FF0000';
			control[1] = false;
		} else {
			if (!isValidEmail(email.value)) {
				err_email.style.color = '#FF0000';
				control[1] = false;
			} else {
				err_email.style.color = '#FFFFFF';
				control[1] = true;
			}
		}
		if (isEmpty(mesg.value, 10)) {
			err_mesg.style.color = '#FF0000';
			control[3] = false;
		} else {
			err_mesg.style.color = '#FFFFFF';
			control[3] = true;
		}
		
		if (!in_array(false, control)) {
			form.submit();
			error.style.color = '#FFFFFF';
		} else {
			error.style.color = '#FF0000';
		}
		
	}