/**
* @version $Id: include.js 13 2005-05-24 10:57:36Z  $
* @package Atirbelevingsmeting
* @copyright (C) 2005 BMA Groep
*/
//<!--
function addLoad(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function on_load() {
	try {
		if (!isIE && document.getElementById('tabel_ruimtestaat') != undefined) {
			document.getElementById('boxMain').style.width = (document.getElementById('tabel_ruimtestaat').offsetWidth + 40) + "px";
		}
		if (!isIE && false) {
			var els = document.getElementsByTagName("table");
			for (i=0;i<els.length;i++) {
				try {
					var width = els[i].offsetWidth;
					if (width > document.getElementById('boxMain').style.width) {
						document.getElementById('boxMain').style.width = width + 40 + "px";
					}
				}
				catch (err) {}
			}
		}
	}
	catch (er) {}
	try {
		var myTable = new SortedTable();
	}
	catch (er2) {
		alert(er2);
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function wachtscherm(tekst) {
	try {
		if (tekst == undefined) tekst = '';
		var wacht = document.createElement('div');
		wacht.id = 'boxWacht';
		wacht.style.className = 'boxWacht';

		var wachtinner = document.createElement('div');
		wachtinner.id = 'boxWachtInner';
		wachtinner.innerHTML = 'Melding';

		var image1 = new Image();
		image1.width = 250;
		image1.height = 151;
		image1.src = base + "images/logo_atir_klein.jpg";

		wacht.appendChild(wachtinner);
		wacht.appendChild(image1);

		wacht.innerHTML += '<br /><br />Een ogenblik geduld a.u.b...<br />';
		wacht.innerHTML += tekst;

		var scrollY = (document.all) ? document.body.scrollTop : window.pageYOffset;
		var windowHeight = (window.innerHeight ? window.innerHeight : document.body.clientHeight);

		wacht.style.top = (((windowHeight + scrollY) / 2) - 75) + "px";
		document.getElementById('boxMain').appendChild(wacht);
	}
	catch (err) {
		//alert (err);
		alert(tekst);
	}
	//return false;
	return true;
}

var xmlRequest;
var isOpera = navigator.userAgent.indexOf("Opera") > -1;
var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera;
var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera;
function Initialize_Callback()
{
	try
	{
		xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			xmlRequest = null;
		}
	}

	if(!xmlRequest && typeof XMLHttpRequest != "undefined")
	{
		xmlRequest = new XMLHttpRequest();
	}
}

function DoCallback(callback, params)
{
	var pageUrl = document.location + "&callback=" + callback + params;

	xmlRequest.open("GET", pageUrl, false);
	xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlRequest.send(null);

	return xmlRequest;
}

function Trim(TRIM_VALUE) {
	if(TRIM_VALUE.length < 1){
		return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE == ""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if (v_length < 0)
	{
		return "";
	}
	var iTemp = v_length -1;

	while (iTemp > -1){
		if (VALUE.charAt(iTemp) == w_space){}
		else {
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	if (v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){}
		else {
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function voegtoe_listitem(field, id, title, select) {
	var doc = field.ownerDocument;
	if (!doc) doc = field.document;

	var opt = doc.createElement('option');
	opt.value = id;
	opt.text = title;
	if (select) opt.selected = true;

	field.options.add(opt, field.options.length);
}

//-->
