function isEmpty(s){return ((s == null) || (s.length == 0))}

function isDigit(c){return ((c >= "0") && (c <= "9"))}

function isInteger(s) {
    var i;
	var defaultEmptyOK = 0;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }
    return true;
}

var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
function swapText(id, str) {
  if (NS4) {
    if(document[id]){
	    with (document[id].document) {
  	    open();
  	    write(str);
  	    close();
  	  }
	}
  } else {
    if(document.all[id]){
    	document.all[id].innerHTML = str;
    }
  }
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}
