﻿// JScript File
<!--

var word = /(\bBITCH\b|\bFUCK|\bCUNT\b|\bASSHOLE\b|\bPOES\b|\bSHIT\b|\bDICK HEAD\b|\bDICKHEAD\b|\bPUSSY\b|\bWHORE\b|\bFAGGAT\b)/;

function CheckNumVehicles(max)
{
    var msg = "";
    var num = 0;
    
    num = document.getElementById("txtVehCount").value;
    if (num >= max)
      msg += "- Maximum number of " + max + " vehicles are allowed.\n";
      
    return msg;
}

function CheckTerms(objTerms)
{
  var msg = "";

  if (!objTerms.checked)
    msg += "- Please accept the terms & conditions.\n";
      
  return msg;
}

function QuoteSubmitCustom(objName,objSName,objAreaCode,objContactNo,objCellNo,objEmail,objDD,objMM,objYY,objSuburb,objCarDes,objHome,homeMin,homeMax,objBuild,btnID,btnUID,MessageSubHeader,checkName,checkSurname,checkTel,checkCell,checkEmail,checkDob,checkSuburb,checkHome,CheckBuild) 
{
  
  var btn = document.getElementById(btnID);
  var msg = "";
 
  msg += CheckNameString(objName, "first name", checkName);
  msg += CheckNameString(objSName, "surname", checkSurname);
  msg += CheckAreaContactNo(objAreaCode, objContactNo, checkTel);
  msg += CheckCellNo(objCellNo, checkCell);
  msg += IsOneContactNumber(objAreaCode, objContactNo, objCellNo);
  msg += CheckEmail(objEmail, word, checkEmail);
  msg += CheckDOB(objDD, objMM, objYY, checkDob);
  msg += CheckSuburb(objSuburb, checkSuburb);
  msg += CheckHomeContents(objHome, homeMin, homeMax, checkHome);
  msg += CheckBuilding(objBuild, CheckBuild);
 
  var numVeh = 0;
  var numCar = 0;
  numVeh = document.getElementById("txtVehCount").value;
  numCar = document.getElementById("txtCarCount").value;

  if ((numVeh == 0) && ((objHome.value == "") || (objHome.value == "0")) && ((objBuild.value == "") || (objBuild.value == "0")))
  {
    if (objCarDes.selectedIndex > 0)
      msg += '- Please press the "Add this vehicle" button to add your vehicle to the quote.\n';
    else
      msg += "- Car, home contents or building cover need to be selected.\n";
  }
  	
  if (msg == "")
  {
    if ((objCarDes.selectedIndex <= 0) ||
        (objCarDes.selectedIndex > 0 && confirm("Would you like to continue without adding the vehicle you have selected?")))
    {
      return true;
    }
    else
    {
      return false;
    }
  } 
  else 
  {	
	  alert(MessageSubHeader +"\n\n" + msg);
	  return false;
  }
}
function QuoteSubmit(objTerms,objName,objSName,objAreaCode,objContactNo,objCellNo,objEmail,objDD,objMM,objYY,objSuburb,objCarDes,objHome,homeMin,homeMax,objBuild,btnID,btnUID) 
{
    var btn = document.getElementById(btnID);
	var msg = "";

	msg += CheckTerms(objTerms);
	msg += CheckNameString(objName, "first name", true);
	msg += CheckNameString(objSName, "surname", true);
	msg += CheckAreaContactNo(objAreaCode, objContactNo, false);
	msg += CheckCellNo(objCellNo, false);
	msg += IsOneContactNumber(objAreaCode, objContactNo, objCellNo);
	msg += CheckEmail(objEmail, word, true);
	msg += CheckDOB(objDD, objMM, objYY, true);
	msg += CheckSuburb(objSuburb, true);
	msg += CheckHomeContents(objHome, homeMin, homeMax, false);
	msg += CheckBuilding(objBuild, false);

	var numVeh = 0;
	var numCar = 0;
	numVeh = document.getElementById("txtVehCount").value;
	numCar = document.getElementById("txtCarCount").value;

    if ((numVeh == 0) && ((objHome.value == "") || (objHome.value == "0")) && ((objBuild.value == "") || (objBuild.value == "0")))
    {
      if (objCarDes.selectedIndex > 0)
        msg += '- Please press the "Add this vehicle" button to add your vehicle to the quote.\n';
      else
        msg += "- Car, home contents or building cover need to be selected.\n";
    }
    
	if (msg == "")
	{
	  if ((objCarDes.selectedIndex <= 0) ||
	      (objCarDes.selectedIndex > 0 && confirm("Would you like to continue without adding the vehicle you have selected?")))
	  {
		return true;
	  }
	  else
	  {
	    return false;
	  }
	} else {	
	  alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
	  return false;
	}
}

