String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
Date.prototype.mGetDay = function() {
return (this.getDay() + 6) %7;
};
function getRand()
{
var uu=Math.round(Math.random()*2147483647);
return uu;
}
function getRandomNr(max)
{
var ranNum= Math.floor(Math.random()*(max));
return ranNum;
}
function getBrowserProperties()
{
return '&tsSW='+self.screen.width+'&tsSH='+self.screen.height+'&tsSC='+self.screen.colorDepth+'&tsPD='+self.screen.pixelDepth;
}
function tsGetUrl()
{
var s="";
s+="tsUUI="+getRand();
//s+="&tsT=" + _tsT;
s += "&tsLho=" + _tsHO;
//s += "&tsLha=" + _tsdlh;
s += "&tsQu=" + _tsQu;
s += "&tsRef=" + _tsRef;
s += "&tsLP="+_tsLP + getBrowserProperties();
return s;
}
/* This source code is Copyright (c) Tailsweep 2007-2008 */
var tsTools = {};
tsTools.isDebug = function(){
if(window.location.href.indexOf('tsDebug=1') != -1){
return true;
}
else{
return false;
}
};
tsTools.getQParamFromStr = function(str, paramName){
var regex = new RegExp("[\\?&]"+paramName+"=([^&#]*)");
var qParam = regex.exec(str);
if(qParam == null){
return "";
}
return qParam[1];
};
tsTools.getQParam = function(paramName){
return tsTools.getQParamFromStr(window.location.href, paramName);
};
tsTools.PosPopUp = function(id,x,y,offset)
{
var el = document.getElementById(id);
el.style.left=x+offset;
el.style.top=y-document.body.scrollTop+offset;
};
var countryCode=tsTools.getQParam('tsCountryCode') ||"US";
var regionCode=tsTools.getQParam('tsRegionCode') ||"%REGION_CODE%";
//var countryCode = "%COUNTRY_CODE%";
//var regionCode = "%REGION_CODE%";
var headerShown = "false";
var placement = "midContent";
var success = 0;
var flashtested = 0;
var flashinstalled = false;
if (typeof(tsAdsRendered_midContent_slot)=="undefined") {var tsAdsRendered_midContent_slot = [];}
if (typeof(tsAdsRendered_midContent)=="undefined") {var tsAdsRendered_midContent = 0;}
if (typeof(tsUrl)=="undefined") {var tsUrl="";}
if (typeof(tsPlacementConfig)=="undefined") {var tsPlacementConfig = [];}
var _tsbd=document;
var _tsdl=_tsbd.location;
var _tsdlh = "";
var _tsBH = "";
var _tsDM= "";
var _tsHO = "";
var _tsLP = "";
var _tsQu = "";
var _tsT =  "";
var _tsFpc = "";
var _tsSession =  "";
var _tsUid = "";
var _tsUV = "";
var _tsRef = "";
if (_tsdl.hostname && _tsdl.hostname != "") { _tsHO = _tsES(_tsdl.hostname); }
if (_tsdl.search && _tsdl.search != "") { _tsQu = _tsES(_tsdl.search); }
//if (_tsdl.hash && _tsdl.hash != "") { _tsdlh=_tsdl.href.substring(_tsdl.href.indexOf('#')); }
if (_tsbd.domain &&  _tsbd.domain != "") {  _tsDM = _tsbd.domain; }
if(_tsdl.pathname && _tsdl.pathname != "") { _tsLP = _tsdl.pathname;}
if(_tsbd.referrer && _tsbd.referrer != "") { _tsRef = _tsES(_tsbd.referrer);}
var nTsUrl="";
if(tsUrl != "")
{
nTsUrl = escape(tsUrl);
}
_tsSession = getCookieValue("ts_session") ? getCookieValue("ts_session") : "";
_tsUid = getCookieValue("ts_uid") ? getCookieValue("ts_uid") : "";
_tsUV = getCookieValue("ts_uv") ? getCookieValue("ts_uv") : "";
var scriptViewMap = {};
var _tsAd1 = new TsAd('http://script.tailsweep.com/html/sitead/5/51/513539_iframe.html?'+tsGetUrl(), '300', '250', '513539', '15088107','GB', '0', 80, '0', '0', '0', Date.parse('March, 14 2010 23:00:00 GMT'), Date.parse('March, 28 2010 21:59:00 GMT'),2);
var iframeViews = [];
var activePeriods = [];
iframeViews.push(new TsIframeAd(2304, 15100627, 1, "", "", '', "", "<scr"+"ipt language=\"Javascript1.1\" type=\"text/javascript\"> var ftClick = \"http://script.tailsweep.com/clicks/513539,15088107/15100627/\"; var ftX = \"\"; var ftY = \"\"; var ftZ = \"\"; var ftContent = \"\"; var ft300x250_OOBclickTrack = \"\"; var ftRandom = Math.random()*1000000; var ftBuildTag1 = \"<scr\"; var ftBuildTag2 = \"</\"; var ftTag = ftBuildTag1 + \'ipt language=\"javascript1.1\" type=\"text/javascript\" \'; ftTag += \'src=\"http://servedby.flashtalking.com/imp/12034;36752;201;js;TailsweepBlogs;300x250MPU/?click=\'+ftClick+\'&ftx=\'+ftX+\'&fty=\'+ftY+\'&ftadz=\'+ftZ+\'&ftscw=\'+ftContent+\'&cachebuster=\'+ftRandom+\'\" id=\"ftscript_300x250\" name=\"ftscript_300x250\"\'; ftTag += \'\">\' + ftBuildTag2 + \'script>\'; document.write(ftTag); </scr"+"ipt> <noscript> <a href=\"http://script.tailsweep.com/clicks/513539,15088107/15100627/http://servedby.flashtalking.com/click/12034;36752;0;209;0/?url=120408\" target=\"_blank\"> <img border=\"0\" src=\"http://servedby.flashtalking.com/imp/12034;36752;205;jpg;TailsweepBlogs;300x250MPU/?\"></a> </noscript> ", activePeriods));
_tsAd1.iframeViews = iframeViews;
scriptViewMap["513539"] = _tsAd1;
var _tsAd2 = new TsAd('http://script.tailsweep.com/html/sitead/5/51/513473_iframe.html?'+tsGetUrl(), '300', '250', '513473', '15086325','GB', '0', 100, '0', '0', '0', Date.parse('February, 21 2010 23:00:00 GMT'), Date.parse('April, 02 2010 21:59:00 GMT'),2);
var iframeViews = [];
var activePeriods = [];
iframeViews.push(new TsIframeAd(2210, 15087214, 1, "", "", '', "", "<scr"+"ipt language=\'JavaScript1.1\' SRC=\"http://ad-emea.doubleclick.net/adj/N1707.Tailsweep/B4303974.2;;sz=300x250;ord=1268853939088;click=http://script.tailsweep.com/clicks/513473,15086325/15087214/\"> </scr"+"ipt> ", activePeriods));
_tsAd2.iframeViews = iframeViews;
scriptViewMap["513473"] = _tsAd2;
function isSet()
{
var a = arguments; var l = a.length; var i=0;
while ( i != l )
{
if (typeof(a[i])=='undefined' || a[i] == undefined || a[i] == '')
{
return false;
}
else
{
i++;
}
}
return true;
}
function _tsES(s,u) {
if (typeof(encodeURIComponent) == 'function') {
if (u) {return encodeURI(s);}
else {return encodeURIComponent(s);}
}
else {
return escape(s);
}
}
function TsHash()
{
this.length = 0;
this.items = [];
for (var i = 0; i < arguments.length; i += 2) {
if (typeof(arguments[i + 1]) != 'undefined') {
this.items[arguments[i]] = arguments[i + 1];
this.length++;
}
}
this.remove = function(in_key)
{
var tmp_value;
if (typeof(this.items[in_key]) != 'undefined') {
this.length--;
var tmp_value = this.items[in_key];
delete this.items[in_key];
}
return tmp_value;
};
this.get = function(in_key) {
return this.items[in_key];
};
this.put = function(in_key, in_value)
{
if (typeof(in_value) != 'undefined') {
if (typeof(this.items[in_key]) == 'undefined') {
this.length++;
}
this.items[in_key] = in_value;
}
return in_value;
};
this.hasItem = function(in_key)
{
return typeof(this.items[in_key]) != 'undefined';
};
}
function tsPlacementHit()
{
var _tsPlUrl = "http://script.tailsweep.com/siteplacementhit/243372" + "?sitePlacements=2,"+window.tailsweep_currPos_midContent +"&tsSession="+_tsSession+"&tsUid="+_tsUid+"&tsUV="+_tsUV+"&tsUrl="+nTsUrl+"&"+tsGetUrl();
var plurl = '<img src="'+_tsPlUrl+'" border="0" width="0" height="0" style="width:0px;height:0px;margin: 0 auto;padding:0;border-style:none;border-width:0;display:none;" alt="" />';
document.write(plurl);
}
function writeSessionCookie (cookieName, cookieValue) {
if (testSessionCookie()) {
document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
return true;
}
else {return false;}
}
function writePersistentCookie (CookieName, CookieValue, periodType, offset) {
var expireDate = new Date ();
offset = offset / 1;
var myPeriodType = periodType;
switch (myPeriodType.toLowerCase()) {
case "years":
var year = expireDate.getYear();
// Note some browsers give only the years since 1900, and some since 0.
if (year < 1000){ year = year + 1900;}
expireDate.setYear(year + offset);
break;
case "months":
expireDate.setMonth(expireDate.getMonth() + offset);
break;
case "days":
expireDate.setDate(expireDate.getDate() + offset);
break;
case "hours":
expireDate.setHours(expireDate.getHours() + offset);
break;
case "minutes":
expireDate.setMinutes(expireDate.getMinutes() + offset);
break;
default:
alert ("Invalid periodType parameter for writePersistentCookie()");
break;
}
document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}
function testSessionCookie () {
document.cookie ="testSessionCookie=Enabled";
if (getCookieValue ("testSessionCookie")=="Enabled")
{ return true;}
else
{  return false;}
}
function getCookieValue (cookieName) {
var exp = new RegExp (escape(cookieName) + "=([^;]+)");
if (exp.test (document.cookie + ";")) {
exp.exec (document.cookie + ";");
return unescape(RegExp.$1);
}
else {return false;}
}
function testPersistentCookie () {
writePersistentCookie ("testPersistentCookie", "Enabled", "minutes", 1);
if (getCookieValue ("testPersistentCookie")=="Enabled")
{  return true;}
else
{  return false;}
}
function showHeader()
{
var h = "<div><a class='tailsweep-link' href='http://www.tailsweep.com/'><img border='0' src='http://files.tailsweep.com/resources/ts_adheader_250_en.png' width='250' height='9' alt='' style='padding:0;margin: 0 auto;border-style:none;border-width:0'/></a></div>";
document.write(h);
}
function incrementCookie(id,frequence,frequenceDays)
{
if(frequence != '' && frequence > 0)
{
var cval = getCookieValue("ts_ad_"+id);
if(!cval)
{
cval = 0;
}
if(cval < frequence)
{
cval++;
//SetCookie("ts_ad_"+id, cval, frequenceDays, "/", _tsHO, undefined);
writePersistentCookie ("ts_ad_"+id, cval, "days", frequenceDays);
return true;
}
return false;
}
return true;
}
function incrementSessionCookie(id, sessionFrequence)
{
if(sessionFrequence != '' && sessionFrequence > 0)
{
var cval = getCookieValue("ts_ad_session"+id);
if(!cval)
{
cval = 0;
}
if(cval < sessionFrequence)//8
{
cval++;
writeSessionCookie("ts_ad_session"+id, cval);
return true;
}
return false;
}
return true;
}
function isInCountry(adCountryCode)
{
var isin = (adCountryCode == '0' || adCountryCode == 0 || adCountryCode == '' || adCountryCode == countryCode || countryCode == "%COUNTRY_CODE%");
return isin;
}
function isInRegion(adRegionCode)
{
var isin = (adRegionCode == '0' || adRegionCode == 0 || adRegionCode =='' || adRegionCode == regionCode || regionCode == "%REGION_CODE%");
return isin;
}
function tsIsAdContentActive(activePeriods)
{
if(activePeriods.length == 0)
{
return true;
}
else
{
var theDate = new Date();
var weekDay = theDate.mGetDay();
var hour = theDate.getHours();
for(var i = 0; i < activePeriods.length; i++)
{
var activePeriod = activePeriods[i];
if(activePeriod.startWeekDay <= weekDay && activePeriod.endWeekDay >= weekDay && activePeriod.startHour <= hour && activePeriod.endHour >= hour)
{
return true;
}
}
}
return false;
}
function TsAd(url, width, height, siteAdId, siteAdConcreteStatisticsId, countryCode, regionCode, sov, frequence, frequenceDays, sessionFrequence, startDate, endDate,renderType) {
this.url = url;
this.width = width;
this.height = height;
this.siteAdId = siteAdId;
this.countryCode = countryCode;
this.regionCode = regionCode;
this.sov = sov;
this.frequence = frequence;
this.frequenceDays = frequenceDays;
this.sessionFrequence = sessionFrequence;
this.startDate = startDate;
this.endDate = endDate;
this.renderType = renderType;
this.siteAdConcreteStatisticsId = siteAdConcreteStatisticsId;
}
function TsIframeAd(id, concreteStatisticsId, type, mainContent, fallbackContent, javascriptSource, javascriptContent, htmlContent, activePeriods) {
this.id = id;
this.concreteStatisticsId = concreteStatisticsId;
this.type = type;
this.mainContent = mainContent;
this.fallbackContent = fallbackContent;
this.javascriptSource = javascriptSource;
this.javascriptContent = javascriptContent;
this.htmlContent = htmlContent;
this.activePeriods = activePeriods;
}
function TsActivePeriod(startWeekDay, endWeekDay, startHour, endHour) {
this.startWeekDay = startWeekDay;
this.endWeekDay = endWeekDay;
this.startHour = startHour;
this.endHour = endHour;
}
function tsAdHit(scriptView,iframeView)
{
var ref = _tsRef;
var theUrl = "http://script.tailsweep.com/siteadhit/"+scriptView.siteAdId + "?tsId=243372&accsid="+iframeView.concreteStatisticsId+"&sacsid="+scriptView.siteAdConcreteStatisticsId+"&rand="+getRand();
var tsUrl = tsGetUrl();
theUrl = theUrl + '&' + tsUrl;
var url = '<img src="'+theUrl+'" border="0" width="0" height="0" alt="" style="width:0px;height:0px;margin:0;padding:0;border-style:none;border-width:0" />';
document.write(url);
}
function detectFlash()
{
if(flashtested == 0)
{
var flashversion = 0;
var MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
var x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = true;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
{
flashinstalled = false;
}
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = true;
flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
var x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
{    flashinstalled = true;}
else
{    flashinstalled = true;}
}
else
{
MSDetect = "true";
}
if(MSDetect == "true")
{
document.write('<SCR'+'IPT LANGUAGE="VBScript"> \n');
document.write('on error resume next \n');
document.write('For i = 2 to 6 \n');
document.write('If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then \n');
document.write('Else \n');
document.write('flashinstalled = true \n');
document.write('flashversion = i \n');
document.write('End If \n');
document.write('Next \n');
document.write('If flashinstalled = 0 Then \n');
document.write('flashinstalled = false \n');
document.write('End If \n');
document.write('</SC'+'RIPT> \n');
}
flashtested = 1;
}
return flashinstalled
}
// Modified version of http://developer.apple.com/internet/webcontent/detectplugins.html
// initialize global variables
var detectableWithVB = false;
var pluginFound = false;
function canDetectPlugins() {
if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
return true;
} else {
return false;
}
}
function detectFlash2() {
pluginFound = detectPlugin('Shockwave','Flash');
// if not found, try to detect with VisualBasic
if(!pluginFound && detectableWithVB) {
pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
}
// check for redirection
return pluginFound;
}
function detectDirector() {
pluginFound = detectPlugin('Shockwave','Director');
// if not found, try to detect with VisualBasic
if(!pluginFound && detectableWithVB) {
pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
}
// check for redirection
return pluginFound;
}
function detectQuickTime() {
pluginFound = detectPlugin('QuickTime');
// if not found, try to detect with VisualBasic
if(!pluginFound && detectableWithVB) {
pluginFound = detectQuickTimeActiveXControl();
}
return pluginFound;
}
function detectReal() {
pluginFound = detectPlugin('RealPlayer');
// if not found, try to detect with VisualBasic
if(!pluginFound && detectableWithVB) {
pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
}
return pluginFound;
}
function detectWindowsMedia(redirectURL, redirectIfFound) {
pluginFound = detectPlugin('Windows Media');
// if not found, try to detect with VisualBasic
if(!pluginFound && detectableWithVB) {
pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
}
return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}
function detectPlugin() {
// allow for multiple checks in a single pass
var daPlugins = detectPlugin.arguments;
// consider pluginFound to be false until proven true
var pluginFound = false;
// if plugins array is there and not fake
if (navigator.plugins && navigator.plugins.length > 0) {
var pluginsArrayLength = navigator.plugins.length;
// for each plugin...
for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
// loop through all desired names and check each against the current plugin name
var numFound = 0;
for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
// if desired plugin name is found in either plugin name or description
if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
// this name was found
numFound++;
}
}
// now that we have checked all the required names against this one plugin,
// if the number we found matches the total number provided then we were successful
if(numFound == daPlugins.length) {
pluginFound = true;
// if we've found the plugin, we can stop looking through at the rest of the plugins
break;
}
}
}
return pluginFound;
} // detectPlugin
// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
document.writeln('<script language="VBscript">');
document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
document.writeln('detectableWithVB = False');
document.writeln('If ScriptEngineMajorVersion >= 2 then');
document.writeln('  detectableWithVB = True');
document.writeln('End If');
document.writeln('\'this next function will detect most plugins');
document.writeln('Function detectActiveXControl(activeXControlName)');
document.writeln('  on error resume next');
document.writeln('  detectActiveXControl = False');
document.writeln('  If detectableWithVB Then');
document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
document.writeln('  End If');
document.writeln('End Function');
document.writeln('\'and the following function handles QuickTime');
document.writeln('Function detectQuickTimeActiveXControl()');
document.writeln('  on error resume next');
document.writeln('  detectQuickTimeActiveXControl = False');
document.writeln('  If detectableWithVB Then');
document.writeln('    detectQuickTimeActiveXControl = False');
document.writeln('    hasQuickTimeChecker = false');
document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
document.writeln('    If IsObject(hasQuickTimeChecker) Then');
document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
document.writeln('        detectQuickTimeActiveXControl = True');
document.writeln('      End If');
document.writeln('    End If');
document.writeln('  End If');
document.writeln('End Function');
document.writeln('</scr' + 'ipt>');
}
function renderAd(myTsAd)
{
var adCountryCode = myTsAd.countryCode;
var adRegionCode = myTsAd.regionCode;
var diff = 1;
/*
if(isSet(myTsAd.endDate))
{
diff = myTsAd.endDate - new Date();
}
*/
var uniqueOK = incrementCookie(myTsAd.siteAdId,myTsAd.frequence, myTsAd.frequenceDays);
var sessionUniqueOK = incrementSessionCookie(myTsAd.siteAdId,myTsAd.sessionFrequence);
var inCountry = isInCountry(adCountryCode);
var inRegion = isInRegion(adRegionCode);
var allOK = diff > 0 && uniqueOK && sessionUniqueOK && inCountry && inRegion;
if(allOK)
{
if(headerShown == "false")
{
headerShown = "true";
showHeader();
}
tsAdsRendered_midContent_slot[currentSlot-1]=1;
tsAdsRendered_midContent++;
++success;
if(success > 1)
{
document.write("<img border='0' src='http://files.tailsweep.com/resources/pix.gif' height='10' width='1' alt='vspacer' style='width:1px;height:10px;margin: 0 auto;padding:0;border-style:none;border-width:0' />");
}
//var divId =
if(myTsAd.renderType==1)
{
document.write('<div style="height:'+myTsAd.height+'px;">');
document.write("<iframe src='" + myTsAd.url +"'  name='tsIframe_" + myTsAd.siteAdId + "' width='" + myTsAd.width + "' height='" + myTsAd.height + "' vspace='0' hspace='0' allowtransparency='true' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' style='width:"+ myTsAd.width + "px; height:" + myTsAd.height + "px; border: 0px;'></iframe>");
document.write("</div>");
}
else if(myTsAd.renderType==2)
{
var scriptView = scriptViewMap[myTsAd.siteAdId];
if(scriptView)
{
var iframeViews = scriptView.iframeViews;
if(iframeViews && iframeViews.length > 0)
{
var maxIterations = 20;
for (var x = 0; x < maxIterations && iframeViews.length; x++)
{
//var flash = detectFlash();
var flash = detectFlash2();
//alert(flash + " "+flash2)
var random = getRandomNr(iframeViews.length);
var iframeView = iframeViews[random];
iframeViews.splice(x, 1);
if(tsIsAdContentActive(iframeView.activePeriods))
{
var siteAdId = scriptView.siteAdId;
var siteAdCsId = scriptView.siteAdConcreteStatisticsId;
var adContentCsId = iframeView.concreteStatisticsId;
if (typeof(tsMeasurement)=="undefined") {var tsMeasurement="";}
if((iframeView.type == 1 && flash) || iframeView.type == 2 || iframeView.type == 0)
{
document.write(iframeView.mainContent);
}
else if(!(navigator.appName && navigator.appName.indexOf("Netscape") >= 0 && navigator.appVersion.indexOf("2.") >= 0))
{
document.write(iframeView.fallbackContent);
}
if(iframeView.javascriptContent != '' && iframeView.javascriptContent.trim().length > 0)
{
var rand = Math.round(Math.random()*2147483647);
var javascriptContent = iframeView.javascriptContent;
javascriptContent = javascriptContent.replace('%RANDOM%', rand);
javascriptContent = javascriptContent.replace('[timestamp]', rand);
eval(javascriptContent);
}
if(iframeView.htmlContent != '' && iframeView.htmlContent.trim().length > 0)
{
document.write(iframeView.htmlContent);
}
if(iframeView.javascriptSource != '' && iframeView.javascriptSource.trim().length > 0)
{
var rand = Math.round(Math.random()*2147483647);
var source = iframeView.javascriptSource;
source = source.replace('%RANDOM%', rand);
source = source.replace('[timestamp]', rand);
document.write('<scr'+'ipt src="'+source+'" type="text/javascr'+'ipt"></scr'+'ipt>');
}
if(tsMeasurement != "external")
{
tsAdHit(scriptView,iframeView);
}
break;
}
}
}
}
}
}
}
function renderSkyScraperAds(ads, maxAds)
{
//Do not bother rendering more than min(ads.length,maxAds) ads
if (ads.length < maxAds)
{
maxAds = ads.length;
}
for(var i = 0; i < maxAds && ads.length > 0; i++)
{
var adIdx = getRandomNr(ads.length);
var ad = ads[adIdx];
var adSov = parseInt(ad.sov,10);
var rand = getRandomNr(100);
if(rand < adSov)
{
renderAd(ad);
}
ads.splice(adIdx,1);
}
}
//The idea is that we try to keep the probability intact for each available slot.
function renderMaxOneAdPerSlot(ads, maxAds)
{
//Do not bother trying to calculate probability for slots which are not used.
if (ads.length < maxAds)
{
maxAds = ads.length;
}
var bookedSov = 0;
//The total number of "slots" available (ads, already shown ads, empty space).
var maxSov = parseInt((maxAds*100),10);
//Set the start and end point for ads within the maxSov (it will be used by the rand stuff later).
//All the ads are located at the beginning of the maxSov range, so if there are 2 ads at 50% SOV and 3 placements, maxSov will be 300 and the ads will occupy the first 100 of those "slots".
for (var i=0;i<ads.length;i++)
{
var ad = ads[i];
var adSov = parseInt(ad.sov,10);
ad.sovRange={"start":bookedSov, "end": (bookedSov + adSov - 1)};
bookedSov = ad.sovRange.end+1;
}
if(bookedSov > maxSov)
{
maxSov = bookedSov;
}
//The probability of hitting an ad (and not empty space) is used later, when we need to resize maxSov as ads are rendered.
var probability = bookedSov/maxSov;
var removed = [];
for(var i=0; i < maxAds; i++)
{
var nextRand = 0;
var loop = 0;
var maxLoop = 10;
while(nextRand == 0 && loop < maxLoop)
{
nextRand = getRandomNr(maxSov);
for (var j=0;j<removed.length; j++)
{
var ad = removed[j];
if(ad.sovRange.start <= nextRand && ad.sovRange.end >= nextRand)
{
nextRand = 0;
break;
}
}
loop++;
}
for (var j=0;j<ads.length;j++)
{
var ad = ads[j];
if(ad.sovRange.start <= nextRand && ad.sovRange.end >= nextRand)
{
ads.splice(j,1);
removed.push(ad);
renderAd(ad);
//We have rendered an ad, to keep the probability of hitting another ad intact, we need to recalculate maxSov.
bookedSov -= (ad.end - ad.start);
var removedSize = 0;
for (var k=0;k<removed.length; k++)
{
var removedAd = removed[k];
removedSize += (removedAd.end - removedAd.start);
}
maxSov = (bookedSov / probability) + removedSize;
}
}
}
return ads;
}
function geoCallback(myTsAd)
{
/*if(headerShown == "false")
{
headerShown = "true";
showHeader();
}*/
var el = document.getElementById(myTsAd.divId);
var s = "";
s += "<iframe src='" + myTsAd.url +"' name='tsIframe_" + myTsAd.siteAdId + "'  width='" + myTsAd.width + "' height='" + myTsAd.height + "' vspace='0' hspace='0' allowtransparency='true' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' style='width:"+ myTsAd.width + "px; height:" + myTsAd.height + "px; border: 0px;'></iframe>";
s += "<img border='0' src='http://files.tailsweep.com/resources/pix.gif' height='10' width='1' alt='vspacer' style='width:1px;height:10px;margin: 0 auto;padding:0;border-style:none;border-width:0' />";
el.innerHTML = s;
}
if (typeof(midContentIdx)=="undefined") {var midContentIdx=1;}
if(window.tailsweep_currPos_midContent!=null)
{
window.tailsweep_currPos_midContent++;
}
else
{
window.tailsweep_currPos_midContent=1;
}
//Placement type 0
var currentSlot = window.tailsweep_currPos_midContent;
tsAdsRendered_midContent_slot[currentSlot-1]=0;
if( currentSlot == midContentIdx )
{
if(tsTools.isDebug() || true)
{
if(typeof(tsAdStyle)=="undefined") {var tsAdStyle='text-align: center';}
document.write('<style type="text/css">.tailsweep-div{font-family: arial,verdana,sans-serif;font-size: 12px;color: #000000;margin: 0 auto; padding: 0; display: block;} .smallBr{font-size: 1px;line-height: 0;} .tailsweep-host,.tailsweep-host:link{color:green;font-size:10} .tailsweep-buylink:link{color:#00c;font-size:12px} .tailsweep-buylink:visited{color:#551a8b;font-size:12px} .tailsweep-buylink:active {color:red;font-size:12px} .tailsweep-link:link {color:#00c;font-size:12px;font-weight:bold} .tailsweep-link:visited {color:#551a8b;font-size:12px} .tailsweep-link:active {color:red;font-size:12px} .tailsweep-title:link {color:#00c;font-size:12px;font-weight:bold} .tailsweep-title:visited {color:#551a8b;font-size:12px} .tailsweep-title:active {color:red;font-size:12px} .tailsweep-title:hover {color:#00c;font-size:16px;text-decoration: underline;}</style>');
document.write("<div class='tailsweep-div' id='tailsweep-div-midContent' style='"+tsAdStyle+"'>");
if(tsTools.isDebug())
{
var randPopUpId = getRandomNr(1000);
document.write('<div id="tsDebugPop_'+randPopUpId+'" style="display:none;border:#666 1px solid;width:200px;height:110px;text-align:left;background:#eee;position:fixed;z-index:99;left:40%;top:40%;padding:0px 5px 10px 5px;"><p style="cursor:pointer;text-align:right;margin:0px;" onclick="this.parentNode.style.display=\'none\';">X</p>Height<br/><input onkeyup="document.getElementById(\'tsDebugAd_'+randPopUpId+'\').style.height=this.value+\'px\';"><br />Width:<br/><input onkeyup="document.getElementById(\'tsDebugAd_'+randPopUpId+'\').style.width=this.value+\'px\';"></div>');
document.write('<button id="tsDebugAd_'+randPopUpId+'" onclick="tsTools.PosPopUp(\'tsDebugPop_'+randPopUpId+'\',this.offsetLeft,this.offsetTop,20);document.getElementById(\'tsDebugPop_'+randPopUpId+'\').style.display=\'block\';" style="border:#000 0px solid;background-image:none;background-color:#ff17fc;text-align:center;font-size:12px;color:#fff; ' );
var H=tsTools.getQParam('tsHMC') ||"250";
var W=tsTools.getQParam('tsWMC') ||"375";
document.write(' height:'+H+'px;width:'+W+'px;">Tailsweep Debug<br />midContent');
document.write('</button>');
}
else
{
var ads_midContent = [[], [], [], [], []];
var tsLoadArray_midContent = true;
if(tsLoadArray_midContent)
{
var tsAd1 = new TsAd('http://script.tailsweep.com/html/sitead/5/51/513473_iframe.html?'+tsGetUrl(), '300', '250', '513473', '15086325', 'GB', '0', 100, '0', '0', '0', Date.parse('February, 21 2010 23:00:00 GMT'), Date.parse('April, 02 2010 21:59:00 GMT'),2);
ads_midContent[0].push(tsAd1);
var tsAd2 = new TsAd('http://script.tailsweep.com/html/sitead/5/51/513539_iframe.html?'+tsGetUrl(), '300', '250', '513539', '15088107', 'GB', '0', 80, '0', '0', '0', Date.parse('March, 14 2010 23:00:00 GMT'), Date.parse('March, 28 2010 21:59:00 GMT'),2);
ads_midContent[0].push(tsAd2);
if (typeof(tsGlobalMaxAds_midContent)=='undefined')
{
var tsGlobalMaxAds_midContent = 0;
for(var i = 0;i<ads_midContent.length && tsGlobalMaxAds_midContent == 0;i++)
{
if(ads_midContent[i].length > 0)
{
tsGlobalMaxAds_midContent = ads_midContent[i].length;
}
}
}
}
var maxAds = 1;
for(var i=0;i<ads_midContent.length;i++)
{
if(ads_midContent[i].length > 0 && success == 0)
{
renderMaxOneAdPerSlot(ads_midContent[i], maxAds);
}
}
}
document.write('</div>');
}
tsPlacementHit();
}
