/*
 *  main.js
 *  
 *  dit bestand zorgt voor algemene afhandeling
 */

/* met deze var kan je het menutype instellen:
 * 1 = horizontaal
 * 2 = verticaal
 */
var pageid = 0;
var path = "/";
var absolutepath = "/home/leonetcms/domains/leonetcms.nl/public_html/activelady";
var menutype = 1;
var http = createHTTPHandler();
var locked;
var editorArray = new Array();
var editorIndex = 0;
var editorOptie = '';
var openlightwindow = true;
var logedIn = false;

$(document).ready(function() {



$('#menu_login input').bind('keypress', function(e) {

        if(e.keyCode==13){
            login();
        }
});

});
window.onload = function() {
$("#overlay").css("visibility", "hidden");
} 	

function initLoader()
{
	$("#overlay").css("visibility", "visible");
}

function endLoader()
{
	$("#overlay").css("visibility", "hidden");
}

function init(pageid)
{
	$("#overlay").css("visibility", "visible");
	this.pageid = pageid;
	initTinyMce();
	var url = path + "verwerking.php?request=lockCheck";
	$.ajax({
	  url: url,	
	  success: function(data) {
		locked = data;			
		validateUser();
	  }
	});	
	
}

function add(id, cmd)
{
	 var inputs = $('.'+id+' :input');
	 $.ajax({
	 type: 'POST',
	 url: path + "verwerking.php?request="+cmd+"&cmd=add&"+inputs.serialize(),
		success: function(data) {
			alert(data);		
		}
	});
}


function refreshContent(id)
{
	//alert('test');
	//if(id != undefined)
	//	this.pageid = id;
	//$.get('/custom.php?request=returnUrl&id='+pageid, function(data) {
   	// $.get('/custom.php?request=returnAjaxContent&url='+data, function(data1) {
	   // 	  $(".ajaxcontent").html(data1);
	//		  ConstrueerMenu();
			  //init(pageid);
	    //	});
	//});
	reloadCurrentPage();
}

function loadFoto(foto, width, height)
{
	$(".fotoframe").fadeOut('slow', function() {
		$(".popupfoto").attr("href", "/classes/module_fotoalbum/foto.php?imagePath="+foto+"&width="+width+"&height="+height);
		$(".fotoframe").css("background-image", "url(/classes/module_fotoalbum/foto.php?imagePath="+foto+"&width="+width+"&height="+height+")");
		$(".fotoframe").fadeIn('slow').delay(500);
	});

	//$('.fotoframe').fadeOut('slow', function() {
		
		//$('.fotoframe').html = "<img src='/classes/module_fotoalbum/foto.php?imagePath="+foto+"&width=500&height=300' />";
		//$('.fotoframe').fadeIn('slow');
	//});  
	//$('.fotoframe').hide();
}

function edit(id, cmd, tinymce)
{
	var content = "";
	if(tinymce != "" && tinymce != undefined)
	{
		content = tinyMCE.get(tinymce);
		content = encodeURIComponent(content.getContent());
	}
	 var inputs = $('.'+id+' :input');
	 $.ajax({
	 type: 'POST',
	 url: path + "verwerking.php?request="+cmd+"&cmd=edit&content=" +content +"&" + inputs.serialize(),
		success: function(data) {
			alert(data);		
		}
	});
}

function del(menunaam, id, cmd, params)
{
	var OK
	OK = confirm("Weet u zeker dat u " + menunaam + " wilt verwijderen?");
	if (OK) {
		$.ajax({
			url: path + "verwerking.php?request=" + cmd + "&cmd=delete&id=" + id + "&" + params,
			success: function(data){
				alert(data);
				refreshPage();
			}
		});
	}
	return OK;
}

function changePosition(id, cmd)
{
	$(function() {
		$("#"+id+" ul").sortable({ opacity: 0.6, cursor: 'move', cursorAt: { left: -20}, update: function() {
			var order = $(this).sortable("serialize") + '&cmd=changePosition&request='+cmd;
			$.post("verwerking.php", order, function(theResponse){
			});
		},
		start: function(event, ui) {	
			openlightwindow = false;
		},
		stop: function(event, ui) {
			setTimeout(function(){ 
    			openlightwindow = true;
  			}, 100 );  
		}			
		});
	});	
	
}

function openFileBrowser(id){
    fileBrowserlink = "/js/filemanager/index.php?editor=standalone&returnID=" + id
	//alert(fileBrowserlink);
    window.open(fileBrowserlink,'pdwfilebrowser', 'width=1000,height=650,scrollbars=no,toolbar=no,location=no');
}


