var HILITE_COLOR = '#FFF5C2';
var RESULT_DELAY = 500;


function toggleContactForm(elem)
{
	if (elem.value == 'beheerder')
	{

		document.getElementById('provincie').style.display = 'none';
		document.getElementById('therapeut').style.display = 'none';
		document.getElementById('verstuur').disabled = false;
	}
	else
	{
		if (document.getElementById('contact').options[0].value == -1)
			document.getElementById('verstuur').disabled = true;
		else
			document.getElementById('verstuur').disabled = false;
	
		if (navigator.appVersion.indexOf("MSIE")!=-1)
		{
			document.getElementById('provincie').style.display = 'block';
			document.getElementById('therapeut').style.display = 'block';
		}	
		else
		{
			document.getElementById('provincie').style.display = 'table-row';
			document.getElementById('therapeut').style.display = 'table-row';
		}
	}
}

function fillSelectAjax(src,dst)
{
	var http = getHTTPObject();
	var now = new Date();
	var openFuncExists = false;
	var timeoutId;
	var provinceId = src.options[src.selectedIndex].value;
	var url = 'index.php?mod=contactform&action=get_contacts&provinceId='+provinceId;
	
	http.open("GET", url, true);
	http.onreadystatechange = function() 
	{
		if (http.readyState == 4) 
		{
			if (http.status == 200)
			{
				window.clearTimeout(timeoutId);

				if (http.responseText == '')
				{
					while (dst.options.length) 
					{
						dst.options[0] = null;
					}
				
					dst.options[dst.options.length] = new Option('geen gevonden',-1);
					document.getElementById('verstuur').disabled = true;
					
					return;
				}

				document.getElementById('verstuur').disabled = false;
				
				var JSON = http.responseText;
				var data = eval(JSON);
				
				while (dst.options.length) 
				{
					dst.options[0] = null;
				}
				
				for (var i=0;i < data.length;i++) {
					dst.options[dst.options.length] = new Option(data[i]['fullname'],data[i]['userid']);
				}
			}
		}
	}

	http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	http.send(null);

	timeoutId = window.setTimeout(
		function() {
			switch (http.readyState) {
				case 1:
				case 2:
				case 3:
					http.abort();
					break;
				default:
					break;
			}
		},
		20000 // twenty seconds
	);
}


function vbConfirm(URL, Item)
{
	if ( confirm('Weet u zeker dat u \'' + Item +'\' wilt verwijderen?') )
		document.location=URL;
}

function changeBgColor(elem, pstrColor)
{
	elem.style.backgroundColor = pstrColor;
	
	if(pstrColor='')
		elem.style.cursor='default';
	else
		elem.style.cursor='pointer';
}

function imgManage(item, state)
{
	imgItem = item;
	win = window.open('htmledit.php?htmlAction=img-search', "imagesearch", "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=516");
}

function ImageUpdate()
{
		imgItem.value=imgID;
}

function downloadManage(item)
{
	downloadItem = item;
	win = window.open('htmledit.php?htmlAction=download-search', "downloadsearch", "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height=250,width=516");
}

function downloadUpdate()
{
	downloadItem.value=downloadID;
}


function OpenWin(URL, h, w)
{
	if (h == undefined)
		h = 550;
	if (w == undefined)
		w = 600;
	win = window.open(URL, "popup", "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height="+h+",width="+w);
}

	var imgID;
	var imgItem;
	var downloadID;
	var downloadItem;