﻿function onSignMeUp() {
    var url = window.location.toString();
    url = url.toUpperCase();
    if (endsWith(url, "/guest/register.aspx")) {
        var tb = document.getElementById("ctl00_cphContent_RegistrationWizard_ctl08_txtCouponCode");
        if (tb != null) {
            tb.value = "LIFETIME";
        }
        var lb = document.getElementById("ctl00_cphContent_RegistrationWizard_ctl08_lbSpecialOffer");
        if (lb != null) {
            lb.style.display = "none";
        }
        else {
            window.location = "/guest/register.aspx?cc=LIFETIME";
        }
    }
    else {
        window.location = "/guest/register.aspx?cc=LIFETIME";
    }
}

// Determines if a string has a specified suffix as 
// the last non white-space characters regardless of case.
function endsWith(myString, suffix) {
    
    // Remove any trailing white spaces.
    myString = myString.trimEnd();

    // Set to lower case.
    myString = myString.toLowerCase();

    // Determine if the string ends with the specified suffix.
    var isTxt = myString.endsWith(suffix.toString());

    if (isTxt === true) {
        return true;
    }
    else {
        return false;
    }
}
