		//	=========================================================================
		//	default.js 
		//	version 	: 1.0.0.1
		//	Author	: AH.
		//	=========================================================================

		//set a value in form field, and create it it if it doesn't exists
		
		var xmlhttp;
		
if (!(typeof document.setFormFieldInFrame == "function")){
		function setFormFieldInFrame(frame, formid, type, varname, value){
			var command = "frame.document.getElementById('" + formid + "')." + varname;
			var result;

			command = command .replace('\n',"\\\n");
			command = command .replace('\r',"\\\r");
			result = eval(command);


			if ((result==undefined))
			{
				var newElem = document.createElement("INPUT");
				newElem.setAttribute("type",type);
				newElem.setAttribute("name",varname);
				newElem.setAttribute("id",varname);
				newElem.setAttribute("value",value);
				
				frame.document.getElementById(formid).appendChild(newElem);
			}
			else{
				command = "frame.document.getElementById('" + formid + "')." + varname + ".value = '" + value + "'";
				command = command .replace('\n',"\\\n");
				command = command .replace('\r',"\\\r");
				eval(command);
			}
		}
}
else alert("Error on including JS-Function 'setFormFieldInFrame'. Function already exists an may not be defined twice!");
	
	
if (!(typeof document.setFormField == "function")){
		//set a value in form field, and create it it if it doesn't exists
		function setFormField(formid, type, varname, value){
			var command = "document.getElementById('" + formid + "')." + varname;
			var result 

			command = command .replace('\n',"\\\n");
			command = command .replace('\r',"\\\r");
			result = eval(command);

			if ((result==undefined))
			{
				var newElem = document.createElement("INPUT");
				newElem.setAttribute("type",type);
				newElem.setAttribute("name",varname);
				newElem.setAttribute("id",varname);
				newElem.setAttribute("value", value);
				document.getElementById(formid).appendChild(newElem);
			}
			else{
				command = "document.getElementById('" + formid + "')." + varname + ".value = '" + value + "'";
				command = command .replace('\n',"\\\n");
				command = command .replace('\r',"\\\r");
				eval(command);
			}
		}
}
else alert("Error on including JS-Function 'setFormField'. Function already exists an may not be defined twice!");
		
if (!(typeof document.createFormField == "function")){
		//set a value in form field, and create it it if it doesn't exists
		function createFormField(formid, type, varname, value){
			var newElem = document.createElement("INPUT");
			newElem.setAttribute("type",type);
			newElem.setAttribute("name",varname);
			newElem.setAttribute("id",varname);
			newElem.setAttribute("value", value);
			document.getElementById(formid).appendChild(newElem);
		}
}
else alert("Error on including JS-Function 'setFormField'. Function already exists an may not be defined twice!");


		var post_active = 0;

if (!(typeof document.resetPostActive == "function")){			
		function resetPostActive(){
			post_active = 0;
		}
}
else alert("Error on including JS-Function 'resetPostActive'. Function already exists an may not be defined twice!");
	
	
if (!(typeof document.postNow == "function")){
		//function to post information
		function postNow(my){	
			var tag = "container_";
			
			while(my.parentNode.nodeName.toLowerCase() != 'div' && my.parentNode.id.substr(0, tag.length) != tag){
				my = my.parentNode;
			}
			parentId = my.parentNode.id;
			setFormField("form1", "hidden", "containerId", parentId);
			
			moduleId = parentId.split("_")[1];
			postModule(moduleId, moduleId);
		}
}
else alert("Error on including JS-Function 'postNow'. Function already exists an may not be defined twice!");
	
	
if (!(typeof document.postModule == "function")){	
		//function to post information
		function postModule(postbackmoduleid, handlemoduleid){
			setFormField("form1", "hidden", "domid", handlemoduleid);
			setFormField("form1", "hidden", "pbmid", postbackmoduleid);
			setFormField("form1", "hidden", "pbtid", "");
			setFormField("form1", "hidden", "dopb", "yes");
			setFormField("form1", "hidden", "dataonly", "yes");
			postAjax();
		}
}
else alert("Error on including JS-Function 'postModule'. Function already exists an may not be defined twice!");


