function CheckForm(form) 
{
	var sc = GetSmartClientController();
	var strTitle = sc.GetControlByAlias('Account User.Title').GetValue();
	if(strTitle.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Title.");
		return false;
	}
	var strName = sc.GetControlByAlias('Account User.First Name').GetValue();
	if ((strName=="") || (strName==null))
	{
		alert("Please specify your first name.");
		return false;
	}
	if(strName.indexOf('<') != -1)
	{
		alert("Invalid character '<' in your First Name.");
		return false;
	}
	strName = sc.GetControlByAlias('Account User.Last Name').GetValue();
	if ((strName == "") || (strName == null)) {
	    alert("Please specify your last name.");
	    return false;
	}
	if (strName.indexOf('<') != -1) {
	    alert("Invalid character '<' in your Last Name.");
	    return false;
	}
	var strPosition = sc.GetControlByAlias('Account User.Position').GetValue();
	if(strPosition.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Position in the Company.");
		return false;
	}
	var strCompanyName = sc.GetControlByAlias('Account.Company Name').GetValue();
	if ((strCompanyName=="") || (strCompanyName==null))
	{
		alert("Please specify your company name.");
		return false;
	}
	if(strCompanyName.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Company Name.");
		return false;
	}
	var strAddress1 = sc.GetControlByAlias('Account.Address Line 1').GetValue();
	if ((strAddress1=="") || (strAddress1==null))
	{
		alert("Please specify the address in the Your Details section.");
		return false;
	}
	if(strAddress1.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Address.");
		return false;
	}
	var strAddress2 = sc.GetControlByAlias('Account.Address Line 2').GetValue();
	if(strAddress2.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Address.");
		return false;
	}
	var strTownCity = sc.GetControlByAlias('Account.Town/City').GetValue();
	if ((strTownCity=="") || (strTownCity==null))
	{
		alert("Please specify the town/city in the Your Details section.");
		return false;
	}
	if(strTownCity.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Town/City.");
		return false;
	}
	var strCounty = sc.GetControlByAlias('Account.County').GetValue();
	if(strCounty.indexOf('<') != -1)
	{
		alert("Invalid character '<' in County.");
		return false;
	}
	var strPC = sc.GetControlByAlias('Account.Postcode').GetValue();
	if ((strPC=="") || (strPC==null))
	{
		alert("Please specify the postcode in the Your Details section.");
		return false;
	}
	if (!CheckPostcode(sc.GetControlByAlias('Account.Postcode')))
	{
		// Don't display a message because the CheckPostcode function has done this already.
		return false
	}
	var strEmail1 = sc.GetControlByAlias('Account User.Email').GetValue();
	var strEmail2 = sc.GetControlByAlias('Account User.Confirm Email').GetValue();
	if ((strEmail1 == "") || (strEmail2 == ""))
	{
		alert("Please specify your Email Address (for future order notification)\nand re-enter it in the Re-enter Email Address field.");
		return false;
	}

	if (strEmail1 != "")
	{
		// The user has entered an email address - check to see if it has been
		// re-entered the same in the second email field...
	    if (strEmail2 != strEmail1)
		{
		    alert("The email addresses entered in the Your Details section do not match, please try again.");
		    return false;
		}
		if (!CheckEmailAddress(strEmail1))
		{
			alert("Your email address entered in the Your Details section is not valid. Please try again.")
			return false
		}
	}
	var strTel = sc.GetControlByAlias('Account User.Telephone').GetValue();
	if ((strTel=="") || (strTel==null))
	{
		alert("Please specify a contact telephone number in the Your Details section.");
		return false;
	}
	if(strTel.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Telephone.");
		return false;
	}
//	var strFax = sc.GetControlByAlias('Account.Fax').GetValue();
//	if ((strFax=="") || (strFax==null))
//	{
//		alert("Please specify a fax number in the Your Details section.");
//		return false;
//	}
//	if(strFax.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in Fax.");
//		return false;
//	}
//	strVatreg = sc.GetControlByAlias('Account.VAT Reg.').GetValue();
//	if(strVatreg.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in Vat Registration Number.");
//		return false;
//	}
//	strCompreg = sc.GetControlByAlias('Account.Company Number').GetValue();
//	if(strCompreg.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in Company Registration Number.");
//		return false;
//	}
//	strDxregion = sc.GetControlByAlias('Account.DX Region').GetValue();
//	if(strDxregion.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in DX Region.");
//		return false;
//	}
//	strDxnumber = sc.GetControlByAlias('Account.DX Number').GetValue();
//	if(strDxnumber.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in DX Number.");
//		return false;
//	}
	strAcctitle = sc.GetControlByAlias('Account.Admin Title').GetValue();
	if(strAcctitle.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Title (Accounts Dept. Contact).");
		return false;
	}
	var strName = sc.GetControlByAlias('Account.Admin Name').GetValue();
	if ((strName=="") || (strName==null))
	{
		alert("Please specify the name of the Accounts Department contact.");
		return false;
	}
	if(strName.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Name (Accounts Dept. Contact).");
		return false;
	}
	var strPos = sc.GetControlByAlias('Account.Admin Position').GetValue();
	if(strPos.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Postion (Accounts Dept. Contact).");
		return false;
	}
//	var strDeptname = sc.GetControlByAlias('Account.Admin Department').GetValue();
//	if (strDeptname.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in Department Name (Accounts Dept. Contact).");
//		return false;
//	}
	var strAddress1 = sc.GetControlByAlias('Account.Admin Address Line 1').GetValue();
	if ((strAddress1=="") || (strAddress1==null))
	{
		alert("Please specify the address in the Accounts Department Details section.");
		return false;
	}
	if(strAddress1.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Address (Accounts Dept. Contact).");
		return false;
	}
	var strAddress2 = sc.GetControlByAlias('Account.Admin Address Line 2').GetValue();
	if(strAddress2.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Address (Accounts Dept. Contact).");
		return false;
	}
	var strTownCity = sc.GetControlByAlias('Account.Admin Town/City').GetValue();
	if ((strTownCity=="") || (strTownCity==null))
	{
		alert("Please specify the town/city in the Accounts Department Details section.");
		return false;
	}
	if(strTownCity.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Town/City (Accounts Dept. Contact).");
		return false;
	}
	var strCounty = sc.GetControlByAlias('Account.Admin County').GetValue();
	if(strCounty.indexOf('<') != -1)
	{
		alert("Invalid character '<' in County (Accounts Dept. Contact).");
		return false;
	}
	var strPC = sc.GetControlByAlias('Account.Admin Postcode').GetValue();
	if ((strPC=="") || (strPC==null))
	{
		alert("Please specify a postcode in the Accounts Department Details section.");
		return false;
	}
	if (!CheckPostcode(sc.GetControlByAlias('Account.Admin Postcode')))
	{
		// Don't display a message because the CheckPostcode function has done this already.
		return false
	}
	var strEmail1 = sc.GetControlByAlias('Account.Admin Email').GetValue();
	var strEmail2 = sc.GetControlByAlias('Account.Confirm Admin Email').GetValue();
	if ((strEmail1 == "") || (strEmail2 == ""))
	{
		alert("Please specify the Accounts Department Email Address\nand re-enter it in the Re-enter Accounts Department Email Address field.");
		return false;
	}

	if (strEmail1 != "")
	{
		// The user has entered an email address - check to see if it has been
		// re-entered the same in the second email field...
	    if (strEmail2 != strEmail1)
		{
		    alert("The email addresses entered in the Accounts Department Details section do not match, please try again.");
		    return false;
		}
		if (!CheckEmailAddress(strEmail1))
		{
			alert("Your email address entered in the Accounts Department Details section is not valid. Please try again.")
			return false
		}
	}
	var strTel = sc.GetControlByAlias('Account.Admin Telephone').GetValue();
	if ((strTel=="") || (strTel==null))
	{
		alert("Please specify a contact telephone number for the Accounts Department.");
		return false;
	}
	if(strTel.indexOf('<') != -1)
	{
		alert("Invalid character '<' in Tel (Accounts Dept. Contact).");
		return false;
	}
//	var strFax = sc.GetControlByAlias('Account.Admin Fax').GetValue();
//	if ((strFax=="") || (strFax==null))
//	{
//		alert("Please specify a fax number for the Accounts Department.");
//		return false;
//	}
//	if(strFax.indexOf('<') != -1)
//	{
//		alert("Invalid character '<' in Fax (Accounts Dept. Contact).");
//		return false;
//	}

	return true;
}