function BikeQuoteSubmit(objTerms,objName,objSName,objAreaCode,objContactNo,objCellNo,objEmail,objDD,objMM,objYY,objSuburb,objBikeDes,btnID,btnUID) 
{
    var btn = document.getElementById(btnID);
	var msg = "";
	  
	msg += CheckTerms(objTerms);
    msg += CheckNameString(objName, "first name", true);
    msg += CheckNameString(objSName, "surname", true);
	msg += CheckAreaContactNo(objAreaCode, objContactNo, false);
	msg += CheckCellNo(objCellNo, false);
	msg += IsOneContactNumber(objAreaCode, objContactNo, objCellNo);
	msg += CheckEmail(objEmail, word, true);
	msg += CheckDOB(objDD, objMM, objYY, true);
	msg += CheckSuburb(objSuburb, true);
	
	var numVeh = 0;
	numVeh = document.getElementById("txtVehCount").value;

    if (numVeh == 0)
    {
      if (objBikeDes.selectedIndex > 0)
        msg += '- Please press the "Add this vehicle" button to add your vehicle to the quote.\n';
      else
        msg += "- At least one motorbike needs to be added.\n";
    }
    
	if (msg == "") {
	  if ((objBikeDes.selectedIndex <= 0) ||
	      (objBikeDes.selectedIndex > 0 && confirm("Would you like to continue without adding the vehicle you have selected?")))
	  {
        return true;
	  }
	  else
	  {
	    return false;
	  }
	} else {	
	  alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
	  return false;
	}
}

function BannerSubmit(objName,objTel,btnID,btnUID)
{
    var btn = document.getElementById(btnID);
    var msg = "";

    msg += CheckNameString(objName, "name", true);
  	msg += CheckFullContactNo(objTel, true);

	  if (msg == "") {
      btn.disabled = true;      
	    __doPostBack(btnUID,'');
	  } else {	
		  alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
		  return false;
	  }
}

function CheckCar(objVehYY, objVehDes, objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, trLic, objLic, objLicMM, objLicYY, objMainYY, maxVeh) 
{
    var msg = "";

    msg += CheckNumVehicles(maxVeh);
    msg += CheckCarDropDown(objVehYY, objVehDes);
    msg += CheckCarDriver(objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, trLic, objLic, objLicMM, objLicYY, objMainYY);
    
		if (msg == "") {
			return true;
		} else {
			alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
			return false;
		}
}

function CheckCarDriver(objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, trLic, objLic, objLicMM, objLicYY, objMainYY)
{
  var drSeq = objDr.selectedIndex;
  var msg = "";
  
  if (drSeq == objDr.length - 1)
  {
    msg += CheckNameString(objDrName, "driver's first name", true);
    msg += CheckNameString(objDrSName, "driver's surname", true);
    msg += CheckDOB(objDrDD, objDrMM, objDrYY, true);
    msg += CheckLic(objLic, objLicMM, objLicYY, objDrYY);
  }
  else if (drSeq == 0 && trLic.style.display != 'none')
  {
    msg += CheckLic(objLic, objLicMM, objLicYY, objMainYY);
  }
  
  return msg;
}

