/*
name			: URL Functions
update			: 20041107
author			: Maurice van Creij
dependencies	: lib_urls.js
info			: http://www.woollymittens.nl/content/details.asp?id=20040719133743

history
20050511		: no prior updates report
*/

/* legacy calls */
			function URLparam(strParamName,strDefaultValue) {
				return getQueryParameter(strParamName,strDefaultValue);
			}
			function URLencode(strForUrl) {
				return encodeURL(strForUrl);
			}
			function URLdecode(strFromUrl) {
				return decodeURL(strFromUrl);
			}
			function HTMLencode(inStr) { 
				return encodeHTML(inStr);
			}
			function URLstrip(strHref){ 
				return stripURL(strHref);
			}

/* functionality */
		// convert relative paths to absolute paths
		function convertAbsToRelUrls(strUrl){
			// is the url a relative path
			if(strUrl.indexOf('/')<0 || strUrl.substr(0,1)=='.' || strUrl.substr(0,1)=='/'){
				// the current absolute path
				strAbs = document.location.href;
				// remove the filename from the end
				strAbs = strAbs.substring(0, strAbs.lastIndexOf('/'));
				// while there are parent markers in the url
				while(strUrl.indexOf('../')==0){
					// remove one level from the absolute path
					strUrl = strUrl.replace('../','');
					// remove one parent marker from the relative path
					strAbs = strAbs.substring(0, strAbs.lastIndexOf('/'));
				}
				// remove all current dir markers from the relative url
				strUrl = strUrl.replace(/\.\//gi,'');
				// add the url to the absolute path
				strUrl = strAbs + '/' + strUrl;
			}
			return strUrl;
		}
	// return a parameter from the url's query strings
	function getQueryParameter(strParamName,strDefaultValue){
		// split the query string at the parameter name
		var arrQueryParameter = document.location.search.split(strParamName+"=");
		// split the parameter value from the rest of the string
		var strQueryParameter = (arrQueryParameter.length>1) ? arrQueryParameter[1].split("&")[0] : null ;
		// return the value or the default value
		return (strQueryParameter==null && strDefaultValue!=null) ? strDefaultValue : strQueryParameter;
	}
	// translate all "reserved" characters of a string to HTML equivalents
	function encodeURL(strForUrl) {
		return escape(strForUrl)
	}
	function decodeURL(strFromUrl) {
		return unescape(strFromUrl)
	}
	// determine the absolute path of a location (strip the domain)
	function stripURL(strHref){ 
		if(strHref==null) strHref = document.location.href;
		arrHref = strHref.split(document.domain);
		return (arrHref.length>1) ? arrHref[1] : strHref;
	}
	// translate all "reserved" characters of a string to HTML equivalents
	function encodeHTML(strToHTML) { 
		return strToHTML.replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/ /gi,"&nbsp;").replace(/\t/gi,"&nbsp;&nbsp;&nbsp;");
	}
	// snip a parameter from the url query
	function removeParameter(strUrl,strParam){
		strUrl = stripURL(strUrl);
		arrPath = lokatie.split('?');
		strNewPath = arrPath[0];
		if(arrPath.length>1){
			strParams = arrPath[1];
			arrParams = strParams.split('&');
			strNewPath += '?' 
			for(var intA=0; intA<arrParams.length; intA++){
				if(arrParams[intA].indexOf(strParam)<0){
					strNewPath += arrParams[intA] + '&'
				}
			}
			strNewPath = strNewPath.substring(0,strNewPath.length-1);
		}
		return strNewPath
	}
	// add a parameter to the end of n url query
	function addParameter(strPath,strParam,strValue){
		strPath += (strNewPath.indexOf('?')>-1) ? '&' : '?';
		strPath += strParam + '=' + escape(strValue);
		return strPath;
	}
