function subscriptionsClass() {
    this.path = "https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=NYR&cds_page_id=26445&cds_response_key=";
    this.giftPath = "https://w1.buysub.com/servlet/GiftsGateway?cds_mag_code=NYR&cds_page_id=26510&cds_response_key=";
    this.path2 = "";

    this.keys = new Object();
    this.keys["headerSubscribe"]="IPDNNC01";
    this.keys["menuSubscribe"]="IPDNNC02";
    //this.keys["arrivalPop"]="IPDNNC05";
	//this.keys["exitingPop"]="IPDNNC06";
    this.keys["contactSubscribe"]="IPDNNC04"; /* contact us */
    //this.keys["promoRailSubscribe"]="IPDNNC03"; /* y promo rail */
    this.keys["footerRightrail"]="";

    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"]="GPDINC01";
    this.gift["promoRailGift"]="GPDINC02"; /* y promo rail */
    this.gift["contactGiftSubscribe"]="GPDINC03";
	
    this.links = new Object();
    this.links["subscriptionQuestions"]="https://w1.buysub.com/servlet/CSGateway?cds_mag_code=NYR";
	this.links["promoRailSubscribe"]="http://m1.buysub.com/webapp/wcs/stores/servlet/PackageAddCmd?catalogId=10101&storeId=10101&categoryId=96831&URL=CartCheckoutView&quantity=1&catEntryId_0=231376&field1_0=1&sourcekey=IVDNZC04";
    this.links["arrivalPop"]="http://m1.buysub.com/webapp/wcs/stores/servlet/PackageAddCmd?catalogId=10101&storeId=10101&categoryId=96831&URL=CartCheckoutView&quantity=1&catEntryId_0=231376&field1_0=1&sourcekey=IVDNZC05";
    this.links["exitingPop"]="http://m1.buysub.com/webapp/wcs/stores/servlet/PackageAddCmd?catalogId=10101&storeId=10101&categoryId=96831&URL=CartCheckoutView&quantity=1&catEntryId_0=231376&field1_0=1&sourcekey=IVDNZC06";

}

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; 
