	
	function DoAjax(field, url, params, method, loadclassname) {
		var http = false;
		if (window.XMLHttpRequest)
			http = new XMLHttpRequest();
		else if (window.ActiveXObject)
			http = new ActiveXObject("Microsoft.XMLHTTP");  
		
		if (!method || method.toLowerCase() == 'get') {
			var method = 'GET';
			url += '?' + params;
		}
		
		if (!params)
			params = '';
		
		http.open(method, url);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
		
		window.status = 'Loading...';
		
		if (loadclassname) {
			document.getElementById(field).className = loadclassname;
			document.getElementById(field).innerHTML = '';
		}
		
		http.onreadystatechange = function() {
			if(http.readyState == 4 && http.status == 200) {
				
				if (loadclassname)
					document.getElementById(field).className = '';
				
				window.status = '';
				document.getElementById(field).innerHTML = http.responseText;
			} 
			else {
				window.status = 'Error...';
			}
		}
		
		http.send(decodeURI(params));
	}
	
	function EncodeInput(q) {
		return encodeURIComponent(q);
	}
	
	function ToggleLightDark(q, out) {
		if (document.getElementById(q).className == 'dark_overlay40')
			document.getElementById(q).className = '';
		
		if (out)
			document.getElementById(q).className = 'dark_overlay40';
	}
	function ToggleLightDark60(q, out) {
		if (document.getElementById(q).className == 'dark_overlay60')
			document.getElementById(q).className = '';
		
		if (out)
			document.getElementById(q).className = 'dark_overlay60';
	}
	
	function ChangeImg(q) {
		document.getElementById('submenudiv').style.backgroundImage = 'url(/img_layout/images/foto'+q+'.jpg)';
	}
	
	var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
	var isMinNS6 = (isMinNS4 && navigator.userAgent.indexOf("Gecko")>=0) ? 1 : 0;
	var isMinIE4 = (document.all) ? 1 : 0;
	var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
	var isDOM = (document.getElementById) ? 1 : 0;
	
	function GetBrowser(name) {
		if (isDOM)
			return document.getElementById(name);
		if (isMinNS4)
			return findLayer(name, document);
		if (isMinIE4)
			return eval('document.all.' + name);
		
		return null;
	}
	
	function ShowMore(name) {
		var name = GetBrowser(name);
		
		if (name.style.display == 'none')
			name.style.display = '';
		else
			name.style.display = 'none';
	}
	
	function ShowMore2(name, show) {
		var name = GetBrowser(name);
		
		if (show == 1)
			name.style.display = '';
		else
			name.style.display = 'none';
	}
	
	function MakeWindow(url, w, h, scroll, windowname) {
		var windowprops = "height=" + h + ",width=" + w + ",left=50,top=50,status=no,location=no,scrollbars=" + scroll + ",menubars=no,toolbars=auto,resizable=yes";
		window.open(url,windowname,windowprops);
	}
	
	function PreviewImg(img) {
		document.getElementById('submenudiv').style.backgroundImage='url('+img+')';
		document.getElementById('cf_div1').style.backgroundImage='url('+img+')';
		document.getElementById('cf_div2').style.backgroundImage='url('+img+')';
	}
	
	var klik = 0;
	function klikken(msg) {
		if(klik > 0) {
			if (msg)
				alert(msg);
			
			return false; 
		} 
		else { 
			klik++ 
			return true; 
		}
	}
	
	function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	};
	
	function jQueryAddNewClient() {
		$('#emaildiv input:last').live('focus', function(){
				$('#emaildiv').append('<br><input type="text" size="30" name="email[]" value="" class="button">');
			});
	}
	
	function SubmitFormNewClient() {
		var msg='';
		var msgmail='';
		var mailchkall='';
		
		if ($.trim($('#company').val()).length < 2)
			msg = '- Er is geen bedrijfsnaam ingevuld\n';
		if ($.trim($('#contactperson').val()).length < 2)
			msg += '- Er is geen contactpersoon ingevuld\n';
		
		$('#emaildiv input').each(function(index) {
			mailchkall += $.trim($(this).val());
			
			if (($('#emaildiv input').length-1) == index && $('#emaildiv input').length > 1) {
				return false;
			}
			else if(!isValidEmailAddress($(this).val()) && $(this).val().length > 0) {
				msgmail += '- \''+$(this).val()+'\' is geen geldig emailadres\n';
			}
		});
		
		// check all email fields
		if (mailchkall.length == 0)
			msg += '- Er is geen emailadres ingevuld';
		else
			msg += msgmail;
		
		if (msg.length > 0) {
			alert('Foutmelding\n'+msg);
			return false;
		}
		else {
			$('#MyForm').submit();
		}
	}
	
	function PreloadImages(arr) {
		if (document.images) {
			obj = new Image();
			
			for(i=0;i<arr.length; i++) {
				obj.src = arr[i];
			}
		}
	}
	
	function GetBottomImageId() {
		var exp = document.getElementById('img_big').src.split('/img/');
		var id = exp[1].split('\.');
		
		return id[0];
	}
	
	function ChangeBottomImage(id, img, text, updatetextrealtime) {
		document.getElementById('img_big').src = img;
		document.getElementById('img_text').innerHTML = text;
	}
	
	function ImageSlider(maxnum, thisnum, fotoarr) {
		if (!thisnum && thisnum != 0) {
			var thisnum = 0;
			var int = 0;
		}
		else {
			var int = 6000;
		}
		
		imageslidetimer = setTimeout(function() {
					document.getElementById('submenudiv').style.backgroundImage = "url("+fotoarr[thisnum]+")";
					
					thisnum++;
					if (thisnum >= maxnum)
						thisnum = 0;
					
					ImageSlider(maxnum, thisnum, fotoarr);
				}, int);
	}
	
	
	
	
	/*** cross fade functions ***/
	
		                    		// total time between 2 messages = cf_fadetime + cf_staytime
	var cf_staytime = 5000;			// time a 'frame' stays visible before it starts to fade again
	var cf_fadetime = 500;			// time the fading between 2 'frames' take
	var cf_stepinterval = 50;		// 0.2 secs (lower is more smooth, but takes more cpu power)
	
	/*** Don't edit under this line ***/
	
	var cf_div_trans = 100;
	var showdiv1 = true;
	var cf_contentCounter = 0;
	
	function crossfade_ie6(thisnum) {
		document.getElementById('cf_div1').style.display='none';
		document.getElementById('cf_div2').style.display='none';
		
		if (!thisnum && thisnum != 0) {
			var thisnum = 0;
			var int = 0;
		}
		else {
			var int = cf_staytime;
		}
		
		imageslidetimer = setTimeout(function() {
					document.getElementById('submenudiv').style.backgroundImage = "url("+cf_content[thisnum]+")";
					
					thisnum++;
					if (thisnum >= cf_content.length)
						thisnum = 0;
					
					crossfade_ie6(thisnum);
				}, int);
	}
	
	
	function crossfade() {
		var div1 = document.getElementById('cf_div1');
		var div2 = document.getElementById('cf_div2');
		
		//set transparency
		div1.style.filter = 'alpha(opacity='+cf_div_trans+')';
		div1.style.MozOpacity = cf_div_trans / 100;
		div1.style.KhtmlOpacity = cf_div_trans / 100;
		div1.style.opacity = cf_div_trans / 100;
		
		div2.style.filter = 'alpha(opacity='+(100-cf_div_trans)+')';
		div2.style.MozOpacity = (100-cf_div_trans) / 100;
		div2.style.KhtmlOpacity = (100-cf_div_trans) / 100;
		div2.style.opacity = (100-cf_div_trans) / 100;
		
		//calculate next transparency
		var cf_stepsize = 100 / cf_fadetime * cf_stepinterval;
		cf_div_trans = showdiv1?cf_div_trans + cf_stepsize:cf_div_trans - cf_stepsize;
		
		
		//catch switches
		if (cf_div_trans < 0) {
			cf_div_trans = 0;
			
			div1.style.backgroundImage = "url("+cf_content[cf_contentCounter]+")";
			
			cf_contentCounter++;
			if (cf_contentCounter >= cf_content.length)
				cf_contentCounter = 0;
			
			//show content for xx seconds
			setTimeout ("crossfade();", cf_staytime);
			showdiv1 = true;
		}
	    else if (cf_div_trans > 100) {
			cf_div_trans = 100;
			
			div2.style.backgroundImage = "url("+cf_content[cf_contentCounter]+")";
			
			cf_contentCounter++;
			if (cf_contentCounter >= cf_content.length)
				cf_contentCounter = 0;
			
			//show content for xx seconds
			setTimeout ("crossfade();", cf_staytime);
			showdiv1 = false;
		}
		else {
			//do next shade of transparency
			setTimeout ("crossfade();", cf_stepinterval);
		}
	}
