//this little dandy of script is to fix the behavior of 'indexOf' in Internet Exploder.
if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
	var len = this.length;

	var from = Number(arguments[1]) || 0;
	from = (from < 0)
		 ? Math.ceil(from)
		 : Math.floor(from);
	if (from < 0)
	  from += len;

	for (; from < len; from++)
	{
	  if (from in this &&
		  this[from] === elt)
		return from;
	}
	return -1;
  };
}

//***** COMIFY ******
//Had to add this because the simtem COMIFY doesn't work. We were getting back
//prices from the db without commas, and needed to add this in for pricing, etc.
function commify(num) {
	var Num = num;
	var newNum = "";
	var newNum2 = "";
	var count = 0;
	
	//check for decimal number
	if (Num.indexOf('.') != -1){  //number ends with a decimal point
		if (Num.indexOf('.') == Num.length-1){
			Num += "00";
		}
		if (Num.indexOf('.') == Num.length-2){ //number ends with a single digit
			Num += "0";
		}
		
		var a = Num.split("."); 

		Num = a[0];   //the part we will commify
		var end = a[1] //the decimal place we will ignore and add back later
	}
	else {var end = "00";}  
 
	//this loop actually adds the commas   
	for (var k = Num.length-1; k >= 0; k--){
	  var oneChar = Num.charAt(k);
	  if (count == 3){
		newNum += ",";
		newNum += oneChar;
		count = 1;
		continue;
	  }
	  else {
		newNum += oneChar;
		count ++;
	  }
   }  //but now the string is reversed!
   
  //re-reverse the string
  for (var k = newNum.length-1; k >= 0; k--){
	  var oneChar = newNum.charAt(k);
	  newNum2 += oneChar;
  }
   
   // add dollar sign and decimal ending from above
   newNum2 = newNum2 + "." + end;
   return newNum2;
}