﻿// Nroso Website JavaScript Library


// Checks for enter key and forces a postback to occur with the target event argument to be the same as the actionName parameter
function performPostbackOnEnter(e, actionName) {
    var characterCode;

    if (e && e.which) {
        e = e;
        characterCode = e.which;
    }
    else {
        e = event;
        characterCode = e.keyCode;
    }

    if (characterCode == 13) {
        __doPostBack('__Page', actionName);
        return false;
    }
    else {
        return true;
    }
}

// Finds a server control on the client side by id
function findObjWithClientId(Id) {
    Id = Id.toLowerCase();
    var ctrls = document.getElementsByTagName("body")[0].getElementsByTagName("*");
    for (var count = 0; count < ctrls.length; count++) {
        var index = ctrls[count].id.toLowerCase().indexOf(Id);
        if (index != -1) {
            if ((ctrls[count].id.length - index) == Id.length) {
                return ctrls[count];
            }
        }
    }
    return null;
}

// Forces the page to do a post back
function requestPagePostBack(postbackEvent) {
    __doPostBack('__Page', postbackEvent);
}


// Shows the terms/conditions popup
function showTermsAndConditionsPopup() {
    // Show the terms and conditions popup
    var url = "termsconditionspopup.aspx";
    var newwindow;
    newwindow = window.open(url, 'termsConditionsPopup', 'left=500, top=225, height=700, width=800, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no');
    if (window.focus) { newwindow.focus() }
}

// Shows the Privacy Policy popup
function showPrivacyPolicyPopup() {
    // Show the Privacy Policy popup
    var url = "privacypolicypopup.aspx";
    var newwindow;
    newwindow = window.open(url, 'privacyPolicyPopup', 'left=500, top=225, height=700, width=800, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no');
    if (window.focus) { newwindow.focus() }
}


// Shows the Refund Policy popup
function showRefundPolicyPopup(url) {
    // Show the Refund Policy popup    
    var newwindow;
    newwindow = window.open(url, 'refundPolicyPopup', 'left=500, top=225, height=700, width=800, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no');
    if (window.focus) { newwindow.focus() }
}


// Trim routine for strings
function trimAll(stringToTrim) {
    while (stringToTrim.substring(0, 1) == ' ') {
        stringToTrim = stringToTrim.substring(1, stringToTrim.length);
    }
    while (stringToTrim.substring(stringToTrim.length - 1, stringToTrim.length) == ' ') {
        stringToTrim = stringToTrim.substring(0, stringToTrim.length - 1);
    }
    return stringToTrim;
}




