	String.prototype.trim = function() {
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}

	String.prototype.replaceAll = function(searchVal,replaceVal) { 
		var str=this;
		ind=str.indexOf(searchVal);
		while (ind!=-1) { 
			str=str.replace(searchVal,replaceVal); 
			ind=str.indexOf(searchVal);
		} 
		return str;
	}
	
	function popup(url,winname,w,h,statusbar,scrollbars,toolbar,resizeable,menubar) {
		var OpenWindow=window.open(url, winname,'status='+statusbar+',scrollbars='+scrollbars+',toolbar='+toolbar+',resizable='+resizeable+',menubar='+menubar+',width='+w+',height='+h+',left=0,top=0'); 	
		OpenWindow.focus();
	}
	
	function getElement(id) {
		if ( document.all ) {
			return document.all[id];
		} else { 
			return document.getElementById(id);
		}
    }

    String.prototype.trimright = function (rightval) {
        var x = this.substring(this.length - rightval.length, this.length);
        if (x == rightval) {
            return this.substring(0, this.length - rightval.length);
        } else {
            return this;
        }
    }

    function setRadioSelectedValue(radioList, val) {
        var options = radioList.getElementsByTagName('input');
        for (i = 0; i < options.length; i++) {
            var opt = options[i];
            if (opt.value.toString().toLowerCase() == val.toString().toLowerCase()) {
                opt.checked = true;
                return;
            }
        }
        return null;
    }


    function getRadioSelectedValue(radioList) {
        var options = radioList.getElementsByTagName('input');
        for (i = 0; i < options.length; i++) {
            var opt = options[i];
            if (opt.checked) {
                return opt.value;
            }
        }
        return null;
    }

    function getRadioSelectedText(radioList) {
        var lbls = radioList.getElementsByTagName('label');
        var options = radioList.getElementsByTagName('input');
        for (i = 0; i < options.length; i++) {
            var opt = options[i];
            if (opt.checked) {
                for (j = 0; j < lbls.length; j++)
                    if (lbls[j].htmlFor == opt.id)
                        return lbls[j].innerHTML.toString();
            }
        }
        return "";
    }
