	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
		    	if (oldonload) {
		    		oldonload();
		    	}
		    	func();
			}
		}
	}

	function trim(str){
		if(str)
			return str.replace(/(^[\s]*)|([\s]*$)/g, "");
		else
			return str;
	}
  
	function checkIsNotEmpty(str){
		if(str == null){
			return false;
		}
		else if(trim(str) == ""){
			return false;
		}
		else
			return true;
	}
  
	function checkIsInteger(st){
		if(st == "")
			return false;
		if(/^(\-?)(\d+)$/.test(st))
			return true;
		else
			return false;
	}
	
	function isValidDecimal( chars ) {
		var re=/^\d*\.?\d{1,2}$/;
		if (chars.match(re) == null)
		return false;
		else
		return true;
	}	

	function isNetscape(){
		app=navigator.appName.substring(0,1);
		if (app=='N') return true;
		else {return false;}
	}

	function isSingleByteString(str)
	{
		var rc = true;
		var j = 0, i = 0;
		for (i=0; i<str.length; i++) {
			j = str.charCodeAt(i);
			if (j>=128) {
				rc = false;
				break;
			}
		}
		return rc;
	} 
	
	function popupDialog(url, w, h, isModal) {
		var param = 'dialogWidth:'+w+'px;dialogHeight:'+h+'px;'+
					'help:0; resizable:1; status:1'		
		
		if (isModal)
			window.showModalDialog(url, 'popupWindow', param);
		else
			window.showModelessDialog(url, 'popupWindow', param);
	}
	
	// abc.html#anchorName 
    function goToAnchor(anchorName){
    	self.location.hash = anchorName;
    }
    
    function insertParam(key, value)
    {
        key = escape(key); value = escape(value);
        var kvp = document.location.search.substr(1).split('&');
        var i=kvp.length; var x; 
        while(i--) 
        {
            x = kvp[i].split('=');
            if (x[0]==key)
            {
                    x[1] = value;
                    kvp[i] = x.join('=');
                    break;
            }
        }

        if(i<0) {
        	kvp[kvp.length] = [key,value].join('=');
        }

        //this will reload the page, it's likely better to store this until finished
        document.location.search = kvp.join('&'); 
    }
    
    // check for hour : 00-24
    function isValidHour(value){
    	var re = /([0-1][0-9])|(2[0-3])/;
    	var matches = re.exec(value);
    	
    	if( matches!=null && matches.length>0) 
    		return true;
    	else
    		return false;
    }
    
    // check for minutes : 00-59
    function isValidMinute(value){
    	var re = /[0-5][0-9]/;
    	var matches = re.exec(value);
    	
    	if( matches!=null && matches.length>0)
    		return true;
    	else 
    		return false;
    }
    
    
    function getElementsByClassName(classname, node) {
    	if (!node) { 
    		node = document.getElementsByTagName('body')[0]; 
    	}
    	
    	// The \b metacharacter is used to find a match at the beginning or end of a word.
    	var a = [], re = new RegExp('\\b' + classname + '\\b'); 
    	els = node.getElementsByTagName('*');
    	for (var i = 0, j = els.length; i < j; i++) { 
    		if ( re.test(els[i].className) ) {
    			a.push(els[i]); 
    		} 
    	} 
    	return a; 
    }
    
    Number.prototype.formatMoney = function(c, d, t){
    var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)
    + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
    };
