var xmlhttp = false;

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e) {
		try {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		} catch (E) {
		xmlhttp=false
		}
		}
		@else
		xmlhttp=false
		@end @*/
	}
}

var introDiv = null;
function showIntroduction(idvalue) {
	if(!$) {
		return;
	}
	
	var contentDiv = $('#'+idvalue);
	if(introDiv == null) {
		introDiv = $('<div id="introContainer" />').appendTo('body');
		introDiv.hide();
	} else {
		introDiv.empty();
	}
	
	var targetOffset = $('.button-introductie', contentDiv.parent()).offset();
	targetOffset.top += 25;
	targetOffset.left -= 135;
	
	introDiv.html(contentDiv.html());
	introDiv.show();
	
	introDiv.offset(targetOffset);
}

function hideIntroduction() {
	if(!$) {
		return;
	}
	
	introDiv.hide();
}

function doOnLoad(lastMod, specialiteit, script) {
	script = script || 'xmlhttp.php';
	setTimeout('xmlupd("' + lastMod + '", ' + specialiteit + ', "' + script + '");', 5000);
}

function xmlupd(lastMod, specialiteit, script) {
	script = script || 'xmlhttp.php';
	
	// get current status 
	var url = script + '?cb=' + (new Date()).getTime() + '&s=' + specialiteit;
	
	xmlhttp.open('GET', url, true);
	
	if(lastMod) {
		xmlhttp.setRequestHeader('If-Modified-Since', lastMod);
	}
	
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {
				var el = document.getElementById('display');
				el.innerHTML = xmlhttp.responseText;
			}
			
			var newLastMod = xmlhttp.getResponseHeader('Last-Modified');
			if(newLastMod) {
				lastMod = newLastMod;
			}
			
			setTimeout('xmlupd("' + lastMod + '", ' + specialiteit + ', "' + script + '");', 5000);
		}
	}
	
	xmlhttp.send(null);
}

