/*
popWin Example:
<a href="index.php?action=legal" onclick="popWin(this.href,'_legal','300','350','toolbar=1,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');return false;" nowrap>CLICK HERE</a>
*/

function askSubmit(form_name,url){
	var f=$(form_name);
	if(validateForm(f)){
		Modalbox.show(url, {title: 'We Appreciate Your Input!', width: 500, params:Form.serialize(form_name) });
	}
	return false;
}

var win = null;
function popWin(mypage,myname,w,h,settings) {
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings = settings + ',width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition;
    win = window.open(mypage,myname,settings);
    if(win!=null) { win.focus(); }
    return win;
}

//function MM_reloadPage(init) {  //reloads the window if Nav4 resized
//	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
//	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
//	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
//}
//MM_reloadPage(true);

function showProps(obj, obj_name) {
	var s = "";
	for(var i in obj)
	s += obj_name + "." + i + "=" + obj[i] + "<br/>";
	return s;
}

function numberFormat(n,decimals) {
    if(n == "NaN" || !n>0) { n=0; }
    if (typeof n != "string") n = String(n);
    if (!/^\$?(\d{1,3},)*\d{3}.\d\d$/.test(n)) {
        n = parseFloat(n.replace(/,|^\$/g, "")).toFixed(decimals);
        var rx = /(\d)(\d{3})([.,])/;
        while (rx.test(n)) {
            n = n.replace(rx, "$1,$2$3");
        }
    }
    return n;
}

function dollarFormat(n,decimals) {
    n = '$' + numberFormat(n,decimals);
    return n;
}