geoLookupNeeded="false";
adsNeedGeo="";
var tsSitePlacementProperties = [];
String.prototype.tsTrim = function () { return this.replace(/^\s+|\s+$/g, ''); };
Date.prototype.mGetDay = function () {
return (this.getDay() + 6) %7;
};
if(window.G === undefined){window.G = window;}
/* --- Create the TS object only once (shared between placements)  */
var TS;
if (TS===undefined) {
TS = {};
/* TS Functions ----------------------------------------------------------------------------------------------------- */
TS.isDebug = function ()
{
if(window.location.href.indexOf('tsDebug=1') != -1){
return true;
}
else{
return false;
}
};
TS.renderDebugAd = function (height, width, text)
{
var randPopUpId = this.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="TS.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; height:'+height+'px;width:'+width+'px;">' + text + '</button>');
};
/* Choose a random filler from the filler array */
TS.renderFillerAd = function (currentSlot, fillerAds, placementId)
{
var randomFiller = this.getRandomNr(fillerAds.length);
var chosenFiller = fillerAds[randomFiller];
document.write(tsApplyRandom(chosenFiller.content));
var theUrl = "http://script.tailsweep.com/siteplacementfillersupplierhit/" +
"338898" + "?" +
"tsId=" + "338898" +
"&placementId=" + placementId +
"&slot=" + currentSlot +
"&supplierId=" + chosenFiller.fillerSupplier +
"&partnerPlacementId=" + chosenFiller.sitePlacement +
"&sitePlacementFillerSupplierId=" + chosenFiller.id;
this.writeStatImg(theUrl);
};
/* Validates if we should display the ad in regard to active periods */
TS.isAdContentActive = function(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;
};
/* http://stackoverflow.com/questions/962802/is-it-correct-to-use-javascript-array-sort-method-for-shuffling */
TS.shuffleArray = function(array) {
var tmp, current, top = array.length;
if(top)
{
while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
}
return array;
};
TS.getQParamFromStr = function (str, paramName)
{
var regex = new RegExp("[\\?&]"+paramName+"=([^&#]*)");
var qParam = regex.exec(str);
if(qParam === null){
return "";
}
return qParam[1];
};
TS.getQParam = function (paramName)
{
return this.getQParamFromStr(window.location.href,paramName);
};
TS.PosPopUp = function (id,x,y,offset)
{
var el = document.getElementById(id);
el.style.left=x+offset;
el.style.top=y-document.body.scrollTop+offset;
};
TS.getRand = function ()
{
var uu=Math.round(Math.random()*2147483647);
return uu;
};
TS.getRandomNr = function (max)
{
var ranNum= Math.floor(Math.random()*(max));
return ranNum;
};
TS.getBrowserProperties = function ()
{
return '&tsSW='+self.screen.width+'&tsSH='+self.screen.height+'&tsSC='+self.screen.colorDepth+'&tsPD='+self.screen.pixelDepth;
};
TS.encode = function (s,u)
{
if (typeof(encodeURIComponent) == 'function') {
if (u) {return encodeURI(s);}
else {return encodeURIComponent(s);}
}
else {
return escape(s);
}
};
TS.writeSessionCookie = function (cookieName, cookieValue)
{
if (this.testSessionCookie()) {
document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
return true;
}
else {return false;}
};
TS.testSessionCookie = function ()
{
document.cookie ="testSessionCookie=Enabled";
if (this.getCookieValue ("testSessionCookie")=="Enabled")
{ return true;}
else
{  return false;}
};
TS.getCookieValue = function (cookieName) {
var exp = new RegExp (escape(cookieName) + "=([^;]+)");
if (exp.test (document.cookie + ";")) {
exp.exec (document.cookie + ";");
return unescape(RegExp.$1);
}
else {return false;}
};
TS.writePersistentCookie = function (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=/";
};
TS.testPersistentCookie = function ()
{
this.writePersistentCookie ("testPersistentCookie", "Enabled", "minutes", 1);
if (this.getCookieValue ("testPersistentCookie")=="Enabled")
{  return true;}
else
{  return false;}
};
TS.incrementCookie = function (id,frequence,frequenceDays)
{
if(frequence != '' && frequence > 0)
{
var cval = this.getCookieValue("ts_ad_"+id);
if(!cval)
{
cval = 0;
}
if(cval < frequence)
{
cval++;
this.writePersistentCookie ("ts_ad_"+id, cval, "days", frequenceDays);
return true;
}
return false;
}
return true;
};
TS.incrementSessionCookie = function (id, sessionFrequence)
{
if(sessionFrequence != '' && sessionFrequence > 0)
{
var cval = this.getCookieValue("ts_ad_session"+id);
if(!cval)
{
cval = 0;
}
if(cval < sessionFrequence)
{
cval++;
this.writeSessionCookie("ts_ad_session"+id, cval);
return true;
}
return false;
}
return true;
};
TS.writeStatImg = function (url)
{
if(window.statImgCSSIsSet === undefined)
{
document.write('<style type="text/css">.tsStatImg{width:0px;height:0px;margin:0;padding:0;border-style:none;border-width:0;display:none;}</style>');
window.statImgCSSIsSet = true;
}
url += "&" + this.getUrl();
document.write('<img src="'+url+'" border="0" width="0" height="0" class="tsStatImg" alt="" />');
};
TS.getUrl = function ()
{
var s="";
s+="tsUUI="+this.getRand();/* Random number */
s += "&tsLho=" + this.ho; 		/* Random hostname */
s += "&tsQu=" + this.qu;  		/* Query string */
s += "&tsRef=" + this.ref; 		/* Referrer */
s += "&tsLP="+this.lp; 			/* Pathname */
s += this.bp; 							/* screen width and height and color- and pixel-depth */
return s;
};
TS.isInCountry = function (adCountryCode)
{
var placeholder = "%COUNTRY"+"_CODE%"; /* If we failed to replace it server-side */
var isin = (adCountryCode === "0" || adCountryCode === 0 || adCountryCode === "" || adCountryCode == this.countryCode || this.countryCode == placeholder);
return isin;
};
TS.isInRegion = function (adRegionCode)
{
var placeholder = "%REGION"+"_CODE%"; /* If we failed to replace it server-side */
var isin = (adRegionCode === "0" || adRegionCode === 0 || adRegionCode === "" || adRegionCode == this.regionCode || this.regionCode == placeholder);
return isin;
};
TS.showAdHeader = function ()
{
document.write('<div><a class="tailsweep-link" href="http://www.tailsweep.com/"><img border="0" src="http://files.tailsweep.com/resources/ts_adheader_140_sv.png" width="140" height="9" alt="" style="padding:0;margin: 0 auto;border-style:none;border-width:0;"/></a></div>');
};
TS.deleteFromAds = function (ads, ad)
{
for(i=0;i<ads.length;i++)
{
if(ads[i].siteAdId === ad.siteAdId)
{
ads.splice(i,1);
}
}
};
TS.contains = function(a, obj)
{
for(var i = 0; i < a.length; i++)
{
if(a[i] === obj)
{
return true;
}
}
return false;
};
/* TS Variables ----------------------------------------------------------------------------------------------------- */
TS.bd=document;
TS.dl=TS.bd.location;
TS.ho = (TS.dl.hostname && TS.dl.hostname != "")  ? TS.encode(TS.dl.hostname) : "";
TS.lp = (TS.dl.pathname && TS.dl.pathname != "") ? TS.dl.pathname : "";
TS.qu = (TS.dl.search && TS.dl.search != "") ? TS.encode(TS.dl.search) : "";
TS.ref = (TS.bd.referrer && TS.bd.referrer != "") ? TS.encode(TS.bd.referrer) :"";
TS.session = TS.getCookieValue("ts_session") ? TS.getCookieValue("ts_session") : "";
TS.uid = TS.getCookieValue("ts_uid") ? TS.getCookieValue("ts_uid") : "";
TS.uv = TS.getCookieValue("ts_uv") ? TS.getCookieValue("ts_uv") : "";
TS.bp = TS.getBrowserProperties() || "";
var tsUrl = (tsUrl === undefined) ? "" : tsUrl;
TS.tsUrl = (tsUrl != "") ? escape(tsUrl) : "";
TS.countryCode=TS.getQParam('tsCountryCode') ||"%COUNTRY_CODE%";
TS.regionCode=TS.getQParam('tsRegionCode') ||"%REGION_CODE%";
}
// Modified version of http://developer.apple.com/internet/webcontent/detectplugins.html
/* Initialize global variables */
var detectableWithVB = false;
var pluginFound = 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 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;
}
/* 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('</scr' + 'ipt>');
}
var headerShown = "false";
var adsRenderedInSlot = 0;  /* Reset  the number of ads rendered in this current slot  (This var used to be named "success" ) */
if(G.tsAdsRendered_right_slot === undefined){G.tsAdsRendered_right_slot =[];}
if(G.tsAdsRendered_right === undefined){G.tsAdsRendered_right=0;}
function toggleAll() {
var current = arguments[0];
var next = arguments[1];
var cQ = current + '_question';
var cA = current + '_answer';
var cB = current + '_button';
var cL = current + '_line';
var nQ = next + '_question';
var nA = next + '_answer';
var nB = next + '_button';
var nL = next + '_line';
toggleIt(cQ,cA,cB,cL,nQ,nA,nB,nL);
}
function toggleIt(obj) {
var elements = [];
for (var i = 0,len = arguments.length;i < len; i++)
{
var element = arguments[i];
var el = document.getElementById(element);
if(el != undefined)
{
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
}
return false;
}
function tsApplyRandom(content)
{
var rand = TS.getRand();
content = content.replace(/\[timestamp\]/g, rand);
return content;
}
function tsPlacementHit()
{
var url = "http://script.tailsweep.com/siteplacementhit/338898" + "?sitePlacements=1,"+G.ts_currentSlot_right +"&tsSession="+TS.session+"&tsUid="+TS.uid+"&tsUV="+TS.uv+"&tsUrl="+TS.tsUrl;
TS.writeStatImg(url);
}
function tsAdHit(scriptView,adContent)
{
var url = "http://script.tailsweep.com/siteadhit/"+scriptView.siteAdId + "?tsId=338898&accsid="+adContent.concreteStatisticsId+"&sacsid="+scriptView.siteAdConcreteStatisticsId+"&rand="+TS.getRand();
TS.writeStatImg(url);
}
function tsRect(id, width, height)
{
var obj = document.getElementById(id);
if(obj)
{
obj.style.clip="rect(0,"+width+"px,"+height+"px,0)";
var emb = tsGetEmbed(obj);
if(emb)
{
emb.style.clip="rect(0,"+width+"px,"+height+"px,0)";
}
}
}
function tsGetEmbed(object)
{
for(var i=0;i<object.childNodes.length;i++)
{
var e = object.childNodes[i];
if(e.nodeName=="EMBED")
{
return e;
}
}
}
function renderAd(siteAdId)
{
var ad = G.ts_right_siteAdMap[siteAdId];
var uniqueOK = TS.incrementCookie(ad.siteAdId,ad.frequence, ad.frequenceDays);
var sessionUniqueOK = TS.incrementSessionCookie(ad.siteAdId,ad.sessionFrequence);
var inCountry = TS.isInCountry(ad.countryCode);
var inRegion = TS.isInRegion(ad.regionCode);
var allOK = uniqueOK && sessionUniqueOK && inCountry && inRegion;
if(allOK)
{
if(headerShown == "false")
{
headerShown = "true";
TS.showAdHeader();
}
tsAdsRendered_right_slot[currentSlot-1]=1;         tsAdsRendered_right++;
if(adsRenderedInSlot > 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;display:none;" />');
}
if(ad.renderType==1)         {
document.write('<div style="height:'+ad.height+'px;">');
document.write("<iframe src='" + ad.url +"'  name='tsIframe_" + ad.siteAdId + "' width='" + ad.width + "' height='" + ad.height + "' vspace='0' hspace='0' allowtransparency='true' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' style='width:"+ ad.width + "px; height:" + ad.height + "px; border: 0px;'></iframe>");
document.write("</div>");
++adsRenderedInSlot;
}
else if(ad.renderType==2)         {
var siteAd = G.ts_right_siteAdMap[ad.siteAdId];
if(siteAd)
{
var adContents = siteAd.adContents;
if(adContents && adContents.length > 0)
{
var maxIterations = 20;
for (var x = 0; x < maxIterations && adContents.length; x++)
{
var flash = detectFlash2();
var random = TS.getRandomNr(adContents.length);
var adContent = adContents[random];
adContents.splice(x, 1);
if(TS.isAdContentActive(adContent.activePeriods))
{
var collHeight = adContent.adContentProperties.expandableHeightCollapsed;
var expHeight =  adContent.adContentProperties.expandableHeightExpanded;
var expandable = typeof(collHeight) != "undefined" && typeof(expHeight) != "undefined";
var rand = TS.getRand();
if(expandable)
{
document.write('<div style="width:'+ad.width+'px;height:'+collHeight+'px;z-index:999996;position:relative;margin:0 auto; padding:0;">');
var onmouseoverFunc = "tsRect('tailsweep-ad-"+adContent.id+"', "+ad.width +", "+expHeight+")";
var onmouseoutFunc = "tsRect('tailsweep-ad-"+adContent.id+"', "+ad.width +", "+collHeight+")";
document.write('<div style="width:'+ad.width+'px;height:'+expHeight+'px;z-index:999997;position:relative;margin:0 auto; padding:0;" onmouseover="'+onmouseoverFunc+'" onmouseout="'+onmouseoutFunc+'">');
}
var tsMeasurement = (tsMeasurement === undefined) ? "" : tsMeasurement;
if((adContent.type == 1 && flash) || adContent.type == 2 || adContent.type == 0)
{
document.write(tsApplyRandom(adContent.mainContent));
}
else if(!(navigator.appName && navigator.appName.indexOf("Netscape") >= 0 && navigator.appVersion.indexOf("2.") >= 0))
{
document.write(tsApplyRandom(adContent.fallbackContent));
}
if(adContent.javascriptContent != '' && adContent.javascriptContent.tsTrim().length > 0)
{
var javascriptContent  = tsApplyRandom(adContent.javascriptContent);
eval(javascriptContent);
}
if(adContent.htmlContent != '' && adContent.htmlContent.tsTrim().length > 0)
{
document.write(tsApplyRandom(adContent.htmlContent));
}
if(expandable)
{
document.write("</div></div>");
}
if(tsMeasurement != "external")
{
tsAdHit(siteAd,adContent);
}
++adsRenderedInSlot;
return true;
}
}
}
}
}
}
}
function renderSkyScraperAds(ads, maxAds)
{
if (ads.length < maxAds)
{
maxAds = ads.length;
}
var numOfAvailableAds = ads.length;
for(var i = 0;  i < numOfAvailableAds; i++)
{
var adIdx = TS.getRandomNr(ads.length);
var ad = ads[adIdx];
var adSov = parseInt(ad.sov,10);
var rand = TS.getRandomNr(100);
if(rand < adSov)
{
renderAd(ad.siteAdId);
}
ads.splice(adIdx,1);
if(adsRenderedInSlot == maxAds)
{
break;
}
}
}
/*
START Site Ads -------------------------------------------------------
*/
// Init siteAdMap once per placement
if(G.ts_right_siteAdMap === undefined)
{
G.ts_right_siteAdMap = {};
}
/*
END Site Ads -------------------------------------------------------
*/
if(G.rightIdx === undefined){G.rightIdx = 1;};
G.ts_currentSlot_right = (G.ts_currentSlot_right === undefined) ? 1 : G.ts_currentSlot_right+1;
var currentSlot = G.ts_currentSlot_right;
G.tsAdsRendered_right_slot[currentSlot-1]=0;
G.ts_right_maxAds = 3;
if( currentSlot == rightIdx )
{
G.ts_slotsEntered = currentSlot+1-rightIdx;
if(TS.isDebug() || true)
{
document.write('<style type="text/css">.tailsweep-div{text-align:center;font-family: arial,verdana,sans-serif;font-size: 12px;color: #000;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{font-size:12px} .tailsweep-link{color:#00c;font-size:12px;font-weight:bold} .tailsweep-title{color:#00c;font-size:12px;font-weight:bold}</style>');
if (typeof(tsAdStyle)=="undefined") {var tsAdStyle="";}
document.write('<div class="tailsweep-div" id="tailsweep-div-right" style="'+tsAdStyle+'">');
if(TS.isDebug())
{
TS.renderDebugAd(600, 160, 'Tailsweep Debug<br />right');
}
else
{
}
document.write('<div class="tailsweep-div" style="'+tsAdStyle+'">'+"<a class='tailsweep-buylink' href='http://www.tailsweep.se/staticse/advertisers.html'>Annonsera h&auml;r</a>"+'</div>');
document.write('</div>');
}
tsPlacementHit();
}

