You are on page 1of 24

var APS = APS || {};

function getVar(key) {
var val;
eval("if(typeof " + key + " != 'undefined') val = " + key);
try {
if (typeof top[key] != "undefined") {
val = top[key]
}
} catch (e) {}
return val
}
function setVar(key, val) {
eval("if(typeof " + key + " != 'undefined') var " + key + ";");
eval(key + "= '" + val + "';");
try {
top[key] = val
} catch (e) {}
}
function getAdxUID() {
var c = null;
try {
if (window.frameElement && window.frameElement.id.lastIndexOf("_") != -1
) {
c = window.frameElement.id.substring(window.frameElement.id.lastInde
xOf("_") + 1)
} else {
c = getVar("uid")
}
} catch (a) {
try {
c = getVar("uid")
} catch (b) {}
}
return c
}
var layerid = 0;
var adxUID = getAdxUID();
APS.DealsHandler = function (j) {
var f = this;
this.partner = j.partner;
this.cityStr = j.city;
this.city = this.cityStr.toLowerCase();
this.cid = "";
this.curDeal;
this.share = null;
this.util = new APS.Util();
this.dealsbasepath = "http://pilot2.socialads.yahoo.com/ads/serveDeal.php";
if (j.datasystem == "static" || j.datasystem == "staticraw") {
this.dealsbasepath = "http://d.yimg.com/qc/deals"
}
this.dealsconf = "";
this.curArea = null;
this.dr = null;
this.useBrowserTime = true;
this.cmpid = j.cmpid;
this.currentServerTime = Math.floor(new Date().getTime() / 1000);
this.serverTimeMS = this.currentServerTime * 1000;
this.serverTimeDateObj = new Date(Math.floor(this.serverTimeMS));
this.localDateObj = new Date();

this.initLocalTimeMS = this.localDateObj.getTime();
this.numDeals = 0;
this.displayNumDeals = 1;
this.adx_data_template = "apsdeals,aidxx,C=" + this.cmpid + ",P=xx,A=na,L=xx
,K=xx";
this.adx_data = this.adx_data_template;
this.tracker = new APS.Track(this.adx_data);
this.dealsLoadStatus = false;
this.endTimeObj = null;
this.timeOutRef = null;
this.imgNum = 0;
this.delayLoad = true;
this.clickURL = "";
this.defaultLandingUrl = "";
this.tlNeeded = false;
this.imgBuf = false;
this.imgElementsCreated = [];
this.divStaticRef;
this.divDynRef;
this.tlElem = [];
this.defaultImgUrl = "";
this.adsystem = "ruby";
this.btlist = [];
this.randomize = false;
this.currentDealsList = [];
if (j.randomize != undefined && j.randomize != null) {
this.randomize = j.randomize
}
this.conf = new Object();
this.conf.currency = "";
if (j.title_id != undefined) {
this.conf.title_id = j.title_id
}
if (j.title_length != undefined) {
this.conf.title_length = j.title_length
}
if (j.desc_id != undefined) {
this.conf.desc_id = j.desc_id
}
if (j.desc_length != undefined) {
this.conf.desc_length = j.desc_length
}
if (j.orig_prc_id != undefined) {
this.conf.orig_prc_id = j.orig_prc_id
}
if (j.discounted_prc_id != undefined) {
this.conf.discounted_prc_id = j.discounted_prc_id
}
if (j.discount_percent_id != undefined) {
this.conf.discount_percent_id = j.discount_percent_id
}
if (j.vendor_id != undefined) {
this.conf.vendor_id = j.vendor_id
}
if (j.vendor_length != undefined) {
this.conf.vendor_length = j.vendor_length
}
if (j.city_id != undefined) {
this.conf.city_id = j.city_id
}

if (j.currency != undefined) {
this.conf.currency = j.currency
}
if (j.img_id != undefined) {
this.conf.img_id = j.img_id
}
if (j.img_container_id != undefined) {
this.conf.img_container_id = j.img_container_id
}
if (j.imgsize != undefined) {
this.conf.imgsize = j.imgsize
}
if (j.bufimg_id != undefined) {
this.conf.bufimg_id = j.bufimg_id
}
if (j.multibind != undefined) {
this.conf.multibind = j.multibind
}
if (j.num_products != undefined) {
this.conf.num_products = j.num_products;
this.displayNumDeals = this.conf.num_products
}
if (j.link_id_list != undefined) {
this.conf.link_id_list = j.link_id_list
}
if (j.samecategory != undefined) {
this.conf.samecategory = j.samecategory ? 1 : 0
}
if (j.mvnext_id != undefined) {
this.conf.mvnext_id = j.mvnext_id;
document.getElementById(this.conf.mvnext_id).onclick = function () {
f.handleMoveNext()
}
}
if (j.mvprev_id != undefined) {
this.conf.mvprev_id = j.mvprev_id;
document.getElementById(this.conf.mvprev_id).onclick = function () {
f.handleMovePrev()
}
}
if (j.adsystem != undefined) {
this.adsystem = j.adsystem
}
if (j.adsystem == "ruby" && j.ruby_clickurl != "${CLICKURL}") {
this.clickURL = j.ruby_clickurl
} else {
if (j.adsystem == "apt" && j.apt_clickurl != "${CLICKURL}") {
this.clickURL = j.apt_clickurl
} else {
if (j.adsystem == "rmx" && j.rmx_clickurl != "${CLICKURL}") {
this.clickURL = j.rmx_clickurl
}
}
}
if (j.default_landingurl != undefined) {
this.defaultLandingUrl = j.default_landingurl
}
if (j.default_imgurl != undefined) {

this.defaultImgUrl = j.default_imgurl
}
if (j.tlcounter != undefined) {
this.tlNeeded = j.tlcounter
}
if (j.img_buf != undefined) {
this.imgBuf = j.img_buf
}
if (j.staticad_id != undefined) {
this.divStaticRef = document.getElementById(j.staticad_id)
}
if (j.dynad_id != undefined) {
this.divDynRef = document.getElementById(j.dynad_id)
}
if (j.tlhr != undefined) {
this.tlElem.tlhr = j.tlhr
}
if (j.tlmin != undefined) {
this.tlElem.tlmin = j.tlmin
}
if (j.tlsec != undefined) {
this.tlElem.tlsec = j.tlsec
}
var c = "";
var k = "";
if (j.adsystem == "rmx") {
if (j.rmxqs != undefined && j.rmxqs != "" && j.rmxqs != "${QUERY_STRING}
") {
var g = j.rmxqs.split("&");
for (var e = 0; e < g.length; e++) {
var h = g[e];
if (h.indexOf("category=") > -1) {
this.publisherCategory = decodeURIComponent(h.split("=")[1])
} else {
if (h.indexOf("ybt=") > -1) {
c = decodeURIComponent(h.split("=")[1])
} else {
if (h.indexOf("ycbt=") > -1) {
k = decodeURIComponent(h.split("=")[1])
} else {
if (h.indexOf("city=") > -1) {
var d = decodeURIComponent(h.split("=")[1]);
this.city = APS.advCityList[APS.publisherCityLis
t[d.toLowerCase()]].toLowerCase();
this.cityStr = this.city
}
}
}
}
}
}
} else {
if (j.adsystem == "ruby") {
if (j.bt1 != undefined && j.bt1 != "%bt2set_noenc%") {
c = decodeURIComponent(j.bt1)
}
if (j.bt2 != undefined && j.bt2 != "%custbtseg%") {
k = decodeURIComponent(j.bt2)
}
}

}
if (c != undefined && c != "") {
this.btlist = c.split(";").slice(0, 50)
}
if (k != undefined && k != "") {
this.btlist = this.btlist.concat(k.split(";").slice(0, 50))
}
this.dealsconf = "?partner=" + j.partner + "&city=" + this.city;
if (j.alldeals != undefined && j.alldeals) {
this.dealsconf += "&alldeals=1"
} else {
if (j.num_products != undefined && j.num_products > 1) {
this.dealsconf += "&numdeals=" + this.conf.num_products;
if (j.samecategory != undefined && j.samecategory == 1) {
this.dealsconf += "&sc=" + this.conf.samecategory
}
}
}
var a = "";
if (j.tseg != undefined && j.tseg != "") {
a = j.tseg;
this.dealsconf += "&tsid=" + j.tseg
}
if (this.btlist.length > 0) {
this.dealsconf += "&bt=" + this.btlist.join(";")
}
if (j.datasystem == "static") {
this.dealsconf = "/" + j.partner + "/approved/" + j.partner + "_" + this
.city
} else {
if (j.datasystem == "staticraw") {
this.dealsconf = "/" + j.partner + "/raw/" + j.partner + "?"+ Math.r
andom();
}
}
// this.tracker.trackBeapEvent("", "ai", "adload_tsid-" + a);
var b = this.dealsbasepath + this.dealsconf;
this.dr = APS.PropertyReaderFactory.getInstance(APS.PropertyReaderFactory.DE
ALS_READER, b, this.dealsloaded, this, this.partner);
this.needAutoCarousel = false;
if (j.autoCarousel != undefined) {
this.needAutoCarousel = j.autoCarousel
}
};
APS.DealsHandler.prototype.dealsloaded = function (a, c) {
this.dealsLoadStatus = c;
if (this.dr == null) {
this.dr = a
}
var b = this;
if (this.dealsLoadStatus) {
this.numDeals = this.dr.getNumDeals();
if (this.numDeals > 0) {
this.displayNextPrev(this.numDeals);
this.displayAd(true);
this.dr.resetRecordNum();
if (this.randomize) {
this.dr.randomize()
}
this.curDeal = this.dr.getCurrent();

setTimeout(function () {
b.delayedLoad1()
}, 500);
this.displayDeal(this.curDeal);
if (this.needAutoCarousel) {
this.startAutoCarousal()
}
} else {
this.displayAd(false);
setTimeout(function () {
b.delayedLoad1()
}, 500)
}
} else {
this.displayAd(false);
setTimeout(function () {
b.delayedLoad1()
}, 500)
}
};
APS.DealsHandler.prototype.displayNextPrev = function (a) {
if (a > 1) {
if (this.conf.mvnext_id != undefined && this.conf.mvnext_id) {
document.getElementById(this.conf.mvnext_id).style.display = "block"
;
document.getElementById(this.conf.mvprev_id).style.display = "block"
;
if (this.needAutoCarousel) {
this.startAutoCarousal()
}
}
} else {
if (this.conf.mvnext_id != undefined && this.conf.mvnext_id) {
document.getElementById(this.conf.mvnext_id).style.display = "none";
document.getElementById(this.conf.mvprev_id).style.display = "none"
}
}
};
APS.DealsHandler.prototype.displayAd = function (a) {
if (a) {
this.divDynRef.style.display = "block";
this.divStaticRef.style.display = "none"
} else {
this.divDynRef.style.display = "none";
this.divStaticRef.style.backgroundImage = "url('" + this.defaultImgUrl +
"')";
this.divStaticRef.style.display = "block"
}
};
APS.DealsHandler.prototype.formatDateMonth = function (a) {
return (a <= 9) ? "0" + a : a
};
APS.DealsHandler.prototype.startCounter = function (b) {
if (this.tlNeeded) {
var a = this;
this.endTimeObj = b;
if (this.tlNeeded) {
this.timeOutRef = setInterval(function () {
a.updateCounter()
}, 1000);

a.updateCounter()
}
}
};
APS.DealsHandler.prototype.stopCounter = function () {
if (this.tlNeeded) {
if (this.timeOutRef != null) {
clearInterval(this.timeOutRef)
}
var a = document.getElementById(this.tlElem.tlhr);
var b = document.getElementById(this.tlElem.tlmin);
var c = document.getElementById(this.tlElem.tlsec);
a.innerHTML = "";
b.innerHTML = "";
c.innerHTML = ""
}
};
APS.DealsHandler.prototype.updateCounter = function () {
if (this.tlNeeded) {
var d = this.util.getTimeLeft(this.endTimeObj, this.serverTimeMS, this.i
nitLocalTimeMS);
var a = document.getElementById(this.tlElem.tlhr);
var b = document.getElementById(this.tlElem.tlmin);
var c = document.getElementById(this.tlElem.tlsec);
if (d.valid > 0) {
a.innerHTML = d.h;
b.innerHTML = d.m;
c.innerHTML = d.s
} else {
a.innerHTML = "00";
b.innerHTML = "00";
c.innerHTML = "00"
}
}
};
APS.DealsHandler.prototype.displayDeal = function (r) {
this.currentDealsList = [];
this.currentDealsList.push(r);
var E = r.getImage.call(r);
var D = r.getTitle();
var w = r.getDescription();
if (this.conf.title_length != undefined && D.length > this.conf.title_length
) {
D = D.substring(0, this.conf.title_length) + "..."
}
if (this.conf.desc_length != undefined && w.length > this.conf.desc_length)
{
w = w.substring(0, this.conf.desc_length) + "..."
}
var t = r.getOriginalPrice();
var v = r.getListingPrice();
var C = r.getListingId();
var g = r.getDiscount();
var z = r.getArea();
var A = r.getVendor();
var d = r.getProduct();
var u;
var s = "",
m = "";
var x, a;

if (this.conf.imgsize != undefined && this.conf.imgsize != "") {


if (E.lastIndexOf("_") > -1) {
var o = E.substring(0, E.lastIndexOf("_"));
var e = E.substring(E.lastIndexOf("_"));
var h = e.substring(e.indexOf("."));
E = o + "_" + this.conf.imgsize + h
}
}
var c = "";
for (var f = 0; f < this.displayNumDeals; f++) {
if (this.conf.multibind) {
c = "_" + f;
if (f > 0) {
r = this.dr.getNext(this.curArea);
this.currentDealsList.push(r);
this.curDeal = r;
E = r.getImage.call(r);
D = r.getTitle();
w = r.getDescription();
if (this.conf.title_length != undefined && D.length > this.conf.
title_length) {
D = D.substring(0, this.conf.title_length) + "..."
}
if (this.conf.desc_length != undefined && w.length > this.conf.d
esc_length) {
w = w.substring(0, this.conf.desc_length) + "..."
}
t = r.getOriginalPrice();
v = r.getListingPrice();
C = r.getListingId();
g = r.getDiscount();
z = r.getArea();
A = r.getVendor();
d = r.getProduct()
}
}
if (this.imgElementsCreated.length <= f) {
this.imgElementsCreated[f] = false
}
if (!this.imgElementsCreated[f]) {
x = document.createElement("img");
x.id = this.conf.img_container_id + "_0" + c;
x.style.display = "none";
this.conf["img_id" + c] = x.id;
if (this.imgBuf) {
a = document.createElement("img");
a.id = this.conf.img_container_id + "_1" + c;
a.style.display = "none";
this.conf["bufimg_id" + c] = a.id
}
}
if (this.imgNum == 0) {
s = this.conf["img_id" + c];
m = s;
if (this.conf["bufimg_id" + c] != undefined) {
m = this.conf["bufimg_id" + c]
}
} else {
s = this.conf["img_id" + c];
m = s;

if (this.conf["bufimg_id" + c] != undefined) {
s = this.conf["bufimg_id" + c];
m = this.conf["img_id" + c]
}
}
if (!this.imgElementsCreated[f]) {
u = x
} else {
u = document.getElementById(s)
}
if (u.src != E) {
u.src = E;
u.style.display = ""
}
if (!this.imgElementsCreated[f]) {
document.getElementById(this.conf.img_container_id + c).appendChild(
x);
if (this.imgBuf) {
document.getElementById(this.conf.img_container_id + c).appendCh
ild(a)
}
this.imgElementsCreated[f] = true
}
if (this.imgBuf) {
this.imgNum = this.imgNum ? this.imgNum - 1 : this.imgNum + 1;
var l = document.getElementById(m);
if (l != undefined) {
u.style.display = "";
l.style.display = "none"
}
}
var k = A;
if (this.conf.vendor_length != undefined && A.length > this.conf.vendor_
length) {
k = A.substring(0, this.conf.vendor_length) + ".."
}
if (document.getElementById(this.conf.title_id + c) != undefined) {
document.getElementById(this.conf.title_id + c).innerHTML = D
}
if (document.getElementById(this.conf.desc_id + c) != undefined) {
document.getElementById(this.conf.desc_id + c).innerHTML = w
}
if (document.getElementById(this.conf.orig_prc_id + c) != undefined) {
document.getElementById(this.conf.orig_prc_id + c).innerHTML = this.
conf.currency + t
}
if (document.getElementById(this.conf.discounted_prc_id + c) != undefine
d) {
document.getElementById(this.conf.discounted_prc_id + c).innerHTML =
this.conf.currency + v
}
if (document.getElementById(this.conf.discount_percent_id + c) != undefi
ned) {
document.getElementById(this.conf.discount_percent_id + c).innerHTML
= g
}
if (document.getElementById(this.conf.vendor_id + c) != undefined) {
document.getElementById(this.conf.vendor_id + c).innerHTML = k
}
if (document.getElementById(this.conf.city_id + c) != undefined) {

document.getElementById(this.conf.city_id + c).innerHTML = this.city


Str
}
var n;
if (this.conf.link_id_list != undefined) {
var j = this.conf.link_id_list;
for (var p = 0; p < j.length; p++) {
n = document.getElementById(j[p]["id"] + c);
if (n != undefined) {
n.setAttribute("href", this.getBeacon(r.getField(j[p]["link"
])));
n.innerHTML = r.getField(j[p]["text"])
}
}
}
var i = r.getDealDates();
var y = i.ed
}
var q = this;
if (!this.delayLoad) {
var B = this.dr.lookupNext();
if (this.imgBuf) {
var b = B.getImage.call(B);
if (l != undefined) {
l.src = b
}
}
} else {
setTimeout(function () {
q.delayedLoad2()
}, 2000);
this.delayLoad = false
}
};
APS.DealsHandler.prototype.delayedLoad1 = function () {
var c = "";
var a = "";
if (this.dealsLoadStatus && this.currentDealsList.length > 0) {
for (var f = 0; f < this.currentDealsList.length; f++) {
if (f == 0) {
a = this.currentDealsList[f].getListingId();
c += a
} else {
c += "-" + this.currentDealsList[f].getListingId()
}
}
var e = this.curDeal.getField("log_data");
var b = this.curDeal.getField("model");
if (b == "" || b == undefined) {
b = "random"
}
if (e != undefined && e != null && e != "") {
var d = this.adx_data_template.replace("aidxx", e);
this.tracker.parseAdxData(d)
}
this.tracker.trackBeapEvent("", "ai", "viewdeal_" + a + "_" + this.city
+ "_" + b + "_na_" + this.partner)
} else {
this.tracker.trackBeapEvent("", "ai", "viewdealdef_")
}

};
APS.DealsHandler.prototype.delayedLoad2 = function () {
var b = "",
a = "";
if (this.imgNum == 0) {
b = this.conf.img_id;
a = b;
if (this.conf.bufimg_id != undefined) {
a = this.conf.bufimg_id
}
} else {
b = this.conf.img_id;
a = b;
if (this.conf.bufimg_id != undefined) {
b = this.conf.bufimg_id;
a = this.conf.img_id
}
}
var g = document.getElementById(a);
var d = this.dr.lookupNext();
var f = d.getImage.call(d);
if (g != undefined) {
if (this.conf.imgsize != undefined && this.conf.imgsize != "") {
if (f.lastIndexOf("_") > -1) {
var h = f.substring(0, f.lastIndexOf("_"));
var e = f.substring(f.lastIndexOf("_"));
var c = e.substring(e.indexOf("."));
f = h + "_" + this.conf.imgsize + c
}
}
g.src = f
}
};
APS.DealsHandler.prototype.handleMoveNext = function () {
this.curDeal = this.dr.getNext(this.curArea);
this.displayDeal(this.curDeal)
};
APS.DealsHandler.prototype.handleMovePrev = function () {
this.curDeal = this.dr.getPrevious(this.curArea);
this.displayDeal(this.curDeal)
};
APS.DealsHandler.prototype.handleAdClick = function (a) {
var d;
var g;
var c = null;
if (a == undefined || a == null) {
c = this.curDeal
} else {
c = this.currentDealsList[a]
}
if (c != null) {
this.city = c.getField("city");
if (this.city == undefined || this.city == null) {
this.city = "all";
}
var e = c.getField("log_data");
var b = c.getField("model");
if (b == "" || b == undefined) {
b = "random"
}

var f = c.getListingId();
g = "click_" + f + "_" + this.city + "_" + b + "_na_" + this.partner;
d = c.getBuyLink()
} else {
g = "clickdef_";
d = this.defaultLandingUrl
}
d = this.getBeacon(d, g, "click_");
window.open(d, "winsd");
this.tracker.trackBeapEvent("", "ai", g)
};
APS.DealsHandler.prototype.getBeacon = function (d, c, a) {
var b;
b = d;
if (this.clickURL != "" && this.adsystem == "ruby") {
b = this.clickURL + "/*" + b
} else {
if (this.clickURL != "" && this.adsystem == "rmx") {
b = this.clickURL + encodeURIComponent(b)
} else {
if (this.clickURL != "" && this.adsystem == "apt") {
b = this.clickURL + b
}
}
}
return b
};
APS.DealsHandler.prototype.autoCarousalIntRef = null;
APS.DealsHandler.prototype.autoCarousal = false;
APS.DealsHandler.prototype.startAutoCarousal = function () {
if (this.numDeals > 1 && !this.autoCarousal && this.autoCarousalIntRef == nu
ll) {
var a = this;
this.autoCarousalIntRef = setInterval(function () {
a.handleMoveNext()
}, 25000);
this.autoCarousal = true
}
};
APS.DealsHandler.prototype.stopAutoCarousal = function () {
this.autoCarousal = false;
if (this.autoCarousalIntRef != null) {
clearInterval(this.autoCarousalIntRef);
this.autoCarousalIntRef = null
}
};
APS.Util = function () {};
APS.Util.prototype.getUrlParam = getVar;
APS.Util.prototype.setUrlParam = setVar;
APS.Util.prototype.getCurrentChannel = function () {
var a;
try {
a = "dummy.yahoo.com"
} catch (b) {
a = "undefined"
}
return (a)
};
APS.Util.prototype.getTrackingParams = function (h, d, j) {
var f;

var e;
var g = getVar("socad_uid");
if (g == undefined || g == null) {
g = this.getUserId()
}
var b = "";
var a = "";
var i = "";
var c = new Array();
c.ch = this.getCurrentChannel();
if (j) {
c.ouid = (f == undefined) ? g : f;
c.suid = g;
c.sch = c.ch
} else {
c.uid = g;
if (f != undefined && f != "") {
c.ouid = f;
c.suid = e
}
c.sch = a == undefined ? "" : a
}
c.dch = h;
c.destChnl = h;
c.label = (!d) ? "undefined" : d;
return c
};
APS.Util.prototype.getHashValue = function (d) {
var f = ["a", "b", "c", "1", "d", "9", "e", "f", "g", "5", "h", "i",
", "k", "3", "l", "m", "n", "o", "8", "p", "q", "7", "r", "s", "t", "u",
", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
", "M", "4", "N", "O", "P", "Q", "R", "S", "2", "T", "U", "V", "W", "X",
"];
var a = 61;
var g;
var c = "";
var b;
var e = d;
while (e > a) {
b = Math.floor(e / a);
g = e - b * a;
if (g > 61 || g < 0) {
g = Math.floor(Math.abs(g) / 62)
}
c += "" + f[g];
e = b
}
return (c + f[e])
};
APS.Util.prototype.getUserId = function () {
var a;
a = getVar("socad_uid");
if (a == undefined || a == null) {
a = "" + this.getHashValue(Math.floor(Math.random() * 1000000) *
0000000 + Number(new Date()));
setVar("socad_uid", a)
}
return a
};
APS.Util.prototype.beapFormat = function (a, b) {

"0",
"v",
"K",
"Y",

"j
"6
"L
"Z

1000000

return this.beap_clean(a) + "$" + this.beap_clean(b)


};
APS.Util.prototype.beap_clean = function (a) {
return ((a) ? escape(a) : "")
};
APS.Util.prototype.sendRequest = function (b, a) {
var c = new Image();
c.onload = c.onerror = function () {
if (a) {}
c.onload = c.onerror = null;
c = null
};
c.src = b
};
APS.Util.prototype.getAdxUID = getAdxUID;
APS.Util.prototype.getNetworkProperty = function (c, b, e, d) {
var g = APS.PropertyReaderFactory.getInstance(APS.PropertyReaderFactory.SOCA
D_CONFIG_READER);
var f = null;
var a = "";
if (d != null) {
if (e != undefined && e != null && e != "") {
a = e + "." + d + "." + c;
f = this.getOverriddenNetworkProperty(g, b, a);
if (f == null) {
a = e + ".default." + c;
f = this.getOverriddenNetworkProperty(g, b, a)
}
}
if (f == null) {
a = d + "." + c;
f = this.getOverriddenNetworkProperty(g, b, a)
}
if (f == null) {
a = "default." + c;
f = this.getOverriddenNetworkProperty(g, b, a)
}
} else {
f = this.getOverriddenNetworkProperty(g, b, c)
}
return f
};
APS.Util.prototype.getOverriddenNetworkProperty = function (d, b, a) {
var c;
if (b != null && b[a] != undefined) {
c = b[a]
} else {
c = d.get(a)
}
return c
};
APS.Util.prototype.escapeHtmlEntities = function (a) {
a = a.split('"').join("&quot;");
a = a.split("<").join("&lt;");
a = a.split(">").join("&gt;");
return a
};
APS.Util.prototype.openPopup = function (a, b) {
if (b == undefined || b == null) {
b = "_blank"

}
window.open(a, b, "height=500,width=800,toolbar=no,scrollbars=yes,resizable=
yes")
};
APS.Util.prototype.openPopupWithVars = function (a, e) {
var d = window.open("", "_blank", "height=500,width=800,toolbar=no,scrollbar
s=yes,resizable=yes");
var b = "<html><head><meta http-equiv='Content-Type' content='text/html; cha
rset=UTF-8'/>";
b += "</head><body><form id='formid' accept-charset='UTF-8' method='post' ac
tion='" + a + "'>";
for (var c in e) {
var f = encodeURIComponent(e[c]);
b += "<input type='hidden' name='" + c + "' value='" + f + "'/>"
}
b += "</form><script type='text/javascript'>";
b += "var frm = document.getElementById('formid');";
b += "for(var i = 0; i < frm.elements.length; i++){";
b += "frm.elements[i].value = decodeURIComponent(frm.elements[i].value);";
b += "/*alert(frm.elements[i].name + ' ' + frm.elements[i].value)*/";
b += "}";
b += "frm.submit();";
b += "<\/script></body></html>";
d.document.write(b)
};
APS.Util.prototype.parseDate = function (c) {
var e = c.split(" ");
var d = e[0].split("-");
var b = e[1].split(":");
var a = new Date();
a.setFullYear(d[0]);
a.setMonth(Number(d[1]) - 1, d[2]);
a.setDate(d[2]);
a.setHours(b[0]);
a.setMinutes(b[1]);
a.setSeconds(b[2]);
return a
};
APS.Util.prototype.getTimeLeft = function (f, i, d) {
var j = new Date().getTime();
var c = j - d;
var l = f.getTime();
var a = l - (i + c);
var e = new Object();
if (a <= 0) {
a = 0
}
var b = Math.floor(a / 1000);
var h = Math.floor(b / 3600);
var m = b - (h * 3600);
var g = Math.floor(m / 60);
var k = Math.floor(m - (g * 60));
e.h = h;
e.m = g;
e.s = k;
e.valid = h + g + k;
return e
};
APS.Track = function (a) {
this.protocol = "http";

this.beapServerName = "beap.adx.yahoo.com";
this.beapScriptName = "reg_rm";
this.beapVer = "1.0.0";
this.beaconParamsToEncode = ["uid", "ouid", "suid", "ch", "sch", "dch"];
this.social_ad_params = {
ty: "rm",
aid: "xxxxxxxxx",
pid: "xxxxxx",
cid: "xxxxxx",
lid: "xxxxx",
advid: "xxxxxxxx",
cmpid: "xxx"
};
this.beapEventCountMap = {
view_video: "1"
};
this.trackingURL = "http://tr.adinterax.com/";
this.adxData = a;
this.adxId;
this.eventCountMap = {};
this.adxEventTypeMap = {
click: "tc,c",
custom: "u"
};
this.util = new APS.Util();
this.parseAdxData()
};
APS.Track.prototype.formBeaconUrl = function (d, n) {
var b = this.social_ad_params;
var f = "";
if (this.beapServerName == undefined || this.beapServerName == null || this.
beapServerName == "") {
return f
}
f = this.protocol + "://" + this.beapServerName + "/" + this.beapScriptName
+ "?bv=" + this.beapVer;
var i = "";
if (d == undefined || d == null || d == "") {
d = "ua"
}
var h;
for (var g in this.beaconParamsToEncode) {
h = this.beaconParamsToEncode[g];
var m = n[h];
if (!(m && m.length) || h == "label") {
continue
}
if (i.length) {
i += ","
}
i += this.util.beapFormat(h, m)
}
var j = this.util.beapFormat("pid", b.pid);
j += "," + this.util.beapFormat("cid", b.cid);
j += "," + this.util.beapFormat("advid", b.advid);
j += "," + this.util.beapFormat("lid", b.lid);
j += "," + this.util.beapFormat("cmpid", b.cmpid);
if (i && i.length) {
j += ",sa(" + i + ")"
}

var a = "cd(type$" + d + "," + this.util.beapFormat("label", n.label) + ")";


var c = this.util.beapFormat("ty", b.ty);
var k = c + ",ci(" + j + ")," + a;
var e = this.util.beapFormat("aid", b.aid);
var l = "ct$36";
f += "&al=(" + l + "," + e + ",dt(" + k + "))";
return f
};
APS.Track.prototype.parseAdxData = function (c) {
var b = this.util.getAdxUID();
if (c != undefined && c != null) {
this.adxData = c
}
if (this.adxData == undefined || this.adxData == null || this.adxData == "un
defined") {
this.adxData = getVar("adx_data")
}
var a = [];
if (this.adxData != null) {
a = this.adxData.split(",")
}
if (a.length > 1) {
this.social_ad_params.cid = a[0];
this.social_ad_params.aid = a[1];
var g = a.length;
var f = {
P: "pid",
C: "cmpid",
A: "advid",
L: "lid"
};
for (var e = 2; e < g; e++) {
var d = a[e].split("=");
if (d.length == 2) {
if (f[d[0]] != undefined) {
this.social_ad_params[f[d[0]]] = d[1]
}
}
}
}
};
APS.Track.prototype.getAdxData = function () {
return this.adxData
};
APS.Track.prototype.trackBeapEvent = function (e, c, b, a) {
if (a == null || a == undefined) {
a = false
}
if (this.adxData == undefined || this.adxData == null || this.adxData == "")
{
this.parseAdxData()
}
if (typeof this.beapEventCountMap[b] === "undefined") {
this.beapEventCountMap[b] = 0
} else {
this.beapEventCountMap[b]++
}
var d = this.beapEventCountMap[b];
this.prepareAndFireBeacon(e, c, b, d, a)
};

APS.Track.prototype.prepareAndFireBeacon = function (a, d, c, e, b) {


var f = this.getBeaconUrl(a, d, c, e);
this.util.sendRequest(f, b)
};
APS.Track.prototype.getBeaconUrl = function (b, d, c, e) {
if (e == undefined || e == null || !e) {
e = "0"
}
c = c + ":" + e;
var a = this.util.getTrackingParams(b, c, false);
return this.formBeaconUrl(d, a)
};
APS.Track.prototype.getBeaconUrlForSharedChannel = function (b, d, c) {
var a = this.util.getTrackingParams("", c, true);
a.uid = "";
a.ch = b;
return this.formBeaconUrl(d, a)
};
APS.PropertiesManager = function () {
this.cb;
this.ctx;
this.test = "test";
this.initialized = false;
this.rowSeparator = "\n";
this.loadSuccess = false
};
APS.PropertiesManager.prototype.readFile = function (c, a, b, d) {};
APS.PropertiesManager.prototype.done = function (a) {
this.initialized = true;
if (this.cb && this.ctx) {
this.cb.call(this.ctx, a, this.loadSuccess)
}
};
APS.PropertiesManager.prototype.setLoadSuccess = function (a) {
this.loadSuccess = a
};
APS.PropertiesManager.prototype.getLoadSuccess = function (a) {
return this.loadSuccess
};
APS.TextPropertiesManager = function () {};
APS.TextPropertiesManager.prototype = new APS.PropertiesManager();
APS.TextPropertiesManager.superclass = APS.PropertiesManager.prototype;
APS.TextPropertiesManager.prototype.readFile = function (a, c, j, k) {
this.cb = c;
this.ctx = j;
this.rowSeparator = k;
var i = document.getElementsByTagName("head");
try {
if (i[0] == undefined || i[0] == null) {
i[0] = document.createElement("head");
var b = document.getElementsByTagName("html");
b[0].appendChild(i[0])
}
} catch (d) {}
var g = i[0];
var f = document.createElement("script");
f.type = "text/javascript";
f.src = a;
g.appendChild(f);
var h = this;

if (this.cb != undefined && this.cb != null) {


f.onload = f.onreadystatechange = function () {
this.complete = false;
if (!this.complete && (!this.readyState || this.readyState === "comp
lete" || (this.readyState === "loaded" && this.nextSibling != null))) {
this.complete = true;
if (!h.loadSuccess) {
h.cb.call(h.ctx, null, h.loadSuccess)
}
f.onload = f.onreadystatechange = null
} else {
if (this.readyState === "loaded" && this.nextSibling == null) {
if (!h.loadSuccess) {
h.cb.call(h.ctx, null, h.loadSuccess)
}
}
}
};
f.onerror = function () {
if (!h.loadSuccess) {
h.cb.call(h.ctx, null, h.loadSuccess)
}
}
}
};
APS.TextPropertiesManager.prototype.handleLoadComplete = function () {};
APS.TextPropertiesManager.prototype.handleCB = function (a) {
if (a) {
this.parsePropertyFile(a)
} else {
this.done(null)
}
};
APS.TextPropertiesManager.prototype.parsePropertyFile = function (a) {
var b = a.split(this.rowSeparator);
this.done(b)
};
function trim(a) {
return a.replace(/^\s+|\s+$/g, "")
}
function ltrim(a) {
return a.replace(/^\s+/, "")
}
function rtrim(a) {
return a.replace(/\s+$/, "")
}
APS.PropertyReader = function () {
this.cb;
this.ctx;
this.initialized = false;
this._rawData;
this.loadSuccess = false;
this.tp = null
};
APS.PropertyReader.prototype.initialize = function (d, a, b, c) {
this.cb = a;
this.ctx = b;
this.tp = new APS.TextPropertiesManager(d, this.onDataReady, this, c);
this.tp.readFile(d, this.onDataReady, this, c)

};
APS.PropertyReader.prototype.onDataReady = function (b, a) {
this.loadSuccess = a;
if (a) {
if (b != null) {
this._rawData = b;
this.parseRawData()
} else {
this.done(a)
}
} else {
this.done(a)
}
};
APS.PropertyReader.prototype.done = function (a) {
if (this.ctx && this.cb) {
this.cb.call(this.ctx, this, this.loadSuccess)
}
};
APS.Deal = function (c, b) {
this.row = [];
for (var a = 0; a < c.length; a++) {
this.row[c[a]] = b[a]
}
};
APS.Deal.prototype.getImage = function () {
return this.row.imageurl
};
APS.Deal.prototype.getDescription = function () {
return this.row.description
};
APS.Deal.prototype.getDealDesc = function () {
return this.row.description
};
APS.Deal.prototype.getOriginalPrice = function () {
return this.row.originalprice
};
APS.Deal.prototype.getListingPrice = function () {
return this.row.discountedprice
};
APS.Deal.prototype.getDiscount = function () {
return this.row.discountpercent
};
APS.Deal.prototype.getListingId = function () {
return this.row.listingid
};
APS.Deal.prototype.getCategory = function () {
return this.row.category
};
APS.Deal.prototype.getTitle = function () {
return this.row.title
};
APS.Deal.prototype.getArea = function () {
return this.row.area
};
APS.Deal.prototype.getVendor = function () {
return this.row.vendor
};
APS.Deal.prototype.getProduct = function () {
return this.row.product

};
APS.Deal.prototype.getBuyLink = function () {
return this.row.landingurl
};
APS.Deal.prototype.getDealDates = function () {
var a = new Object();
a.sd = this.row.startdate;
a.ed = this.row.enddate;
return a
};
APS.Deal.prototype.getField = function (a) {
return this.row[a]
};
APS.Deal.prototype.setField = function (a, b) {
this.row[a] = b
};
APS.DealsReader = function () {
this.classname = "DealsReader";
this._parsedData = new Array();
this.currentRecordNum = 0;
this.headerList;
this._dealsByArea = new Object();
this._areaList = new Array()
};
APS.DealsReader.prototype = new APS.PropertyReader();
APS.DealsReader.prototype.parseRawData = function () {
this.headerList = this._rawData[0].split("\t");
var f = "";
var e = "";
var c = "";
for (var d = 1; d < this._rawData.length; d++) {
if (trim(this._rawData[d]) != "") {
var a = this._rawData[d].split("\t");
var j = new APS.Deal(this.headerList, a);
if (j.getField("log_data") != null && j.getField("log_data") != "")
{
f = j.getField("log_data")
} else {
j.setField("log_data", f)
}
if (j.getField("model") != null && j.getField("model") != "") {
var h = j.getField("model").split(":");
e = (h.length > 1) ? h[0] : h[0];
j.setField("model", e)
} else {
j.setField("model", e)
}
if (j.getField("response_code") != undefined && j.getField("response
_code") != "") {
c = j.getField("response_code")
} else {
j.setField("response_code", c)
}
this._parsedData.push(j);
var b = j.getArea();
var g = this._dealsByArea[b];
if (g == undefined || g == null) {
g = new Array();
this._dealsByArea[b] = g;
this._areaList.push(b)

}
g.push(j)
}
}
this.initialized = true;
this.done(this.initialized)
};
APS.DealsReader.prototype.getNext = function (a) {
if (!this.initialized) {
throw new Error("DealsReader not initialized")
}
this.currentRecordNum++;
this.currentRecordNum = this.getBoundedIdx(a, this.currentRecordNum);
var b = this.getCurrent(a);
return b
};
APS.DealsReader.prototype.getCurrent = function (a) {
var b;
b = (a != null) ? this._dealsByArea[a][this.currentRecordNum] : this._parsed
Data[this.currentRecordNum];
return b
};
APS.DealsReader.prototype.getPrevious = function (a) {
if (!this.initialized) {
throw new Error("DealsReader not initialized")
}
this.currentRecordNum--;
this.currentRecordNum = this.getBoundedIdx(a, this.currentRecordNum);
var b = this.getCurrent(a);
return b
};
APS.DealsReader.prototype.resetRecordNum = function () {
this.currentRecordNum = 0
};
APS.DealsReader.prototype.lookupNext = function (b) {
if (!this.initialized) {
throw new Error("DealsReader not initialized")
}
var a = this.currentRecordNum + 1;
var c;
a = this.getBoundedIdx(b, this.currentRecordNum);
c = (b != null) ? this._dealsByArea[b][a] : this._parsedData[a];
return c
};
APS.DealsReader.prototype.getAreaList = function () {
return this._areaList
};
APS.DealsReader.prototype.randomize = function (b) {
var a;
a = (b != null) ? this._dealsByArea[b].length : this._parsedData.length;
this.currentRecordNum = this.getBoundedIdx(b, Math.floor(Math.random() * a))
};
APS.DealsReader.prototype.getBoundedIdx = function (c, b) {
var a;
a = (c != null) ? this._dealsByArea[c].length : this._parsedData.length;
return (b >= a ? 0 : (b < 0 ? a - 1 : b))
};
APS.DealsReader.prototype.getNumDeals = function (c, b) {
var a;
a = (c != null) ? this._dealsByArea[c].length : this._parsedData.length;

return a
};
function cb(d) {
var g = "default";
if (d != undefined && d != null) {
var i = d.split("");
if (i.length > 0) {
var f = i[0].split("\t");
var h = i[1].split("\t");
var b = new APS.Deal(f, h);
if (b != undefined && b != null) {
var e = b.getField("partner");
if (e != undefined && e != null) {
g = e
} else {
var c = b.getImage();
if (c != undefined && c != null) {
g = c.split("/")[5]
}
}
}
}
}
var a = APS.PropertyReaderFactory.getInstance(APS.PropertyReaderFactory.DEAL
S_READER, null, null, null, g);
if (a != undefined && a != null) {
if (a.tp != null) {
a.tp.setLoadSuccess.call(a.tp, true);
a.tp.handleCB.call(a.tp, d, true)
}
}
}
APS.SocadConfPropertyReader = function () {
this.classname = "SocadConfPropertyReader";
this._parsedData = new Object()
};
APS.SocadConfPropertyReader.prototype = new APS.PropertyReader();
APS.SocadConfPropertyReader.prototype.parseRawData = function () {
for (var c = 0; c < this._rawData.length; c++) {
if (this._rawData[c] != "") {
var d = trim(this._rawData[c]);
var e = d.split("=");
var a = e[0];
var b = (e.length > 1) ? e[1] : "";
if (a.charAt(0) != "#" && a.length > 0) {
this._parsedData[a] = b
}
}
}
this.initialized = true
};
APS.SocadConfPropertyReader.prototype.get = function (a) {
if (!this.initialized) {
throw new Error("SocadConfPropertyReader not initialized")
}
var b = this._parsedData[a];
return this._parsedData[a]
};
var pr = [];

APS.PropertyReaderFactory = function () {};


APS.PropertyReaderFactory.SOCAD_CONFIG_READER = 1;
APS.PropertyReaderFactory.DEALS_READER = 2;
pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER] = [];
pr[APS.PropertyReaderFactory.DEALS_READER] = [];
APS.PropertyReaderFactory.getInstance = function (d, c, a, b, e) {
if (e == undefined || e == null) {
e = "default"
}
if (d == APS.PropertyReaderFactory.SOCAD_CONFIG_READER) {
if (pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER][e] != undefined &&
pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER][e] != null) {
return pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER][e]
} else {
var f = new APS.SocadConfPropertyReader();
pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER][e] = f;
if (c != undefined && c != null) {
f.initialize.call(f, c, a, b, ";")
}
return pr[APS.PropertyReaderFactory.SOCAD_CONFIG_READER][e]
}
} else {
if (d == APS.PropertyReaderFactory.DEALS_READER) {
if (pr[APS.PropertyReaderFactory.DEALS_READER][e] != undefined && pr
[APS.PropertyReaderFactory.DEALS_READER][e] != null) {
return pr[APS.PropertyReaderFactory.DEALS_READER][e]
} else {
var f = new APS.DealsReader();
pr[APS.PropertyReaderFactory.DEALS_READER][e] = f;
if (c != undefined && c != null) {
f.initialize.call(f, c, a, b, "")
}
return pr[APS.PropertyReaderFactory.DEALS_READER][e]
}
}
}
};

You might also like