//AJAX
function isEmail(inputVal) {
	var regex = /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,4}$/
	if (!regex.test(inputVal)) {
		return true;
	}
	return false;
}

function xmlhttpPost(strURL, waarde1, waarde2, divnaam) {
   if (divnaam == 'newsletter') {
   	if (( isEmail(waarde2) == true) || (waarde1 == '')) {
		alert('Incorrect e-mail address/name');
		return false;
	}
   }
   var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,divnaam);
        }
    }
   self.xmlHttpReq.send(getquerystring(waarde1,waarde2));
}

function getquerystring(qstring1,qstring2) {
	qstr = 'waarde1=' + qstring1 + '&waarde2=' +qstring2;
    return qstr;
}


function updatepage(str,divstr){
  //alert(str);
  document.getElementById(divstr).style.display = 'block';
  document.getElementById(divstr).innerHTML = str;
}

