
var _listingAdPreViewportWidth,adServerURL,d,ds,dsv;
TradeMeAds={};
_listingAdPreViewportWidth=1024;adServerURL="http://ads.trademe.co.nz";d=document.domain;ds=d.split('.');dsv=ds[ds.length-3].toLowerCase();
if(dsv=="trademe"){document.domain="trademe.co.nz";}
else if(dsv=="findsomeone"){document.domain="findsomeone.co.nz";}
else if(dsv=="oldfriends"){document.domain="oldfriends.co.nz";}
else if(dsv=="travelbug"){document.domain="travelbug.co.nz";}
function JsonTradeMeAds(data){
var divOfAdTwo = null;
var adData = data.html.split('**|**');
//handle banner ad
if(data.type.toLowerCase()=='banner468x60'){
if (adData.length>1){
jQuery("#sideAd").show();
jQuery("#SkyscraperAdLabel").show();
jQuery("#SkyscraperAd").css("overflow","hidden");
jQuery("#SkyscraperAd").css("width","160px");
jQuery("#SkyscraperAd").css("height","600px");
divOfAdTwo='SkyscraperAd';}}
//else handle a tower ad
else if(data.type.toLowerCase()=='tower')
{jQuery("#divTab").css("overflow","hidden");jQuery("#divTab").css("width","200px");jQuery("#divTab").css("height","80px");divOfAdTwo='divTab';}
if(data.html!=""){
if(data.type.toLowerCase()=='tower'||data.type.toLowerCase()=='skyscraper'){jQuery("#"+data.divID).css("margin-left","auto");jQuery("#"+data.divID).css("margin-right","auto");}
if(data.width!=="" && data.height!==""&& data.width!="-1"&& data.height!="-1"){jQuery("#"+data.divID).css("overflow","hidden");}
if(data.width!=="" && data.width!=="-1"){jQuery("#"+data.divID).css("width",data.width+"px");}
if(data.height!=="" && data.height!=="-1"){jQuery("#"+data.divID).css("height",data.height+"px");}
if (adData[0].indexOf('TMBlankAd') == -1 && jQuery("#BannerAdLabel").length != 0){jQuery("#BannerAdLabel").show();}
jQuery("#"+data.divID).append(adData[0]);
if (divOfAdTwo!=null){jQuery("#"+divOfAdTwo).append(adData[1]);}
if(data.isFlash=="True"){jQuery.getScript(adServerURL+"/JavaScript/swfobject.js",function(){eval(data.script);eval(data.scriptAdTwo);});}
    else {if (data.script!="") {eval(data.script);} if (data.scriptAdTwo!="") {eval(data.scriptAdTwo);}}}}
