function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
	return false;
}
function MoneyFormat(nStr) {
	nStr = parseFloat(nStr);
	nStr = nStr.toFixed(2);
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function EndsWith(Needle, Haystack) {
	var startPos = Haystack.length - Needle.length;
	if (startPos < 0) {
		return false;
	}
	return (Haystack.lastIndexOf(Needle, startPos) == startPos);
};

function findParentDiv(elem){
	var parent = elem.parentNode;
	if(parent && parent.tagName.toUpperCase()!="DIV"){
		parent = findParentDiv(parent);
	}
	return parent;
}

function GetQueryVariables(Query) {
	Vars = Query.split("&");
	Values = {};
	for (i=0;i<Vars.length;i++) {
		Pair = Vars[i].split("=");
		Values[Pair[0]] = Pair[1];
	}
	return Values;
}