		function createRequestObject(){
			var request_o; //variabele die basis object bijhoudt
			var browser = navigator.appName;
			if(browser == "Microsoft Internet Explorer"){
				/* Microsoft manier */
				request_o = new ActiveXObject("Microsoft.XMLHTTP");
			}else{
				/* Andere manier */
				request_o = new XMLHttpRequest();
			}
			return request_o; 
		}
		var http = createRequestObject();
		
		//var http = getHTTPObject(); // Create the HTTP Object
		
		
		
		function validate_submission(f)
		{
			//alert('boe5');
			//Reset the form so it looks like there are no errors
			reset_errors(f);
			
			//Get the string, and send it on it's way
			var xml = create_xml(f);
			//alert(xml);
			send_form(xml);
			
			//Always return false.  Form submission happens in state_handler() if there are no errors.
			return false;
			//alert(xml);
		}
		
		//This creates an XML string of the form to be submitted for validation
		function create_xml(f)
		{
			var xml = '<?xml version="1.0" encoding="UTF-8" ?>';
			xml += "<form name=\""+ f.name + "\">";
				for (i=0; i<f.elements.length; i++)
				{
					if (f.elements[i].name)
					{
						xml += "<input name='"+f.elements[i].name+"' value='"+f.elements[i].value+"' \/>";
					}
				}
			xml += "<\/form>";
			return xml;
		}
		
		function send_form(xml)
		{
			//alert(xml);
			http.open("POST", "validation_server.php", true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			
			// Send the string as $_POST['xml']
			http.send("xml="+xml);
			http.onreadystatechange = state_handler;
		}
		
		function state_handler()
		{
			if (http.readyState == 4)
			{
				if (http.status == 200)
				{
					//alert(http.responseText);
					
					//Get the XML document
					xmldoc  	= http.responseXML;
					
					//Get the form node & then get it's name so we can set f again
					form 		= xmldoc.getElementsByTagName('form')[0];
					form_name	= form.getAttribute('name');
					f 			= document.forms[form_name];
					//alert(form);
					Errors = new Array();
					
					//Cycle through the form elements, getting whatever data we may need from it.
					for (var i = 0; i < form.childNodes.length; i++)
					{
						Element = form.childNodes[i];

						if (Element.getAttribute('valid') == "0")
						{
							//Create a new Error object with the item's name and the error message
							Errors[Errors.length] = new Error(Element.getAttribute('name'), Element.getAttribute('error_message'));
						}
					}
					//alert("test2");
					
					//Now that we have all the errors, we can do whatever we want with them.  
					//I am just going to display the first one found.
					if (Errors.length > 0)
					{
						error_obj = f.elements[Errors[0].name];
						msg = Errors[0].error_message;
						error_box(f, error_obj, msg);
						//alert('boe');
					}
					//If no errors, submit the form.
					else
					{
						f.submit();
						return true;
					}
				}
			}
		}
		
		function error_box(f, input_el, msg)
		{
			//Clear any trace of old error messages
			reset_errors(f)
			
			//Make the background yellow, focus on it, and select the text
			input_el.style.background = "#cccccc";
			input_el.focus();
			if (input_el.getAttribute('type') == 'text')
				input_el.select();

			//Display the message
			if (document.getElementById('error_box'))
				document.getElementById('error_box').innerHTML = msg;
		}
		
		
		
		function reset_errors(f)
		{
			//Reset the element styles
			for (var i=0; i<f.elements.length; i++)
			{
				if (f.elements[i].type)
				{
					f.elements[i].style.background = "white";
				}
			}
			
			if(document.getElementById('error_box'))
				document.getElementById('error_box').innerHTML = "&nbsp;";
		}
		
		function Error(name, error_message){
			this.name 			= name;
			this.error_message 	= error_message;
		}
		
		function getHTTPObject()
		{
		  var xmlhttp;
		  
		  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
				try {
					xmlhttp = new XMLHttpRequest();
				} catch (e) {
					xmlhttp = false;
				}
		  }
		  return xmlhttp;
		}
		
		function validate_newsletter(form){
			
			errors = false;
			form.name.style.background = "#ffffff";
			form.firstname.style.background = "#ffffff";
			form.email.style.background = "#ffffff";
			
			if(form.name.value ==""){
				errors = true;
				form.name.style.background = "#cccccc";
			}
			
			if(form.firstname.value ==""){
				errors = true;
				form.firstname.style.background = "#cccccc";
			}
			
			if(form.email.value ==""){
				errors = true;
				form.email.style.background = "#cccccc";
			}
			
			if(!isEmail(form.email.value)){
				errors = true;
				form.email.style.background = "#cccccc";
			}
			
			if(!errors){
				return true;	
			}else{
				return false;	
			}
		}
		
		function isEmail(value)
		{
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			
			if (filter.test(value)){
				return true;
			}else{
				return false;
			}
		}