// JavaScript Document
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
    return typeof a == 'string';
}

function hide(elem) {
	if (isString(elem)) {
		elem = document.getElementById(elem);	
	}
	if (elem) {
		elem.style.display='none';
	}
}

function show(elem) {
	if (isString(elem)) {
		elem = document.getElementById(elem);	
	}
	if (elem) {
		elem.style.display='';
	}
}

function bold(elem) {
	if (isString(elem)) {
		elem = document.getElementById(elem);	
	}
	if (elem) {
		elem.style.fontWeight = 'bold';
	}	
}

function unbold(elem) {
	if (isString(elem)) {
		elem = document.getElementById(elem);	
	}
	if (elem) {
		elem.style.fontWeight = '';
	}		
}

// 
function getKeyCode(e)
{
	if (window.event)
		return window.event.keyCode;
	else 
		if (e)
			return e.which;
		else
			return null;
}

function keyRestrict(e, validchars) {
	var key='', keychar='';
	key = getKeyCode(e);
	if (key == null)
		return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	return false;
}
