function is_numeric(str) {
	return (str === '') ? false : !isNaN(str * 1);
}

function formatCurrency(str, show_cents) {
	str		= str.toString().replace(/\$|\,/g,'');
	str		= !is_numeric(str) ? 0.00 : parseFloat(str);
	sign	= (str < 0);
	str		= (parseInt((Math.abs(str) + .005) * 100) / 100).toString();
	if ((typeof(show_cents) == 'undefined') || (show_cents == true)) {
		// show "cents"
		str = (str.indexOf('.') < 0) ? (str + ".00") : ((str.indexOf('.') == (str.length - 2)) ? (str + "0") : str);
	} else {
		// do not show "cents"
		if (str.indexOf('.') >= 0) {
			// there is already a decimal present, remove it by splitting the string
			if (str.indexOf('.') == 0) {
				str = '0';
			} else {
				var spl = str.split('.');
				str = spl[0];
			}
		}
	}
	return ((sign) ? "-" : "") + str;
}

function popUp(url,width,height,scrollbars,resizable,querystring,windowname) {
	if((typeof(width) == "undefined") || (width == null)) var width = 500;
	if((typeof(height) == "undefined") || (height == null)) var height = 400;	
	if((typeof(scrollbars) == "undefined") || (scrollbars == null)) var scrollbars = 0;
	if((typeof(resizable) == "undefined") || (resizable == null)) var resizable = 0;
	if((typeof(querystring) == "undefined") || (querystring == null)) var querystring = '';
	if((typeof(windowname) == "undefined") || (windowname == null)) var windowname = 'popup';
	var full_url = url + querystring;
	var w;
	w = window.open(full_url, windowname, "width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scrollbars+",resizable="+resizable);
	w.focus();
}

