﻿
var ord = Math.floor(Math.random() * 100000000000000000);

function loadAds() {
    var ad, x = 0;
    if (typeof (ffxAds) != "undefined") { 
    
        while (ad = ffxAds[x]) {
            if (typeof (ad.position) == "undefined")
                pos = "1";
            else
                pos = ad.position;
                
            if (typeof (ad.height) == "undefined")
                hei = "1";
            else
                hei = ad.height;

            if (typeof (ad.width) == "undefined")
                wid = "1";
            else
                wid = ad.width;

            if (typeof (ad.cat) == "undefined")
                cat = "other";
            else
                cat = ad.cat;

            if (typeof (ad.ctype) == "undefined")
                ctype = "index";
            else
                ctype = ad.ctype;

            if (typeof (ad.keyvalues) == "undefined")
                keyvalues = "";
            else
                keyvalues = ad.keyvalues;

            if (typeof (ad.site) == "undefined")
                site = "onl.lifeislocal";
            else
                site = ad.site;

            if (typeof (ad.publication) == "undefined")
                publication = "thecanberratimes";
            else
                publication = ad.publication;

            var holderDivId = "#ffxad" + (x + 1);
            var adscript = '<script type="text/javascript" src="http://ad-apac.doubleclick.net/adj/' + site + '/' + publication + '/' + cat + ';ctype=' + ctype + ';cat=' + publication + ';cat1=' + cat + ';' + keyvalues + 'pos=' + pos + ';sz=' + wid + 'x' + hei + ';tile=' + (x + 1) + ';ord=' + ord + '?"></script>';

            $(holderDivId).writeCapture().html(adscript);
            x++;
        }
    }
}
