var display = new Object();

display.hideElement = function(e) {
	if ( document.getElementById(e) )
		document.getElementById(e).style.display = "none";
}
display.showElement = function(e) {
	if ( document.getElementById(e) )
		document.getElementById(e).style.display = "";
}
display.blockElement = function(e) {
	if ( document.getElementById(e) )
		document.getElementById(e).style.display = "block";
}
display.colorize = function( e, colorized, type, c1, c2) {
	if ( document.getElementById(e) ) {
		obj = document.getElementById(e);
		switch ( type ) {
			case 'form' :
				obj.style.borderColor = !colorized ? c1 : c2;
				break;
			case 'text' :
				obj.style.color = !colorized ? c1 : c2;
				break;
		}
	}
}
function elementValidator(element,elementWB,isValid,type,c1,c2) {
	if ( isValid )
		display.hideElement(elementWB);
	else
		display.showElement(elementWB);
	display.colorize(element,isValid,type,c1,c2);
	return isValid;
}
function trim (str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}
function mid (str,s,l) {
	if ( s < str.length ) {
		if ( str.length < s + l )
			return str.substr(s,str.length-s);
		else
			return str.substr(s,l);
	}
	else
		return '';
}