function CheckMotorbike(objVehYY, objVehMake, objVehDes, objVehModel, objVal, objClass, objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, objDrLic, trBikeLic, objMin, objMax, maxVeh, minReg) 
{
    var msg = "";

    msg += CheckNumVehicles(maxVeh);
    msg += CheckMotorbikeDropDown(objVehYY, objVehMake, objVehDes, objVehModel, minReg);
    msg += CheckMotorbikeDetails(objVal, objClass, objMin, objMax);
    msg += CheckBikeDriver(objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, objDrLic, trBikeLic);
    
		if (msg == "") {
			return true;
		} else {
			alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
			return false;
		}
}

function CheckBikeDriver(objDr, objDrName, objDrSName, objDrDD, objDrMM, objDrYY, objDrLic, trBikeLic)
{
  var drSeq = objDr.selectedIndex;
  var drLic = objDrLic.selectedIndex;

  var msg = "";
  
  if (drSeq == objDr.length - 1)
  {
    msg += CheckNameString(objDrName, "driver's first name", true);
    msg += CheckNameString(objDrSName, "driver's surname", true);
    msg += CheckDOB(objDrDD, objDrMM, objDrYY, true);
  }
  
  if (trBikeLic.style.display != 'none' && drLic <= 0)
    msg += "- Please select driver's licence type.";
  
  return msg;
}

function CheckCaravan(objVehYY, objVehDes, objVal, objContVal, objMin, objMax, objContMin, objContMax, maxVeh, minReg) 
{
    var msg = "";

    msg += CheckNumVehicles(maxVeh);
    msg += CheckCaravanDropDown(objVehYY, objVehDes, minReg);
    msg += CheckCaravanDetails(objVal, objContVal, objMin, objMax, objContMin, objContMax);
    
		if (msg == "") {
			return true;
		} else {
			alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
			return false;
		}
}

function CheckTrailer(objVehYY, objVehDes, objVal, objMin, objMax, maxVeh, minReg) 
{
    var msg = "";

    msg += CheckNumVehicles(maxVeh);
    msg += CheckTrailerDropDown(objVehYY, objVehDes, minReg);
    msg += CheckTrailerDetails(objVal, objMin, objMax);
    
		if (msg == "") {
			return true;
		} else {
			alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
			return false;
		}
}

function SuburbSubmit(objHome) 
{
    var msg = "";
    var home = objHome.value;

    //Trim all data
    home = home.replace(/^\s+|\s+$/,''); 
					
    if (home==""){
      msg += "- Please enter suburb .\n";
    }
    if (home.length < 3){
      msg += "- Please enter three or more characters for the suburb.\n";
    }						
    if (msg == "") {
	    return true;
    } else {
	    alert("It seems Hippo would like you to look at the following little potholes.\n\n" + msg);
	    return false;
    }
}

function CheckMotorbikeDropDown(objVehYY, objVehMake, objVehDes, objVehModel, minReg)
{
  var vehyy = objVehYY.value;
  var vehmake = objVehMake.selectedIndex;
  var nummod = objVehModel.options.length - 2;
  var msg = "";
  
  if (vehyy.match(/^\d{4}$/))
  {
    if (vehyy < minReg)
        msg += "- We cannot insure motorcycles registered before " + minReg + ".\n"; 
  }
  else
  {
    msg += "- Please enter a valid year registered.\n"; 
  }
      
  if (vehmake == 0)
  {
    if (nummod > 0)
      msg += "- Please select motorbike make, model and capacity.\n";
    else
      msg += "- Please select motorbike make and capacity.\n";
  }
  else
  {
    var vehdes = objVehDes.selectedIndex;
    var vehmod = objVehModel.selectedIndex;

    if (vehdes < 1 || vehmod < 1)
    {
      if (nummod > 0)
        msg += "- Please select motorbike make, model and capacity.\n";
      else
        msg += "- Please select motorbike make and capacity.\n";    
    }
  }
  
  return msg;
}

//-->