function SubmitFirstForm()
{
	if (ChkFormBusiness())
	{
		document.frmBusiness.submit();
	}
	
}


function SubmitLastForm()
{	
	if(CheckBTIForm_Step3()) 
	{
		document.frmBusiness.submit();
	}
}

function SubmitForm(CoverID)
{
	document.frmBusiness.txtMemberID.value = CoverID;
	document.frmBusiness.submit();
}

function ChkFormBusiness()
{
	if (!document.frmBusiness.chkmanualWork.checked)
	{
		alert("Please tick the box to confirm that you have read and agree with the qualifying booking conditions regarding this policy.");
		return false;
	}
	return true;
}

function CheckmyPolicyForm()
{
	if (document.frmPolLogin.txtemail.value == "")
	{
		alert("Please enter your email.");
		document.frmPolLogin.txtemail.focus();
		return false;
	}
	
	if (document.frmPolLogin.txtPassword.value == "")
	{
		alert("Please enter your password.");
		document.frmPolLogin.txtPassword.focus();
		return false;
	}
	return true;
}


function IsNumeric(str)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < str.length && IsNumber == true; i++) 
      { 
      Char = str.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function UpdateBTICCAddress()
{
	document.frmBusiness.txtCCAddress.value = document.frmBusiness.txtAddress.value;	
}

function UpdateCCForm(CCType,CountryCode)
{
	myDivCardCVVOn	= document.getElementById("CardCVVOn");
	myDivCardCVVOff = document.getElementById("CardCVVOff");
	
	switch (CCType)
	{
		case "Visa":
			myDivCardCVVOn.style.display  = 'block';
			myDivCardCVVOff.style.display = 'none'; 
			break;
		case "MC":
			myDivCardCVVOn.style.display  = 'block';
			myDivCardCVVOff.style.display = 'none'; 
			break;
		case "Laser":
			myDivCardCVVOn.style.display  = 'none';
			myDivCardCVVOff.style.display = 'block'; 
			break;
		case "Switch":
			myDivCardCVVOn.style.display  = 'block';
			myDivCardCVVOff.style.display = 'none'; 
			break;
	}
	
	if (CountryCode == "UK") 
	{
		myDivCardIssueNoOn	= document.getElementById("CardIssueNoOn")
		myDivCardIssueNoOff	= document.getElementById("CardIssueNoOff")
		
		switch (CCType)
		{
			case "Visa":
				myDivCardIssueNoOn.style.display = 'none';
				myDivCardIssueNoOff.style.display = 'block';
				break;
			case "MC":
				myDivCardIssueNoOn.style.display = 'none';
				myDivCardIssueNoOff.style.display = 'block';
				break;
			case "Laser":
				myDivCardIssueNoOn.style.display = 'none';
				myDivCardIssueNoOff.style.display = 'block';
				break;
			case "Switch":
				myDivCardIssueNoOn.style.display = 'block';
				myDivCardIssueNoOff.style.display = 'none';
				break;
		}
	}
}

function DisplayEmailBoxes()
{
	myDivAddEmails = document.getElementById("AddEmails");
	BoxCnt = document.frmBusiness.optNumEmails.value;	
	if (BoxCnt == 0)
	{
		strHTML = "";
		myDivAddEmails.innerHTML = strHTML;
		myDivAddEmails.style.display = "none";
	}
	else
	{	
		strHTML = "<table cellpadding='2' cellspacing='0'><colgroup><col width='39%'></col><col width='55%'></col></colgroup>"			
		
		if (document.frmBusiness.txtCntAddEmails != null)
		{
			cnt = Number(document.frmBusiness.txtCntAddEmails.value) + Number(1);			
		}
		else
		{
			cnt = 1;
		}
		
		for (i = cnt; i <= BoxCnt; i++)
		{
			strHTML = strHTML + "<tr><td width='39%' algin='left'>Additional Email "+i+"</td>";
			strHTML = strHTML + "<td><input type='text' name='txtAddEmail"+i+"' size='40'></td></tr>";
		}
		
		strHTML = strHTML + "</table>";
		
	
		myDivAddEmails.innerHTML = strHTML;
		myDivAddEmails.style.display = "block";
	}
}

function CheckBTIForm_Step3()
{
	//Check Mandatory Fields
	if (document.frmBusiness.txtCompName.value == "")
	{
		alert("Please enter the companies name.");
		document.frmBusiness.txtCompName.focus();
		return false;
	}
	if (document.frmBusiness.txtAddress.value == "")
	{
		alert("Please enter the companies postal address.");
		document.frmBusiness.txtAddress.focus();
		return false;
	}
	if (document.frmBusiness.txtBusinessDesc.value == "")
	{
		alert("Please emter the companies business description.");
		document.frmBusiness.txtBusinessDesc.focus();
		return false;
	}
	if (document.frmBusiness.txtContactName.value == "")
	{
		alert("Please enter a contact name for the company.");
		document.frmBusiness.txtContactName.focus();
		return false;
	}
	
	if (document.frmBusiness.txtEmail.value == "")
	{
		alert("Please enter an email address for policy correspondence to be sent.");
		document.frmBusiness.txtEmail.focus();
		return false;
	}
	if (document.frmBusiness.txtNumDirectors.value == "")
	{
		alert("Please enter the number of directors on the policy.");
		document.frmBusiness.txtNumDirectors.focus();
		return false;
	}
	if (!IsNumeric(document.frmBusiness.txtNumDirectors.value))
	{
		alert("Please enter a number for the amount of Directors on the policy.");
		document.frmBusiness.txtNumDirectors.focus();
		return false;
	}
	if (document.frmBusiness.txtNumStaff.value == "")
	{
		alert("Please enter the number of staff excluding directors on the policy.");
		document.frmBusiness.txtNumStaff.focus();
		return false;
	}
	if (!IsNumeric(document.frmBusiness.txtNumStaff.value,"0123456789"))
	{
		alert("Please enter a number for the amount of Staff excluding directors on the policy.");
		document.frmBusiness.txtNumStaff.focus();
		return false;
	}
	
	if (document.frmBusiness.chkmanualWork != null)
	{
		if (!document.frmBusiness.chkmanualWork.checked)
		{
			alert("Please tick the box to confirm that you have read and agree with the qualifying booking conditions regarding this policy.");
			return false;
		}	
	}
	
	if (document.frmBusiness.txtCCName.value == "")
	{
      alert("Please enter the Credit/Debit Card Holders Name as it appears on their card.");
      document.frmBusiness.txtCCName.focus();
      return false;
	}
	if (document.frmBusiness.optCCType.value == "Select")
	{
      alert("Please select the card type");
      document.frmBusiness.optCCType.focus();
      return false;
	}
	if (document.frmBusiness.txtCCNumber.value == "")
	{
      alert("Please enter your Credit/Debit Card Number.");
      document.frmBusiness.txtCCNumber.focus();
      return false;
	}
    
	if ((document.frmBusiness.optCCType.value != "Laser") && (document.frmBusiness.optCCType.value != "Switch"))
	{
      if (document.frmBusiness.txtCCCVVType.value == "")
      {
          alert("Please enter your CVV number.  This is the last three digits at the back of your card.");
          document.frmBusiness.txtCCCVVType.focus();
          return false;
      }
	}
	if (document.frmBusiness.optCCMonth.value == "None")
	{
      alert("Please complete the Credit Cards Expiry Date Details.");
      document.frmBusiness.optCCMonth.focus();
      return false;
	}
	if (document.frmBusiness.optCCYear.value == "None")
	{
      alert("Please complete the Credit Cards Expiry Date Details.");
      document.frmBusiness.optCCYear.focus();
      return false;
	}
	
	
	myDivPaymentButton = document.getElementById("PaymentButton");
	myDivPaymentProcessing = document.getElementById("PaymentProcessing");
			
	myDivPaymentButton.style.display = "none";
	myDivPaymentProcessing.style.display = "block";
	return true;
}


function GenOverLib(Message,Caption)
{	
	return overlib(Message,WIDTH,290,CSSCLASS,FULLHTML,VAUTO,HAUTO);
}