﻿if (!Application) var Application = {};
if (!Application.Page) Application.Page = {};
if (!Application.Page.ClientCAPTCHA) {
    Application.Page.ClientCAPTCHA = {
        sessionIDString: '',
        captchaURL: [],
        getRandomLetter: function () { return String.fromCharCode(Application.Page.ClientCAPTCHA.getRandom(65, 90)); },
        getRandom: function (lowerBound, upperBound) { return Math.floor((upperBound - lowerBound + 1) * Math.random() + lowerBound); },
        getSID: function () {
            if (Application.Page.ClientCAPTCHA.sessionIDString.length <= 0) {
                var tempSessionIDString = '';
                for (var i = 0; i < 32; ++i) tempSessionIDString += Application.Page.ClientCAPTCHA.getRandomLetter();
                Application.Page.ClientCAPTCHA.sessionIDString.length = tempSessionIDString;
            }
            return Application.Page.ClientCAPTCHA.sessionIDString;
        },
        getURL: function () {
            if (Application.Page.ClientCAPTCHA.captchaURL.length <= 0) {
                var tempURL = 'http://www.onelinerbooks.nl/ezee/admin/resources/form_designs/captcha/index.php?c=';

                tempURL += Application.Page.ClientCAPTCHA.getRandom(1, 1000);
                tempURL += '&ss=' + Application.Page.ClientCAPTCHA.getSID();
                Application.Page.ClientCAPTCHA.captchaURL.push(tempURL);
            }
            return Application.Page.ClientCAPTCHA.captchaURL;
        }
    }
}

var temp = Application.Page.ClientCAPTCHA.getURL();
for (var i = 0, j = temp.length; i < j; i++) document.write('<img src="' + temp[i] + '" alt="img' + i + '" />');

function CheckMultiple1(frm, name) {
    for (var i = 0; i < frm.length; i++) {
        fldObj = frm.elements[i];
        fldId = fldObj.id;
        if (fldId) {
            var fieldnamecheck = fldObj.id.indexOf(name);
            if (fieldnamecheck != -1) {
                if (fldObj.checked) {
                    return true;
                }
            }
        }
    }
    return false;
}
function CheckForm1(f) {
    var email_re = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
    if (!email_re.test(f.email.value)) {
        alert("Vul jouw e-mailadres in.");
        f.email.focus();
        return false;
    }

    if (f.captcha.value == "") {
        alert("Voer de getoonde veiligheidscode in");
        f.captcha.focus();
        return false;
    }

    return true;
}
