document.write('<'+'div id="ct-902bb837bfdeb648880c130985364ed7"'+'>'+'<'+'/div'+'>');
(function() {
function _cmpTbl() {
this.url = 'www.ad4mat.de';
this.tcUrl = 'gd.ad4mat.de';
var $this = this;
var s, d, t, p, cid, jq, imgSizer;
var $cfg = {
data : {
table : {
thead : { },
tbody : { }
},
outConfig: {
headerSort: [],
sortCols: {}
}
},
tbl: { }
};
s = {
init: function() {
s.loadSettings();
},
restore: function() {
},
setBindings: function() {
jq('a.olink').click(function(e) {
e.preventDefault();
t.track("click", jq(this).attr("data-row"), jq(this).attr("data-col"));
});
jq('#'+$cfg.data.tableId+' tbody tr').click(function(e) {
e.preventDefault();
t.track("click", jq(this).attr("data-row"), "rowclick");
var deeplink = jq(this).attr("data-link");
var ztp = $cfg.data.ztp;
var splitter = ztp.split("C");
var subid = splitter[0];
var sublink = "S" + subid + "T";
sublink = deeplink.replace("T", sublink);
var newlink = 'http://ad.zanox.com/ppc/?'+ztp+'&ULP='+sublink+'&zpar0=ad4mat-comparison-table_' + $cfg.data.id + '_' + $cfg.data.adName;
window.open(newlink);
});
},
loadSettings: function() {
jq.ajax({
url : 'http://'+$this.url+'/ads/admin/modules/xml/cmptbl/load.php',
data: 'a=s&p='+cid,
type: 'GET',
async : true,
dataType : 'jsonp',
success: function(data){
$cfg.data = jq.extend(true, {}, $cfg.data, data);
if($cfg.data.autoUpdate) {
$cfg.data.outConfig.sortCols = {};
s.getEntireTable();
} else {
jq('#ct-'+cid).html(d.setupTable($cfg.data.outConfig.tbl));
d.appendCSSFile();
s.setBindings();
t.setImpression();
p.init();
}
}
});
},
getEntireTable: function(){
jq.ajax({
url : 'http://'+$this.url+'/ads/admin/modules/xml/cmptbl/load.php',
data: 'a=t&b='+$cfg.data.table.id,
type: 'GET',
async : true,
dataType : 'jsonp',
success: function(data){
jq('#ct-'+cid).html(d.setupTable(data));
d.appendCSSFile();
s.setBindings();
t.setImpression();
p.init();
}
});
}
};
d = {
appendCSSFile: function() {
jq('head').append('');
},
setupTable: function(tblObj) {
var html = "
";
if($cfg.data.table.limitRows || $cfg.data.table.limitRows == "true") {
var maxRows = $cfg.data.table.maxRows;
maxRows++;
} else {
var maxRows = parseInt(tblObj.rowCount);
}
for(var i = 1; i <= maxRows; i++) {
var key = i;
var val = tblObj.row[i];
if(key == 1) { /** setup table header **/
html += d.setupTableHeader(val.col);
}
if(key == 2) { /** setup table body **/
html += "";
}
if(key >= 2) {
clname = ((key-1)%2 == 0) ? 'even' : 'odd';
html += d.setupTableBody(val.col, clname, key);
}
if(key-1 == $cfg.data.table.maxRows) {
html += "";
}
}
html += "
";
return html;
},
setupTableHeader: function(valCol) {
var tblHeader = "";
tblHeader += "";
var isAfterDL = false;
var colIndex = 1;
var DLindex = 0;
jq.each(valCol, function(key, value) {
if(value.contentType == "deeplink") {
DLindex = key;
}
});
jq.each($cfg.data.outConfig.headerSort, function(key, colKey) {
var okey = key;
var key = parseInt(colKey);
key++;
if(key >= DLindex) isAfterDL = true;
//if( isAfterDL )
// key++;
var col = valCol[key];
var ns = "";
if(col.isSortable == "0") {
ns = "nsort";
$cfg.data.outConfig.sortCols[okey] = {
sorter: false
};
}
if ($cfg.data.table.colWidths == "undefined") {
tblHeader += '| ';
} else {
var width = $cfg.data.table.colWidths[colIndex] - $cfg.data.table.colWidths[colIndex - 1];
tblHeader += ' | ';
colIndex++;
}
tblHeader += col.content;
if(okey == 0) {
var deeplink = "http://ad.zanox.com/ppv/?23001867C655738024T";
var ztp = $cfg.data.ztp;
var splitter = ztp.split("C");
var subid = splitter[0];
var sublink = "S" + subid + "T";
sublink = deeplink.replace("T", sublink);
tblHeader += ' ';
}
tblHeader += ' | ';
});
tblHeader += "
";
tblHeader += "";
return tblHeader;
},
setupTableBody: function(valCol, className, rowKey) {
var innerHtml = "";
var isAfterDL = false;
jq.each($cfg.data.outConfig.headerSort, function(key, colKey){
var key = parseInt(colKey);
key++;
if(valCol[key].contentType == "deeplink") {
isAfterDL = true;
}
if( isAfterDL )
key++;
var col = valCol[key];
if( col.contentType == "picture" ) {
minWidthStyle = ' width:'+ $cfg.data.imageWidth +'px;';
} else {
minWidthStyle = '';
}
innerHtml += "";
switch(col.contentType) {
case 'text':
innerHtml += col.content;
break;
case 'link':
innerHtml += ""+col.content+"";
break;
case 'cta':
if($cfg.data.table.tbody.textLinks) {
innerHtml += ""+col.content+"";
} else {
innerHtml += "";
}
break;
case 'picture':
innerHtml += " ";
break;
}
innerHtml += " | ";
});
var tblBody = "";
tblBody += "";
tblBody += innerHtml;
tblBody += "
";
return tblBody;
}
};
p = {
init: function() {
p.sorter();
p.startImgSizer();
},
sorter: function() {
jq.getScript("http://"+$this.url+"/ads/js/sorter.js", function() {
sorterPlugin(jq);
jq('#'+$cfg.data.tableId).tablesorter({
textExtraction: function(node) {
return node.getAttribute("data-sort");
},
headers: $cfg.data.outConfig.sortCols
}).bind("sortEnd", function(){
jq('#'+$cfg.data.tableId+' tbody tr').each(function(idx){
var clname = ((idx-1)%2 == 0) ? 'even' : 'odd';
jq(this).removeClass("odd").removeClass("even").addClass(clname);
});
});
});
},
startImgSizer: function() {
var aImgs = document.getElementById($cfg.data.tableId).getElementsByTagName("img");
imgSizer.collate(aImgs);
}
};
imgSizer = {
Config : {
imgCache : []
,spacer : "/path/to/your/spacer.gif"
}
,collate : function(aScope) {
var isOldIE = (document.all && !window.opera && !window.XDomainRequest) ? 1 : 0;
if (isOldIE && document.getElementsByTagName) {
var c = imgSizer;
var imgCache = c.Config.imgCache;
var images = (aScope && aScope.length) ? aScope : document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
images.origWidth = images.offsetWidth;
images.origHeight = images.offsetHeight;
imgCache.push(images);
c.ieAlpha(images);
images.style.width = "100%";
}
if (imgCache.length) {
c.resize(function() {
for (var i = 0; i < imgCache.length; i++) {
var ratio = (imgCache.offsetWidth / imgCache.origWidth);
imgCache.style.height = (imgCache.origHeight * ratio) + "px";
}
});
}
}
}
,ieAlpha : function(img) {
var c = imgSizer;
if (img.oldSrc) {
img.src = img.oldSrc;
}
var src = img.src;
img.style.width = img.offsetWidth + "px";
img.style.height = img.offsetHeight + "px";
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
img.oldSrc = src;
img.src = c.Config.spacer;
}
,resize : function(func) {
var oldonresize = window.onresize;
if (typeof window.onresize != 'function') {
window.onresize = func;
} else {
window.onresize = function() {
if (oldonresize) {
oldonresize();
}
func();
}
}
}
};
t = {
setImpression: function() {
t.track('impression');
},
setClick: function(row, col) {
t.track('click', row, col );
},
track: function( type, row, col ) {
if( typeof row == "undefined" )
row = 0;
if( typeof col == "undefined" )
col = 0;
jq.ajax({
url: 'http://'+$this.tcUrl+'/ads/admin/modules/xml/cmptbl/tc.php',
data: { t: type, c: cid, r: row, co: col },
type: 'GET',
async: true,
dataType: 'jsonp',
success: function(data){
}
});
}
};
return {
setJQuery: function (a) {
jq = a
},
init: function (c) {
cid = c;
s.init()
},
restore: function () {
s.restore();
}
}
}
var j,d,s,tb;
j = _cmpTbl();
if(typeof jQuery == "undefined") {
d = window.document.createElement("script");
d.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
d.onload=function(){
j.setJQuery(jQuery.noConflict(!0));
j.init('902bb837bfdeb648880c130985364ed7');
};
window.document.getElementsByTagName("head")[0].appendChild(d);
} else {
j.setJQuery(jQuery);
j.init('902bb837bfdeb648880c130985364ed7');
}
})();