/******************************************************************************* 
Ajax XMLHTTPRequest functies 
*******************************************************************************/
function getURL(url, callback) { 
    var xhr = null;  
    if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
	else if (window.ActiveXObject) xhr = new ActiveXObject("Microsoft.XMLHTTP");
    if (xhr != null) {
		xhr.onreadystatechange = function() {
			if ((xhr.readyState==4) && (xhr.status==200)) callback(xhr);
		}
		//url = url + "&ms=" + new Date().getTime();
		xhr.open("GET", url, true);
		xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		xhr.setRequestHeader("Cache-Control", "no-cache");
		xhr.setRequestHeader("X_USERAGENT", "WebiaXHR");
		xhr.send(null);
    }
}

function postURL(url, data, callback) {
    var xhr = null;  
    if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
    else if (window.ActiveXObject) xhr = new ActiveXObject("Microsoft.XMLHTTP");
    if (xhr != null) {
        xhr.onreadystatechange = function() {
            if ((xhr.readyState==4) && (xhr.status==200)) callback(xhr);
        }
        xhr.open('POST', url, true);
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.setRequestHeader("Content-length", data.length);
        xhr.setRequestHeader("Connection", "close");
        //xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        //xhr.setRequestHeader("Cache-Control", "no-cache");
        xhr.setRequestHeader("X_USERAGENT", "WebiaXHR");
        xhr.send(data);
    }
}

/******************************************************************************* 
Hulpfuncties voor bepalen afmeting en positie van DOM-object/element 
*******************************************************************************/
function getX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
		}
	}
	return curleft;
}
function getY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;
		}
	}
	return curtop;
}
function getWidth(obj) {
	return obj.offsetWidth;
}
function getHeight(obj) {
	return obj.offsetHeight;
}

//haal een specifieke waarde van een parameter uit de window.location.href
function gup(name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if (results == null) return "";
	else return results[1];
}

function popupPhoto(oid, nr) {
	var photo = '<a href="#" onclick="closePopup(); return false"><img src="data/'+oid+'/photos/photo'+nr+'-l.jpg" border="0" title="Klik om te sluiten"></a>';
	document.getElementById('popupcontent').innerHTML = photo;
	showPopup();
}

function closePopup() {
	document.getElementById('popupcontent').innerHTML = '';
	document.getElementById('popup').style.display = 'none';
}

function showPopup() {
	document.getElementById('popup').style.display = 'block';
}