function initTinyMce()
{
	tinyMCE.init({
		mode:'none',
		theme : "advanced",
		language : "nl",
		plugins : "safari,spellchecker,pagebreak,style,Archiv,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		 paste_auto_cleanup_on_paste : true,
        setup : function(ed) { 
            ed.onInit.add(function(ed) { 
                ed.pasteAsPlainText = true;
                ed.controlManager.setActive("pastetext", true);
            });
        },
		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,code,forecolor,backcolor,hr,fullscreen",
		theme_advanced_buttons3 : "tablecontrols",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		force_br_newlines : false,
        force_p_newlines : true,
		extended_valid_elements : "input[type|value|name|size],form[name|method|action|onsubmit],script[type|language],hr[class|width|size|noshade],font[size|color|style],span[class|align|style],iframe[src|width|height|name|align]",
		file_browser_callback: "filebrowser",
		formats : {
		      Standaard : {inline : 'span', classes : 'Standaard'},
		      Kopjes : {inline : 'span', classes : 'Kopjes'},
		      Introductie : {inline : 'span', classes : 'Introductie'},
		      Ervaringen : {inline : 'span', classes : 'Ervaringen'},
		},
		theme_advanced_blockformats : "Standaard,Kopjes,Introductie,Ervaringen"
	});
}

function filebrowser(field_name, url, type, win) {
		
	fileBrowserURL = "/js/filemanager/index.php?editor=tinymce&filter=" + type;
			
	tinyMCE.activeEditor.windowManager.open({
		title: "PDW File Browser",
		url: fileBrowserURL,
		width: 950,
		height: 650,
		inline: 0,
		maximizable: 1,
		close_previous: 0
	},{
		window : win,
		input : field_name
	});		
}
function ajaxSave(id, request, rand) {
	var ed = "";
	if(request != 'Content')
	{
		ed = tinyMCE.get('content_tinymce_'+request+'_'+id);
	}
	else
	{
		if(rand == undefined)
			rand = "";
		ed = tinyMCE.get('content_tinymce_'+rand);
	}
		// Do you ajax call here, window.setTimeout fakes ajax call
	ed.setProgressState(1); // Show progress
	window.setTimeout(function() {
		ed.setProgressState(0); // Hide progress
		 $.post(path + "verwerking.php?request="+request+"&cmd=saveUpdatedContent", { content: ed.getContent(), id: id },
		   function(data) {
		     alert(data);
		});
		
	}, 1000);
}

function testtest(naam)
{
	$( naam ).dialog('open');

}

function addEmailAccount()
{
	var addEmailAccount_arr = new Array();
	addEmailAccount_arr.push(encodeURIComponent($("#addEmail_emailadres").val()));
	addEmailAccount_arr.push(encodeURIComponent($("#addEmail_wachtwoord").val()));
	addEmailAccount_arr.push(encodeURIComponent($("#addEmail_quota").val()));
		
	$.ajax({
	 url: path + "verwerking.php?request=addEmailAccount&Array=" + addEmailAccount_arr,	
		success: function(data) {
			alert(data);
			$.ajax({
			 url: path + "verwerking.php?request=accountManagement",	
				success: function(data) {
					$("#fragment-1").html(data);
					
				}
			});			
		}
	});
	
}

function DeleteAccount(email, type, id)
{
	var OK
	OK = confirm("Weet u zeker dat u " + email + " wilt verwijderen?");
	if (OK)
	{
		$.ajax({
		 url: path + "verwerking.php?request=emailAccounts&cmd=deleteAccount&email="+email+"&Array=" + type,	
			success: function(data) 
			{
				$("#"+id).html(data);				
			}
		});
	}
	return OK 
}

function addForwarder_addForwarderAccount()
{
	var addForwarder_arr = new Array();
	addForwarder_arr.push(encodeURIComponent($("#addForwarder_emailAdres").val()));
	addForwarder_arr.push(encodeURIComponent($("#addForwarder_curAdres").val()));
	
	$.ajax({
	 url: path + "verwerking.php?request=emailAccounts&cmd=addForwarderAccount&Array=" + addForwarder_arr,	
		success: function(data) {
			alert(data);
			$.ajax({
			 url: path + "verwerking.php?request=emailAccounts&cmd=getForwarderOverview",	
				success: function(data) {
					$("#fragment-3").html(data);
					
				}
			});			
		}
	});
}