function CheckForm2(form) {
    var sc = GetSmartClientController();

    var strUserName = sc.GetControlByAlias('Clients.User Name').GetValue();

    if (strUserName == "") {
        alert("Please specify the User Name.");
        return false;
    }

    if (strUserName.indexOf(' ') != -1 ||
        strUserName.indexOf('<') != -1 
        || strUserName.indexOf('>') != -1) {
        alert("Invalid character ' ', '<' and '>' in User Name.");
        return false;
    }

    var strEmail = sc.GetControlByAlias('Clients.Email').GetValue();
    if (strEmail == "") {
        alert("Please specify the Email Address.");
        return false;
    }

    if (!CheckEmailAddress(strEmail)) {
        alert("Your email address entered in the Email field is not valid. Please try again.")
        return false;
    }

    var strPsw1 = sc.GetControlByAlias('Clients.Password').GetValue();
    var strPsw2 = sc.GetControlByAlias('Clients.Confirm Password').GetValue();
    if ((strPsw1 == "") || (strPsw2 == "")) {
        alert("Please specify the Password\nand re-enter it in the Confirm Password field.");
        return false;
    }

    if (strPsw1.indexOf(' ') != -1)
    {
        alert("Password should not contain spaces.");
        return false;
    }

    if (!CheckPostcode(sc.GetControlByAlias('Clients.Postcode').Control)) {
        // Don't display a message because the CheckPostcode function has done this already.
        return false
    }

    if (!ValidateRegistrationPassword()) return false;

    if (!ValidatRegistrationBuildingInfo(form)) return false;

    if (!jcap()) {
        alert('Please, enter valid image code!');
        return false;
    }

    return true;
}

