
	//.. --------------------------------------------------------------------------------------
	//..	General SYSTEM scripts	
	//.. --------------------------------------------------------------------------------------
	
	function SYSTEM__navigate(url, delay ,newwindow) {
		
		if ((typeof(delay) != 'undefined')&& (delay !== false)) {
			setTimeout(	function() { SYSTEM__navigate(url) }, delay);
			return;
		}
		
		if ((typeof(delay) == 'undefined')) 
			newwindow = false;
		
		if (!url.length) return;
		
		//.. This function makes sure that IE also respects BASE URL
		var base = (document.getElementsByTagName('BASE')[0] && document.getElementsByTagName('BASE')[0].href) || "";
		var browser = SYSTEM__detectBrowserVersion();
		if (browser['name'] == 'ie') {
			if (newwindow)
				window.open(base+url);
			else
				document.location = base+url;	
		}
		else {
			if (newwindow)
				window.open(url);
			else
				document.location = url;
		}
			
		return;
	}
	
	function SYSTEM__detectBrowserVersion(){
		var userAgent = navigator.userAgent.toLowerCase();
		$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
		var version = 0;
		var browser = "unknown";
		
		// Is this a version of IE?
		if($.browser.msie){
		userAgent = $.browser.version;
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browser = 'ie';
		}
		
		// Is this a version of Chrome?
		if($.browser.chrome){
		userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		// If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
		$.browser.safari = false;
		browser = 'chrome';
		}
		
		// Is this a version of Safari?
		if($.browser.safari){
		userAgent = userAgent.substring(userAgent.indexOf('safari/') +7);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browser = 'safari';
		}
		
		// Is this a version of Mozilla?
		if($.browser.mozilla){
		//Is it Firefox?
		if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){
		userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browser = 'firefox';
		}
		// If not then it must be another Mozilla
		else{
		}
		}
		
		// Is this a version of Opera?
		if($.browser.opera){
		userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
		userAgent = userAgent.substring(0,userAgent.indexOf('.'));
		version = userAgent;
		browser = 'opera';
		}
		
		var data = new Array();
		data['name'] = browser;
		data['version'] = parseFloat(version);
		
		return data;
	} 
	
	function SYSTEM__uniEvent(e,specialKey, matchFilter) {
	   
        if ((typeof(e) == 'undefined')||(e === null)) return false;

		var shiftPressed = e.shiftKey;
		var altPressed   = e.altKey;
		var ctrlPressed  = e.ctrlKey;
	
		if ((e.type == 'click')||(e.type == 'mousedown')||(e.type == 'mouseup')||(e.type == 'mouseover')||(e.type == 'mousemove')||(e.type == 'dblclick')||(e.type == 'mouseout')) {
			//.. mouse button pressed
			
			if ((typeof(specialKey) != 'undefined')&&(specialKey!=false)) {
				if ((specialKey == 'ctrl')&&(!ctrlPressed))
					return false;
				
				if ((specialKey == 'alt')&&(!altPressed))
					return false;
					
				if ((specialKey == 'shift')&&(!shiftPressed))
					return false;
			}
	
			return e.button;
		}
				
		//.. Cross-browser solution for returning pressed key
		var code =  e.keyCode? e.keyCode : e.charCode
		
		if (typeof(matchFilter) == 'undefined') return code;
		
		//.. Check if code matches a key in matchFilter
		if ($.inArray(code,matchFilter) == -1)
			return false;
		else
			return true;	
		
	}

	function SYSTEM__reload(clear_variables) {
		
		//.. This function will reload the page without $_GET variables attached to it
		//.. if clear_variables = true all variables will be deleted
		//.. if clear_variables = false all variables will be kept intact
		//.. if clear_variables is a string seperated with : it will clear those variables
		
		if (typeof(clear_variables) == 'undefined')
			var clear_variables = false;

		var url 		= 	window.location.href;
		var url_data	=	url.split("?");
		
		if (clear_variables == false) {
			window.location.reload();
			return;
		}
		
		if (url_data.length == 1) {
			window.location.reload();
			return;
		}
		
		if (clear_variables == true) {
			document.location = url_data[0];
			return;
		}
		
		var variables	=	clear_variables.split(":");
		
		var amount		=	variables.length;
		
		var url_vars	=	url_data[1];
		
		var url_vars	=	url_vars.split("&");
		
		for (var i =0;i< amount;i++) {
			
			var delete_var = variables[i];
			
			for (var j = 0;j < url_vars.length;j++) {
				if (url_vars[j].search(delete_var+"=") != -1) {
					url 	=	url.replace(url_vars[j]+"&","");
					url 	=	url.replace(url_vars[j],"");
					break;
				}
			}						
		}
		
		if ((url.charAt(url.length-1) == "&") || (url.charAt(url.length-1) == "?")) {
			url = url.slice(0,url.length-1);
		}
		
		document.location = url;
		
		return;		
		
	}
		
	function SYSTEM__modalmessage(header, title, description) {
		
		//.. more info: http://www.ericmmartin.com/projects/simplemodal/
		
		if (!((title === false)||(typeof(title)=='undefined')))
			document.getElementById('simplemodal_title').innerHTML = title;
		if (!((description === false)||(typeof(description)=='undefined')))
			document.getElementById('simplemodal_text').innerHTML = description;
		
		if (!$(".simplemodal_content").length) {
			alert('ERROR: Kan geen modalmessage box laden omdat u nog geen template heeft gemaakt.');
			return;
			
			/* EXAMPLE:	
				<div class="simplemodal_content">
					<div id="simplemodal_title" style=" color:#FFF; font-weight:bold; margin-bottom: 4px;">Een ogenblik geduld a.u.b..</div>
					<div id="simplemodal_text" style="margin-bottom: 8px; color:#CCC; font-size:10px">Bezig met het opslaan van de gegevens. Dit kan enkele minuten duren afhankelijk van hoeveel informatie opgeslagen moet worden.</div>
					<div id="simplemodal_loader"><img src="../resources/images/loading2.gif" width="300" height="10" alt="loading" /></div>
				</div>
			*/	
		}

		$(".simplemodal_content").modal({onOpen: function (dialog) {

				dialog.overlay.fadeIn(500, function () {
					dialog.data.hide();
					dialog.container.fadeIn(500, function () {
						dialog.data.show();
					});
				});
			
			}, 
					
			
			onClose: function (dialog) {
					dialog.data.fadeOut(200, function () {
						dialog.container.fadeOut(200, function () {
							dialog.overlay.fadeOut(500, function () {
								$.modal.close();
							});
						});
					});
			}
		});

		
		return;	
	}
	
	//.. --------------------------------------------------------------------------------------
	//..	HIGHSLIDE scripts	
	//.. --------------------------------------------------------------------------------------
	
	var HIGHSLIDE_variables = new Array();
	
	function HIGHSLIDE_getVars(obj) {
			
		if (typeof(obj.headingText) != 'undefined') {
			var expanderObject = obj; //.. obj=sender=expander
		}
		else if (typeof(obj['groupID']) == 'undefined') {
			var expanderObject = hs.getExpander(obj);
		}
		else if (typeof(HIGHSLIDE_variables[obj['groupID']]) != 'undefined')
			return HIGHSLIDE_variables[obj['groupID']][obj['highslideID']];
		else return null;
		
		if (!expanderObject) return null;
		
		//.. Learn info
		var headingText = expanderObject.headingText;
		var temp = headingText.split('class="');
		temp = temp[1].split('"');
		var groupClassName = temp[0];
		var groupID = SYSTEM__str_replace("highslideGroup_","",groupClassName);
		
		temp = headingText.split('id="');
		temp = temp[1].split('"');
		var highslideID = temp[0];
		
		if (typeof(HIGHSLIDE_variables[groupID]) != 'undefined')
			return HIGHSLIDE_variables[groupID][highslideID];
		else
			return null;
			
	}

	function HIGHSLIDE_show(obj,settings,variables) {
		 
		//.. This function only allows 1 highslide open per groupID.
		//.. If no groupID is specified then 'default' is used
		//.. If a new highslide is opened with the same groupID as an already opened
		//.. highslide then the old highslide will be closed with all its children.
		
		//.. Variables example: {fixed: true}
		//.. Variables will passed to the highslide object. If fixed=true then highslide is fixed.
		
		//.. First make sure we can open multiple highslides
		hs.allowMultipleInstances = true;
		
		var groupID = 'default';
		if (typeof(settings['groupID']) != 'undefined') {
			groupID = settings['groupID'];
		}
		var groupClassName = 'highslideGroup_'+groupID;
				
		//.. Check if he is a child of another highslide
		var expanderObject = hs.getExpander(obj);
		var isChild = false;
		var parentGroupID = false;
		var parentID = false;
		if (expanderObject != null) {
			isChild = true;
			
			//.. Learn info about parent
			var headingText = expanderObject.headingText;
			var temp = headingText.split('class="');
			temp = temp[1].split('"');
			parentGroupID = temp[0];
			
			temp = headingText.split('id="');
			temp = temp[1].split('"');
			parentID = temp[0];
			
			groupClassName = parentGroupID;
			groupID = SYSTEM__str_replace("highslideGroup_","",parentGroupID);
		}
		
		//.. Check for defined classes
		var headingText = settings['headingText'];
		if (typeof(variables) != 'undefined') {
			if (typeof(variables['headingClassName']!='undefined')) {
				headingText = "<span class='"+variables['headingClassName']+"'>"+headingText+"</span>";	
			}
		}
		
		//.. Add info to new highslide object in heading
		//.. Create uniqueID first
		i = 0;
		while (document.getElementById('highslideObject_'+i)!= null) {i++;}
		var uniqueID = "highslideObject_"+i;
		if (isChild)  
			settings['headingText'] = headingText+'<div class="'+groupClassName+'" id="'+uniqueID+'" style="display:none">'+groupID+':CHILD</div>';
		else
			settings['headingText'] = headingText+'<div class="'+groupClassName+'" id="'+uniqueID+'" style="display:none"></div>';
		
		if (!isChild) {
			//.. Object with same group name already exists
			//.. This is not a child of that object
			//.. Close all highslides with this GroupID and their children
			HIGHSLIDE_close(groupID);				
		}
		
		//.. Clean our variables from settings
		delete settings['groupID'];
		
		//.. Now check for variables you want to pass through
		if (typeof(variables) != 'undefined') {
			
			if (typeof(HIGHSLIDE_variables[groupID]) == 'undefined')
				HIGHSLIDE_variables[groupID] = new Array();
				
			HIGHSLIDE_variables[groupID][uniqueID] = variables;
		}
		
		//.. Open new highslide		
		return hs.htmlExpand(obj, settings);		
		
	}
	
	function HIGHSLIDE_close(groupID) {
		
		//.. This close function does not only close the current highslide but also all its children.
		//.. If a groupID is given it will close all highslides with this groupID
		
		//.. HIGHSLIDE_close accepts a groupID or an object inside a highslide just like hs.close()
		//.. If object it will learn its groupID
		
		var groupClassName = "";

		if (typeof(groupID) == 'object') {
			var expanderObject = hs.getExpander(groupID);
			//.. Learn info
			var headingText = expanderObject.headingText;
			var temp = headingText.split('class="');
			temp = temp[1].split('"');
			groupClassName = temp[0];				
		}
		else
			groupClassName = "highslideGroup_"+groupID;
		
		if (!$("."+groupClassName).length) {
			//.. No highslides opened with this groupID
			return false;	
		}
		
		var highslideObjects = $("."+groupClassName);
		
		for (var i = 0; i < highslideObjects.length; i++) {
			hs.close(highslideObjects[i]);	
		}
		
		//.. Clean variabes
		delete HIGHSLIDE_variables[groupID];
		
		return true;
	}
	
	//.. --------------------------------------------------------------------------------------
	//..	EXTJS Grid scripts	
	//.. --------------------------------------------------------------------------------------
	
	var GLOBAL_EXTJS_selected_record = false;
	var GLOBAL_EXTJS_lastClicked_id	= false;
	var GLOBAL_EXTJS_lastClicked_rec = false;
	
	function EXTJS_saveGridItemAmount(obj,gridID,location) {
		
			if (typeof(location) == 'undefined') {location = gridID;}
	
			var amount = obj.value;
			
			if (amount < 1) {
				alert('De waarde die u opgeeft moet minstens 1 zijn!');
				obj.focus();
				return;	
			}
			
			$('#GridItemAmount_loading').fadeIn(200);
			obj.disabled = true;
			
			SYSTEM__AjaxFuncRequest("_GLOBAL_ajax.php",'EXTJS_saveGridItemAmount',{amount: amount, location: location, gridID: gridID}, function(response) {

				document.getElementById('GridItemAmount_loading').style.display = 'none';
				$('.viewOptions_container').slideUp(500);
				document.getElementById('GridItemAmount').disabled = false;
				
				EXTJS_reload_grids();
				//NAVIGATION_update(response);
				
				
				
			});
	}
	
	function EXTJS_saveColumnwidth(columnName,newSize,gridID) {
			SYSTEM__AjaxFuncRequest('_GLOBAL_ajax.php','EXTJS_saveColumnwidth',{gridID: gridID, columnName: columnName, newSize: newSize});
			//SYSTEM__AjaxRequest('','save_Columnwidth',gridID,columnName,newSize);	
	}
	
	function EXTJS_saveColumnPosition(columnName,newIndex,gridID) {
			SYSTEM__AjaxFuncRequest('_GLOBAL_ajax.php','EXTJS_saveColumnPosition',{gridID: gridID, columnName: columnName, newIndex: newIndex});
			//SYSTEM__AjaxRequest('','save_ColumnPosition',gridID,columnName,newIndex);	
	}
	
	function EXTJS_saveColumnVisibility(columnName,hidden,gridID) {
			SYSTEM__AjaxFuncRequest('_GLOBAL_ajax.php','EXTJS_saveColumnVisibility',{gridID: gridID, columnName: columnName, hidden: hidden});
			//SYSTEM__AjaxRequest('','save_ColumnVisibility',gridID,columnName,hidden);	
	}
	
	function EXTJS_reload_grids() {
						
		var i = 0;
		while (Ext.StoreMgr.lookup('ExtGrid'+i)) {
			Ext.StoreMgr.lookup('ExtGrid'+i).reload();
			i++;	
		}
		
		$.modal.close();
	}
	
	function EXTJS_CALLBACK__rowmousedown(grid, rowIndex, e, rec) {
	
		if (rec.get("id")) {
			GLOBAL_EXTJS_lastClicked_id = rec.get("id");
			GLOBAL_EXTJS_lastClicked_rec = rec;
		}
		else {
			GLOBAL_EXTJS_lastClicked_id = false;
			GLOBAL_EXTJS_lastClicked_rec = false;
		}
		
		//.. Check for other callback functions
		if(typeof window.EXTJS_GRID_rowmousedown == 'function') {
			EXTJS_GRID_rowmousedown(grid, rowIndex, e,rec);
		}
		
	}
	
	function EXTJS_CALLBACK__rowclick(grid, rowIndex, colIndex,rec,gridnr,amount) {
		if ($.isArray(rec))
			GLOBAL_EXTJS_selected_record = rec;
		else
			GLOBAL_EXTJS_selected_record = new Array(rec);
			
		//.. Check for other callback functions
		if(typeof window.EXTJS_GRID_rowclick == 'function') {
			EXTJS_GRID_rowclick(grid, rowIndex, colIndex,rec,gridnr,amount);
		}		
	}
	
	function EXTJS_get_selectedItems(value,seperator) {
		
		//.. Returns a list with the values of the items that are selected.
		//.. You can specify in which value you are interested, for example id or email or firstname.
		
		if (typeof(value)=='undefined') value = 'id';
		if (typeof(seperator)=='undefined') seperator = '#';
		
		if (!$.isArray(GLOBAL_EXTJS_selected_record)) {
			return false; // Nothing selected
		}
		
		var list = "";
		for (var i = 0;i < GLOBAL_EXTJS_selected_record.length;i++) {
			if (list.length)
				list = list+seperator+GLOBAL_EXTJS_selected_record[i].get(value);
			else
				list = GLOBAL_EXTJS_selected_record[i].get(value);
		}

		if (list.length)
			return list;
		else
			return false;
			
	}
		
	
	function EXTJS_delete_items(id,name,singleItem,callerObj,deleteRedirectFunction) {

		//.. This function now supports multiple items to be deleted at once
		//.. It will ask for a confirmation
		
		//.. To delete all selected items use: EXTJS_delete_items()
		//.. To delete a single item use: EXTJS_delete_items(id,name ...)
		if ((!$.isArray(GLOBAL_EXTJS_selected_record))&&((typeof(id)=='undefined')||(id===false))) {
			alert('U heeft nog geen items geselecteerd!');
			return false; // Nothing to delete	
		}
		
		//.. Check if item is not on the deleteIgnoreList
		for (var i = 0;i < GLOBAL_EXTJS_selected_record.length;i++) {
				var id = GLOBAL_EXTJS_selected_record[i].get('id');
				var deleteIgnoreList = GLOBAL_EXTJS_selected_record[i].get('deleteIgnoreList');
				
				if (deleteIgnoreList == id) {
					alert('U heeft items geselecteerd die niet verwijderd mogen worden!\nSelecteer alleen items die verwijderd mogen worden.');
					return;	
				}
		}
				
		if ((!GLOBAL_EXTJS_selected_record.length)||(singleItem === true)) {
			
			if (name !== false)
				var answer = confirm("Weet u zeker dat u '"+name+"' wilt verwijderen?");
			else
				var answer = confirm("Weet u zeker dat u deze wilt verwijderen?");
			if (!answer) return;
		
			//.. Custom delete function
			if (typeof(deleteRedirectFunction)!='undefined') {
				
				try {
					eval(deleteRedirectFunction+"("+id+")");
				}
				catch(err) {
					alert('ERROR: No custom delete function defined\n\nExpected: function '+deleteRedirectFunction+'(IDlist)\nExample: IDlist=2|3|5|10');	
				}
				return;
			}
		
		
			if(typeof window.delete_item == 'function') {
					delete_item(id);
			}
			else {
				alert('ERROR: No delete function defined\n\nExpected: function delete_item(IDlist)\nExample: IDlist=2|3|5|10');	
			}
			return;
		}
		
		if (GLOBAL_EXTJS_selected_record.length > 1) {
			var answer = confirm("U heeft "+GLOBAL_EXTJS_selected_record.length+" items geselecteerd.\nWeet u zeker dat u deze allemaal wilt verwijderen?");
			if (!answer) return;
		}
		else {
			var answer = confirm("U heeft 1 item geselecteerd.\nWeet u zeker dat u deze wilt verwijderen?");
			if (!answer) return;
		}
		
		var id = "";
		for (var i = 0;i < GLOBAL_EXTJS_selected_record.length;i++) {
			if (id.length)
				id = id+"|"+GLOBAL_EXTJS_selected_record[i].get('id');
			else
				id = GLOBAL_EXTJS_selected_record[i].get('id');
		}
		
		//.. Custom delete function
		if (typeof(deleteRedirectFunction)!='undefined') {
			
			try {
				eval(deleteRedirectFunction+"("+id+")");
			}
			catch(err) {
				alert('ERROR: No custom delete function defined\n\nExpected: function '+deleteRedirectFunction+'(IDlist)\nExample: IDlist=2|3|5|10');	
			}
			return;
		}
		
		if(typeof window.delete_item == 'function') {
				delete_item(id);
		}
		else {
			alert('ERROR: No delete function defined\n\nExpected: function delete_item(IDlist)\nExample: IDlist=2|3|5|10');	
		}
		
	}
	
	//.. --------------------------------------------------------------------------------------
	//..	GLOBALLY USES FUNCTIONS
	//.. --------------------------------------------------------------------------------------
	
	function SYSTEM__html_entity_decode (string, quote_style) {
		// Convert all HTML entities to their applicable characters  
		// 
		// version: 1008.1718
		// discuss at: http://phpjs.org/functions/html_entity_decode    // +   original by: john (http://www.jd-tech.net)
		// +      input by: ger
		// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   bugfixed by: Onno Marsman    // +   improved by: marc andreu
		// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +      input by: Ratheous
		// +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		// +      input by: Nick Kolosov (http://sammy.ru)    // +   bugfixed by: Fox
		// -    depends on: get_html_translation_table
		// *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
		// *     returns 1: 'Kevin & van Zonneveld'
		// *     example 2: html_entity_decode('&amp;lt;');    // *     returns 2: '&lt;'
		var hash_map = {}, symbol = '', tmp_str = '', entity = '';
		tmp_str = string.toString();
		
		if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {        return false;
		}
	 
		// fix &amp; problem
		// http://phpjs.org/functions/get_html_translation_table:416#comment_97660    delete(hash_map['&']);
		hash_map['&'] = '&amp;';
	 
		for (symbol in hash_map) {
			entity = hash_map[symbol];        tmp_str = tmp_str.split(entity).join(symbol);
		}
		tmp_str = tmp_str.split('&#039;').join("'");
		
		return tmp_str;
	}
	
	function SYSTEM__get_html_translation_table (table, quote_style) {
		// Returns the internal translation table used by htmlspecialchars and htmlentities  
		// 
		// version: 1008.1718
		// discuss at: http://phpjs.org/functions/get_html_translation_table    // +   original by: Philip Peterson
		// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   bugfixed by: noname
		// +   bugfixed by: Alex
		// +   bugfixed by: Marco    // +   bugfixed by: madipta
		// +   improved by: KELAN
		// +   improved by: Brett Zamir (http://brett-zamir.me)
		// +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		// +      input by: Frank Forte    // +   bugfixed by: T.Wild
		// +      input by: Ratheous
		// %          note: It has been decided that we're not going to add global
		// %          note: dependencies to php.js, meaning the constants are not
		// %          note: real constants, but strings instead. Integers are also supported if someone    // %          note: chooses to create the constants themselves.
		// *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
		// *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
		
		var entities = {}, hash_map = {}, decimal = 0, symbol = '';    var constMappingTable = {}, constMappingQuoteStyle = {};
		var useTable = {}, useQuoteStyle = {};
		
		// Translate arguments
		constMappingTable[0]      = 'HTML_SPECIALCHARS';    constMappingTable[1]      = 'HTML_ENTITIES';
		constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
		constMappingQuoteStyle[2] = 'ENT_COMPAT';
		constMappingQuoteStyle[3] = 'ENT_QUOTES';
		 useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
		useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
	 
		if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
			throw new Error("Table: "+useTable+' not supported');        // return false;
		}
	 
		entities['38'] = '&amp;';
		if (useTable === 'HTML_ENTITIES') {        entities['160'] = '&nbsp;';
			entities['161'] = '&iexcl;';
			entities['162'] = '&cent;';
			entities['163'] = '&pound;';
			entities['164'] = '&curren;';        entities['165'] = '&yen;';
			entities['166'] = '&brvbar;';
			entities['167'] = '&sect;';
			entities['168'] = '&uml;';
			entities['169'] = '&copy;';        entities['170'] = '&ordf;';
			entities['171'] = '&laquo;';
			entities['172'] = '&not;';
			entities['173'] = '&shy;';
			entities['174'] = '&reg;';        entities['175'] = '&macr;';
			entities['176'] = '&deg;';
			entities['177'] = '&plusmn;';
			entities['178'] = '&sup2;';
			entities['179'] = '&sup3;';        entities['180'] = '&acute;';
			entities['181'] = '&micro;';
			entities['182'] = '&para;';
			entities['183'] = '&middot;';
			entities['184'] = '&cedil;';        entities['185'] = '&sup1;';
			entities['186'] = '&ordm;';
			entities['187'] = '&raquo;';
			entities['188'] = '&frac14;';
			entities['189'] = '&frac12;';        entities['190'] = '&frac34;';
			entities['191'] = '&iquest;';
			entities['192'] = '&Agrave;';
			entities['193'] = '&Aacute;';
			entities['194'] = '&Acirc;';        entities['195'] = '&Atilde;';
			entities['196'] = '&Auml;';
			entities['197'] = '&Aring;';
			entities['198'] = '&AElig;';
			entities['199'] = '&Ccedil;';        entities['200'] = '&Egrave;';
			entities['201'] = '&Eacute;';
			entities['202'] = '&Ecirc;';
			entities['203'] = '&Euml;';
			entities['204'] = '&Igrave;';        entities['205'] = '&Iacute;';
			entities['206'] = '&Icirc;';
			entities['207'] = '&Iuml;';
			entities['208'] = '&ETH;';
			entities['209'] = '&Ntilde;';        entities['210'] = '&Ograve;';
			entities['211'] = '&Oacute;';
			entities['212'] = '&Ocirc;';
			entities['213'] = '&Otilde;';
			entities['214'] = '&Ouml;';        entities['215'] = '&times;';
			entities['216'] = '&Oslash;';
			entities['217'] = '&Ugrave;';
			entities['218'] = '&Uacute;';
			entities['219'] = '&Ucirc;';        entities['220'] = '&Uuml;';
			entities['221'] = '&Yacute;';
			entities['222'] = '&THORN;';
			entities['223'] = '&szlig;';
			entities['224'] = '&agrave;';        entities['225'] = '&aacute;';
			entities['226'] = '&acirc;';
			entities['227'] = '&atilde;';
			entities['228'] = '&auml;';
			entities['229'] = '&aring;';        entities['230'] = '&aelig;';
			entities['231'] = '&ccedil;';
			entities['232'] = '&egrave;';
			entities['233'] = '&eacute;';
			entities['234'] = '&ecirc;';        entities['235'] = '&euml;';
			entities['236'] = '&igrave;';
			entities['237'] = '&iacute;';
			entities['238'] = '&icirc;';
			entities['239'] = '&iuml;';        entities['240'] = '&eth;';
			entities['241'] = '&ntilde;';
			entities['242'] = '&ograve;';
			entities['243'] = '&oacute;';
			entities['244'] = '&ocirc;';        entities['245'] = '&otilde;';
			entities['246'] = '&ouml;';
			entities['247'] = '&divide;';
			entities['248'] = '&oslash;';
			entities['249'] = '&ugrave;';        entities['250'] = '&uacute;';
			entities['251'] = '&ucirc;';
			entities['252'] = '&uuml;';
			entities['253'] = '&yacute;';
			entities['254'] = '&thorn;';        entities['255'] = '&yuml;';
		}
	 
		if (useQuoteStyle !== 'ENT_NOQUOTES') {
			entities['34'] = '&quot;';    }
		if (useQuoteStyle === 'ENT_QUOTES') {
			entities['39'] = '&#39;';
		}
		entities['60'] = '&lt;';    entities['62'] = '&gt;';
	 
	 
		// ascii decimals to real symbols
		for (decimal in entities) {        symbol = String.fromCharCode(decimal);
			hash_map[symbol] = entities[decimal];
		}
		
		return hash_map;
	}
	
	function SYSTEM__str_replace (search, replace, subject, count) {
		// Replaces all occurrences of search in haystack with replace  
		// 
		// version: 1008.1718
		// discuss at: http://phpjs.org/functions/str_replace    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   improved by: Gabriel Paderni
		// +   improved by: Philip Peterson
		// +   improved by: Simon Willison (http://simonwillison.net)
		// +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    // +   bugfixed by: Anton Ongson
		// +      input by: Onno Marsman
		// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +    tweaked by: Onno Marsman
		// +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   input by: Oleg Eremeev
		// +   improved by: Brett Zamir (http://brett-zamir.me)
		// +   bugfixed by: Oleg Eremeev
		// %          note 1: The count parameter must be passed as a string in order    // %          note 1:  to find a global variable in which the result will be given
		// *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
		// *     returns 1: 'Kevin.van.Zonneveld'
		// *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
		// *     returns 2: 'hemmo, mars'    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
				f = [].concat(search),
				r = [].concat(replace),
				s = subject,
				ra = r instanceof Array, sa = s instanceof Array;    s = [].concat(s);
		if (count) {
			this.window[count] = 0;
		}
		 for (i=0, sl=s.length; i < sl; i++) {
			if (s[i] === '') {
				continue;
			}
			for (j=0, fl=f.length; j < fl; j++) {            temp = s[i]+'';
				repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
				s[i] = (temp).split(f[j]).join(repl);
				if (count && s[i] !== temp) {
					this.window[count] += (temp.length-s[i].length)/f[j].length;}        }
		}
		return sa ? s : s[0];
	}
	
	function SYSTEM__strpos (haystack, needle, offset) {
		// Finds position of first occurrence of a string within another  
		// 
		// version: 1006.1915
		// discuss at: http://phpjs.org/functions/strpos    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   improved by: Onno Marsman    
		// +   bugfixed by: Daniel Esteban
		// +   improved by: Brett Zamir (http://brett-zamir.me)
		// *     example 1: strpos('Kevin van Zonneveld', 'e', 5);    // *     returns 1: 14
		var i = (haystack+'').indexOf(needle, (offset || 0));
		return i === -1 ? false : i;
	}
	
	function SYSTEM__isset () {
		// !No description available for isset. @php.js developers: Please update the function summary text file.
		// 
		// version: 1006.1915
		// discuss at: http://phpjs.org/functions/isset    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   improved by: FremyCompany
		// +   improved by: Onno Marsman
		// *     example 1: isset( undefined, true);
		// *     returns 1: false    // *     example 2: isset( 'Kevin van Zonneveld' );
		// *     returns 2: true
		
		var a=arguments, l=a.length, i=0;
			if (l===0) {
			throw new Error('Empty isset'); 
		}
		
		while (i!==l) {        if (typeof(a[i])=='undefined' || a[i]===null) { 
				return false; 
			} else { 
				i++; 
			}    }
		return true;
	}
	
	function SYSTEM__addslashes (str) {
		// http://kevin.vanzonneveld.net
		// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   improved by: Ates Goral (http://magnetiq.com)
		// +   improved by: marrtins
		// +   improved by: Nate
		// +   improved by: Onno Marsman
		// +   input by: Denny Wardhana
		// +   improved by: Brett Zamir (http://brett-zamir.me)
		// +   improved by: Oskar Larsson Högfeldt (http://oskar-lh.name/)
		// *     example 1: addslashes("kevin's birthday");
		// *     returns 1: 'kevin\'s birthday'
		return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
	}
	
	function SYSTEM__stripslashes (str) {
		// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		// +   improved by: Ates Goral (http://magnetiq.com)
		// +      fixed by: Mick@el
		// +   improved by: marrtins
		// +   bugfixed by: Onno Marsman
		// +   improved by: rezna
		// +   input by: Rick Waldron
		// +   reimplemented by: Brett Zamir (http://brett-zamir.me)
		// +   input by: Brant Messenger (http://www.brantmessenger.com/)
		// +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		// *     example 1: stripslashes('Kevin\'s code');
		// *     returns 1: "Kevin's code"
		// *     example 2: stripslashes('Kevin\\\'s code');
		// *     returns 2: "Kevin\'s code"
		return (str + '').replace(/\\(.?)/g, function (s, n1) {
			switch (n1) {
			case '\\':
				return '\\';
			case '0':
				return '\u0000';
			case '':
				return '';
			default:
				return n1;
			}
		});
	}
	
	function SYSTEM__getSelectionStart(obj) {
		
		//.. Tells you where a selection starts in a input field
		
		if (obj.createTextRange) {
			var r = document.selection.createRange().duplicate()
			r.moveEnd('character', obj.value.length)
			if (r.text == '') return obj.value.length
			return obj.value.lastIndexOf(r.text)
		} else return obj.selectionStart
	}
	
	function SYSTEM__getSelectionEnd(obj) {
		if (obj.createTextRange) {
			var r = document.selection.createRange().duplicate()
			r.moveStart('character', -obj.value.length)
			return r.text.length
		} else return obj.selectionEnd
	}
	
	function SYSTEM__validateform(checkFields,obj,e, options) {
	
		//.. SET VARS
		if (typeof(options) == 'undefined') var options = {};
		if (typeof(obj) == 'undefined') var obj = false;
		if (typeof(e) == 'undefined') var e = false;

		//.. DEFINE GLOBAL LAYOUTS
		if (typeof(options['layout_error']) != 'undefined')
			var layout_error	=	'<span id="ERROR_[!-id-!]">'+String(options['layout_error'])+'</span>';
		else
			var layout_error	=	'<div id="ERROR_[!-id-!]" class="FORM_error"><span class="FORM_error_description">[!-description-!]</span></div>';

		//.. DEFINE GLOBAL VARIABLES
		var errors 				= 	false;
		var errorFields			=	new Array();
		var triggeredByObject 	= 	false;
				
		if (obj !== false) {
			if (e === false) {
				alert('Cannot validate form fields without event object!');
				return;	
			}
			var triggeredByObject = true;	
		}
		
		//.. *****************************************************************
		//.. IGNORE SOME EVENTS
		//.. *****************************************************************
		if (triggeredByObject) {
			//.. Jumping with TAB through a form should not activate error on next field
			if (SYSTEM__uniEvent(e) == 9) return;	
		}
		
		//.. *****************************************************************
		//.. CHECK: FIELDS
		//.. *****************************************************************
		
		//.. How to use:   fieldID[,placeErrorMsgHere]#TestIfNotEmpty(=true/false)#errorMsgIfEmpty#TestWithSpecialFunction(=false/functionName)[,extra variables]#errorMsg
		//.. More info	   [] means optional. For example if you want to error message to appear above id2 instead of id1 when checking id1 use:  id1,id2#true#Enter your name
		//.. Returns:	   ID list of fields with an error if no OBJ is given. Otherwise it returns TRUE (=errors) or FALSE (=no errors)
		//.. Extra:		   If you special function returns a string this is considered to be the error message
		
		//.. EXAMPLE:
		/*
		var checkFields	=	new Array();
		var  i = 0;
		checkFields[i++]		=	'firstname#true#U moet een voornaam opgeven';
		checkFields[i++]		=	'lastname#true#U moet een achternaam opgeven';
		checkFields[i++]		=	'street#true#U moet een straatnaam opgeven';
		checkFields[i++]		=	'street_number#true#U moet een huisnummer opgeven';
		checkFields[i++]		=	'zipcode#true#U moet een postcode opgeven';
		checkFields[i++]		=	'city#true#U moet een woonplaats opgeven';
		checkFields[i++]		=	'telephone#true#U moet een telefoonnummer opgeven';
		checkFields[i++]		=	'email#true#U moet een e-mail adres opgeven#SYSTEM__validate_email#U moet een geldig e-mail adres opgeven';
		checkFields[i++]		=	'password#true#U moet een wachtwoord opgeven#checkPassword';
		checkFields[i++]		=	'password2#true#Uw wachtwoord bevestiging moet gelijk zijn aan uw gekozen wachtwoord#checkPassword';
		checkFields[i++]		=	'voorwaarden,voorwaarden_error#false##checkVoorwaarden#U moet de voorwaarden accepteren';
		checkFields[i++]		=	'password_check#true#Als u een bestaande klant bent moet u hier uw wachtwoord invoeren';
		
		checkFields[i++]		=	'delivery_street#true#U moet een straatnaam opgeven';
		checkFields[i++]		=	'delivery_street_number#true#U moet een huisnummer opgeven';
		checkFields[i++]		=	'delivery_zipcode#true#U moet een postcode opgeven';
		checkFields[i++]		=	'delivery_city#true#U moet een woonplaats opgeven';
		*/
		
		//.. VALIDATION CODE
		for (var i = 0;i < checkFields.length; i++) {
						
			var temp = checkFields[i].split("#");
			checkFields_id 				= temp[0];
			checkFields_testNotEmpty	= temp[1];
			checkFields_errorMsg_1	 	= temp[2];
			checkFields_testFunction	= false;
			checkFields_errorMsg_2		= false;
			checkFields_errorPlace		= checkFields_id;
			
			if (SYSTEM__isset(temp[3])) {
				checkFields_testFunction = temp[3];
				checkFields_errorMsg_2 = temp[4];	
			}
			
			if (SYSTEM__strpos(checkFields_id,",")!== false) {
				temp = checkFields_id.split(",");
				checkFields_id = temp[0];
				checkFields_errorPlace = temp[1];
			}
			
			if (obj !== false) {
				if (checkFields_id != obj.id) continue;
			}
			
			//.. If field does not exist then continue
			if (document.getElementById(checkFields_id) == null) continue;
			
			//.. If field is not visible then continue
			var parentsField = $('#'+checkFields_id).parents();
			var hiddenField = false;
			while (typeof(parentsField[0]) != 'undefined') {
				if (parentsField[0].style.display == 'none') {hiddenField = true;break;}
				var parentsField = $(parentsField[0]).parents();	
			}
			if (hiddenField) continue;
			
			//.. CHECK IF EMPTY
			if (checkFields_testNotEmpty == 'true') {		
			
				value = $.trim(document.getElementById(checkFields_id).value);
				if (!value.length) {
					var temp = layout_error;
					temp = SYSTEM__str_replace('[!-id-!]',checkFields_id,temp);
					temp = SYSTEM__str_replace('[!-description-!]',checkFields_errorMsg_1,temp);
					if (document.getElementById('ERROR_'+checkFields_id) == null) {
						if ((typeof(options['after'])=='undefined')||(options['after']==false))
							$('#'+checkFields_errorPlace).before(temp);
						else
							$('#'+checkFields_errorPlace).after(temp);	
					}
					else {
						document.getElementById('ERROR_'+checkFields_id).outerHTML = temp;
						$('#ERROR_'+checkFields_id).show();					
					}
					$('#ERROR_'+checkFields_id).slideDown(200);
					errors = true;
					errorFields[errorFields.length] = checkFields_id;
					continue;	
				}
			}
			
			//.. CHECK SPECIAL FUNCTION
			if (checkFields_testFunction !== false) {
				value = $.trim(document.getElementById(checkFields_id).value);
				try {
					var response = eval(checkFields_testFunction+"('"+SYSTEM__addslashes(checkFields_id)+"')");
				}
				catch(err) {
					alert("ERROR: Bij het uitvoeren van een test functie is een fout opgetreden.\n\nFoutmelding:\n"+err);
					return;
				}
				if (response === false) {
					//.. TestFunction tell us there is no match
					
					//.. Check event
					if (triggeredByObject) {
						//.. Do not show errors while you are typing and you did not press Enter, Escape or Tab
						if ((e.type == 'keyup')&&(!SYSTEM__uniEvent(e,false,[13,27,9]))) continue;	
					}
					
					var temp = layout_error;
					temp = SYSTEM__str_replace('[!-id-!]',checkFields_id,temp);
					temp = SYSTEM__str_replace('[!-description-!]',checkFields_errorMsg_2,temp);
					if (typeof(checkFields_errorMsg_2) == 'undefined') {
						alert('ERROR in test functie.\n\nTest functie geeft FALSE (=fout) terug maar er is geen standaard foutmelding gespecificeerd!');
						return;	
					}
					if (document.getElementById('ERROR_'+checkFields_id) == null) {
						if ((typeof(options['after'])=='undefined')||(options['after']==false))
							$('#'+checkFields_errorPlace).before(temp);	
						else
							$('#'+checkFields_errorPlace).after(temp);	
					}
					else {
						document.getElementById('ERROR_'+checkFields_id).innerHTML = '<span class="FORM_error_description">'+checkFields_errorMsg_2+'</span>';					
					}
					$('#ERROR_'+checkFields_id).slideDown(200);
					errors = true;
					errorFields[errorFields.length] = checkFields_id;
					continue;		
				}
				else if ($.isArray(response)) {
					//.. Everything is OK. Please remove all error messages from
					//.. objects with these ID's
					for (var k = 0;k < response.length; k++) {
						$('#ERROR_'+response[k]).slideUp(200, function() {$('#ERROR_'+response[k]).remove()});	
					}
					continue;
				}
				else if (response !== true) {
					//.. Show custom message from function
					//.. testFunction tries to tell us something

					//.. Check event
					if (triggeredByObject) {
						//.. Do not show errors while you are typing and you did not press Enter, Escape or Tab
						if ((e.type == 'keyup')&&(!SYSTEM__uniEvent(e,false,[13,27,9]))) continue;	
					}
					
					var temp = layout_error;
					temp = SYSTEM__str_replace('[!-id-!]',checkFields_id,temp);
					temp = SYSTEM__str_replace('[!-description-!]',response,temp);
					if (document.getElementById('ERROR_'+checkFields_id) == null) {
						if ((typeof(options['after'])=='undefined')||(options['after']==false))
							$('#'+checkFields_errorPlace).before(temp);	
						else
							$('#'+checkFields_errorPlace).after(temp);	
					}
					else {
						//document.getElementById('ERROR_'+checkFields_id).innerHTML = '<span class="FORM_error_description">'+response+'</span>';					
						document.getElementById('ERROR_'+checkFields_id).outerHTML = temp;
						$('#ERROR_'+checkFields_id).show();	
					}
					$('#ERROR_'+checkFields_id).slideDown(200);
					errors = true;
					errorFields[errorFields.length] = checkFields_id;
					continue;	
				}
			}
			//.. No errors
			$('#ERROR_'+checkFields_id).slideUp(200, function() {$('#ERROR_'+checkFields_id).remove()});
			
		}
		
		//.. *****************************************************************
		//.. RESULTS
		//.. *****************************************************************
		if (obj !== false)
			return errors;
		else
			return errorFields;
	}

	function SYSTEM__GetCaretPosition (ctrl) {
		var CaretPos = 0;	// IE Support
		if (document.selection) {
		ctrl.focus ();
			var Sel = document.selection.createRange ();
			Sel.moveStart ('character', -ctrl.value.length);
			CaretPos = Sel.text.length;
		}
		// Firefox support
		else if (ctrl.selectionStart || ctrl.selectionStart == '0')
			CaretPos = ctrl.selectionStart;
		return (CaretPos);
	}
	
	function SYSTEM__setCaretPosition(ctrl, pos){
		if(ctrl.setSelectionRange)
		{
			ctrl.focus();
			ctrl.setSelectionRange(pos,pos);
		}
		else if (ctrl.createTextRange) {
			var range = ctrl.createTextRange();
			range.collapse(true);
			range.moveEnd('character', pos);
			range.moveStart('character', pos);
			range.select();
		}
	}

	
	function SYSTEM__onlyLettersOrNumbers(evt,ExceptionsAllowed) {
	
		//.. HOW TO USE:  add onkeypress = "return SYSTEM__onlyLettersOrNumbers(event)" to input	
	
		if (!SYSTEM__onlyLetters(evt,ExceptionsAllowed)){
			if (!SYSTEM__onlyNumbers(evt,ExceptionsAllowed)) 
				return false;	
			else
				return true;
		}
		
		
		return true;
		
	}
	
	function SYSTEM__onlySpecificChars(evt,CharList,Allowed) {
		
		//.. HOW TO USE:  add onkeypress = "return SYSTEM__onlySpecificChars(event,[' ','@'],true)" to input	
		//.. If allowed then only use charlist characters else do not use these
		
		//.. Expecting it to be an array like AllowedCharList = [" ","@","."]
		for (var i = 0;i < AllowedCharList.length; i++) {
				var temp = AllowedCharList[i];
				if (charCode === temp.charCodeAt(0)) {
					if (Allowed)
						return true;
					else
						return false;
				}
		}
		
		if (Allowed)		
			return false
		else
			return true;
			
	}
	
	function SYSTEM__getcharCode(evt) {
	
		 evt = (evt) ? evt : event;
       	 var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
         ((evt.which) ? evt.which : 0));
		
		return charCode;
	}
	
	function SYSTEM__onlyLetters(evt,ExceptionsAllowed) {
	
		//.. HOW TO USE:  add onkeypress = "return SYSTEM__onlyLetters(event)" to input	
		
       evt = (evt) ? evt : event;
       var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
          ((evt.which) ? evt.which : 0));
		  
	   if (typeof(ExceptionsAllowed) != 'undefined') {
		   //.. Expecting it to be an array like ExceptionsAllowed = [" ","@","."]
		   for (var i = 0;i < ExceptionsAllowed.length; i++) {
				var temp = ExceptionsAllowed[i];
				if (charCode === temp.charCodeAt(0))
					return true;   
		   }
	   }
		  
       if (charCode > 31 && (charCode < 65 || charCode > 90) &&
          (charCode < 97 || charCode > 122)) {
          return false;
       }
       return true;
     }
	
	function SYSTEM__onlyNumbers(evt,ExceptionsAllowed) {
		
		//.. HOW TO USE:  add onkeypress = "return SYSTEM__onlyNumbers(event)" to input
		
		var e = evt;
		if(window.event){ // IE
			var charCode = e.keyCode;
		} else if (e.which) { // Safari 4, Firefox 3.0.4
			var charCode = e.which
		}
		
		if (typeof(ExceptionsAllowed) != 'undefined') {
		   //.. Expecting it to be an array like ExceptionsAllowed = [" ","@","."]
		   for (var i = 0;i < ExceptionsAllowed.length; i++) {
				var temp = ExceptionsAllowed[i];
				if (charCode === temp.charCodeAt(0))
					return true;   
		   }
	    }
		
		if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
		return true;
	}
	
	function SYSTEM__onlyPrices(obj,evt) {
		
		//.. HOW TO USE:  add onkeypress = "return SYSTEM__onlyPrices(event)" to input
		
		var e = evt;
		if(window.event){ // IE
			var charCode = e.keyCode;
		} else if (e.which) { // Safari 4, Firefox 3.0.4
			var charCode = e.which
		}
		else
			var charCode = 0;

		if ((charCode > 31 && (charCode < 48 || charCode > 57))&&(charCode != 44)) return false;
		
		//.. Check for backspace
		if (charCode == 8) return true;
		if (charCode == 0) return true; //.. special key pressed like arrows, end, page-up etc.
		
				
		//.. No two comma's
		var posComma = SYSTEM__strpos(obj.value,",");
		if ((posComma!==false)&&(charCode==44))
			return false;
		
		//.. DO not start with a komma
		if ((obj.value.length == 0)&&(charCode==44)) return false;
		
		//.. No more then two numbers after the komma
		var posCaret	=	SYSTEM__GetCaretPosition(obj);
		if (posCaret > posComma) {
			//.. You are typing behind the komma
			var test = obj.value.split(",");
			if (test.length > 1)
				if (test[1].length > 1) return false;
		}
			
		
		return true;
	}
	
	function SYSTEM__correctPrice(obj) {
		
		if (obj.value.length == 0) {
			obj.value = "0,00";
			return;	
		}
		
		var posComma = SYSTEM__strpos(obj.value,",");
		
		if (posComma === false) return;
		
		var digitsAfterComma = obj.value.length - (posComma+1);
		if (digitsAfterComma == 2) {
			return;			
		}
		else if (digitsAfterComma == 1) {
			obj.value = obj.value+"0";	
		}
		else if (digitsAfterComma == 0) {
			obj.value = obj.value+"00";	
		}
		
		return;
			
	}
    
    function SYSTEM__initialise_inputfield(obj,mode) {
		
		//.. Example: onblur="SYSTEM__initialise_inputfield(this,1)" onfocus="SYSTEM__initialise_inputfield(this,0)" alt="Zoeken naar..(=default value):text(=type):[colorInActive:colorFocus:colorActive]"
		
		//.. If you change the type of an input field for example from text to password this is not possible due to security reasons.
		//.. A workaround is dublicating the input giving the first a type text and extend the id with -text en the other the type password and hide it.
		//.. This function will then swap both inputs
		
		//.. Optional
		//.. colorInActive: color of textfield when not yet changed
		//.. colorFocus: color of textfield when it is focussed and user is typing
		//.. colorActive: color of textfield after user is finished typing and value has changed to something else then default.
		
		if (typeof(	obj.alt ) != 'undefined') {
			var properties = obj.alt.split(":");
		}
		else {
			var properties = new Array();
			properties[0] = obj.title;
			properties[1] = false;	
		}
		
		var defaultText = properties[0];
		var inputType = properties[1];

		//.. Clicked
		if (mode == 0) {
			if (obj.value == defaultText) {
				obj.value = "";
				if (inputType !== false) {
					
					//.. SET FOCUS COLOR
					if (typeof(properties[3])!='undefined') $(obj).css('color',properties[3]);
					
					var temp = obj.id+"";
					temp = temp.split("-");
					if ((temp[1] == 'text')&&(document.getElementById(temp[0]))) {
						//.. Show hidden form of other type
						$(obj).hide();
						$(document.getElementById(temp[0])).show();
						$(document.getElementById(temp[0])).focus();	
					}
					else
						obj.type = inputType; //.. does not work in older IE					
				}
			}			
			return;
		}
		
		//.. Blur
		if (mode == 1) {
			if ((obj.value == defaultText)||(!$.trim(obj.value).length)) {
				obj.value = defaultText;
				if (inputType !== false) {
					
					if (document.getElementById(obj.id+"-text")) {
						//.. Show hidden form of other type
						$(obj).hide();
						$(document.getElementById(obj.id+"-text")).show();	
					}
					else
						obj.type = 'text'; //.. does not work in older IE
					
					//.. SET INACTIVE COLOR: OLDER BROWSERS DO NOT UNDERSTAND CSS :FOCUS
					if (typeof(properties[2])!='undefined') $(obj).css('color',properties[2]);
					
				}
			}
			else {
				//.. SET ACTIVE COLOR IF DEFINED
				if (typeof(properties[4])!='undefined') 
					$(obj).css('color',properties[4]);
				else {
					if (typeof(properties[2])!='undefined') $(obj).css('color',properties[2]);
				}
			}
			return;
		}
	}
	
	function SYSTEM__validate_email(address) {

		if (document.getElementById(address) !== null)
			address = document.getElementById(address).value;
		
	   	filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(address))
		  return true;
		else
		  return false;	   
	}
	
	
	//.. --------------------------------------------------------------------------------------
	//..	SPECIAL: Checkbox functions
	//.. --------------------------------------------------------------------------------------
	function CHECKBOX_check(checkbox) {
	
		if(typeof(checkbox) != 'object') {
			if (document.getElementById(checkbox) != null)
				checkbox = document.getElementById(checkbox);
			else
				return false;
		}

		checkbox.checked = true;
		
		return;		
	}
	
	function CHECKBOX_disable(checkbox) {
	
		if(typeof(checkbox) != 'object') {
			if (document.getElementById(checkbox) != null)
				checkbox = document.getElementById(checkbox);
			else
				return false;
		}

		checkbox.disabled = true;
		
		return;		
	}
	
	//.. --------------------------------------------------------------------------------------
	//..	SPECIAL: Radiobox functions
	//.. --------------------------------------------------------------------------------------
	
	function RADIO__disableValue(radioGroup, value) {

		if(typeof(radioGroup) != 'object') {
			if (document.getElementsByName(radioGroup) != null)
				radioObj = document.getElementsByName(radioGroup);
			else
				return false;
		}
		else
			radioObj = radioGroup;
			
		for(var i = 0; i < radioObj.length; i++) {
			
			if(radioObj[i].value == value) {
				radioObj[i].disabled = true;
			}
			else
				radioObj[i].disabled = false;
		}
		
		return true;
	}
	
	function RADIO__selectValue(radioGroup, value) {

		if(typeof(radioGroup) != 'object') {
			if (document.getElementsByName(radioGroup) != null)
				radioObj = document.getElementsByName(radioGroup);
			else
				return false;
		}
		else
			radioObj = radioGroup;
			
		for(var i = 0; i < radioObj.length; i++) {
			
			if(radioObj[i].value == value) {
				radioObj[i].checked = true;
			}
			else
				radioObj[i].checked = false;
		}
		
		return true;
	}
	
	function RADIO__setValue(radioGroup, newValue) {
		if(typeof(radioGroup) != 'object') {
			if (document.getElementsByName(radioGroup) != null)
				radioObj = document.getElementsByName(radioGroup);
			else
				return false;
		}
		else
			radioObj = radioGroup;
			
		var radioLength = radioObj.length;
		if(radioLength == undefined) {
			radioObj.checked = (radioObj.value == newValue.toString());
			return;
		}
		for(var i = 0; i < radioLength; i++) {
			radioObj[i].checked = false;
			
			if(radioObj[i].value == newValue.toString()) {
				radioObj[i].checked = true;
			}
		}
	}
	
	function RADIO__getValue(radioGroup) {
		if(typeof(radioGroup) != 'object') {
			if (document.getElementsByName(radioGroup) != null)
				radioObj = document.getElementsByName(radioGroup);
			else
				return false;
		}
		else
			radioObj = radioGroup;
			
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return false;
	}


	//.. --------------------------------------------------------------------------------------
	//..	SPECIAL: Listbox functions
	//.. --------------------------------------------------------------------------------------
	
	function LISTBOX__addOddEvenRowStyles(listbox,oddClassName, evenClassName) {
	
		if (typeof(listbox) != 'object')
			listbox = document.getElementById(listbox);
			
		for (var i = 0;i < listbox.options.length;i++) {
			
				if (i%2 == 0)
					$(listbox.options[i]).addClass(	evenClassName );
				else
					$(listbox.options[i]).addClass(	oddClassName );	
		}
		
		return;
		
	}
	
	function LISTBOX__select(listboxID,value) {
	
		if (document.getElementById(listboxID) == null) return false;
		
		var mylistbox = document.getElementById(listboxID);
		
		for (var i = 0;i < mylistbox.options.length;i++) {
			
				if (mylistbox.options[i].value == value) {
					mylistbox.options[i].selected = true;
				}
				else
					mylistbox.options[i].selected = false;			
		}
		
		return true;
		
	}
	
	function LISTBOX__clear(listboxID)
	 {
	  // returns 1 if all items are sucessfully removed
	  // otherwise returns zero.
	
		var mylistbox = document.getElementById(listboxID);
	
	  if(mylistbox == null)
	   return 1;
	  while(mylistbox.length > 0)
	  {
	   mylistbox.remove(0);
	  }
	  return 1;
	 }
	 
	function LISTBOX__edit(listboxID, itemNR, strText, strValue, strId) {
		
		var objList = document.getElementById(listboxID);
			
		if ((typeof(strValue)!='undefined')&&(strValue !== false))
			objList.options[itemNR].value = strValue;
		
		if ((typeof(strText)!='undefined')&&(strText !== false)) {
			objList.options[itemNR].text = strText;
		}
			
		if ((typeof(strId)!='undefined')&&(strId !== false))
			objList.options[itemNR].id = strId;
	
		return true;
		
	}
	
	function LISTBOX__add(listboxID, strText, strValue ,strId, className)
		{
		  var newOpt;
		  
		  var objListBox = document.getElementById(listboxID);
			 
		  newOpt = document.createElement("OPTION");
		  newOpt = new Option(strText,strValue);
		  if ((typeof(strId)!='undefined')&&(strId !== false))
		  	newOpt.id = strId;
			
		  if ((typeof(className)!='undefined')&&(className !== false))
		  	$(newOpt).addClass(className);
				
 		  //newOpt.style.backgroundColor = '#e8e8e8';
		  objListBox.options.add(newOpt);
	
		}
	
	function LISTBOX__remove(listboxID, value) {
		
		//.. Backwards compatibility
		if (typeof(value) == 'undefined') LISTBOX__removeSelected(listboxID);
		
		var selectbox = document.getElementById(listboxID);
		var i;
		for(i=selectbox.options.length-1;i>=0;i--)
		{
		if(selectbox.options[i].value == value)
		selectbox.remove(i);
		}	
	}
		
	function LISTBOX__removeSelected(listbox)
	{
		if (typeof(listbox) != 'object')
			listbox = document.getElementById(listbox);
		
		var count = 0;	
		for(var i = 0; i < listbox.options.length; i++)
		{
			if(listbox.options[i].selected) {
				listbox.remove(i);
				count++;
			}
		}
		
		return count;
	}
	
	function LISTBOX__inlist(listboxID,text,value) {
		
		var objList = document.getElementById(listboxID);
	
		for (var i = 0;i < objList.options.length;i++) {
			
			if ((value !== false)&&(typeof(value)!='undefined')) {
				if (objList.options[i].value.toLowerCase() == value.toLowerCase())
					return true;
			}
			
			if (text !== false) {
				if (objList.options[i].text.toLowerCase() == text.toLowerCase())
					return true;
			}

		}
		
		return false;
		
	}
	
	function LISTBOX__getlist(listboxID,selectedOnly) {
	
		var objList = document.getElementById(listboxID);
		
		var listValues = new Array();
		var listNames = new Array();
		var listItemNR = new Array();
		
		if (!objList.options.length) return false;
		
		for (var i = 0;i < objList.options.length;i++) {
			
			var temp = "";
			
			if ((typeof(selectedOnly)!='undefined')&&(selectedOnly === true)) {
				if (!objList.options[i].selected) continue;	
			}
			
			listValues[listValues.length] = objList.options[i].value;
			listNames[listNames.length] = objList.options[i].text;
			listItemNR[listItemNR.length] = i;
			
		}
		
		var list = new Array();
		
		list[0] = listNames;
		list[1] = listValues;
		list[2] = listItemNR;		
		
		return list;
			

	}
	
	function LISTBOX__move(listboxID, direction) {
		
		//.. direction is UP or DOWN
		//.. Does not support multiselection
		
		var listbox = document.getElementById(listboxID);
		var selIndex = listbox.selectedIndex;
	
		if(-1 == selIndex) {
			return false;
		}
	
		var increment = -1;
		if(direction == 'up')
			increment = -1;
		else
			increment = 1;
	
		if((selIndex + increment) < 0 ||
			(selIndex + increment) > (listbox.options.length-1)) {
			return;
		}
	
		var selValue = listbox.options[selIndex].value;
		var selText = listbox.options[selIndex].text;
		listbox.options[selIndex].value = listbox.options[selIndex + increment].value
		listbox.options[selIndex].text = listbox.options[selIndex + increment].text
	
		listbox.options[selIndex + increment].value = selValue;
		listbox.options[selIndex + increment].text = selText;
	
		listbox.selectedIndex = selIndex + increment;
	}

	function LISTBOX__sort(listboxID,keepOnTopValue, keepSelection) {
		if (!SYSTEM__isset(keepOnTopValue)) keepOnTopValue = false;
		if (!SYSTEM__isset(keepSelection)) keepSelection = true;

		var lb = document.getElementById(listboxID);

		if (!lb.options.length) return;
		
		arrTexts = new Array();
		
		var topText = "";
		var topValue = "";
		var topSelected = false;
			
		for(i=0; i<lb.length; i++)  {
			
			if (( keepOnTopValue !== false )&&(keepOnTopValue == lb.options[i].value )) {
				topText  = lb.options[i].text;
				topValue = lb.options[i].value;
				topSelected = lb.options[i].selected;
			}
			else {
			    arrTexts[arrTexts.length] = lb.options[i].text+"#-!-#"+lb.options[i].value+"#-!-#"+lb.options[i].selected;
			}
		  
		}

		arrTexts.sort();
				
		var k = 0;
		if ( keepOnTopValue !== false ) {
			lb.options[k].text	= topText;
			lb.options[k].value	= topValue;
			lb.options[k].selected = topSelected;		
			k++;
		}
					  
		for(i=0; i<arrTexts.length; i++)  {
		  var temp = arrTexts[i];
		  temp = temp.split("#-!-#");
		  lb.options[k].text = temp[0];
		  lb.options[k].value = temp[1];
		  
		  if (temp[2] == "true")
		  	lb.options[k].selected = true;
		  else
		  	lb.options[k].selected = false;
		  
		  k++;
		}
		
		
	}

	//.. --------------------------------------------------------------------------------------
	//..	AJAX TOOLS
	//.. --------------------------------------------------------------------------------------

	function SYSTEM__AjaxFuncRequest(url,funcID,data,returnFunc) {
	
		//.. This script calls a certain function inside a PHP server script and returns
		//.. the results of this function
		
		//.. Using jQuery library
		
		if (returnFunc !== 'undefined')
			$.post(url+"?SYSTEM__callFunc="+funcID,data, returnFunc);
		else
			$.post(url+"?SYSTEM__callFunc="+funcID,data);
		
	}
	
	
	


	
	
	//.. --------------------------------------------------------------------------------------
	//..	END: Secret Codes: hidden from general public	
	//.. --------------------------------------------------------------------------------------

	