function fillArray(naam, type, id)
{
	editorArray[editorIndex] = new Array(2);
	editorArray[editorIndex][0] = naam;
	editorArray[editorIndex][1] = type;	
	editorArray[editorIndex][2] = id;	
	editorIndex++;
}

function modulebeheer_editActive()
{
	var modules = new Array();
	
	$("#modulebeheer_id :checked").each(function() 
	{		
		modules.push($(this).val());
					   
	});
	
	$.ajax({
	 url: path + "verwerking.php?request=updateModules&moduleArray=" + modules,	
			success: function(data) {
				if(data == 'true')
				{
					alert('Modulen bijgewerkt');
				}	
				else	
				{
					alert("Er is een fout opgetreden, als deze fout zich blijft voordoen neem dan contact op met de webmaster");
				}
			}
	});
}
            


function changeBanner()
{
	var waarde = '';
	for(i = 0; i < document.banner.active.length; i++)
	{
		if(document.banner.active[i].checked)
		{
			waarde = document.banner.active[i].value;
			break;
		}
	}
	var url = path + "verwerking.php?request=changeBanner&id="+waarde+"&pageid="+this.pageid;
	//alert("verwerking.php?request=changeBanner&id="+waarde+"&pageid="+this.pageid);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if(resultaat == 'true')
				alert('Banner succesvol gewijzgid');
			else
				alert(resultaat);
		}
	} 
}

function clickSeo()
{
	if ($("#woot").is(":hidden")) {
		retrieveSeo();
		$("#woot").slideDown("slow");
		} else {
		$("#woot").slideUp("slow");
		}
}
function dragNdrop()
{
	$(function() {
		$("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
			var order = $(this).sortable("serialize") + '&request=updateRecordsListings';
			$.post("verwerking.php", order, function(theResponse){
			});
		}
		});
	});

}

function dragAndDrop(id, cmd)
{
	$(function() {
		$("#"+id+" ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
			var order = $(this).sortable("serialize") + '&request=updateRecordsListings&cmd='+cmd;
			$.post("verwerking.php", order, function(theResponse){
			});
		}
		});
	});
}

function dragNdropSubmenu(id, type)
{
	if(type == undefined)
	{
		$(function() {
			$("#contentLeft_"+id+" ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
				var order = $(this).sortable("serialize") + '&request=updateRecordsListings';
				$.post("verwerking.php", order, function(theResponse){
					//alert('n');
				});
			}
			});
		});
	}
	else if(type == 'nieuws')
	{
		$(function() {
			$("#contentLeft_"+id+" ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
				var order = $(this).sortable("serialize") + '&request=updateRecordsListings&cmd=nieuws';
				$.post("verwerking.php", order, function(theResponse){
					//alert('nieuws');
				});
			}
			});
		});
	}
	else if(type == 'download')
	{
		$(function() {
			$("#contentLeft_"+id+" ul").sortable({ opacity: 0.6, cursor: 'pointer', cursorAt: { left: -20}, update: function() {
				var order = $(this).sortable("serialize") + '&request=updateRecordsListings&cmd=downloads';
				$.post("verwerking.php", order, function(theResponse){ 
					//alert('downloads');
				});
			}
			});
		});
	}

}

function dragNdropPortfolio(id)
{
	$(function() {
		$("#contentLeft_"+id+" ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
			var order = $(this).sortable("serialize") + '&cmd=portfolio&request=updateRecordsListings';
			$.post("verwerking.php", order, function(theResponse){
				alert('portfolio');
			});
		}
		});
	});

}

function refreshFotos(id, rand)
{
	var url = path + "verwerking.php?request=portfolioItems&id="+id+"&rand="+rand;
	//alert(url);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;			
			document.getElementById('bewerk_portfolio'+rand).innerHTML = resultaat;
		}
	}
}

function removeFoto(id, id2, rand)
{
	//alert('ja');
	var url = path + "verwerking.php?request=removeFoto&id="+id;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			//var resultaat = http.responseText;			
			//if(resultaat == "true")
				refreshFotos(id2, rand);
			//alert(resultaat);
		}
	}
}
$(function(){

	// Progressbar
	$("#progressbar").progressbar({
		value: 20 
	});
	
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	
});


function checkChecked()
{
	alert($("#testCheck :checked").size());
	$("#testCheck :checked").each(function() 
	{
		$.ajax({
		  url: path + "verwerking.php?request=updateAccount&id=" + $(this).val(),	
		  success: function(data) {
			
		  }
		});					   
	});
	

}

function check() {
	var url = path + "verwerking.php?request=lockCheck";
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			return resultaat;	
		}
	}
}

