
	Math.randomize // Older versions of the JavaScript-implementation on browsers require this to 'shuffle' the random-generator.

	/* ***************************************************************************************************

		General Functions

	*************************************************************************************************** */

	function openWindow(theUrl, theWidth, theHeight)
	{
		window.open(theUrl, '', 'height = ' + theHeight + ', width = ' + theWidth + ', status = no, location = no, menubar = 0, resizable = yes, scrollbars = yes, titlebar = yes, toolbar = no');
	}

	function randomCode(digits)
	{
		if(randomCode.arguments.length == 0)
		{
			digits = 64;
		}

		var characters = new Array('a', 'b', 'c', 'd', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
		var result = '';

		for(var i = 0; i < digits; i++) // (62 ^ [digits] mogelijke codes)
		{
			result += characters[Math.floor(Math.random() * characters.length)];
		}

		return result;
	}

	function openImage(theUrl, theWidth, theHeight)
	{
		window.open(theUrl, '', 'height = ' + theHeight + ', width = ' + theWidth + ', status = no, location = no, menubar = 0, resizable = yes, scrollbars = no, titlebar = yes, toolbar = no');
	}

	function doClose()
	{
		window.close();
	}

	function setReferrer(url)
	{
		document.referrer.doRedirect(url);
	}

	function doRedirect(url)
	{
		document.location.href = url;
	}

	function escapeHtml(s)
	{
		var result = '' + s;

		result = result.replace(/&/g, '&amp;');
		result = result.replace(/</g, '&lt;');
		result = result.replace(/>/g, '&gt;');
		result = result.replace(/\"/g, '&quot;');

		return result;
	}

	/* ***************************************************************************************************

		Validation functions

	*************************************************************************************************** */

	// is string een boolean
	function isBoolean(theValue)
	{
		theValue = theValue.toLowerCase();

		if(theValue == "ja")
		{
			return true;
		}
		else
		{
			if(theValue == "nee")
			{
				return true;
			}
		}

		return false;
	}

	// is string een hexadecimale kleurcode
	function isColor(theValue)
	{
		var expr = "^[#]([0-9a-fA-F]){6,6}$";

		if(theValue.match(expr)) // Voldoet aan syntax (#XXXXXX)
		{
			return true;
		}
		
		return false;
	}

	// is string een datum
	function isDate(theValue)
	{
		var expr = "^[0-9]{1,2}[-]{1,1}[0-9]{1,2}[-]{1,1}[0-9]{4,4}$";

		if(theValue.match(expr)) // Voldoet aan syntax (d-m-j)
		{
			var arr = theValue.split("-");

			if(arr[0].substr(0, 1) == "0")
			{
				arr[0] = arr[0].substr(1, 2);
			}

			if(arr[1].substr(0, 1) == "0")
			{
				arr[1] = arr[1].substr(1, 2);
			}

			var dag = parseInt(arr[0]);
			var maand = parseInt(arr[1]);
			var jaar = parseInt(arr[2]);

			if((maand == 1) || (maand == 3) || (maand == 5) || (maand == 7) || (maand == 8) || (maand == 10) || (maand == 12))
			{
				// De maanden Januari, Maart, Mei, juli, Augustus, Oktober en December hebben altijd maximaal 31 dagen

				if(dag <= 31)
				{
					return true;
				}
			}
			else
			{
				if((maand == 4) || (maand == 6) || (maand == 9) || (maand == 11))
				{
					// De maanden April, Juni, September en November hebben altijd maximaal 30 dagen

					if(dag <= 30)
					{
						return true;
					}
				}
				else
				{
					if(maand == 2)
					{
						// De maand februari heeft normaal maximaal 28 dagen, maar in schrikkeljaren 29 dagen

						if((jaar % 4 == 0) && (jaar % 400 != 0)) // Schrikkeljaar
						{
							if(dag <= 29)
							{
								return true;
							}
						}
						else
						{
							if(dag <= 28)
							{
								return true;
							}
						}
					}
				}
			}
		}

		return false;
	}

	// is string een decimale waarde
	function isDecimal(theValue)
	{
		var expr = "^[-]{0,1}[0-9]+([,]{1,1}[0-9]*){0,1}$";

		if(theValue.match(expr)) // Voldoet aan syntax
		{
			return true;
		}

		return false;
	}

	// is string een document
	function isDocument(theValue)
	{
		var arr = theValue.split("."); // kijk of file een afbeelding is

		if(arr.length > 1)
		{
			var extentie = arr[arr.length - 1].toLowerCase(); // laatste index

			if((extentie == "doc") || (extentie == "txt") || (extentie == "pdf") || (extentie == "ppt") || (extentie == "xsl"))
			{
				return true;
			}
		}

		return false;
	}

	// is string een emailadres
	function isEmail(theValue)
	{
		var expr = "^([a-zA-Z0-9]){1,}(([a-zA-Z0-9\-_])|(([\.]){1,1}([a-zA-Z0-9]){1,})){0,}([@]){1,1}([a-zA-Z0-9]){1,}(([a-zA-Z0-9\-_])|(([\.]){1,1}([a-zA-Z0-9]){1,})){0,}([\.]){1,1}([a-zA-Z0-9]){2,4}$";
		if(theValue.match(expr)) // Voldoet aan syntax
		{
			return true;
		}

		return false;
	}

	// is string een file
	function isFile(theValue)
	{
		var arr = theValue.split("."); // kijk of file een afbeelding is

		if(arr.length > 1)
		{
			var extentie = arr[arr.length - 1].toLowerCase(); // laatste index
			if((extentie == "doc") || (extentie == "txt") || (extentie == "pdf") || (extentie == "ppt") || (extentie == "xsl") || (extentie == "jpg") || (extentie == "jpeg") || (extentie == "gif") || (extentie == "png"))
			{
				return true;
			}
		}

		return false;
	}

	// is string een htmltekst
	function isHtml(theValue)
	{
		return true;
	}

	// is string een afbeelding
	function isImage(theValue)
	{
		var arr = theValue.split("."); // kijk of file een afbeelding is

		if(arr.length > 1)
		{
			var extentie = arr[arr.length - 1].toLowerCase(); // laatste index
			if((extentie == "jpg") || (extentie == "jpe") || (extentie == "jpeg") || (extentie == "gif") || (extentie == "png"))
			{
				return true;
			}
		}

		return false;
	}


	function isIp(theValue)
	{
		var expr = "^([0-9]){1,3}([\.]){1,1}([0-9]){1,3}([\.]){1,1}([0-9]){1,3}([\.]){1,1}([0-9]){1,3}$";

		if(theValue.match(expr))
		{
			var arr = theValue.split(".");

			if((arr[0] < 256) && (arr[1] < 256) && (arr[2] < 256) && (arr[3] < 256))
			{
				return true;
			}
		}

		return false;
	}

	// is string numeriek
	function isNumeric(theValue)
	{
		var expr = "^[-]{0,1}[0-9]{0,}$";

		if(theValue.match(expr)) // Voldoet aan syntax
		{
			return true;
		}

		return false;
	}

	// is string een tekst
	function isText(theValue)
	{
		return true;
	}

	// is string een tijdstip
	function isTime(theValue)
	{
		var expr = "^[0-9]{1,2}[:]{1,1}[0-9]{2,2}$";

		if(theValue.match(expr)) // Voldoet aan syntax (d-m-j)
		{
			var arr = theValue.split(":");

			if(arr[0].substr(0, 1) == "0")
			{
				arr[0] = arr[0].substr(1, 2);
			}

			if(arr[1].substr(0, 1) == "0")
			{
				arr[1] = arr[1].substr(1, 2);
			}

			var uren = parseInt(arr[0]);
			var minuten = parseInt(arr[1]);

			if(uren < 24)
			{
				if(minuten < 60)
				{
					return true;
				}
			}
		}

		return false;
	}

	// is string een url
	function isUrl(theValue)
	{
		var expr = "^(ftp|http|https){1,1}([:]){1,1}([/]){2,2}(.){2,}";

		if(theValue.match(expr)) // Voldoet aan syntax
		{
			return true;
		}

		return false;
	}

	// is string een url
	function isWord(theValue)
	{
		var expr = "^[a-zA-Z0-9\.\-_]*$";

		if(theValue.match(expr)) // Voldoet aan syntax
		{
			return true;
		}

		return false;
	}
