	function limit_chars(inputId, limit, outputId) {
		inputTxt = document.getElementById(inputId).value;
		strLength = limit - inputTxt.length;
		if (strLength < 0) {
			strLength = 0;
			document.getElementById(inputId).value = inputTxt.substring(0,limit);
		}
		if (outputId != "") {
			document.getElementById(outputId).innerHTML = 'chars left: ' + strLength;
		}
	}



	// trims whitespace from beginning and end of string
	function trim(str) {
		return str.replace(/^\s+|\s+$/g, '');
	}
	
	// Replaces spaces from beginning, middle and end of string with a character or string
	function noSpaces(str, replacementChar) {
		return str.replace(/\s/g, replacementChar);
	}


function isNumeric(str) {
		str = str.replace(/^\s+|\s+$/g, '');
		if((str.length == 1 && str.match(/^\d+$/g)) || ((str.length > 1) && str.match(/^[-]{0,1}\d*[.]{0,1}\d*$/g))) return true;
		return false;
	}
	
	
	function nl2br (string) {
		return (string + '').replace(/([^>]?)\n/g, '$1'+ '<br />' +'\n');
	}

	function str_replace(search, replace, subject, count) {
		// example: str_replace(' ', '.', 'Kevin van Zonneveld');
		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 substr (f_string, f_start, f_length) {
		f_string += '';
		if (f_start < 0) {
			f_start += f_string.length;
		}
		if (f_length == undefined) {
			f_length = f_string.length;
		} else if (f_length < 0){
			f_length += f_string.length;
		} else {
			f_length += f_start;
		}
		if (f_length < f_start) {
			f_length = f_start;
		}
		return f_string.substring(f_start, f_length);
	}

	function isValidURL(url){
		var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
		if(RegExp.test(url)){
			return true;
		}else{
			return false;
		}
	}

	function insertAtCursor(myField, myValue) {
		//IE support
		if (document.selection) {
			myField.focus();
			sel = document.selection.createRange();
			sel.text = myValue;
		}
		//MOZILLA/NETSCAPE support
		else if (myField.selectionStart || myField.selectionStart == '0') {
			var startPos = myField.selectionStart;
			var endPos = myField.selectionEnd;
			myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
		} else {
			myField.value += myValue;
		}
	}

