function subscribeUser(name,email,promoid,layout){
    
    document.getElementById("moment").style.display = 'block';
	document.getElementById("button").style.display = 'none';
	
	if (name.length < 3){
		alert ('De naam moet uit minimaal 3 karakters bestaan!');
		document.getElementById("moment").style.display = 'none';
		document.getElementById("button").style.display = 'block';
	}
	
	if (!isValidEmail(email)){
		alert('Er is een ongeldig e-mailadres opgegeven!');
		document.getElementById("moment").style.display = 'none';
		document.getElementById("button").style.display = 'block';
	}else {		
	   
       	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request")
			return
		}
		
		//Bunch of new vars need to be passed along for the transaction
        
		var url="../../modules/sendActivation.php"
		url=url+"?name="+name
		url=url+"&email="+email
        url=url+"&promoid="+promoid;
        url=url+"&layout="+layout;
		xmlHttp.onreadystatechange= function() {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				result = xmlHttp.responseText;				
				if (result=="OKAY"){
					document.getElementById("moment").style.display = 'none';
					document.getElementById("button").style.display = 'none';
					document.getElementById("done").style.display = 'block';					
				}else {
					alert("De downloadlink kon niet worden aangemaakt!");
					document.getElementById("moment").style.display = 'none';
					document.getElementById("button").style.display = 'block';
				}
			}
			
		}
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}	
}

// Simple emailadres checker
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

