String.prototype.trim = function(){
return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))
}

String.prototype.startsWith = function(str){
return (this.match("^"+str)==str)
}

String.prototype.endsWith = function(str){
return (this.match(str+"$")==str)
}

Array.prototype.contains = function(searchStr) {
	return (this.getIndex(searchStr) == -1?  false: true);
}

Array.prototype.getIndexStartsWith = function(searchStr) {
   var pos = -1;
   for (var i=0; i<this.length; i++) {
     if (this[i].startsWith(searchStr)) {
		pos = i;
		break;
	}
   }
   return pos;
}

Array.prototype.getIndex = function(searchStr) {
   var pos = -1;
   for (var i=0; i<this.length; i++) {
     if (this[i]==searchStr) {
		pos = i;
		break;
	}
   }
   return pos;
}
function setFormValue(obj, val){
	if(obj){
		obj.value = val;
	}
}
function showIt(name){
	var atag  = document.getElementById(name);	
	if (atag){
		atag.style.display = 'block';			
	}
}

function hideIt(name){
	var atag  = document.getElementById(name);	
	if (atag){
		atag.style.display = 'none';			
	}
}
function setElmtClass(name, classname){
	var atag  = document.getElementById(name);	
	if (atag){
		atag.className = classname;			
	}
}
function trimString (str) {
	if(str == null)
		return '';
	return str.replace(/^\s+|\s+$/g, '') ;
}
function isEmpty(value){
	if(value){
		return value.length ==0? true : false;
	}	
	return true;
}
function onKeyPressOnlyNumbers(e){
	var key;
	var keychar;

	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || 
		(key==13) || (key==27) || (key==37) || (key==39) || (key==46))
	   return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	return false;
}

function STMRCWindow(page, sHeight, swidth) {
	if (swidth && sHeight) {
			window.open(page, "CtrlWindow", ",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,dependent=no,directories=no,width="+swidth+",height="+sHeight+",x=50,y=50");
	}
	else {
		window.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,dependent=no,directories=no,width=655,height=640,x=50,y=50");
	}
}