// Simulate the "power of" (^) operator
/////////////////////////////////////////
function power(op1, op2) 
{
var result = 1

for (var i = 1; i <= op2; i++) 
{
	result *= op1
}
return result
}

// Simulate the div (integral division)
// operator
/////////////////////////////////////////
function div(op1, op2) 
{
return Math.round(op1 / op2 - op1 % op2 / op2)
}

// Returns a digit (maximum hexadecimal)
// based on its decimal value
/////////////////////////////////////////
function getDigit(val) 
{
if (val == 10) return "A"
if (val == 11) return "B"
if (val == 12) return "C"
if (val == 13) return "D"
if (val == 14) return "E"
if (val == 15) return "F"
return val
// the return statement terminates the function,
// so there is no need for else statements
}
/////////////////////////////////////////
// Returns the decimal value of a digit
// (maximum hexadecimal)
/////////////////////////////////////////
function getValue(dig) 
{
  if (dig == "A") return 10;
  if (dig == "B") return 11;
  if (dig == "C") return 12;
  if (dig == "D") return 13;
  if (dig == "E") return 14;
  if (dig == "F") return 15;
  return dig;
  // the return statement terminates the function,
  // so there is no need for else statements
}

function toDec(num, base) 
{
  if (base == 8)
    return parseInt("0" + num);

  if (base == 16)
    return parseInt("0x" + num);

  num = "" + num; // convert to string by casting
  var numLength = num.length;

  // the length property returns the length of a string
  // initialization
  var newNum = 0;

  // (must be 0 so the sum is not affected)
  var curDigit = "";

  var contributedValueValue = 0;

  for (var i = numLength - 1; i >= 0; --i) 
  {
    curDigit = num.charAt(i);
    contributedValue = getValue(curDigit);
	contributedValue *= power(base, numLength - (i + 1));
	newNum += parseInt(contributedValue);

  }

	return newNum;
	//alert(newNum);

}
/////////////////////////////////////////////////////////////
// creates the binary number given the values in each field
/////////////////////////////////////////////////////////////
function createBinary(){

  var binary = "";

  for (var i = 0; i < document.myform.time.length; i++) 
  {

    if (document.myform.time[i].checked) 
	{
	  binary += "1";
	}
	else
	{
      binary += "0";
    }

  }

  for (var i = 0; i < document.myform.price.length; i++) 
  {
    if (document.myform.price[i].checked) 
	{
	    binary += "1";
	}
	else
	{
      binary += "0";
    }
  }

  for (var i = 0; i < document.myform.type.length; i++) 
  {
    if (document.myform.type[i].checked) 
	{
      binary += "1";
    }
	else
	{
      binary += "0";
    }
  }
  //alert(binary);

  usrNum = toDec(binary, '2');

  //alert(usrNum);
}