	function validateEmail(id) {  
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;  
		return emailPattern.test(id);  
	}

	var xmlHttp;
	
	function createXMLHttpRequest() {
		if ( window.ActiveXObject ) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if ( window.XMLHttpRequest ) {
			xmlHttp = new XMLHttpRequest();
		}
	}

	function fn_switch_homecenter(section) {
		createXMLHttpRequest();

		params = "section=" + section;

		if ( section == 'news' ) {
			xmlHttp.open("POST","/inc/inc-homeCenterDIV-news.php", true);
		}
		if ( section == 'webstore' ) {
			xmlHttp.open("POST","/inc/inc-homeCenterDIV-webshop.php", true);
		}
		if ( section == 'newsletter' ) {
			xmlHttp.open("POST","/inc/inc-homeCenterDIV-newsletter.php", true);
		}

		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		xmlHttp.onreadystatechange = function() {
			if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
				document.getElementById("homeCenterDIV").innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.send(params);
	}

	function fn_subscribe() {
		createXMLHttpRequest();

		get_naam = document.getElementById("frm_nl_naam").value;
		get_email = document.getElementById("frm_nl_email").value;

		if ( get_naam != '' && validateEmail(get_email) === true ) {
			params = "naam=" + get_naam + "&email=" + get_email;
	
			xmlHttp.open("POST","/ajax/ajax-newsletter.php", true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	
			xmlHttp.onreadystatechange = function() {
				if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
					document.getElementById("nlDIV").innerHTML = xmlHttp.responseText;
				}
			}
			xmlHttp.send(params);
		} else {
			jAlert('Gelieve alle velden in te vullen!','Opgepast');
		}
	}

	function fn_subscribe_band() {
		createXMLHttpRequest();

		get_naam = document.getElementById("frm_band_naam").value;
		get_genre = document.getElementById("frm_band_genre").value;
		get_email = document.getElementById("frm_band_email").value;
		get_myspace = document.getElementById("frm_band_myspace").value;

		if ( get_naam != '' && get_genre != '' && get_myspace != '' && validateEmail(get_email) === true ) {
			params = "naam=" + get_naam + "&email=" + get_email + "&genre=" + get_genre + "&myspace=" + get_myspace;
	
			xmlHttp.open("POST","/ajax/ajax-bandclash.php", true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

			xmlHttp.onreadystatechange = function() {
				if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
					document.getElementById("bandClashDIV").innerHTML = xmlHttp.responseText;
				}
			}
			xmlHttp.send(params);
		} else {
			jAlert('Gelieve alle velden in te vullen!','Opgepast');
		}
	}
	
	function fn_add_basket(ID,token) {
		createXMLHttpRequest();

		params = "ID=" + ID + "&token=" + token;

		xmlHttp.open("POST","/ajax/ajax-add-basket.php", true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		xmlHttp.onreadystatechange = function() {
			if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
				var formfield = "item" + ID
				document.getElementById(eval("formfield")).innerHTML = '<span class="more">Zit in mandje</span>';
				
				setTimeout ("fn_update_cart('" + token + "');", 1000);
			}
		}
		xmlHttp.send(params);
	}

	function fn_update_cart(token) {
		createXMLHttpRequest();

		params = "token=" + token;

		xmlHttp.open("POST","/ajax/ajax-update-cart.php", true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		xmlHttp.onreadystatechange = function() {
			if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
				document.getElementById("cartContentDIV").innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.send(params);
	}

	function fn_change_amount(action, cartID) {
		createXMLHttpRequest();

		params = "action=" + action + "&cartID=" + cartID;

		xmlHttp.open("POST","/ajax/ajax-change-amount.php", true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
				document.getElementById("cartcontent").innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.send(params);
	}

	function fn_delete_shopitem(shopID) {
		createXMLHttpRequest();

		params = "shopID=" + shopID;

		xmlHttp.open("POST","/ajax/ajax-delete-shopitem.php", true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
				document.getElementById("cartcontent").innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.send(params);
	}