function retrieveSeo()
{
	var mogelijkheden 	= '<div id="dialog_seo" title="SEO" style="font-size: 11px;">';
	mogelijkheden		+= "<div id='seo'></div>";
	mogelijkheden		+= "</div>";
	mogelijkheden 		+= '<div id="dialog_users" title="Gebruikers beheer" style="font-size: 11px;">';
	mogelijkheden		+= "<div id='users'></div>";
	mogelijkheden		+= "</div>";
	document.getElementById("editbox").innerHTML += mogelijkheden;
	var url = path + "verwerking.php?request=seo&id="+pageid;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			document.getElementById('seo').innerHTML = resultaat;
		}
	}
}
var paramid;
var paramid2;
function ConstrueerMenu()
{
	if(locked == "false")
	{ 
		
		setOption("none");	
		$("#locked").css("display", "block");
		$("#unlocked").css("display", "none");
	//	document.getElementById("locked").style.display = "block";
		//document.getElementById("unlocked").style.display = "none";
		editFields("none");
		//retrievePage();
		
	}
	else
	{
		
		setOption("block");				
		$("#locked").css("display", "none");
		$("#unlocked").css("display", "block");
		editFields("block");
	}
	
	dragNdrop();
}

var fadeIn = false;

function editFields(option)
{
				if(locked == "true")
			{
				$(".cmsbuttons").fadeIn('fast');
				$(".bewerkvelden").fadeIn('fast');
			}
			else
			{
				$(".bewerkvelden").fadeOut('fast');
				$(".cmsbuttons").fadeOut('fast');
			}
}

function refreshPage(refreshid)
{

	initLoader();
	refreshContent(refreshid);
}

function reloadCurrentPage()
{
	var url = "";
	
	url = path + "verwerking.php?request=refreshUrl&id="+pageid;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			window.location.href = resultaat;	
				
		}
	}
}

function editDownloadDetails(id, naam, omschrijving)
{
	var url = path + "verwerking.php?request=editDownloadDetails&id="+id+"&naam="+encodeURIComponent(naam)+"&omschrijving="+encodeURIComponent(omschrijving);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if(resultaat == "true")
				alert('Details bijgewerkt')
			else
				alert('Details niet bijgewerkt'); 	
				
		}
	}
}


function setOption(option)
{
	getal = 0;
	var isTrue = true;
	while(true)
	{
		var element = document.getElementById("options"+getal);
		if(document.getElementById("options"+getal) != null)
		{
			element.style.display = option;
			//document.getElementById("veld"+getal).style.display = "none";
			
			subgetal = 0;
			var subisTrue = true;
			
			while(subisTrue)
			{
				var subelement = document.getElementById("suboptions"+subgetal);
				if(document.getElementById("suboptions"+subgetal) != null)
				{
					
					subelement.style.display = option;
					//document.getElementById("subveld"+subgetal).style.display = "none";
				}
				else
				{
					subisTrue = false;
					break;
				}
				subgetal++;
			}
		}
		else
		{
			isTrue = false;
			break;
		}
		getal++;
	}
	
}

function login()
{
	document.getElementById('button').style.display = 'none';
	document.getElementById('loading').innerHTML = "<img src='"+path + "images/loader.gif' alt='loading'";
	var username 	= document.getElementById('gebnaam').value;
	var pass		= document.getElementById('pass').value;
	var url = path + "verwerking.php?request=inloggen&gebruikersnaam="+username+"&wachtwoord="+pass;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if(resultaat == "false")
			{
				document.getElementById('button').style.display = 'block';
				document.getElementById('loading').innerHTML = "<span class='leonet'>Gebruikersnaam/wachtwoord combinatie onjuist";
			}
			else
			{
				reloadCurrentPage();
			}
		}
	}
}


function validateUser() {
	var url = path + "verwerking.php?request=login";
	
	$.ajax({
	  url: url,	
	  success: function(data) {
		if (data == "true")
		{
			logedIn = true;
			toonMogelijkheden();	
		}
	  }
	});	

}

function saveMenuItem(id)
{
	var naam = $("#menunaam"+id).val();
	var url = path + "verwerking.php?request=saveMenu&id=" + id + "&menunaam=" + encodeURIComponent(naam);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "true")
			{		
				$('#dialog_menu_' + id ).dialog('close');
				refreshPage();
				//refreshMenu();				
				//alert("Menuitem " + naam + " bijgewerkt");
			}
			else
			{	
				$('#dialog_menu_' + id ).dialog('close');
				//refreshMenu();
			}
		}
	}
}

