/** * Display ads from Adsys * * @param string sAdsURL The base URL from Adsys to pull ad data from * @param string sDomain The domain name for the given suite of ads * @param array aAdSet The ads to be displayed * * @access public */ function displayAd(sAdsURL, sDomain, aAdSet) { var adNumber = null; var adLink = ""; var nUsed = 0; var aAds = new Array(); var sSubURL = sAdsURL; // Create the "superglobal" adsys array if (!document.adsys) { document.adsys = new Array(); } // Remove "duplicate" ads for(nUsed = 0; nUsed < aAdSet.length; nUsed++) { if (!document.adsys[aAdSet[nUsed][1]]) { aAds[aAds.length] = aAdSet[nUsed]; } } // Randomly find an ad if (aAds.length == 0) { document.write(""); return; } else if (aAds.length == 1) { adNumber = 0; } else { adNumber = Math.floor(Math.random()*aAds.length); } // Ad the adNumber to the list of ads we've seen document.adsys[aAds[adNumber][1]] = 1; // Assign the "base" URI for all operations sAdsURL += "/" + Math.floor(Math.random()*100000000000000); // Build the URL for retrieving the ad element sAdsURL += "/creative/" + sDomain + "/" + aAds[adNumber][0]; sAdsURL += "/" + aAds[adNumber][1] + "." + aAds[adNumber][2]; // Determine which "type" of ad we are going to render switch(aAds[adNumber][2]) { // For Flash files, build the following tags case "swf": if (aAds[adNumber][5] != '') { sSubURL += "/" + Math.floor(Math.random()*100000000000000); // Build the URL for retrieving the ad element sSubURL += "/creative/" + sDomain + "/" + aAds[adNumber][6]; sSubURL += "/" + aAds[adNumber][1] + "." + aAds[adNumber][2]; sAdsURL += "?clickTAG=" + sSubURL + "%3Fr%3D" + aAds[adNumber][5]; } adLink = ''; adLink += ''; adLink += ''; adLink += ''; adLink += ''; adLink += ''; adLink += ''; adLink += ''; break; // Format a javascript file URL for text-based ads case "js": adLink = ''; adLink += ''; break; // The default is to assume image-style servering default: if (aAds[adNumber][3] != "") { if (aAds[adNumber][3].substring(0,7) == "mailto:") { adLink = ''; } else { adLink = ''; if (aAds[adNumber][3] != "") { adLink += ''; } } document.write(adLink); }aAds = new Array(); aAds[0] = new Array(); aAds[0][0] = 'class02-ledger-news'; aAds[0][1] = '14545'; aAds[0][2] = 'gif'; aAds[0][3] = 'http://southofboston.abracat.com/c2/autos/search/index.xml'; aAds[0][4] = '0'; displayAd('http://adsys.townnews.com', 'southofboston.com', aAds);