var CaliberDataTopOffers = function() {
var TopOffers =
new Array(
"" +
"
" +
" " +
" | " +
" Get theses great cashbacks from Post-Gazette!" +
" | " +
"
" +
"
" +
""
);
var CurrentOffer;
var Parent;
var Interval;
AddLoadEvent(WindowsLoaded);
function AddLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else {
window.onload = function() {
oldonload();
func();
}
}
}
function WindowsLoaded() {
Parent = document.getElementById('cdaddiv');
if (Parent) {
try {
SetHtml(0);
}
catch (ex) {
alert(ex);
}
CurrentOffer = 0;
Interval = setInterval('CaliberDataTopOffers.UpdateCaliberDataOffer()', 5000);
}
}
function SetHtml(offer) {
var htmlTemplate = "#HtmlTemplate#";
var map = TopOffers[offer];
for (var key in map) {
var reg = new RegExp('#'+key+'#','gi');
htmlTemplate = htmlTemplate.replace(reg, map[key].toString());
}
Parent.innerHTML = htmlTemplate;
}
return {
UpdateCaliberDataOffer: function() {
CurrentOffer++;
if (CurrentOffer >= TopOffers.length) {
CurrentOffer = 0;
}
SetHtml(CurrentOffer);
},
PrevOffer: function (){
clearInterval(Interval);
CurrentOffer--;
if (CurrentOffer < 0) {
CurrentOffer = TopOffers.length-1;
}
SetHtml(CurrentOffer);
},
NextOffer: function (){
clearInterval(Interval);
CurrentOffer++;
if (CurrentOffer == TopOffers.length) {
CurrentOffer = 0;
}
SetHtml(CurrentOffer);
}
};
} ();