
function formatCurrency(amount, dp) {
	var start = 0;
	
	if (field.lastvalue != field.value && field.value.length > 0) {
	
		if (field.value.substr(0, 1) == "-") {
			start = 1;
		}
			
		if (dp > 0 && field.value.indexOf(".") == -1) {
			field.value += ".";
		}
		
		if (field.value.substr(start, 1) == ".") {
			field.value = field.value.substr(0, start) + "0" + field.value.substr(start, field.value.length - start);
		}
		
		while (field.value.length - field.value.indexOf(".") - 1 < dp) {
			field.value += "0";
		}
		
		field.lastvalue = field.value;
	}
}

function openWindow(page, pagename, width, height, windowfeatures) {
	if (windowfeatures != "") {
		//windowfeatures = "," + windowfeatures + ",status";
		windowfeatures = "," + windowfeatures;
	}
	
	var left = screen.availWidth/2 - width/2;	
	var top = screen.availHeight/2 - height/2;	
		
	pagename = pagename.toString().replace(/[\s-&.]/g, "");

	var w  = window.open(page, pagename,"LEFT=" + left + ",TOP=" + top + ",HEIGHT=" + height + ",WIDTH=" + width + windowfeatures);	

	try {
		if (windowfeatures.indexOf('maximized') != -1) {
			w.moveTo(0,0);
			if (document.all) {
				w.resizeTo(screen.availWidth,screen.availHeight);
			} else if (document.layers||document.getElementById) {
				if (w.outerHeight < screen.availHeight||w.outerWidth < screen.availWidth) {
					w.outerHeight = screen.availHeight;
					w.outerWidth = screen.availWidth;
				}					
			}		
		}
	} catch(e) {}

	var browser = browserSniff();
	
	if (browser != "NS" && browser != "OPR") {
		eval("try {w.focus();} catch(e) {}");
	}
	
	return w;
}
