var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) {
	eq = nv[i].indexOf('=');
	url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
	//alert("url[" + nv[i].substring(0,eq).toLowerCase() + "] = " + unescape(nv[i].substring(eq + 1)))
}

function roundOff(value) {
	value = "" + value 
	precision = 2;
	var whole = "" + Math.round(value * Math.pow(10, precision));
	var decPoint = whole.length - precision;
	if(decPoint != 0) {      
		result = whole.substring(0, decPoint);
        result += ".";
        result += whole.substring(decPoint, whole.length);
	} else { 
		result = whole; 
	}
	return result;
}

function stringFilter(str) {
	filteredValues = "1234567890.";     // Characters to allow
	var i;
	var returnString = "";
	for (i = 0; i < str.length; i++) {  // Search through string and append filtered values to returnString.
		var c = str.charAt(i);
		if (filteredValues.indexOf(c) != -1) returnString += c;
	}
	return(returnString);
}

function currency(number) {
   anynum=eval(number)
   workNum=Math.abs((Math.round(number*100)/100));
   workStr=""+workNum
   if (workStr.indexOf(".")==-1)
   		{ workStr+=".00"}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))
   while (pStr.length<3)
   		{pStr+="0"}

   if (dNum>=1000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
   }

   if (dNum>=1000000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
   }
   retval = dStr + pStr 
   if (number<0) 
   		{retval="("+retval+")"}
   return "$"+retval
}

function checkEnter(event){
  var code = 0;//declares variable "code"
  var NS4 = ((document.layers)?true:false);//sets NS4 to true if browser is netscape, else false
  if(NS4)
    code = event.which;//grabs the code for the keypressed 
  else
    code = event.keyCode;//grabs the code for the keypressed 
  if(code == 13) {//keycode 13 is "enter" key
  	calculate();//calculate if "enter" key is pressed
  	}
}// JavaScript Document