function loadForm(id) {
	var xmlhttp = false;

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} else {
		alert("Your browser does not support AJAX controls.");	
	}

	if (xmlhttp) {
		
		// build query string using inited variables and a random number to bypass caching
		var url = "includes/templates/home-maillist_" + id + ".html.php?num=" + Math.random();
		var obj = document.getElementById('mailingbox');
		xmlhttp.open("GET", url);
		
		// execute and insert
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;	
			}
		}
		
		xmlhttp.send(null);
	}
}

function subscribe() {
	var xmlhttp = false;

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} else {
		alert("Your browser does not support AJAX controls.");	
	}

	if (xmlhttp) {
		
		var params = "sendinfo=666&";
		params += "fore=" + document.mailinglist.fore.value + "&";
		params += "sur=" + document.mailinglist.sur.value + "&";
		params += "email=" + document.mailinglist.email.value;
		
		// send out request via POST method
		var url = "includes/modules/home-maillist_add.mod.php";
		var obj = document.getElementById('mailingbox');
		xmlhttp.open("POST", url);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;	
			}
		}
		
		xmlhttp.send(params);
	}
}

function unsubscribe() {
	var xmlhttp = false;

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");	
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} else {
		alert("Your browser does not support AJAX controls.");	
	}

	if (xmlhttp) {
		
		var params = "sendinfo&email=" + document.mailinglist.email.value;
		
		// send out request via POST method
		var url = "includes/modules/home-maillist_remove.mod.php";
		var obj = document.getElementById('mailingbox');
		xmlhttp.open("POST", url);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;	
			}
		}
		
		xmlhttp.send(params);
	}
}
