<!--

var validationField = "";

function goTo(loc, win) {
  if(!win) win = window;
  win.location = loc;
}

function getFrame(name, treeTop) {
  if(!treeTop) treeTop = top;
  if(treeTop.name == name) return treeTop;

  for(var i = 0; i < treeTop.frames.length; i++)
    if(result = getFrame(name, treeTop.frames[i]))
      return result;

  return null;
}

function addslashes(s) {
  s = "" + s;
  s = s.replace(/\\/g, "\\\\");
  s = s.replace(/'/g, "\\'");
  s = s.replace(/"/g, "\\\"");
  return s;
}

function phone_format(field) {
  if(new String(field.value).replace(/\D/g, '').length == 10)
    field.value = new String(field.value).replace(/\D/g, '').replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3')
}

function number_format(n, d, s, round) {
  // get the number to be formatted. defaults to zero if invalid number
  if(String(n = Number(n)) == "NaN") n = 0;

  // get the number of decimal points to be allowed. defaults to zero if invalid number
  // note - if d is negative, rounding is done to the left of the decimal point
  if(String(d = Number(d)) == "NaN") d = 0;

  // get the thousands separator. defaults to a comma if not specified
  if(typeof(s) == "undefined") s = ",";

  // get the rounding request. defaults to true if not specified
  if(typeof(round) == "undefined") round = true;

  if(round) { // if rounding has been requested
    // eliminate any digits beyond desired decimal point length by rounding
    n = Math.round(n * Math.pow(10, d)) / Math.pow(10, d);
  }
  else {
    // eliminate any digits beyond desired decimal point length by truncating
    n = Math.floor(n * Math.pow(10, d)) / Math.pow(10, d);
  }

  // split number into two parts - digits before the decimal and digits after the decimal
  var parts = new String(n).split(".", 2);

  // make both parts into strings to make digits accessible by index
  parts[0] = new String(parts[0]);
  parts[1] = typeof(parts[1]) == "undefined" ? "" : new String(parts[1]);

  // if there is a leading sign character (+/-), temporarily remove
  var sign = "";
  if(parts[0].charAt(0) == "+" || parts[0].charAt(0) == "-") {
    sign = parts[0].charAt(0);
    parts[0] = parts[0].substr(1);
  }

  // if desired decimal places is greater than what is actually there, pad right side with zeros
  while(d > parts[1].length) parts[1] += "0";

  // apply thousands separators
  var new_part_one = "";
  for(var i = parts[0].length - 1, digits = 0; i >= 0; i--, digits++)
    new_part_one = parts[0].charAt(i) + (digits != 0 && digits % 3 == 0 ? s : "") + new_part_one;
  parts[0] = new_part_one;

  // join the two formatted parts back together and return with temporarily removed sign
  return sign + (parts[1] ? parts.join(".") : parts[0]);
}

function var_dump(variable, indent) {
  indent = indent || "";
  var indentchar = "\t";

  switch(typeof(variable)) {

    case "string"   : return "\"" + addslashes(variable) + "\"";

    case "number"   : return "" + variable;

    case "function" : return "\n" + variable;

    case "undefined": return "\"undefined\"";

    case "object"   : var output = "{";
                      var separator = "\n";

                      for(var i in variable) {
                        output += separator + indent + indentchar + var_dump(i, indent + indentchar) + " : " + var_dump(variable[i], indent + indentchar);
                        separator = ",\n";
                      }

                      return output + (separator == ",\n" ? "\n" + indent : "") + "}";

    default         : return "whaaaaaaa??????";
  }

}
//-->
