﻿function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object') {
        if (navigator.appName.indexOf("Netscape") > (-1)) {
            if (e.keyCode == 13) {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}

function clickOnce(btn, msg) {
    // Test if we are doing a validation
    if (typeof (Page_ClientValidate) == 'function') {
        // if we are doing a validation, return if it's false
        if (Page_ClientValidate() == false) {
            return false;
        }
    }

    // Ensure that the button is not of type "submit"
    if (btn.getAttribute('type') == 'button') {
        // The msg attibute is absolutely optional
        // msg will be the text of the button while it's disabled
        if (!msg || (msg == 'undefined')) {
            msg = 'Loading...';
        }

        btn.value = msg;

        // The magic :D
        btn.disabled = true;
        btn.style.cursor = 'wait';
        document.body.style.cursor = 'wait';
        //btn.style.backgroundImage = 'url(images/submit_order.jpg)';
    }

    return true;
}

function checkoutClickOnce(btn) {
    // Test if we are doing a validation
    if (typeof (Page_ClientValidate) == 'function') {
        // if we are doing a validation, return if it's false
        if (Page_ClientValidate() == false) {
            return false;
        }
    }

    // Ensure that the button is not of type "submit"
    if (btn.getAttribute('type') == 'button') {
        // The msg attibute is absolutely optional
        // msg will be the text of the button while it's disabled
        //        if (!msg || (msg == 'undefined')) {
        //            msg = 'Loading...';
        //        }

        //        btn.value = msg;

        // The magic :D
        btn.disabled = true;
        btn.style.cursor = 'wait';
        document.body.style.cursor = 'wait';
        btn.style.outline = 'none';
        btn.style.backgroundImage = 'url(images/submit_loading.jpg)';
    }

    return true;
}

function resetDotNetScrollPosition() {
    var scrollX = document.getElementById('__SCROLLPOSITIONX');
    var scrollY = document.getElementById('__SCROLLPOSITIONY');

    if (scrollX != null && scrollY != null) {
        scrollX.value = 0;
        scrollY.value = 0;
    }
}

function popup(mylink, windowname) {
    if (!window.focus) return true;
    
    var href;
    if (typeof (mylink) == 'string')
        href = mylink;
    else
        href = mylink.href;

    window.open(href, windowname, 'height=550, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=yes');
    
    return false;
}

