﻿function btnSubmit_Click() {
    if (validate_form(document.forms["form1"]))
        document.forms["form1"].submit();
}

var inputs = new Array('iName', 'Naam', 'iMail', 'E-mailadres')

if (!Array.indexOf) {
    Array.prototype.indexOf = function (obj, start) {
        for (var i = (start || 0); i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
    }
}

function validate_iMail(field, alerttxt) {
    with (field) {
        apos = value.indexOf("@");
        dotpos = value.lastIndexOf(".");
        if (apos < 1 || dotpos - apos < 2)
        { alert(alerttxt); return false; }
        else { return true; }
    }
}

function validate_form(thisform) {
    with (thisform) {
        if (validate_iMail(iMail, "Vul een geldig e-mailadres in") == false)
        { iMail.focus(); return false; }
        else { alert("Bedankt voor het inschrijven op onze nieuwsbrief"); return true; }
    }
}

// Defining addEvent function since Internet Explorer does not support the official way of adding events

function addEvent(obj, type, fn) {
    if (obj.addEventListener)
        obj.addEventListener(type, fn, false);
    else if (obj.attachEvent) {
        obj["e" + type + fn] = fn;
        obj[type + fn] = function () {
            obj["e" + type + fn](window.event);
        }
        obj.attachEvent("on" + type, obj[type + fn]);
    }
}

function inputWatermark() {
    if (inputs.length < 2 || inputs.length % 2 != 0) {

    }
    for (i = 0; i < inputs.length; i++) {
        if (i % 2 == 0 && (document.getElementById(inputs[i]) || document.getElementsByName(inputs[i])[0])) {
            var cur = (document.getElementById(inputs[i])) ? (document.getElementById(inputs[i])) : (document.getElementsByName(inputs[i])[0]);
            cur.value = inputs[i + 1];
            addEvent(cur, "focus", onFocusHandler);
            addEvent(cur, "blur", onBlurHandler);
        }
    }
}

function onFocusHandler() {
    var inpname = this.id ? this.id : this.name;
    if (this.value == '' || this.value == inputs[inputs.indexOf(inpname) + 1]) {
        this.value = '';
    }
}

function onBlurHandler() {
    var inpname = this.id ? this.id : this.name;
    if (this.value == '') {
        this.value = inputs[inputs.indexOf(inpname) + 1];
    }
}

function selectSeminar(client, seminarGuid, userId, subscriptionId, title, seminarId) {

    tb_show(title, "SeminarContainer.aspx?seminarId=" + seminarId + "&client=" + client + "&seminarGuid=" + seminarGuid + "&userId=" + userId + "&subscriptionId=" + subscriptionId + "&KeepThis=true&TB_iframe=true&height=552&width=806");

}

addEvent(window, "load", inputWatermark);

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16756145-1']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

