var Lng_CHFORM01 = "date must be greater than"; var Lng_CHFORM02 = "date"; var Lng_CHFORM03 = "The field"; var Lng_CHFORM04 = "must be a number"; var Lng_CHFORM05 = "that is greater than"; var Lng_CHFORM06 = "that is less than"; var Lng_CHFORM07 = "The form was not submitted due to the following error(s)"; var Lng_CHFORM08 = "The following fields must be entered:"; var Lng_CHFORM09 = "The 2 password fields do not match"; var Lng_CHFORM10 = "Password must be at least 6 characters long"; var Lng_CHFORM11 = "The form was not submited due to the following error(s)"; var Lng_CHFORM12 = "Email address is invalid"; var Lng_CHFORM14 = "Destination IP address is invalid!"; var Lng_CHFORM15 = "The domain name doesn't seem to be valid."; var Lng_CHFORM16 = "The address must end in a three-letter domain, or two letter country."; var Lng_CHFORM17 = "This address is missing a hostname!"; var Lng_CHFORM18 = "Ip address is invalid"; var Lng_CHFORM19 = "Password must be at least {0} characters long"; var Lng_CHFORM20 = "Time value is invalid"; var submitFlag = false; function submitForm(a, b) { if (!submitFlag) { submitFlag = true; b.command.value = a.name; b.submit() } }; function submitFormA(a, b) { if (!submitFlag) { submitFlag = true; document.body.style.cursor = "wait"; b.command.value = a; b.submit() } };


function checkForm(a) {
    var b = ""; var c = ""; var d;
    for (var i = 0; i < a.length; i++) {
        d = a.elements[i];
        if (d.date != null) {
            if (d.value > d.date.value) {
                c += "- " + d.text1 + " " + Lng_CHFORM01 + " " + d.text2 + " " + Lng_CHFORM02 + "\n"
            }
            continue
        }
        if ((d.type == "text" || d.type == "textarea" || d.type == "file" || d.type == "password") && d.required) {
            if (d.value == null || d.value == "" || isBlank(d.value)) {
                b += "          " + d.text + "\n";
                continue
            }
        } if (d.required || (!d.required && d.value != "")) {
            if (d.numeric || (d.min != "" && d.min != null) || (d.max != "" && d.max != null)) {
                n = parseFloat(d.value);
                if (isNaN(n) || (d.min != "" && d.min != null && (n < d.min)) || (d.max != "" && d.max != null && (n > d.max))) {
                    c += "- " + Lng_CHFORM03 + " '" + d.text + "' " + Lng_CHFORM04;
                    if ((d.min != "") && (n < d.min)) {
                        c += " " + Lng_CHFORM05 + " " + (d.min - 1)
                    } else if ((d.max != "" && max != null) && (n > d.max)) {
                        c += " " + Lng_CHFORM06 + " " + (d.max + 1)
                    } c += "\n"
                }
                else {
                    d.value = n
                }
            }
        }
    } if (b == "" && c == "") {
        return true
    } else {
        msg = Lng_CHFORM07 + "\n";
        if (b != "") {
            msg += "\n- " + Lng_CHFORM08 + "\n" + b
        }
        if (c != "") {
            msg += "\n" + c
        }
        alert(msg);
        return false
    } 
};
function checkPasswords(a, b, c)
{ var d = ""; var e = trim(String(a.value)); var f = trim(String(b.value)); if (e != f) { d += "- " + Lng_CHFORM09 + "\n" } if (!c && e.length < 6) { d += "- " + Lng_CHFORM10 + "\n" } if (d != "") { var g = Lng_CHFORM11 + "\n" + d; alert(g); return false } return true }; function checkTime(a) { if (!(/^(((1[0-2])|(0[1-9]))\:([0-5][0-9])\s?((A|P)M))|((([01][0-9])|(2[0-4]))\:([0-5][0-9]))$/i).test(a)) { alert(Lng_CHFORM20); return false } return true }; function checkPasswordsEx(a, b, c) { if (!c) return false; var d = ""; var e = trim(String(a.value)); var f = trim(String(b.value)); if (e != f) { d += "- " + Lng_CHFORM09 + "\n" } if (e.length < c) { d += "- " + formatStr(Lng_CHFORM19, c) + "\n" } if (d != "") { var g = Lng_CHFORM11 + "\n" + d; alert(g); return false } return true }; function isBlank(s) { var i; var c; for (i = 0; i < s.length; i++) { c = s.charAt(i); if (c != ' ' && c != '\n' && c != '\t') return false } return true }; function emailCheck(a) { var b = /^(([\w!#\$%&'\*\+\-\/=\?\^\{\|\}]+(\.[\w!#\$%&'\*\+\-\/=\?\^\{\|\}]+)*)|("((?=[\x20-\x7E])[^"\\]|\\[\x20-\x7E])*"))@(((?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.)|(?:([\w-]+\.)+))(?:[a-zA-Z]{2,4}|\d{1,3})\]?)$/; var c = a.match(b); if (!c) { alert(Lng_CHFORM12); return false } return true }; function mobileCheck(a) { var b = a.replace(/[^\d]/g, ''); if (b.length < 8 && a != "n/a") return false; return true }; function ipAddressCheck(a) { var b = /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/; if (!a.match(b)) { alert(Lng_CHFORM18); return false } return true }; function formatNum(a, b) { var k = Math.pow(10, b); var c = Math.floor(a); var d = a - c + 1; var e = String(Math.round(d * k) / k); var s = e.substr(2); while (s.length < b) { s += "0" } return c + "." + s }; function ltrim(a) { return a.replace(/^\s+/, '') }; function rtrim(a) { return a.replace(/\s+$/, '') }; function trim(a) { return rtrim(ltrim(a)) }; function formatStr() { var d = arguments.length; if (d <= 0) return ""; var e = String(arguments[0]); var f = arguments; e = e.replace(/\{(\d+)\}/g, function(a, b) { var c = parseInt(b); return (!isNaN(c) && (c + 1) < d ? f[c + 1] : a) }); return e };

var Lng_CHFORM21 = "Realex Merchant ID is invalid";
function checkRealexMerchantID(merchantID) {
    var merchantIDRegex = /^([A-Z]|[a-z]|[0-9]){1,50}$/;
    if (!merchantID.match(merchantIDRegex)) {
        alert(Lng_CHFORM21);
        return false;
    }
    return true;
};

var Lng_CHFORM22 = "Realex Sub-Account name is invalid";
function checkRealexSubAccount(subaccount) {
    var subAccountRegex = /^([A-Z]|[a-z]|[0-9]){1,30}$/;
    if (!subaccount.match(subAccountRegex)) {
        alert(Lng_CHFORM22);
        return false;
    }
    return true;
};

Lng_CHFORM23 = "The 2 secret key fields do not match";
function checkRealexSecretKey(secretKey, secretKeyConfirm) {
    if (secretKey != secretKeyConfirm) {
        alert(Lng_CHFORM23);
        return false;
    }
    return true;
}

