// JavaScript Document
function Form_Validator(theForm)
{
  var tempstr;
  var validnum = "0123456789."
  var validstr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_"
  var ok = "yes";
  var temp;

  if (theForm.NowPrice.value == "")
  {
    alert("请输入新车价格。");
    theForm.NowPrice.focus();
    return (false);
  }
  tempstr=theForm.NowPrice;
  
  while(''+tempstr.value.charAt(tempstr.value.length-1)==' ')
    tempstr.value=tempstr.value.substring(0,tempstr.value.length-1);
    
  if (tempstr.value.length < 1)
  {
    alert("\"新车价格\"字段至少要输入1个数字，不能全部输入空格。");
    theForm.NowPrice.focus();
    return (false);
  }
  
  for (var i=0; i<tempstr.value.length; i++) 
  {
    temp = "" + tempstr.value.substring(i, i+1);
    if (validnum.indexOf(temp) == "-1") 
      ok = "no";
  }
  if (ok == "no") 
  {
    alert("\"新车价格\"字段只能输入数字，不能有其他字符。");
    theForm.NowPrice.focus();
    return (false);
  }


    if (theForm.NowMiles.value == "")
  {
    alert("请输入\"已行驶\"字段。");
    theForm.NowMiles.focus();
    return (false);
  }
  tempstr=theForm.NowMiles;
  
  while(''+tempstr.value.charAt(tempstr.value.length-1)==' ')
    tempstr.value=tempstr.value.substring(0,tempstr.value.length-1);
    
  if (tempstr.value.length < 1)
  {
    alert("\"已行驶\"字段至少要输入1个数字，不能全部输入空格。");
    theForm.NowMiles.focus();
    return (false);
  }
  
  for (var i=0; i<tempstr.value.length; i++) 
  {
    temp = "" + tempstr.value.substring(i, i+1);
    if (validnum.indexOf(temp) == "-1") 
      ok = "no";
  }
  if (ok == "no") 
  {
    alert("\"已行驶\"字段只能输入数字，不能有其他字符。");
    theForm.NowMiles.focus();
    return (false);
  }  
  
  if (theForm.UsedYears.value == "")
  {
    alert("请输入\"已使用\"字段。");
    theForm.UsedYears.focus();
    return (false);
  }
  tempstr=theForm.UsedYears;
  
  while(''+tempstr.value.charAt(tempstr.value.length-1)==' ')
    tempstr.value=tempstr.value.substring(0,tempstr.value.length-1);
    
  if (tempstr.value.length < 1)
  {
    alert("\"已使用\"字段至少要输入1个数字，不能全部输入空格。");
    theForm.UsedYears.focus();
    return (false);
  }
  
  for (var i=0; i<tempstr.value.length; i++) 
  {
    temp = "" + tempstr.value.substring(i, i+1);
    if (validnum.indexOf(temp) == "-1") 
      ok = "no";
  }
  if (ok == "no") 
  {
    alert("\"已使用\"字段只能输入数字，不能有其他字符。");
    theForm.UsedYears.focus();
    return (false);
  }
    var myhref = "/pinggu/calc_result.asp?UsedYears=" + 
	theForm.UsedYears.value +  "&classimport=" + 
	theForm.classimport.value + "&NowMiles=" + theForm.NowMiles.value + "&NowPrice=" + 
	theForm.NowPrice.value + "&classhome=" + theForm.classhome.value;
	openwindow(myhref);
	return (false);

}
function openwindow(myhref)
{
window.open(myhref,'myh','width=240,height=100');
}