	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 = '';
		
		window.status = 'Loading...';
		
		if (loadclassname) {
			document.getElementById(field).className = loadclassname;
			document.getElementById(field).innerHTML = '';
		}
		
		http.open(method, url);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
		
		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));
	}
	
	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 htmlspecialchars(p_string) {
		p_string = p_string.replace(/&/g, '&amp;');
		p_string = p_string.replace(/</g, '&lt;');
		p_string = p_string.replace(/>/g, '&gt;');
		p_string = p_string.replace(/"/g, '&quot;');
		return p_string;
	}
	
	function ChangeBottomImage(id, img, text, updatetextrealtime) {
		document.getElementById('img_big').src = img;
		
		if (!updatetextrealtime)
			document.getElementById('img_text').innerHTML = htmlspecialchars(text);
		else
			DoAjax('img_text', updatetextrealtime, '&id='+id, 'POST');
	}
	
	function GetBottomImageId() {
		var exp = document.getElementById('img_big').src.split('/fotos/');
		var id = exp[1].split('\.');
		
		return id[0];
	}
	
	function PreloadImages(arr) {
		if (document.images) {
			obj = new Image();
			
			for(i=0;i<arr.length; i++) {
				obj.src = arr[i];
			}
		}
	}
	
	var klik = 0;
	function klikken(msg) {
		if(klik > 0) {
			if (msg)
				alert(msg);
			
			return false; 
		} 
		else { 
			klik++ 
			return true; 
		}
	}
	
	function trim(value) {
		value = value.replace(/^\s+/,'');
		value = value.replace(/\s+$/,'');
		return value;
	}
	
	function CheckFormInputSelectfields(arr) {
		var msg='';
		for (q=0;q<arr.length;q ++) {
			for (i=0;i<document.getElementById(arr[q]).length;i ++) {
				if (document.getElementById(arr[q])[i].value == 0 && document.getElementById(arr[q])[i].selected == true) {
					msg += arr[q]+'\n';
					break;
				}
			}
		}
		
		return msg;
	}
	
	function CheckFormTextFields(arr) {
		var msg='';
		for (i=0;i<arr.length;i ++) {
			
			var val = trim(document.getElementById(arr[i]).value);
			if (val.length == 0)
				msg += arr[i].replace('_', ' ')+'\n';
		}
		
		return msg;
	}
	
	function CheckFormInput(arr, arrfields) {
		var msg='';
		if (arr)
			msg += CheckFormTextFields(arr);
		
		if (arrfields)
			msg += CheckFormInputSelectfields(arrfields);
		
		if (msg) {
			msg = 'The following fields are not completed or incorrectly\n\n'+msg;
			alert(msg);
			
			return false;
		}
		else {
			return true;
		}
	}
	
	function ToggleField(id1, id2) {
		if (document.getElementById(id1).checked == true)
			ShowMore2(id2, false);
		else
			ShowMore2(id2, true);
	}