function ValidatShoppingCartCaseInfo(form) {
    var oNames = ["Case.Building Number", "Case.Building Name"];
    var oController = GetSmartClientController();

    var IsValid = false;
    for (var i = 0; i < oNames.length; i++) {
        var oSmart = oController.GetControlByAlias(oNames[i]);
        if (oSmart != null) 
        {
            if (oSmart.GetValue() != "")
                IsValid = true;
        }
    }

    if (!IsValid) {
        alert("It is required to enter Building Number or Building Name");
        return false;
    }

    return true;
}

function ValidatRegistrationBuildingInfo(form) {
    var oNames = ["Clients.Building Number", "Clients.Building Name"];
    var oController = GetSmartClientController();

    var IsValid = false;
    for (var i = 0; i < oNames.length; i++) {
        var oSmart = oController.GetControlByAlias(oNames[i]);
        if (oSmart != null) {
            if (oSmart.GetValue() != "")
                IsValid = true;
        }
    }

    if (!IsValid) {
        alert("It is required to enter Building Number or Building Name");
        return false;
    }

    return true;
}

function ValidateRegistrationPassword() {
    var bIsValid = true;

    var pwd_validators = new Array();
    pwd_validators.openerWindow = window;

    var ctlPassword = GetSmartClientController().GetControlByAlias('Clients.Password');
    var ctlConfirmPassword = GetSmartClientController().GetControlByAlias('Clients.Confirm Password');

    var sPassword = ctlPassword.GetValue();
    var sConfirmPassword = ctlConfirmPassword.GetValue();

    if (sPassword == "" && sConfirmPassword == "")
        return true;

    var reDigits = /[0-9_]+/;
    var reLetters = /[A-Za-z_]+/;
    var reInvalidChars = /[^a-zA-Z0-9_\!\"\£\$\%\^\&\*\(\)]+/;

    if (sPassword != "") {
        if (sPassword.search(reInvalidChars) != -1) {
            alert("Invalid password entered, please only use alpha-numeric, underscore and \!\"£\$\%\^\&\*\(\) characters.");
            bIsValid = false;
        }
        if (sPassword.search(reDigits) == -1) {
            alert("Invalid password entered, please use at least one number.");
            bIsValid = false;
        }
        if (sPassword.search(reLetters) == -1) {
            alert("Invalid password entered, please use at least one letter.");
            bIsValid = false;
        }
        if (sPassword.length < 6) {
            alert("Please specify a password that is at least 6 characters long.");
            bIsValid = false;
        }
        if (bIsValid)
            if (sPassword != sConfirmPassword) {
            alert("The passwords entered do not match, please try again.");
            bIsValid = false;
        }
    }

    return bIsValid;
}
