function subscriptionsClass() {

    if (document.location.href.indexOf('stag.cookiemag') != -1) {

    this.path = "https://admin.buysub.com/servlet/ConvertibleGateway?cds_mag_code=KIE&cds_page_id=61284&cds_response_key_gift=G9BIBAPN&cds_response_key=";
    //https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=53217&cds_response_key=
    this.giftPath = "https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24462&cds_response_key="
    //"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24462&cds_response_key=";
    this.path2 = "https://w1.buysub.com/servlet/GiftsGateway?cds_mag_code=KIE&cds_page_id=54165&cds_response_key=";

    this.keys = new Object();
    this.keys["menuSubscribe"]="I9BNAAYN"; /* nav bar */
    this.keys["headerSubscribe"]="I9BNAAKL"; /* subscription center: cover and text */
    this.keys["headerEnterSubscribe"]="I9BNAADC"; /*header image*/
    this.keys["arrivalPop"]="I9BNAA1S";
    this.keys["exitingPop"]="I9BNAA2T";
    this.keys["promoRailSubscribe"]="I9BNAAWP"; /* y promo rail */
    //this.keys["contactSubscribe"]="IXDN7C04"; /* contact us */
      //this.keys["magSubHome"]="IXDN7C08";
    /*this.keys["includeSubscribe"]="I2DN7SAG"; /* footer subs unit */

    this.keys2 = new Object();
    // create alt keys here. Make sure to comment out the matching key from this.keys.

    this.gift = new Object();
    this.gift["headerGift"]="GXDI7C01";
    this.gift["promoRailGift"]="GXDI7C02";
    this.gift["contactGiftSubscribe"]="GXDI7C03";
    this.gift["giftMagSubHome"]="GXDI7C04";

    this.links = new Object();
    this.links["subscriptionQuestions"]="https://admin.buysub.com/servlet/CSGateway?cds_mag_code=KIE";
    this.links["autosubFooter"]="https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24463&cds_response_key=IYDN71S3";
    this.links["intlMagSubHome"]="https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24463&cds_response_key=IXDN7C09";
    this.links["customerService"]="https://admin.buysub.com/servlet/CSGateway?cds_mag_code=KIE";
    this.links["contactSubscribe"]="https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=53217&cds_response_key=IXDN7C04";
    this.links["magSubHome"]="https://admin.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=53217&cds_response_key=IXDN7C08";

        } else {

    this.path = "https://w1.buysub.com/servlet/ConvertibleGateway?cds_mag_code=KIE&cds_page_id=61284&cds_response_key_gift=G9BIBAPN&cds_response_key=";
    this.giftPath = "https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24462&cds_response_key="
    //"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24462&cds_response_key=";
    this.path2 = "https://w1.buysub.com/servlet/GiftsGateway?cds_mag_code=KIE&cds_page_id=54165&cds_response_key=";

    this.keys = new Object();
    this.keys["menuSubscribe"]="I9BNAAYN"; /* nav bar */
    this.keys["headerSubscribe"]="I9BNAAKL"; /* subscription center: cover and text */
    this.keys["headerEnterSubscribe"]="I9BNAADC"; /*header image*/
    this.keys["arrivalPop"]="I9BNAA1S";
    this.keys["exitingPop"]="I9BNAA2T";
    this.keys["promoRailSubscribe"]="I9BNAAWP"; /* y promo rail */
    //this.keys["contactSubscribe"]="IXDN7C04"; /* contact us */
      //this.keys["magSubHome"]="IXDN7C08";
    /*this.keys["includeSubscribe"]="I2DN7SAG"; /* footer subs unit */

    this.keys2 = new Object();
    // create alt keys here. Make sure to comment out the matching key from this.keys.
      this.keys2["magSubHomeImage"]="X8IIFAYW";
      this.keys2["giftUSMagSubHome"]="X8IIFAYW";

    this.gift = new Object();
    this.gift["headerGift"]="GXDI7C01";
    this.gift["promoRailGift"]="GXDI7C02";
    this.gift["contactGiftSubscribe"]="GXDI7C03";
    this.gift["giftMagSubHome"]="GXDI7C04";

    this.links = new Object();
    this.links["subscriptionQuestions"]="https://w1.buysub.com/servlet/CSGateway?cds_mag_code=KIE";
    this.links["autosubFooter"]="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24463&cds_response_key=IYDN71S3";
    this.links["intlMagSubHome"]="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=24463&cds_response_key=IXDN7C09";
    this.links["customerService"]="https://w1.buysub.com/servlet/CSGateway?cds_mag_code=KIE";
    this.links["contactSubscribe"]="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=53217&cds_response_key=IXDN7C04";
    this.links["magSubHome"]="https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=KIE&cds_page_id=53217&cds_response_key=IXDN7C08";
    }

}


var subscriptions=new subscriptionsClass();

/* Used to specify urls you don't want exit pops opening on. */
function definePopExclusions() {
  if (typeof(SubscriptionPopups) != 'undefined') {
    SubscriptionPopups.suppressUrl(this.path);
    SubscriptionPopups.suppressUrl(this.giftPath);
  }
}

function getLinks(name) {
  if (typeof name == "string") {
            var url = "";
            name=name.substring(name.lastIndexOf('/')+1);
            if (typeof this.keys[name] == "string") {
                url = this.path+this.keys[name];
            } else if (typeof this.keys2[name] == "string") {
                url = this.path2+this.keys2[name];
            } else if (typeof this.gift[name] == "string") {
                url = this.giftPath+this.gift[name];
            } else if (typeof this.links[name] == "string") {
                url = this.links[name];
            }

           if (url != "") {
               window.open(url, 'subsWin', 'top=0,left=0,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes');
           }
   }

   return false;
}

function assignLinks() {
    this.definePopExclusions();
    for (var i=0; i<document.links.length; i++) {
        var name="";
        if (typeof document.links[i].name == "string") {
            /* works only in newer browsers !!! */
            name=document.links[i].name;
        } else {
            /* for older browsers !!! */
            name=document.links[i].href;
        }
        if (name == null) { continue; }
        if (typeof name != "string") { continue; }
        if (name.length < 5) { continue; }
        if (name.indexOf('javascript') != -1) { continue; }
        if (typeof name == "string") {
            name=name.substring(name.lastIndexOf('/')+1);
            if (typeof this.links[name] == "string") {
                document.links[i].href=this.links[name];
                document.links[i].target="_blank";
            } else if (typeof this.keys[name] == "string") {
                document.links[i].href=this.path+this.keys[name];
                document.links[i].target="_blank";
            } else if (typeof this.keys2[name] == "string") {
                document.links[i].href=this.path2+this.keys2[name];
                document.links[i].target="_blank";
            } else if (typeof this.gift[name] == "string") {
                document.links[i].href=this.giftPath+this.gift[name];
                document.links[i].target="_blank";
            }
        } /* end if */
    } /* end for */
} /* end assignLinks */

subscriptionsClass.prototype.definePopExclusions=definePopExclusions;
subscriptionsClass.prototype.assign=assignLinks;
subscriptionsClass.prototype.getlink=getLinks;
