﻿var isClientLoginFormActive = false;
function hlClientLoginForm_Click() {
    if (isContactFormActive) {
        new Effect.Fade('divClientLogin', {
            duration: 0.6
        });
        new Effect.Fade('divLightBox', {
            duration: 0.6
        });
        document.getElementById("divLightBox").style.zIndex = 1000;
        isContactFormActive = false;
    } else {
    new Effect.Appear('divClientLogin', {
            duration: 0.6
        });
        new Effect.Appear('divLightBox', {
            duration: 0.6
        });
        document.getElementById("divLightBox").style.zIndex = 19000;
        isContactFormActive = true;
    }
    return false;
}

function btnClientLogin_Click() {
    document.form1.action = "http://" + document.form1.loginCMS$Domain.value + "/Admin/Login.aspx"
}

var isContactFormActive = false;
function hlContactForm_Click() {
    document.getElementById("divLightBox").style.zIndex = 1000;
    if (isContactFormActive) {
        new Effect.Morph('divContactUs', {
            style: { height: '36px' },
            duration: 0.6
        });
        new Effect.Fade('divLightBox', {
            duration: 0.6 
        });
        isContactFormActive = false;
    } else {
        new Effect.Morph('divContactUs', {
            style: { height: '543px' },
            duration: 0.6
        });
        new Effect.Appear('divLightBox', {
            duration: 0.6
        });
        isContactFormActive = true;
    }
    return false;
}

function submit_form() {
    if (typeof (validateCaptchaAndSubmit) != 'undefined') {
        validateCaptchaAndSubmit();
    } else {
        check_webtolead_fields();
    }
}
function check_webtolead_fields() {
    if (document.getElementById('bool_id') != null) {
        var reqs = document.getElementById('bool_id').value;
        bools = reqs.substring(0, reqs.lastIndexOf(';'));
        var bool_fields = new Array();
        var bool_fields = bools.split(';');
        nbr_fields = bool_fields.length;
        for (var i = 0; i < nbr_fields; i++) {
            if (document.getElementById(bool_fields[i]).value == 'on') {
                document.getElementById(bool_fields[i]).value = 1;
            }
            else {
                document.getElementById(bool_fields[i]).value = 0;
            }
        }
    }
    if (document.getElementById('req_id') != null) {
        var reqs = document.getElementById('req_id').value;
        reqs = reqs.substring(0, reqs.lastIndexOf(';'));
        var req_fields = new Array();
        var req_fields = reqs.split(';');
        nbr_fields = req_fields.length;
        var req = true;
        for (var i = 0; i < nbr_fields; i++) {
            if (document.getElementById(req_fields[i]).value.length <= 0 || document.getElementById(req_fields[i]).value == 0) {
                req = false;
                break;
            }
        }
        if (req) {
            document.WebToLeadForm.submit();
            return true;
        }
        else {
            alert('Please provide all the required fields');
            return false;
        }
        return false
    }
    else {
        document.WebToLeadForm.submit();
    }
}
function validateEmailAdd() {
    if (document.getElementById('webtolead_email1').value.length > 0) {
        if (document.getElementById('webtolead_email1').value.match(/^\w+(['\.\-\+]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/) == null) {
            alert('Not a valid email address');
        }
    }
    if (document.getElementById('webtolead_email2').value.length > 0) {
        if (document.getElementById('webtolead_email2').value.match(/^\w+(['\.\-\+]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/) == null) {
            alert('Not a valid email address');
        }
    }
}
