
function hideshow(which, which1, which2)
{

	if (!document.getElementById)
	return;
	
	if (document.getElementById(which).style.display=="none")
	{
	  document.getElementById(which).style.display="";
	  document.getElementById(which1).style.display="none";
	  document.getElementById(which2).style.display="none";
	}
	else
	{
	  document.getElementById(which).style.display="none";
	  document.getElementById(which1).style.display="";
	  document.getElementById(which2).style.display="";
	}

}

function EnsureNumeric()
{

  var key = window.event.keyCode;

  if (key <48 || key >57)

    window.event.returnValue = false;

}

function do_totals1()
 {
	document.all.pleasewaitScreen.style.pixelTop = (document.body.scrollTop + 200)
	document.all.pleasewaitScreen.style.visibility="visible";
	window.setTimeout('do_totals2()',1)
 }
 
function do_totals2()
 {
	 //calc_totals();
	 document.all.pleasewaitScreen.style.visibility="hidden";
 } 

function jumpConfirmation()
{
	return confirm("Are you sure you would like to jump to a different section? All unsaved work will be lost.");
}

function checkUserStatus()
{
	if (document.getElementById("acceptTerms").value == "y" && document.getElementById("HCToBeSent").value == "y")
	{
		document.getElementById("submitApp").disabled = false;
	}
	else
	{
		document.getElementById("submitApp").disabled = true;
	}
}

function remove(which)
{
	document.getElementById(which).value = "y";
}

function hideshow1(which, which1)
{

	if (!document.getElementById)
	return;
	
	if (document.getElementById(which).style.display=="none")
	{
	  document.getElementById(which).style.display="";
	  document.getElementById(which1).style.display="none";

	}

}


function checkDeclaration()
{
	var errorMessage = "";
	if ((document.getElementById('acceptTerms').value=="n") || (document.getElementById('HCToBeSent').value=="n"))
	{
		if (document.getElementById('acceptTerms').value=="n")
			errorMessage= errorMessage + "You MUST accept the terms of the above declaration to submit your application\n";
		if (document.getElementById('HCToBeSent').value=="n")
			errorMessage= errorMessage + "You MUST declare that hardcopies of all required evidence will be sent before submitting your application";
		alert(errorMessage);
		return false;
	}
	else
	{
		if(document.getElementById('acceptTerms').value=="y")
			return confirm("Are you sure you would like to submit the application?\n\nYou will receive a confirmation e-mail after your application is succesfully submitted.");
		else
			return false;
	
	}
}




function checkAcceptance()
{
	if (document.getElementById('acceptTerm').checked)
	{
		document.getElementById('subcontractorbut').disabled = !document.getElementById('subcontractorbut').disabled;
		document.getElementById('supplierbut').disabled = !document.getElementById('supplierbut').disabled;
	}
	else
	{
		document.getElementById('subcontractorbut').disabled = "disabled";
		document.getElementById('supplierbut').disabled = "disabled";
	}
}

function checkDate(vDay, vMonth, vYear)
{
	strDate = document.getElementById(vDay).value +"/"+ document.getElementById(vMonth).value+"/"	+document.getElementById(vYear).value;
	if(isitToday(strDate,3)) 
		return true;
	else
		return false;
}



function limitText(limitField, limitCount, limitNum) {
	if (document.getElementById(limitField).value.length > limitNum) {
		document.getElementById(limitField).value = document.getElementById(limitField).value.substring(0, limitNum);
	} else {
		document.getElementById(limitCount).value = limitNum - document.getElementById(limitField).value.length;
	}
}


