String.prototype.ltrim = function () { return this.replace(/^ */,"");}
String.prototype.rtrim = function () { return this.replace(/ *$/,"");}
String.prototype.trim = function () { return this.ltrim().rtrim();}
String.prototype.StartsWith = function(str) {return (this.match("^" + str) == str)}
String.prototype.EndsWith = function(str) {return (this.match(str + "$") == str)}

function setupForEnter() {
	try {
		$(document).ready(function () {
			// get only input tags with class data-entry
			objecten = $(".IsMoveNext");
			// now we check to see which browser is being used
			if ($.browser.mozilla) {$(objecten).keypress(checkForEnter);}
			else {$(objecten).keydown(checkForEnter);}
		});
	}
	catch (err) {}
}
function checkForEnter(event) {
	try {
		if (event.keyCode == 13) {
			if (this.className.indexOf("IsSuggest") != -1) {return true;}
			if (this.className.indexOf("IsTextArea") != -1) {return true;}
			currentBoxNumber = objecten.index(this);
			if (objecten[currentBoxNumber + 1] != null) {
				nextBox = objecten[currentBoxNumber + 1]
				nextBox.focus();
				if (this.type == 'text') {nextBox.select();}
				event.preventDefault();
			}
			return false;
		}
		return true;
	}
	catch (err) {}
}

function updateTrace(text) {
	try {
		$('#__Trace').append(' | ' + text);
	}
	catch(err) {}
}
function textCounter(field, cntfield, maxlimit) {
	try {
		if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);}
		else {document.getElementById(cntfield).innerHTML = maxlimit - field.value.length;}
	}
	catch(err) {}
}
function checkLength(obj, maxlen) {
	try {
		maxlen = maxlen - 1;
		if (obj.getAttribute && obj.value.length > maxlen)obj.value = obj.value.substring(0,maxlen)
	}
	catch(err) {}
}
function toggle(obj) {
	try {$('#' + obj).slideToggle("200");}
	catch(err) {}
}
function slimboxReset() {
	try {
		$("a[rel^='lightbox']").slimbox({  }, null, function(el) {
			return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
		});
	}
	catch(err) {}
}
function getEventKey(e) {
	try {
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		return code;
	}
	catch(err) {}
}
function getEventMouse(e) {
	try {return event.button;}
	catch(err) {}
}
function setValue(objId, val) {
	try {
		document.getElementById(objId).value = val;
		setTimeout("__doPostBack('" + objId + "','')", 0);
	}
	catch(err) {}
}
function focusEmpty() {
	try {
		var allObj;
		if (typeof _j_focusPanel != 'undefined' && _j_focusPanel != null && _j_focusPanel != '') {
			allObj = document.getElementById(_j_focusPanel).getElementsByTagName('*');}
		else {
			allObj = document.getElementsByTagName("*");}
		var l = allObj.length,i;
		var bak = '';
		for(i = 0; i < l; i++) {
			switch(allObj[i].type) {
				case 'text': case 'select-one': case 'textarea': case 'password': case 'file':
				if (allObj[i].value == '') {
					allObj[i].focus();
					return;
				}
				else {bak = allObj[i].id;}
			}
		}
		if (bak != '') {
			document.getElementById(bak).focus();
		}
	}
	catch(err) {}
}
function focusSave(obj) {
	try {
		document.getElementById("__LASTFOCUS").value = obj.id;
	}
	catch(err) {}
}
function nextField(e, obj) {
	try {
		if (getEventKey(e) == 13) {return focusNext(e,obj);}
		return true;
	}
	catch(err) {}
}
function focusNext(e, obj) {
	try {
		var objId = obj.id;
		if (objId == '') {
			if (obj.hasChildNodes()) {
				for(var c=0; c < obj.childNodes.length; c++) {
					if (obj.childNodes[c].id != '') {objId = obj.childNodes[c].id;}
				}
			}
		}
		var allObj;
		if (typeof _j_focusPanel != 'undefined' && _j_focusPanel != null && _j_focusPanel != '') {
			allObj = document.getElementById(_j_focusPanel).getElementsByTagName('*');}
		else {
			allObj = document.getElementsByTagName("*");}
		var found = 0;
		var l = allObj.length,i;
		for(i = 0; i < l; i++) {
			if (allObj[i].id == '') continue;
			if (found == 0) {if (allObj[i].id == objId) {found = 1;}}
			else {
				switch(allObj[i].type) {
					case 'text':
					case 'select-one':
					case 'textarea':
					case 'checkbox':
					case 'submit':
					case 'password':
						allObj[i].focus();
						return cancelEvent(e);

				}
			}
		}
	}
	catch(err) {}
	cancelEvent(e);
	document.getElementById(objId).focus();
	return false;
}
function cancelEvent(e) {
	try {
		e.returnValue = false;
		e.cancelBubble = true;
		if (e && e.preventDefault) e.preventDefault(); // DOM style
		return false; // IE style
	}
	catch(err) {}
}
function focusObject(objId) {
	try {
		$(document).ready(function () {
			$('#' + objId).focus();
		});
	}
	catch(err) {}
}