1 /** Optimized methods for fetching ad-banners via OpenX */
3 /** see: http://enterprisejquery.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/ */
5 (function( openx, $, undefined ) {
12 openx.fetch_ads = function(server, zones) {
16 spc = "<script type='text/javascript' src='";
17 spc += location.protocol == 'https:' ? 'https://' + server + ':8443':'http://' + server;
18 spc += "/www/delivery/spc.php?zones=";
20 /** Only fetch banners, that are really included in this page */
21 $('.oa').each(function() {
23 for(var name in zones) {
24 if (node.hasClass(name)) {
25 var id = 'oa_' + ++count;
27 spc += escape(id + '=' + zones[name] + "|");
32 spc += "&nz=1&source=" + escape(OA_source);
33 spc += "&r=" + Math.floor(Math.random()*99999999);
34 spc += "&block=1&charset=UTF-8";
36 if (window.location) spc += "&loc=" + escape(window.location);
37 if (document.referrer) spc += "&referer=" + escape(document.referrer);
42 document.write("<script type='text/javascript' src='http://" + server + "/www/delivery/fl.js'></script>");
46 openx.render_ads = function() {
48 /** Render the fetched ad-banners... */
49 for (var id in slots) {
50 // alert(id + ": " + OA_output[id]);
51 if (typeof(OA_output[id]) != 'undefined' && OA_output[id] != '') {
52 document.write("<div id='" + id + "'>");
53 document.write(OA_output[id]);
54 document.write("</div>");
56 // alert('Banner ' + id + ': ' + OA_output[id]);
62 openx.show_ads = function() {
64 /** Show the rendered banners */
65 for (var i=0; i<ads.length; i++) {
66 var ad = $('#'+ads[i]).detach();
67 slots[ads[i]].append(ad);
71 } ( window.openx = window.openx || {}, jQuery ));