function isitToday(dateString,dateType) {
/*
   function isitToday 
   parameters: dateString dateType
   returns: boolean
   
   dateString is a date passed as a string in the following
   formats:

   type 1 : 19970529
   type 2 : 970529
   type 3 : 29/05/1997
   type 4 : 29/05/97
   
   dateType is a numeric integer from 1 to 4, representing
   the type of dateString passed, as defined above.

   Returns true if the date passed is equal to todays date
   Returns false if the date passed is NOT equal to todays
   date or if dateType is not 1 to 4.
*/


    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());

    if (dateType == 1)
        var date = new Date(dateString.substring(0,4),
                            dateString.substring(4,6)-1,
                            dateString.substring(6,8));
    else if (dateType == 2)
        var date = new Date(dateString.substring(0,2),
                            dateString.substring(2,4)-1,
                            dateString.substring(4,6));
    else if (dateType == 3)
        var date = new Date(dateString.substring(6,10),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else if (dateType == 4)
        var date = new Date(dateString.substring(6,8),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else
        return false;

    if (date > today)
        return true;
    else
        return false;
}




function valEmail(emailaddress)
{
	str = document.getElementById(emailaddress).value;
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	
	return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	
	return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	
	return false
	}
	
	if (str.indexOf(at,(lat+1))!=-1){
	
	return false
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	
	return false
	}
	
	if (str.indexOf(dot,(lat+2))==-1){
	
	return false
	}
	
	if (str.indexOf(" ")!=-1){
	
	return false
	}
	
	return true					
}

function checkApplicability(which1, which2)
{
	if(document.getElementById(which1).checked == true)
		document.getElementById(which2).value = "";
}

function charValidation(which)
{
	
	//var illegalChars= /[\<\>\*\!\%\^\+\{\}\|\\\/\[\]]/
	//if (document.getElementById(which).value.match(illegalChars)) 
		//return false;
	//else 
		return true;
}

