function newWindow(carWindow) {
carWindow = window.open
(carWindow,'carWindow','toolbar=yes,resizable=yes,scrollbars=yes,location=no,width=630,height=400')
carWindow.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function FrontPage_Form1_Validator(theForm)
{

  if (theForm.Surname.value == "")
  {
    alert("Please enter a value for the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }

 if (theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"Firstname\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.Surname.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }

  if (theForm.Surname.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }
if (theForm.postcode.value.length < 1)
  {
    alert("Please enter your postcode in the  \"Postcode\" field.");
    theForm.postcode.focus();
    return (false);
  }
if (theForm.Addressline1.value.length < 1)
  {
    alert("Please enter your Address in the \"Address\" field.");
    theForm.Addressline1.focus();
    return (false);
  }

if (theForm.telephone.value.length < 1)
  {
    alert("Please enter your Telephone number in the \"Telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }

if (theForm.SumAssured.value.length < 1)
  {
    alert("Please enter a value in the \"Sum Assured\" field.");
    theForm.SumAssured.focus();
    return (false);
  }

if (theForm.DOBself.value.length < 1)
  {
    alert("Please enter your Date of Birth in the  \"Date of Birth\" field.");
    theForm.DOBself.focus();
    return (false);
  }

 var radioSelected = false;
  for (i = 0;  i < theForm.SelfSmoke.length;  i++)
  {
    if (theForm.SelfSmoke[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please input whether you smoke or not.");
    return (false);
  }

var radioSelected = false;
  for (i = 0;  i < theForm.PolicyType.length;  i++)
  {
    if (theForm.PolicyType[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select a Policy type.");
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < theForm.WaiverPremium.length;  i++)
  {
    if (theForm.WaiverPremium[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select one of the \"Is Waiver of Premium Required\" options.");
    return (false);
  }

  if (theForm.PolicyTerm.value == "")
  {
    alert("Please enter a value for the \"Policy Term\" field.");
    theForm.PolicyTerm.focus();
    return (false);
  }

  if (theForm.PolicyTerm.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Policy Term\" field.");
    theForm.PolicyTerm.focus();
    return (false);
  }

  if (theForm.PolicyTerm.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"Policy Term\" field.");
    theForm.PolicyTerm.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.PolicyTerm.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Policy Term\" field.");
    theForm.PolicyTerm.focus();
    return (false);
  }
var radioSelected = false;
  for (i = 0;  i < theForm.Repayment.length;  i++)
  {
    if (theForm.Repayment[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please input whether this enquiry is in respect of a repayment mortgage.");
    return (false);
  }
  
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1" && prsVal <= "100"))
  {
    alert("Please enter a value greater than or equal to \"1\" and less than or equal to \"100\" in the \"Policy Term\" field.");
    theForm.PolicyTerm.focus();
    return (false);
  }

} 
