function ge(id) {
	return document.getElementById(id);
}
function openUrl(url) {
	window.location.href = url;
}
function newUrl(url) {
	var w = window.open(url);
}
function doPrint() {
	window.print();
}
function sbPrev(id) {
	var sb = ge(id);
	if(sb == null) return;
	if(sb.selectedIndex > 0) {
		sb.selectedIndex = sb.selectedIndex - 1;
		try { sb.onchange(); } catch(ex) {}
	}
}
function sbNext(id) {
	var sb = ge(id);
	if(sb == null) return;
	if(sb.selectedIndex < sb.options.length-1) {
		sb.selectedIndex = sb.selectedIndex + 1;
		try { sb.onchange(); } catch(ex) {}
	}
}
function newClass(e, className) {
    e.oClass = e.className;
	e.className = className;
}
function oldClass(e) {
    if(e.oClass == null) return;
    e.className = e.oClass;
}
function display(id,show) {
    if(id == null) return;
    if(typeof(id) != "string") { 
        id.style.display = show ? "" : "none";  
        return; 
    }
    var e = ge(id);
    if(e == null) return;
    e.style.display = show ? "" : "none";
}

String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g,"");
}
String.prototype.after = function(delim) {
    if(delim == null || delim == "") return this;
    var index = this.indexOf(delim);
    return index > -1 ? this.substring(index + delim.length,this.length) : this;    
}
String.prototype.afterLast = function(delim) {
    if(delim == null || delim == "") return this;
    var index = this.lastIndexOf(delim);
    return index > -1 ? this.substring(index + delim.length,this.length) : this;     
}
String.prototype.before = function(delim) {
    if(delim == null || delim == "") return this;
    var index = this.indexOf(delim);
    return index > -1 ? this.substring(0,index) : this;    
}
String.prototype.beforeLast = function(delim) {
    if(delim == null || delim == "") return this;
    var index = this.lastIndexOf(delim);
    return index > -1 ? this.substring(0,index) : this;    
}
String.prototype.startsWith = function(s) {
    if(s.length == 0) return true;
    if(s.length > this.length) return false;
    return this.indexOf(s) == 0;
}
String.prototype.endsWith = function(s) {	
    if(s.length == 0) return true;	
    if(s.length > this.length) return false;
    return this.slice(this.length - s.length) == s;	
}
String.prototype.truncate = function(length,suffix) {
    if(this.length <= length) return this;            	
    return this.substring(0,length) + (suffix == null ? "" : suffix);
}