function charValidationAllowCom(which)
{
	//var illegalChars= /[\<\>\*\!\%\^\+\{\}\|\\\/\[\]]/
	//if (document.getElementById(which).value.match(illegalChars)) 
		//return false;
	//else 
		return true;
}
function validation(sec)
{
	var cando = true;
	var specialMessage = false;
	var errMessage = "";
	switch(sec)
	{
		case "1":
			if(!checkLength("companyName"))
			{
				cando=false;
				errMessage = "*Name of your company\n";
			}
			if(!checkLength("companyAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Address of your company\n";
			}
			if(!checkLength("companyPostCode"))
			{
				cando=false;
				errMessage = errMessage + "*Postal address postcode of your company\n";
			}
			if(!checkLength("companyTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Contact telephone number of your company\n";
			}

			if(!checkLength("contactName"))
			{
				cando=false;
				errMessage = errMessage + "*Name of the contact person in your company\n";
			}
			if(!checkLength("contactTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Telephone number of the contact person\n";
			}
			if(!checkLength("contactEmail"))
			{
				cando=false;
				errMessage = errMessage + "*E-mail address of the contact person\n";
			}
			if(!checkLength("contactAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Postal address of the contact person\n";
			}
			if(!checkLength("contactPostcode"))
			{
				cando=false;
				errMessage = errMessage + "*Postcode of the contact address\n";
			}
			
			
			
			//if(!valEmail("contactEmail"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Please enter your real e-mail address\n";
//			}
			
			if(!charValidation("companyName"))
			{
				cando=false;
				errMessage = "*Special characters not allowed in name of your company\n";
			}
			if(!charValidation("companyAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyAdd2"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyAdd3"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyPostCode"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in postcode of your company\n";
			}
			if(!charValidation("companyTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in contact telephone number of your company\n";
			}

			if(!charValidation("contactName"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in name of the contact person in your company\n";
			}
			if(!charValidation("contactTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in telephone number of the contact person\n";
			}
			//if(!charValidation("contactEmail"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Special characters not allowed in E-mail address of the contact person\n";
//			}
			if(!charValidation("contactAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in company's registered address\n";
			}
			if(!charValidation("contactAdd2"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in company's registered address\n";
			}
			if(!charValidation("contactAdd3"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in company's registered address\n";
			}
			if(!charValidation("contactPostcode"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in postcode of the contact address\n";
			}


			
			break;
		case "2":
			if(!checkLength("regNum"))
			{
				cando=false;
				errMessage = errMessage + "*Registration number of your company\n";
			}
			
			if(!checkLength("utr"))
			{
				cando=false;
				errMessage = errMessage + "*UTR number of your company\n";
			}
			
			//if(!checkDate("regExpDD", "regExpMM", "regExpYYYY"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Invalid Date of CIS Reg Expiry\n";
//			}
			
			if(document.getElementById("finASCCompanies").value == "1")
			{
				if(!checkLength("finASCCDetails"))
				{
					cando=false;
					errMessage = errMessage + "*Details of your company's associated companies\n";
				}
			}
			
			//if(!checkLength("contractValueToTake[]"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Value of contract that your company is willing to undertake\n";
//			}
			
			
			if(!checkLength("bankRef"))
			{
				cando=false;
				errMessage = errMessage + "*Bank Reference\n";
			}
			
			if(!checkLength("tradeRef"))
			{
				cando=false;
				errMessage = errMessage + "*Trade Reference\n";
			}
			
			if(!document.getElementById("notApplicable1").checked)
			{
				if(!checkLength("fineeInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your company's Employers Liability Insurance Policy\n";
				}
				if(!checkLength("fineeLiabilityNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Employers Liability Insurance\n";
				}
				if(!checkLength("fineeLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Employers Liability Insurance Policy\n";
				}
			}
			if(!document.getElementById("notApplicable2").checked)
			{
				if(!checkLength("finppInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your Public Liability Insurance Policy\n";
				}
				if(!checkLength("finppLiabilityNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Public Liability Insurance\n";
				}
				if(!checkLength("finppLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Public Liability Insurance Policy\n";
				}
			}
			
			if(!document.getElementById("notApplicable3").checked)
			{
				if(!checkLength("finIndemnityInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your Professional Indemnity Insurance Policy\n";
				}
				if(!checkLength("finIndemnityNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Professional Indemnity Insurance\n";
				}
				if(!checkLength("finIndemnityLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Professional Indemnity Insurance Policy\n";
				}
			}
			
			if(!document.getElementById("notApplicable4").checked)
			{
				if(!checkLength("finAllRisksInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your Contractors All Risks Insurance Policy\n";
				}
				if(!checkLength("finAllRisksNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Contractors All Risks Insurance\n";
				}
				if(!checkLength("finAllRisksLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Contractors All Risks Insurance Policy\n";
				}
			}
			if(document.getElementById('notApplicable1').checked == false)
			{
				if(!checkDate("fineeLimitOfCoverExpDD", "fineeLimitOfCoverExpMM", "fineeLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Employers Liability Insurance'\n";
				}
			}
			if(document.getElementById('notApplicable2').checked == false)
			{
				if(!checkDate("finppLimitOfCoverExpDD", "finppLimitOfCoverExpMM", "finppLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Public Liability Insurance'\n";
				}
			}
			if(document.getElementById('notApplicable3').checked == false)
			{
				if(!checkDate("finIndemnityLimitOfCoverExpDD", "finIndemnityLimitOfCoverExpMM", "finIndemnityLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Professional Indemnity Insurance'\n";
				}
			}
			if(document.getElementById('notApplicable4').checked == false)
			{
				if(!checkDate("finAllRisksLimitOfCoverExpDD", "finAllRisksLimitOfCoverExpMM", "finAllRisksLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'All Risks Insurance'\n";
				}
			}
			
			if(!charValidation("regNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in registration number of your company\n";
			}
			
			if(!charValidation("bankRef"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in Bank Reference\n";
			}
			
			if(!charValidation("tradeRef"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in Trade Reference\n";
			}
			
			if(!charValidation("fineeInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your company's Employers Liability Insurance Policy\n";
			}
			if(!charValidation("fineeLiabilityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Employers Liability Insurance\n";
			}
			if(!charValidation("fineeLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Limit of cover for your Employers Liability Insurance Policy\n";
			}
			if(!charValidation("finppInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your Public Liability Insurance Policy\n";
			}
			if(!charValidation("finppLiabilityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Public Liability Insurance\n";
			}
			if(!charValidation("finppLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Public Liability Insurance Policy\n";
			}
			if(!charValidation("finIndemnityInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your Public Liability Insurance Policy\n";
			}
			if(!charValidation("finIndemnityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Public Liability Insurance\n";
			}
			if(!charValidation("finIndemnityLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Public Liability Insurance Policy\n";
			}
			
			if(!charValidation("finAllRisksInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your Public Liability Insurance Policy\n";
			}
			if(!charValidation("finAllRisksNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Public Liability Insurance\n";
			}
			if(!charValidation("finAllRisksLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Public Liability Insurance Policy\n";
			}
			break;
		case "3":
			if(!checkLength("workingAreas[]"))
			{
				cando=false;
				errMessage = errMessage + "*Your preferred georaphical working area \n";
			}
			if(!checkLength("workNetworks[]"))
			{
				cando=false;
				errMessage = errMessage + "*The railway/tube networks that your company currently works for or willing to undertake work from\n";
			}
			break;
		case "4":
			
			if(!checkLength("accidentRate"))
			{
				cando=false;
				errMessage = errMessage + "*Accident rate \n";
			}
			
			if(!charValidation("accidentRate"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in accident rate\n";
			}
			if(!charValidation("linkupNetworkRailApproval"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in link up network rail approval\n";
			}
			if(!charValidation("CERTothersName"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in other accreditations\n";
			}
			if(!charValidation("CERTothers"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in other accreditation number\n";
			}
			if(!charValidation("genNJCBI"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in NJCBI Registration No.\n";
			}
			if(!charValidation("genCITB"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in CITB Registration No.\n";
			}
			if(!charValidation("genNHBC"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in NHBC Registration No.\n";
			}
			
			break;
		case "5":
			var selectedTrade = false;

			for(var i=0; i<75; i++)
			{
				if(document.getElementById('TRADE'+ i).checked)
				selectedTrade = true;
			}
			if(!selectedTrade)
			{
				cando = false;
				specialMessage = true;
				errMessage = "At least one trading area is needed.\n";	
			}

			break;
		case "6":
			if(document.getElementById('addtionalInfo').value.length >=500)
			{
				cando=false;
				specialMessage=true;
				errMessage = "Please make sure your message contains less than 500 characters.\n";
			}
			
			if(!charValidation("addtionalInfo"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in additional information.\n";
			}
			break;
	}
	if(!cando && !specialMessage)
	{
		alert("Please correctly fill in or select the following field(s):\n\n" + errMessage);
	}
	else
	if(specialMessage)
	{
		alert(errMessage);
	}
	return cando;
	
}

function validationSup(sec)
{
	var cando = true;
	var specialMessage = false;
	var errMessage = "";
	switch(sec)
	{
		case "1":
			if(!checkLength("companyName"))
			{
				cando=false;
				errMessage = "*Name of your company\n";
			}
			if(!checkLength("companyAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Address of your company\n";
			}
			if(!checkLength("companyPostCode"))
			{
				cando=false;
				errMessage = errMessage + "*Postal address postcode of your company\n";
			}
			if(!checkLength("companyTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Company telephone number of your company\n";
			}
			if(!checkLength("companyFax"))
			{
				cando=false;
				errMessage = errMessage + "*Company fax number of your company\n";
			}
			
			if(!checkLength("contactName"))
			{
				cando=false;
				errMessage = errMessage + "*Name of the contact person in your company\n";
			}
			if(!checkLength("contactTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Telephone number of the contact person\n";
			}
			if(!checkLength("contactEmail"))
			{
				cando=false;
				errMessage = errMessage + "*E-mail address of the contact person\n";
			}
			if(!checkLength("contactAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Postal address of the contact person\n";
			}
			if(!checkLength("contactPostcode"))
			{
				cando=false;
				errMessage = errMessage + "*Postcode of the contact address\n";
			}

			if(!checkLength("regNum"))
			{
				cando=false;
				errMessage = errMessage + "*Registration number of your company\n";
			}

			if(document.getElementById("finASCCompanies").value == "1")
			{
				if(!checkLength("finASCCDetails"))
				{
					cando=false;
					errMessage = errMessage + "*Details of your company's associated companies\n";
				}
			}

			if(!checkLength("workingAreas[]"))
			{
				cando=false;
				errMessage = errMessage + "*Your preferred georaphical working area \n";
			}

			
			if(!charValidation("companyName"))
			{
				cando=false;
				errMessage = "*Special characters not allowed in name of your company\n";
			}
			if(!charValidation("companyAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyAdd2"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyAdd3"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in address of your company\n";
			}
			if(!charValidation("companyPostCode"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in postal address postcode of your company\n";
			}
			if(!charValidation("companyTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in contact telephone number of your company\n";
			}
			if(!charValidation("companyFax"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in company fax number of your company\n";
			}

			if(!charValidation("contactName"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in name of the contact person in your company\n";
			}
			if(!charValidation("contactTelephone"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in telephone number of the contact person\n";
			}
			//if(!valEmail("contactEmail"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Please enter your real e-mail address\n";
//			}
			//if(!charValidation("contactEmail"))
//			{
//				cando=false;
//				errMessage = errMessage + "*Special characters not allowed in e-mail address of the contact person\n";
//			}
			if(!charValidation("contactAdd1"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in registered address of the company\n";
			}
			if(!charValidation("contactAdd2"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in registered address of the company\n";
			}
			if(!charValidation("contactAdd3"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in registered address of the company\n";
			}
			if(!charValidation("contactPostcode"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in postcode of the contact address\n";
			}

			if(!charValidation("regNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in registration number of your company\n";
			}
			
			if(!charValidation("finVATNo"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in VAT number\n";
			}
			
			if(!charValidation("finASCCDetails"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in associated companies detail\n";
			}
			
			if(!charValidation("finParentCompanyDetails"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in parent company detail\n";
			}
			
			
			
			
			
			break;
		case "2":
			
			
			if(!checkLength("fineeInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Insurer of your company's Employers Liability Insurance Policy\n";
			}
			if(!checkLength("fineeLiabilityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Policy number of your Employers Liability Insurance\n";
			}
			if(!checkLength("fineeLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Limit of cover for your Employers Liability Insurance Policy\n";
			}
			
			if(checkLength("finppInsurer")||checkLength("finppLiabilityNum")||checkLength("finppLimitOfCover"))
			{
				if(!checkLength("finppInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your Public Liability Insurance Policy\n";
				}
				if(!checkLength("finppLiabilityNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Public Liability Insurance\n";
				}
				if(!checkLength("finppLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Public Liability Insurance Policy\n";
				}
			}
			
			if(checkLength("finIndemnityInsurer")||checkLength("finIndemnityNum")||checkLength("finIndemnityLimitOfCover"))
			{
				if(!checkLength("finIndemnityInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your company's Indemnity Insurance Policy\n";
				}
				if(!checkLength("finIndemnityNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Indemnity Insurance\n";
				}
				if(!checkLength("finIndemnityLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Indemnity Insurance Policy\n";
				}
			}
			
			
			if(checkLength("finAllRisksInsurer")||checkLength("finAllRisksNum")||checkLength("finAllRisksLimitOfCover"))
			{
				if(!checkLength("finAllRisksInsurer"))
				{
					cando=false;
					errMessage = errMessage + "*Insurer of your company's Contractors All Risks Insurance Policy\n";
				}
				if(!checkLength("finAllRisksNum"))
				{
					cando=false;
					errMessage = errMessage + "*Policy number of your Contractors All Risks Insurance\n";
				}
				if(!checkLength("finAllRisksLimitOfCover"))
				{
					cando=false;
					errMessage = errMessage + "*Limit of cover for your Contractors All Risks Insurance Policy\n";
				}
			}
			
			if(!checkDate("fineeLimitOfCoverExpDD", "fineeLimitOfCoverExpMM", "fineeLimitOfCoverExpYYYY"))
			{
				cando=false;
				errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Employers Liability Insurance'\n";
			}
			if(checkLength("finppInsurer")||checkLength("finppLiabilityNum")||checkLength("finppLimitOfCover"))
			{
				if(!checkDate("finppLimitOfCoverExpDD", "finppLimitOfCoverExpMM", "finppLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Public Liability Insurance'\n";
				}
			}
			if(checkLength("finIndemnityInsurer")||checkLength("finIndemnityNum")||checkLength("finIndemnityLimitOfCover"))
			{
				if(!checkDate("finIndemnityLimitOfCoverExpDD", "finIndemnityLimitOfCoverExpMM", "finIndemnityLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'Professional Indemnity Insurance'\n";
				}
			}
			if(checkLength("finAllRisksInsurer")||checkLength("finAllRisksNum")||checkLength("finAllRisksLimitOfCover"))
			{
				if(!checkDate("finAllRisksLimitOfCoverExpDD", "finAllRisksLimitOfCoverExpMM", "finAllRisksLimitOfCoverExpYYYY"))
				{
					cando=false;
					errMessage = errMessage + "*Invalid 'Insurance Expiry Date' for 'All Risks Insurance'\n";
				}
			}

			if(!charValidation("fineeInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your company's Employers Liability Insurance Policy\n";
			}
			if(!charValidation("fineeLiabilityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Employers Liability Insurance\n";
			}
			if(!charValidation("fineeLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Employers Liability Insurance Policy\n";
			}
			
			if(!charValidation("finppInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your Public Liability Insurance Policy\n";
			}
			if(!charValidation("finppLiabilityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Public Liability Insurance\n";
			}
			if(!charValidation("finppLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Public Liability Insurance Policy\n";
			}
			
			if(!charValidation("finIndemnityInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your company's Indemnity Insurance Policy\n";
			}
			if(!charValidation("finIndemnityNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Indemnity Insurance\n";
			}
			if(!charValidation("finIndemnityLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Indemnity Insurance Policy\n";
			}
			
			if(!charValidation("finAllRisksInsurer"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in insurer of your company's Contractors All Risks Insurance Policy\n";
			}
			if(!charValidation("finAllRisksNum"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in policy number of your Contractors All Risks Insurance\n";
			}
			if(!charValidation("finAllRisksLimitOfCover"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in limit of cover for your Contractors All Risks Insurance Policy\n";
			}
			

			break;
		
		case "3":
			if(!charValidation("linkupNetworkRailApproval"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in link up Network Rail Approval\n";
			}
			if(!charValidationAllowCom("nhbcNumber"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in NHBC Registration Number\n";
			}
			
			break;
		
		case "5":
			if(document.getElementById('addtionalInfo').value.length >=500)
			{
				cando=false;
				specialMessage=true;
				errMessage = "Please make sure your message contains less than 500 characters.\n";
			}
			
			if(!charValidation("addtionalInfo"))
			{
				cando=false;
				errMessage = errMessage + "*Special characters not allowed in additional informaiton\n";
			}
			break;
	}
	if(!cando && !specialMessage)
	{
		alert("Please correctly fill in or select the following field(s):\n\n" + errMessage);
	}
	else
	if(specialMessage)
	{
		alert(errMessage);
	}
	return cando;
	
}


function checkLength(which)
{
	if (document.getElementById(which).value.replace(/^\s*|\s*$/g,"").length==0)
	return false;
	else
	return true;
}

function openSelectFile(url) 
{
	var wWidth=400; var wHeight=280; 
	var gauche = (screen.width - wWidth)/2; 
	var topmargin = (screen.height - wHeight)/2; 
	window.open(url,"uploadFiles","width="+wWidth+",height="+wHeight+",left="+gauche+",top="+topmargin+",dependent=yes,resizable=0,scrollbars=0,toolbar=0");
}	