function AddMenuItem(id, subtype, toevoeging, menutype)
{
	var menunaam = document.getElementById("menuitem"+id+toevoeging).value;
	alert("verwerking.php?request=insertmenu&menunaam=" + encodeURIComponent(menunaam) + "&id="+id+"&subtype="+subtype+"&menutype="+menutype);
	var url = path + "verwerking.php?request=insertmenu&menunaam=" + encodeURIComponent(menunaam) + "&id="+id+"&subtype="+subtype+"&menutype="+menutype;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "true") {
				refreshMenu();
				//ConstrueerMenu();
				refreshPage();
			} else {
				alert(menunaam + " niet toegevoegd, menuitem " + menunaam + " bestaat al");
			}
		}
	}
}

function deleteMenuItem(id)
{
	var url = path + "verwerking.php?request=deletemenu&menuid=" + id;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "false") {
				//refreshMenu();
				refreshPage();
			} else {
				alert(menunaam + " niet toegevoegd, menuitem " + menunaam + " bestaat al");
			}
		}
	}
}

function DelAlert(menunaam, id, type) 
{ 
	var OK
	OK = confirm("Weet u zeker dat u " + menunaam + " wilt verwijderen?");
	if (OK)
	{
		if(type == undefined)
			deleteMenuItem(id);
		else if(type == 'download')
			deleteDownload(id);
	}
	return OK 
}

function deleteDownload(id)
{
	var url = path + "verwerking.php?request=deleteDownload&id=" + id;
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "true") {
				refreshPage();
			} 
		}
	}
}

function Bewerk(naam)
{
	var element  = document.getElementById("veld"+naam).style.display;

	if(element == "none")
	{
		document.getElementById("options"+naam).style.display = "none";
		document.getElementById("naam"+naam).style.display = "none";
		document.getElementById("veld"+naam).style.display = "block";
	} 
	else
	{
		
		document.getElementById("veld"+naam).style.display = "none";
		document.getElementById("naam"+naam).style.display = "block";
		document.getElementById("options"+naam).style.display = "block";
	}
   
}

function BewerkMenuItem()
{
	var menunaam = document.getElementById("menuitem").value;
	
	var url = path + "verwerking.php?request=insertmenu&menunaam=" + encodeURIComponent(menunaam);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if (http.readyState != 4) {
			document.getElementById("menuitem").innerHTML = "Menu wordt toegvoegd ..";
		}
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "true") {
				refreshMenu();
				alert('Toegevoegd');
			} else {
				alert(menunaam + " niet toegevoegd, mogelijk bestond menuitem " + menunaam + " al");
			}
		}
	}
}
function refreshMenu()
{
	var url = path + "verwerking.php?request=menuupdate";
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {			
			//alert(http.responseText);
			document.getElementById("menuitems").innerHTML = http.responseText;	
			ConstrueerMenu();
		}
	}
}

function toonMogelijkheden() {
	
	$(function(){
		// Dialog			
		$('#dialog_seo').dialog({
			autoOpen: false,
			width: 600,
			height: 200
		
		});
		$('#dialog_users').dialog({
			autoOpen: false,
			width: 600,
			height: 200
		
		});
	});
	
	ConstrueerMenu();
}

function saveSeo(id)
{
	var titel = document.getElementById('titel').value;
	var keywords = document.getElementById('keywords').value;
	var description = document.getElementById('description').value;
	var url = path + "verwerking.php?request=saveSeo&id="+id+"&titel="+encodeURIComponent(titel)+"&keywords="+encodeURIComponent(keywords)+"&description="+encodeURIComponent(description);
	http.open("GET", url, true);
	http.send(null);
	http.onreadystatechange = function() {
		if(http.readyState == 4) {
			var resultaat = http.responseText;
			if (resultaat == "true") {
				alert("Zoekmachine optimalisatie doorgevoerd");	
				//clickSeo();							
			}
		}
	}
}

function lock()
{
	if(locked == "true")
		locked = "false";
	else
		locked = "true";
			
	ConstrueerMenu();	
	var url = path + "verwerking.php?request=setLock";
	$.ajax({
	  url: url,	
	  success: function(data) {
		locked = data;
	  }
	});
}
function createHTTPHandler() {
	/*
	 * De ajax handler
	 */

	httphandler = false;
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		try {
			httphandler = new XMLHttpRequest();
		} catch (e) {
			httphandler = false;
		}
		// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		try {
			httphandler = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httphandler = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				httphandler = false;
			}
		}
	}
	return httphandler;
}
