﻿function $$(elementId) {
    return document.getElementById(elementId);
}

function blockUI(element) {
    var obj = $(element);
    var offset = obj.offset();
    var iX = Math.floor((obj.width() - 35) / 2) + offset.left;
    var iY = Math.floor((obj.height() - 35) / 2) + offset.top;

    var ovrl = $('#ShowAnimation');
    ovrl.css({ top: iY, left: iX });
    ovrl.show();
}

function unblockUI() {
    $('#ShowAnimation').hide();
}

function ShowMenu(id, bShow) {
    var el = document.getElementById(id);
    if (bShow)
        el.style.display = "block";
    else
        el.style.display = "none";

}

function KeyDownHandler(sName) {
    // process only the Enter key
    if (event.keyCode == 13) {
        // cancel the default submit
        event.returnValue = false;
        event.cancel = true;
        // submit the form by programmatically clicking the specified button
        document._ctl0[sName].click();
    }
}

function ValidateDropDowns() {
    var i, f;
    f = document.forms[1];
    for (i = 3; i < aDropdowns.length; i += 2) {
        if (f[aDropdowns[i]].selectedIndex == 0) {
            alert("Please select " + aDropdowns[i - 1]);
            return false;
        }
    }
}

function ValidateDropDowns1() {
    var i, f;
    f = document.forms[0];
    for (i = 3; i < aDropdowns.length; i += 2) {
        if (f[aDropdowns[i]].selectedIndex == 0) {
            alert("Please select " + aDropdowns[i - 1]);
            return false;
        }
    }
}


function serializeForm(form) {
    var sData = "";
    $('input', form).each(function() {
        var type = this.type;

        // it's ok to reset the value attr of text inputs,
        // password inputs, and textareas
        if (type == 'text' || type == 'password' || type == 'hidden') {
            sData += "&" + this.name + "=" + escape(this.value);
        }
        else if (type == 'checkbox' || type == 'radio') {
            if (this.checked) {
                sData += "&" + this.name + "=" + escape(this.value);
            }
        }
    });
    $('textarea', form).each(function() {
        sData += "&" + this.name + "=" + escape(this.value);
    });
    $('select', form).each(function() {
        sData += "&" + this.name + "=" + escape($(this).val());
    });
    return sData;
}