function SendJSONRequest(query){
var screenRes,url;
if(jQuery(window).width()<975){screenRes=1;}else{screenRes=2;}
url=adServerURL+"/DisplayJSONAd.aspx?"+query+"&res="+screenRes;
jQuery.getJSON(url+"&jsoncallback=?",function(data){JsonTradeMeAds(data);});}
TradeMeAds.GetAds={
displayAd:function(theParamObject){
var adDivElement,whatsCool,TradeMeAd_adIframe,TradeMeAd_adIframeUrl,TradeMeAd_adIframeUrl_width,TradeMeAd_adIframeUrl_height,screenRes;
adDivElement=document.getElementById(theParamObject.adDiv);
if (theParamObject.t == 'WhatsCool') {
whatsCool = document.getElementById('WhatsCoolControl');
if (whatsCool != null) {
whatsCool.style.display='none';whatsCool.style.visibility='hidden';}}
if(adDivElement){
TradeMeAd_adIframe=document.createElement("iframe");
if(dsv=='trademe'){
if (TradeMe.Dom.getViewportWidth()<975){screenRes=1;}else{screenRes=2;}
_listingAdPreViewportWidth=TradeMe.Dom.getViewportWidth();
}else{screenRes=2;}
TradeMeAd_adIframe.id="TradeMeAd_adIframe_" + theParamObject.t;
TradeMeAd_adIframe.name="TradeMeAd_adIframe_name_" + theParamObject.t;
TradeMeAd_adIframe.scrolling="no";
TradeMeAd_adIframe.frameBorder="0";
TradeMeAd_adIframe.allowTransparency="true";
TradeMeAd_adIframe.style.marginLeft="0.1px";
switch(theParamObject.t){
case "Tab":
case "EnvironmentTab":TradeMeAd_adIframeUrl_width="200px";TradeMeAd_adIframeUrl_height="80px";break;
case "Tower":TradeMeAd_adIframeUrl_width="150px";TradeMeAd_adIframeUrl_height="300px";break;
case "Banner468x60":
case "AgridataBanner468x60_1":
case "AgridataBanner468x60_2":
case "AgridataBanner468x60_3":
case "AgridataBanner468x60_4":
case "InterestMortgagesBanner468x60_2":
case "InterestMortgagesBanner468x60_3":
case "InterestMortgagesBanner468x60_4":
case "InterestMortgagesBanner468x60_5":
case "InterestCallBanner468x60_1":
case "InterestCallBanner468x60_2":
case "InterestCallBanner468x60_3":
case "InterestCallBanner468x60_4":
case "InterestCallBanner468x60_5":
case "InterestTerm1Banner468x60_1":
case "InterestTerm1Banner468x60_2":
case "InterestTerm1Banner468x60_3":
case "InterestTerm1Banner468x60_4":
case "InterestTerm1Banner468x60_5":
case "InterestTerm2Banner468x60_1":
case "InterestTerm2Banner468x60_2":
case "InterestTerm2Banner468x60_3":
case "InterestTerm2Banner468x60_4":
case "InterestTerm2Banner468x60_5":
case "InterestCashpiesBanner468x60_1":
case "InterestCashpiesBanner468x60_2":
case "InterestCashpiesBanner468x60_3":
case "InterestNewsHomeBanner468x60_1":
case "InterestNewsHomeBanner468x60_2":
case "InterestNewsHomeBanner468x60_3":
case "InterestNewsHomeBanner468x60_4":
case "InterestNewsHomeBanner468x60_5":
case "InterestRatesblogBanner468x60_1":
case "InterestRatesblogBanner468x60_2":
case "InterestRatesblogBanner468x60_3":
case "InterestRatesblogBanner468x60_4":
case "InterestRatesblogBanner468x60_5":TradeMeAd_adIframeUrl_width="468px";TradeMeAd_adIframeUrl_height="60px";break;
case "AgridataBanner760x120":
case "InterestMortgagesBigBanner":
case "InterestCallBigBanner":
case "InterestTerm1BigBanner":
case "InterestTerm2BigBanner":
case "InterestCashpiesBigBanner":
case "InterestNewsHomeBigBanner":
case "InterestHomeBigBanner":
case "InterestAccountFeesBigBanner":
case "InterestResourcesBigBanner":
case "InterestRegisterBigBanner":
case "InterestGalleriesBigBanner":
case "InterestRatesblogBigBanner":TradeMeAd_adIframeUrl_width="760px";TradeMeAd_adIframeUrl_height="120px";break;
case "LandingPage":TradeMeAd_adIframeUrl_width="300px";TradeMeAd_adIframeUrl_height="250px";break;
case "UtilityBar":if(dsv=='travelbug'){TradeMeAd_adIframeUrl_width="330px";TradeMeAd_adIframeUrl_height="20px";}else{TradeMeAd_adIframeUrl_width="150px";TradeMeAd_adIframeUrl_height="50px";}break;
case "CategoryTile":
case "WatchlistTile":TradeMeAd_adIframeUrl_width="200px";TradeMeAd_adIframeUrl_height="60px";break;
case "NewCarsLandingTileOne":
case "NewCarsLandingTileTwo":
case "NewCarsLandingTileThree":
case "NewCarsLandingTileFour":
case "LandingPageTileOne":
case "LandingPageTileTwo":
case "LandingPageTileThree":
case "LandingPageTileFour":TradeMeAd_adIframeUrl_width="135px";TradeMeAd_adIframeUrl_height="66px";break;
case "ListingOne":if(screenRes==1){TradeMeAd_adIframeUrl_width="160px";TradeMeAd_adIframeUrl_height="180px";}else{TradeMeAd_adIframeUrl_width="330px";TradeMeAd_adIframeUrl_height="75px";}break;
case "MessageBoard":TradeMeAd_adIframeUrl_width="163px";TradeMeAd_adIframeUrl_height="603px";break;
case "NewCarsBuyersChecklist":TradeMeAd_adIframeUrl_width="500px";TradeMeAd_adIframeUrl_height="120px";break;
case "PropertyChecklist":TradeMeAd_adIframeUrl_width="0px";TradeMeAd_adIframeUrl_height="0px";break;
case "MotorsChecklist":TradeMeAd_adIframeUrl_width="0px";TradeMeAd_adIframeUrl_height="0px";break;
case "JobsChecklist":TradeMeAd_adIframeUrl_width="0px";TradeMeAd_adIframeUrl_height="0px";break;
case "LandingPageIsland":
case "Island300x250":
case "NewCarsDetailsIsland":TradeMeAd_adIframeUrl_width="300px";TradeMeAd_adIframeUrl_height="250px";break;
case "InterestHomeSkyscraperLeft":
case "InterestHomeSkyscraperRight":
case "InterestMortgagesSkyscraperRight1":
case "InterestMortgagesSkyscraperRight2":
case "InterestMortgagesSkyscraperRight3":
case "InterestMortgagesSkyscraperRight4":
case "InterestCallSkyscraperRight1":
case "InterestCallSkyscraperRight2":
case "InterestCallSkyscraperRight3":
case "InterestCallSkyscraperRight4":
case "InterestTerm1SkyscraperRight1":
case "InterestTerm1SkyscraperRight2":
case "InterestTerm1SkyscraperRight3":
case "InterestTerm1SkyscraperRight4":
case "InterestTerm2SkyscraperRight1":
case "InterestTerm2SkyscraperRight2":
case "InterestTerm2SkyscraperRight3":
case "InterestTerm2SkyscraperRight4":
case "InterestCashpiesSkyscraperRight1":
case "InterestCashpiesSkyscraperRight2":
case "InterestCashpiesSkyscraperRight3":
case "InterestNewsHomeSkyscraperRight1":
case "InterestNewsHomeSkyscraperRight2":
case "InterestNewsHomeSkyscraperRight3":
case "InterestNewsHomeSkyscraperRight4":
case "InterestRatesblogSkyscraperRight1":
case "InterestRatesblogSkyscraperRight2":
case "InterestRatesblogSkyscraperRight3":
case "InterestRatesblogSkyscraperRight4":
case "InterestAccountFeesSkyscraperRight1":
case "InterestAccountFeesSkyscraperRight2":
case "InterestAccountFeesSkyscraperRight3":
case "InterestAccountFeesSkyscraperRight4":
case "InterestResourcesSkyscraperRight1":
case "InterestResourcesSkyscraperRight2":
case "InterestResourcesSkyscraperRight3":
case "InterestResourcesSkyscraperRight4":
case "InterestRegisterSkyscraperRight1":
case "InterestGalleriesSkyscraperRight1":
case "InterestGalleriesSkyscraperRight2":
case "InterestGalleriesSkyscraperRight3":
case "InterestGalleriesSkyscraperRight4":
case "Skyscraper":TradeMeAd_adIframeUrl_width="160px";TradeMeAd_adIframeUrl_height="600px";break;
case "WhatsCool":TradeMeAd_adIframeUrl_width="200px";TradeMeAd_adIframeUrl_height="250px";break;
case "TravelbugTravellersTips":
case "TravelbugEmailBanner":TradeMeAd_adIframeUrl_width="375px";TradeMeAd_adIframeUrl_height="60px";break;
default:TradeMeAd_adIframeUrl_width="0px";TradeMeAd_adIframeUrl_height="0px";}
TradeMeAd_adIframe.style.width=TradeMeAd_adIframeUrl_width;
if(TradeMeAd_adIframeUrl_height!=""){TradeMeAd_adIframe.style.height=TradeMeAd_adIframeUrl_height;}
TradeMeAd_adIframeUrl="s="+theParamObject.s+"&t="+theParamObject.t+"&sc="+theParamObject.sc;
if(theParamObject.i!=null&& theParamObject.i!=''){TradeMeAd_adIframeUrl=TradeMeAd_adIframeUrl+'&i='+theParamObject.i;}
if(theParamObject.clp!=null&& theParamObject.clp!=''){TradeMeAd_adIframeUrl=TradeMeAd_adIframeUrl+'&clp='+theParamObject.clp;}
if(theParamObject.tbal!=null&& theParamObject.tbal!=''){TradeMeAd_adIframeUrl=TradeMeAd_adIframeUrl+'&tbal='+theParamObject.tbal;}
if(theParamObject.rn!=null&& theParamObject.rn!=''){TradeMeAd_adIframeUrl=TradeMeAd_adIframeUrl+'&rn='+theParamObject.rn;}
TradeMeAd_adIframeUrl=TradeMeAd_adIframeUrl+"&res="+screenRes;
TradeMeAd_adIframeUrl=adServerURL+"/DisplayAd.aspx?"+TradeMeAd_adIframeUrl;
TradeMeAd_adIframe.src=TradeMeAd_adIframeUrl;
adDivElement.appendChild(TradeMeAd_adIframe);}},
reloadListingAds:function(){
var f,fcw;
if(_listingAdPreViewportWidth>975&& TradeMe.Dom.getViewportWidth()<=975){
f=document.getElementById('TradeMeAd_adIframe_ListingOne');
if(f!=null){
fcw=f.contentWindow.document.getElementById('lols');
if (fcw!=null){fcw.style.display='block';}
f.style.width="160px";
f.style.height="180px";
}}else if(_listingAdPreViewportWidth<=975&& TradeMe.Dom.getViewportWidth()>975){
f=document.getElementById('TradeMeAd_adIframe_ListingOne');
if(f!=null){
fcw=f.contentWindow.document.getElementById('lols');
if(fcw!=null){fcw.style.display='none';}
f.style.width="330px";
f.style.height="75px";}}
_listingAdPreViewportWidth=TradeMe.Dom.getViewportWidth();},
showWC:function(){
var whatsCool,f;
whatsCool=document.getElementById('WhatsCoolControl');
if (whatsCool!=null) {
f=document.getElementById('TradeMeAd_adIframe_WhatsCool');
if(f!=null){f.style.width='0px';f.style.height='0px';f.style.visibility='hidden';f.style.display='none';}
whatsCool.style.display='block';
whatsCool.style.visibility='visible';}},
hideTile:function(){
var f,ctc;
f=document.getElementById('TradeMeAd_adIframe_CategoryTile');
if(f!=null){f.style.width='0px';f.style.height='0px';f.style.visibility='hidden';f.style.display='none';}
ctc=document.getElementById('CategoryTileContainer');
if(ctc!=null){ctc.style.visibility='hidden';ctc.style.display='none';}},
hideAd:function(tfn){
var f,theId,ctc;
theId='TradeMeAd_adIframe_'+tfn;
f=document.getElementById(theId);
if(f!=null){f.style.width='0px';f.style.height='0px';f.style.visibility='hidden';f.style.display='none';}
ctc=document.getElementById('CategoryTileContainer');
if(ctc!=null){ctc.style.visibility='hidden';ctc.style.display='none';}},
resizeJLP:function(){
var f=document.getElementById('TradeMeAd_adIframe_LandingPageIsland');
if(f!=null){f.style.width='200px';f.style.height='200px';}},
showAdLabels:function(){
if(document.getElementById('sideAd')!=null){document.getElementById('sideAd').style.display='block';}
if(document.getElementById('BannerAdLabel')!=null){document.getElementById('BannerAdLabel').style.display='block';}
if(document.getElementById('SkyscraperAdLabel')!=null){document.getElementById('SkyscraperAdLabel').style.display='block';}},
showAdSection:function(tfn){
var f,theId,adSec,adTitle,adSecSpacer;
theId='TradeMeAd_adIframe_' + tfn;
f=document.getElementById(theId);
if(f!=null){
if(tfn=='ListingOne'){
adSec=document.getElementById('advertSection');
if(adSec!=null){adSec.style.display='block';}
adTitle=document.getElementById('advertTitle');
if(adTitle!=null){adTitle.style.display='block';}
adSecSpacer=document.getElementById('adSecSpacer');
if(adSecSpacer!=null){adSecSpacer.style.display='none';}}
else if(tfn=='LandingPageIsland'){
adSec=document.getElementById('LandingPageIslandAdLabel');
if (adSec!=null){adSec.style.display='block';}}
else if(tfn=='CategoryTile'){
adSec=document.getElementById('CategoryTileAdLabel');
if (adSec!=null){adSec.style.display='block';}}}},
redisplayAd:function(ifn){
var f,c,pElement,pos;
f=document.getElementById(ifn);
c=null;
if(f!=null) {
pElement=f.parentNode;
c=f.contentWindow.document.body.innerHTML;
f.style.display='none';
if(c!=null){
pos=c.indexOf('script');
if(pos!=-1){c=c.substring(0,pos-1);}
if(pElement!=null){pElement.innerHTML=c;}}}},
resizeMTA:function(){
var f,swfDiv;
f=document.getElementById('TradeMeAd_adIframe_Tower');
if(f!=null){
swfDiv=f.contentWindow.document.getElementById('BCITOFlashAd');
if(swfDiv!=null){f.style.height="600px";}}},
showClassicCarsLozenge:function(ifn){
var f,c,scriptIndex;
if(typeof parent.isClassicCar=='undefined'||!parent.isClassicCar){return;}
f=document.getElementById(ifn);
if(f==null){return;}
c=f.contentWindow.document.body.innerHTML;
if(c==null){return;}
c=c.replace(/(<a [^>]*href=")[^"]*ListingTwo[^"]*www\.state\.co\.nz[^"]*(".*?<img [^>]*src=")[^"]*"/i,"$1" + parent.classicCarUrl + "$2/images/ads/swann_listing_lozenge-classic.gif\"");
c=c.replace(/class="?listingAd"?/ig,'style="display: inline; padding: 5px;"');
scriptIndex=c.toLowerCase().indexOf("<script");//>
if(scriptIndex!=-1){c=c.substr(0,scriptIndex-1);}
f.style.display='none';
document.getElementById('tmClassicCarsAdContent').innerHTML=c;},
showRVALozenge:function(ifn){
var f,c,scriptIndex;
if(typeof parent.isRVAMember=='undefined'||!parent.isRVAMember){return;}
f=document.getElementById(ifn);
if(f==null){return;}
c=f.contentWindow.document.body.innerHTML;
if(c==null){return;}
c=c.replace("non_RVA-ad.gif", "rva-ad.gif");
c=c.replace("/Link.aspx?i=15118", parent.rvaUrl);
c=c.replace(/class="?listingAd"?/ig,'style="display: inline; padding: 5px;"');
scriptIndex=c.toLowerCase().indexOf("<script");//>
if(scriptIndex!=-1){c=c.substr(0,scriptIndex-1);}
f.style.display='none';
document.getElementById('tmRVAAdContent').innerHTML=c;}};
if (dsv=='trademe'){addEvent(window,"resize",TradeMeAds.GetAds.reloadListingAds);}