function FormatNumberBy3(num, decpoint, sep) {
  // check for missing parameters and use defaults if so
  if (arguments.length == 2) {
    sep = ",";
  }
  if (arguments.length == 1) {
    sep = ",";
    decpoint = ".";
  }
  // need a string for operations
  num = num.toString();
  // separate the whole number and the fraction if possible
  a = num.split('.');
  x = a[0]; // decimal
  y = a[1]; // fraction
  z = "";


  if (typeof(x) != "undefined") {
    // reverse the digits. regexp works from left to right.
    for (i=x.length-1;i>=0;i--)
      z += x.charAt(i);
    // add seperators. but undo the trailing one, if there
    z = z.replace(/(\d{3})/g, "$1" + sep);
    if (z.slice(-sep.length) == sep)
      z = z.slice(0, -sep.length);
    x = "";
    // reverse again to get back the number
    for (i=z.length-1;i>=0;i--)
      x += z.charAt(i);
    // add the fraction back in, if it was there
    if (typeof(y) != "undefined" && y.length > 0)
      x += decpoint + y;
  }
  return x;
}

function getCheckedValue(radioObj) {
  if(!radioObj)
    return "";
  var radioLength = radioObj.length;
  if(radioLength == undefined)
    if(radioObj.checked)
      return radioObj.value;
    else
      return "";
  for(var i = 0; i < radioLength; i++) {
    if(radioObj[i].checked) {
      return radioObj[i].value;
    }
  }
  return "";
}

function submitForm () {
  document.forms[0].submit();
}
function imageClick(ioEvent) {
  if (!ioEvent) var ioEvent = window.event;
  var loObject = document.getElementById("image");
  var lnImageLeft = 0, lnImageTop = 0;
  do {
    lnImageLeft += loObject.offsetLeft;
    lnImageTop += loObject.offsetTop;
  } while(loObject = loObject.offsetParent)
  var lnPosX = ioEvent.clientX + document.body.scrollLeft + document.documentElement.scrollLeft - lnImageLeft;
  var lnPosY = ioEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop- lnImageTop;
  // alert (lnPosX + ', ' + lnPosY);
  document.forms[0].x.value = lnPosX;
  document.forms[0].y.value = lnPosY;
  document.forms[0].action.value = 'savetip';
  submitForm();
  return false;
}
function makeBet() {
  document.forms[0].action.value = 'makebet';
  submitForm();
  return false;
}
function showRules() {
  document.forms[0].action.value = 'rules';
  submitForm();
  return false;
}