if (!(typeof document.postModuleAdvanced == "function")){		
		function postModuleAdvanced(postbackmoduleid, handlemoduleid, postbackpagetree, dopostback, handleparameters){
			setFormField("form1", "hidden", "domid", handlemoduleid);
			setFormField("form1", "hidden", "pbmid", postbackmoduleid);
		    setFormField("form1", "hidden", "pbtid", postbackpagetree);
		    setFormField("form1", "hidden", "pbprm", handleparameters);
		    setFormField("form1", "hidden", "dopb", dopostback);
			setFormField("form1", "hidden", "dataonly", "yes");
			postAjax();
		}
}
else alert("Error on including JS-Function 'postModuleAdvanced'. Function already exists an may not be defined twice!");

if (!(typeof document.postAjax == "function")){		
	function postAjax(){			
		postUrl = "index.php?";
		var elem = document.getElementById('form1').elements;
		for(var i = 0; i < elem.length; i++){
			if(elem[i].name != undefined && elem[i].value != undefined){
				//console.log(elem[i].name + " as " + elem[i].type + " = " + elem[i].value + " / " + elem[i].checked);
				
				switch(elem[i].type){
					case "checkbox" : 
						if (elem[i].checked)
							postUrl = postUrl+''+elem[i].name+'='+elem[i].value+'&';
						else
							postUrl = postUrl+''+elem[i].name+'=0&';
						break;
					case "radio" : 
						if (elem[i].checked)
							postUrl = postUrl+''+elem[i].name+'='+elem[i].value+'&';
						break;
					default: 
						postUrl = postUrl+''+elem[i].name+'='+elem[i].value+'&';
				}
				
				
			}
		}
		
		postUrl = postUrl + '&submit=true&postajax=yes';
		
		//console.log(postUrl);
		
		if (post_active == 0){
			ajaxUrl(postUrl);
			showBusy();
		}
		else{
			//alert('Een Ogenblik a.u.b. we zijn bezig met het verwerken van gegevens');
		}

		post_active = post_active + 1;
		
		if (post_active > 1){
			//alert("Een ogenblik geduld a.u.b. De gegevens worden verwerkt.")
		}
	}
}
else alert("Error on including JS-Function 'postAjax'. Function already exists an may not be defined twice!");

	
if (!(typeof document.ajaxUrl == "function")){	
	//function to post information
	function ajaxUrl(url){
		xmlhttp=null;
		if (window.XMLHttpRequest){
			// code for Firefox, Opera, IE7, etc.
			xmlhttp=new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (xmlhttp!=null){
			xmlhttp.onreadystatechange=stateChanged;
			xmlhttp.open("POST",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser does not support XMLHTTP.");
		}
	}
}
else alert("Error on including JS-Function 'ajaxUrl'. Function already exists an may not be defined twice!");


if (!(typeof document.stateChanged == "function")){	
		//function to post information
		function stateChanged(){
			if (xmlhttp.readyState==4){
				// 4 = "loaded"
				if (xmlhttp.status==200){
					// 200 = "OK"
					resetPostActive();
					document.location.href = xmlhttp.responseText;
				} else {
					alert("Problem retrieving data:" + xmlhttp.statusText);
				}
			}
		}
}
else alert("Error on including JS-Function 'stateChanged'. Function already exists an may not be defined twice!");


if (!(typeof document.SetDivOpacity == "function")){	
	function SetDivOpacity (div, opacity){
		opacityDiv = document.getElementById(div);
		opacityDiv .style.filter = "alpha(opacity:" + opacity + ")";
		opacityDiv .style.opacity = 0.01*opacity;
		opacityDiv .style.MozOpacity = 0.01*opacity;
	}
}
else alert("Error on including JS-Function 'SetDivOpacity'. Function already exists an may not be defined twice!");

if (!(typeof document.showBusy == "function")){	
	function showBusy(){
		document.getElementById('mainOverlay').style.display = 'block';
	}
}
else alert("Error on including JS-Function 'showBusy'. Function already exists an may not be defined twice!");

if (!(typeof document.hideBusy == "function")){	
	function hideBusy(){
		document.getElementById('mainOverlay').style.display = 'none';
	}
}
else alert("Error on including JS-Function 'showBusy'. Function already exists an may not be defined twice!");

if (!(typeof document.externalLinks == "function")){
	function externalLinks() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
		}	
	}
}
else alert("Error on including JS-Function 'externalLinks'. Function already exists an may not be defined twice!");
