function ValidateShippertoBusiness(theForm, lngDestination)
{
	var strMsg;

	if (theForm.txt_Surname.value.length==0){
	alert("Please enter your surname in the space provided..")
	theForm.txt_Surname.focus();
			return false;
	}
	
	if (theForm.txt_FirstName.value.length==0){
		alert("Please enter your first name in the space provided..")
			theForm.txt_FirstName.focus();
			return false;
	}

	if (theForm.txt_AgentName.value.length==0){
		alert("Please enter your company name in the space provided..")
			theForm.txt_AgentName.focus();
			return false;
	}

	if (theForm.txt_Address1.value.length == 0) {
		alert("Please enter the first line of your address in the space provided..")
			theForm.txt_Address1.focus();
			return false;
	}

	if (theForm.txt_Town.value.length == 0) {
		alert("Please enter the town of your address in the space provided..")
			theForm.txt_Town.focus();
			return false;
	}

//	if (theForm.txt_County.value.length == 0) {
//		alert("Please enter the county of your address in the space provided..")
//			theForm.txt_County.focus();
//			return false;
//	}
	
	if (theForm.txt_PostCode.value.length == 0) {
		alert("Please enter your postcode in the space provided..")
			theForm.txt_PostCode.focus();
			return false;
	}

	if (theForm.txt_CountryID.options[theForm.txt_CountryID.selectedIndex].text != "United Kingdom"){
		alert("Sorry. We can only provide insurance cover to companies based in the UK.")
		return false;
	}

	if (theForm.txt_Telephone.value.length>0){
		if (!isPhone(theForm.txt_Telephone.value)){
			alert("Invalid telephone number")
			theForm.txt_Telephone.focus();
			return false;
		}
	} else {
		alert("Please enter your telephone number in the space provided..")
			theForm.txt_Telephone.focus();
			return false;
	}

	if (theForm.txt_Fax.value.length>0){
		if (!isPhone(theForm.txt_Fax.value)){
			alert("Invalid fax number")
			theForm.txt_Fax.focus();
			return false;
		}
	}
	if ((theForm.txt_CompanyRegistration.value.length==0) && (theForm.txt_CompanyVAT.value.length==0)){
		alert("Please enter either your company registration number or your VAT number in the space provided..")
			theForm.txt_CompanyRegistration.focus();
			return false;
	} else {
		if (theForm.txt_CompanyRegistration.value.length > 0 && !isCompanyRegistration(theForm.txt_CompanyRegistration.value)) {
			alert("Invalid company registration number. Must be a 8 digit number without spaces e.g. 12345678")
			theForm.txt_CompanyRegistration.focus();
			return false;
		}
		if (theForm.txt_CompanyVAT.value.length > 0 && !isVAT(theForm.txt_CompanyVAT.value)) {
			alert("Invalid VAT number. Must be 'GB' followed by 9 digits e.g. GB000123456")
			theForm.txt_CompanyVAT.focus();
			return false;
		}
	}
	
	theForm.action="Shipper.asp?id=" + lngDestination;
	disableButtons(theForm);
	theForm.submit();
	
}

function ValidateShipperBusinessDetails(theForm){

	if (!theForm.txt_BusinessImport.checked && !theForm.txt_BusinessExport.checked && !theForm.txt_BusinessSellBuy.checked){
		alert("One or more business types must be selected");
		return false;
	}	
	
	if (theForm.txt_GoodsType.value.length == 0){
		alert("A type of goods must be entered")
		theForm.txt_GoodsType.focus()
		return false;
	}
		
	if (!theForm.txt_CargoByAir.checked && !theForm.txt_CargoByOceanFCL.checked && !theForm.txt_CargoByOceanLCL.checked && !theForm.txt_CargoByRoadRail.checked){
		alert("One or more transport methods must be selected")
		return false;
	}
	
	if (theForm.txt_AnnualInsured.value.length == 0){
		alert("An annual value of insured cargo must be entered")
		theForm.txt_AnnualInsured.focus()
		return false;
	} else {
		if (!isNumeric(theForm.txt_AnnualInsured.value)){
			alert("Annual value of insured cargo must be numeric")
			theForm.txt_AnnualInsured.focus()
			return false;
		} else {
			if (theForm.txt_AnnualInsured.value == 0 || theForm.txt_AnnualInsured.value > 999999999999999999){
				alert("Annual value of insured cargo must be greater than 0 and less than 999999999999999999")
				theForm.txt_AnnualInsured.focus()
				return false;
			}
		}
	}
	//JPipe 14/09/06
/*  JPipe 15/09/06	if (theForm.txt_MarineCargo.value == 1){
		alert("Sorry. We cannot offer cover for you through this website. \n\nYou should use your current Marine Cargo Policy.");
		theForm.txt_MarineCargoUnderwriter.focus()
		return false;
	}*/
	
	if ((theForm.txt_MarineCargo.value == 1) && theForm.txt_MarineCargoUnderwriter.value.length == 0){
		alert("The marine cargo underwriter must be entered")
		theForm.txt_MarineCargoUnderwriter.focus()
		return false;
	}

	if (theForm.txt_MarineCargoWithdrawn.value == 1){
		alert("Sorry. We cannot offer cover for you through this website. \n\nPlease contact GoCargoInsurance using the details on the Contact page");
		return false;
	}
	disableButtons(theForm);
}
	
function ValidateShipperID(theForm) {
	
	if (theForm.txt_SHemail.value.length==0){
		alert("Please enter your email address in the space provided.")
		theForm.txt_SHemail.focus();
		return false;	
	}
	if (!isEmail(theForm.txt_SHemail.value)){
		alert("Please enter a valid email address in the space provided.")
		theForm.txt_SHemail.focus();
		return false;	
	}

	if (theForm.txt_SHpassword.value.length < 5){
		alert("Password must be at least 5 characters")
		theForm.txt_SHpassword.focus();
		return false;
	}
	if (theForm.txt_SHUserName.value.length==0){
		alert("Please enter your company name in the space provided.")
		theForm.txt_SHUserName.focus();
		return false;	
	}
	document.getElementById("backgroundcolor").value = getIDedStyleProperty('BODY', 'backgroundColor')
	return true
}
function getIDedStyle (elementID) {
  var re = new RegExp("" + elementID + "$", "gi");
  if (document.all) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].rules.length; r++)
        if (document.styleSheets[s].rules[r].selectorText.search(re) 
!= -1) {
          return document.styleSheets[s].rules[r].style;
        }
  }
  else if (document.getElementById) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
        if (document.styleSheets[s].cssRules[r].selectorText.search
(re) != -1){
          document.styleSheets[s].cssRules[r].sheetIndex = s;
          document.styleSheets[s].cssRules[r].ruleIndex = s;
          return document.styleSheets[s].cssRules[r].style;
        }
  }
  else if (document.layers)
    return document.ids[elementID];
  return null;
}
function getIDedStyleProperty (elementID, propertyName) {
  var styleClass = getIDedStyle(elementID);
  if (styleClass)
    return styleClass[propertyName];
  else 
    return null;
}

function FormNavigate(theForm,ID){
		theForm.action="Shipper.asp?id=" + ID;
		disableButtons(theForm);
		theForm.submit();
}