// takes bid and converts it to currency
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}

function Form1_Validator(theForm)
{
// make sure URL field is filled
if (theForm.url.value.length < 8)
  {
  alert("Please enter a URL beginning with http://");
  theForm.url.focus();
  return (false);
  }
// check for a period in the url
var exists = 0
var checkStr = theForm.url.value
for(i=0;i<checkStr.length;i++)
  {
  if (checkStr.charAt(i) == ".")
    {
    exists = 1;
    }
  }
if (exists != 1)
  {
  alert("Please enter a correct URL.");
  theForm.url.focus();
  return (false);
  }
// if a site title is entered....
//if ((theForm.title.value.length > 3) || (theForm.setuptermsforme.checked == false))
//  {
  // make sure a title is entered
  if (theForm.title.value.length < 4)
     {
     alert("Please enter your site title.");
     theForm.title.focus();
     return (false);
     }
  // make sure description is entered
  if (theForm.description.value.length < 4)
     {
     alert("Please enter your site description.");
     theForm.description.focus();
     return (false);
     }
  // only allow 250 characters in description
  if (theForm.description.value.length > 250)
     {
     alert("Please shorten your site description to less than 250 characters.");
     theForm.description.focus();
     return (false);
     }
  // make sure bid is entered
  if (theForm.bid.value.length < 3)
    {
    alert("Please enter a correct bid amount.");
    theForm.bid.focus();
    return (false);
    }
  // only allow numbers to be entered in bid
  if (isNaN(theForm.bid.value))
     {
     alert("Please enter a correct bid amount.");
     theForm.bid.focus();
     return (false);
     }
  // make sure bid is in increments of .05
  var checkStr = theForm.bid.value
  var lentest = checkStr.length - 1;
  if ((checkStr.charAt(lentest) != "0") && (checkStr.charAt(lentest) != "5"))
     {
     alert("Bid increments must be in increments of .05.");
     theForm.bid.focus();
     return (false);
     }
  if (checkStr < "0.25")
     {
     alert("Please enter a bid of $0.25 or greater.");
     theForm.bid.focus();
     return (false);
     }
//  }
if (theForm.setuptermsforme.checked == false)
  {
  if (theForm.itemterms.value == "")
    {
    alert("Please enter at least one search term.");
    theForm.itemterms.focus();
    return (false);
    }
  // allow only 15000 search terms
  if (theForm.itemterms.value.length > 15000)
    {
    alert("You have entered more than 1000 search terms. Please shorten your list.");
    theForm.itemterms.focus();
    return (false);
    }
}
if ((theForm.setuptermsforme.checked == false) || (theForm.setuptermsforme.checked == true))
  {
  if (theForm.itemterms.value.length > 15000)
    {
    alert("You have entered more than 1000 search terms. Please shorten your list.");
    theForm.itemterms.focus();
    return (false);
    }
}
}