function AD(_placementID, _sizeID) {
    this.networkID = 665; //Morningstar
    this.placementID = _placementID;
    this.sizeID = _sizeID;
}

var ADDictionary = new Dictionary();

ADDictionary.add('topADSmallDefault', new AD('1595083', '1653')); //Additional banner next to leaderboard 195x90
//ADDictionary.add('ToolsFundOverviewMPU', new AD('2018723', '170')); //Tools Fund Overview MPU 300x250


ADDictionary.add('HomepageSkyescraper', new AD('2369196', '154')); //Homepage Skyescraper 160x600
ADDictionary.add('HomepageTop', new AD('2369194', '225')); //Homepage Top 728x60
ADDictionary.add('HomepageMPU', new AD('2369197', '170')); //Homepage MPU 300x250
ADDictionary.add('HomepageBottom', new AD('2369195', '1748'));
ADDictionary.add('HomepageOverlay', new AD('2717121', '16')); //Homepage Overlay 1x1

//---------------------------------------------------------------------------------
// These ROS adverts are to be used on all pages if another ad isn't defined below.
// They should be copied and renamed as required on each page.
//---------------------------------------------------------------------------------
ADDictionary.add('ROSSkyescraper', new AD('2018721', '154')); //Default Skyescraper 160x600
ADDictionary.add('ROSTop', new AD('2018720', '225')); //Default Top 728x60
ADDictionary.add('ROSMPU', new AD('2018723', '170')); //Default MPU 300x250
ADDictionary.add('ROSBottom', new AD('2018719', '1748'));
ADDictionary.add('ROSTopAdSmall', new AD('1595083', '1748'));
ADDictionary.add('ROSButton', new AD('2018722', '12'));
ADDictionary.add('ROSTextSponsor', new AD('2328797', '1748'));

ADDictionary.add( 'MembershipHomeTop', new AD('2018720', '225') );//Membership Home Top 728x60
ADDictionary.add( 'MembershipLoginTop', new AD('2018720', '225') );//Membership Login Top 728x90
ADDictionary.add( 'MembershipNewUserRegTop', new AD('2018720', '225') );//Membership New User Registration 728x60
ADDictionary.add( 'MembershipLogOutLeaderboard', new AD('2018720', '225') );//Membership Log Out Leaderboard 728x60
ADDictionary.add( 'MembershipMyProfileTop', new AD('2018720', '225') );//Membership My Profile Top 728x90
ADDictionary.add( 'MembershipMyProfileRight', new AD('2146402', '154') );//Membership My Profile Rightsnapshot 160x600
ADDictionary.add( 'OeicsHomeTop', new AD('2018720', '225') );//Oeics Home Top 728x90
ADDictionary.add( 'OeicsHomeMPU', new AD('2018723', '170') );//Oeics Home MPU 300x250

ADDictionary.add('BottomLeaderboard', new AD('2018719', '1748')); //Bottom Leaderboard 728x110

ADDictionary.add('MarketsTop', new AD('2018720', '225')); //Equities Top 728x90
//ADDictionary.add('MarketsRight', new AD('1867478', '154')); //Equities Right 160x600
//ADDictionary.add('MarketsSquare', new AD('2479113', '6')); //Equities Square 125x125
ADDictionary.add('MarketsMPU', new AD('2018723', '170')); //Equities MPU 300x250

//ETFs
ADDictionary.add('ETFCenterTop', new AD('3120189', '225')); //ETFs Top CoverPage Leaderboard 728x90
ADDictionary.add('ETFCenterMPU', new AD('3120191', '170')); //ETFs MPU CoverPage 300x250
ADDictionary.add('ETFCenterBottom', new AD('3120187', '1748')); //ETFs CoverPage Bottom Leaderboard 728x90 Common for all
ADDictionary.add('ETFCenterSkyscraper', new AD('3120194', '154')); //ETFs Home Square 125x125
ADDictionary.add('ETFCenterSquare', new AD('3120182', '6')); //ETFs Home Square 125x125

ADDictionary.add('ETFSolutionsTop', new AD('3134627', '225')); //ETFs Top CoverPage Leaderboard 728x90
ADDictionary.add('ETFSolutionMPU', new AD('3134628', '170')); //ETFs MPU CoverPage 300x250
ADDictionary.add('ETFSolutionsBottom', new AD('3134625', '1748')); //ETFs CoverPage Bottom Leaderboard 728x90 Common for all
ADDictionary.add('ETFSolutionsSkyscraper', new AD('3134630', '154')); //ETFs Home Square 125x125

ADDictionary.add('ETFsHomeTop', new AD('3134643', '225')); //ETFs Top CoverPage Leaderboard 728x90
ADDictionary.add('ETFsHomeMPU', new AD('3134644', '170')); //ETFs MPU CoverPage 300x250
ADDictionary.add('ETFDefaultBottom', new AD('3134637', '1748')); //ETFs CoverPage Bottom Leaderboard 728x90 Common for all
ADDictionary.add('ETFsHomeSkyscraper', new AD('3134640', '154')); //ETFs Home Square 125x125

ADDictionary.add('ETFsSurveyTop', new AD('3134623', '225')); //ETFs Top Survey Leaderboard 728x90 (actually the same)
ADDictionary.add('ETFSurveyMPU', new AD('3134628', '170')); //ETFs MPU Survey 300x250 (actually the same)
ADDictionary.add('ETFSurveyBottom', new AD('3134624', '1748')); //ETFs Bottom Leaderboard 728x90
ADDictionary.add('ETFSurveySkyscraper', new AD('3134629', '154')); //ETFs Home Square 125x125

ADDictionary.add('ETFWebinarTop', new AD('3134646', '225')); //ETFs Top Survey Leaderboard 728x90 (actually the same)
ADDictionary.add('ETFWebinarMPU', new AD('3134649', '170')); //ETFs MPU Survey 300x250 (actually the same)
ADDictionary.add('ETFWebinarBottom', new AD('3134648', '1748')); //ETFs Bottom Leaderboard 728x90
ADDictionary.add('ETFWebinarSkyscraper', new AD('3134647', '154')); //ETFs Home Square 125x125

ADDictionary.add('ETFNewsLetterTop', new AD('3134639', '225')); //ETFs Newsletter Top leaderboard
ADDictionary.add('ETFNewsLetterMPU', new AD('3134638', '170') );//ETFs Newsletter MPU 300x250
ADDictionary.add('ETFNewsLetterBottom', new AD('3134641', '1748') ); //ETFs Newsletter Bottom ETFLeaderboard 728x110
ADDictionary.add('ETFNewsletterSkyscraper', new AD('3134642', '154')); //ETFs Home Square 125x125

ADDictionary.add( 'ETFArticleTop', new AD('3134627', '225') ); //ETF Morningstar Articles Top 728x90
ADDictionary.add( 'ETFArticleRight', new AD('3134630', '154') );//ETF Morningstar Articles Right 160x600
ADDictionary.add( 'ETFArticleMPU', new AD('3134626', '170') );//ETF Morningstar Article MPU 300x250

ADDictionary.add( 'ETFQuickrankTop', new AD('3134627', '225') );//Tools Fund Quickrank Top 728x90
ADDictionary.add( 'ETFQuickrankRight', new AD('3134630', '154') );//Tools Fund Quickrank Right 160x600
ADDictionary.add( 'ETFQuickRankBottomLeftMPU', new AD('3134626', '170') );//Bottom MPU Left

ADDictionary.add( 'ETFArchiveTop', new AD('3134627', '225') );//Archive Top 728x90
ADDictionary.add( 'ETFArchiveRight', new AD('3134630', '154') );//Archive Right 160x600

ADDictionary.add( 'ETFScreenerTop', new AD('3134627', '225') );//Tools Fund Screener Top 728x90
ADDictionary.add( 'ETFScreenerRight', new AD('3134630', '154') );//Tools Fund Screener Right 160x600
ADDictionary.add( 'ETFsLeaderboard', new AD('3134627', '225') );//Portfolio Leaderboard 728x60

// Pensions
ADDictionary.add('LnPSkyescraper', new AD('3052948', '154')); //Default Skyescraper 160x600
ADDictionary.add('LnPHomeTop', new AD('3052943', '225')); //Default Top 728x60
ADDictionary.add('LnPHomeMPU', new AD('3052944', '170')); //Default MPU 300x250
ADDictionary.add('LnPBottom', new AD('3052949', '1748'));
ADDictionary.add('LnPBottomAdSmall', new AD('3052946', '1653'));
ADDictionary.add('LnPTopAdSmall', new AD('3052947', '1653'));
ADDictionary.add('LnPButton', new AD('3052945', '12'));

// Tools - Fund Quickrank
ADDictionary.add('ToolsHomeTop', new AD('2387698', '225')); //Default Top 728x60
ADDictionary.add('ToolsBottom', new AD('2384692', '1748'));
ADDictionary.add('FundQuickrankTop', new AD('2387698', '225')); //Tools Fund Quickrank Top 728x90
ADDictionary.add('FundQuickrankBottom', new AD('2384692', '225')); //Tools Fund Quickrank Top 728x90


// See LT admin htmlsections for this
ADDictionary.add('ETFQuickrankRight', new AD('3134642', '154')); //ETFs Skyscrapper for Quickrank and Snapshot

ADDictionary.add('LnPQuickRankTop', new AD('3052943', '225')); //Life and Pension Quick Rank Top 728x90
ADDictionary.add('LnPQuickRankRight', new AD('3052948', '154')); //Life and Pension Quick Rank Right 160x600
ADDictionary.add('LnPQuickRankBottomLeft', new AD('3052949', '170')); //Life & Pensions Quick Rank Bottom Left 300x250
ADDictionary.add('LnPQuickRankBottomRightBottom', new AD('2146405', '186')); //Life & Pensions Quick Rank Bottom right bottom 150

//ADDictionary.add('QuickRankBottomLeft', new AD('2018719', '170')); //Quick Rank Bottom Left 300x250
ADDictionary.add('QuickRankBottomLeft', new AD('3232478', '170')); //Quick Rank Bottom Left 300x250
ADDictionary.add( 'QuickRankBottomRightTop', new AD('1709875', '186') );//Quick Rank Bottom right top 150
//ADDictionary.add('QuickRankBottomRightBottom', new AD('2018719', '186')); //Quick Rank Bottom right bottom 150

ADDictionary.add('ToolsHomeTop', new AD('2018720', '225')); //Tools Home Top 728x90
ADDictionary.add('ToolsHomeRight', new AD('2018721', '154')); //Tools Home Right 160x600

ADDictionary.add('MarketsTop', new AD('2018720', '225')); //Equities Top 728x90
ADDictionary.add('MarketsRight', new AD('2018721', '154')); //Equities Right 160x600
ADDictionary.add('MarketsMPU', new AD('2018723', '170')); //Equities Square 125x125

ADDictionary.add('HelpTop', new AD('2018720', '225')); //Help Top 728x90
ADDictionary.add('HelpRight', new AD('2018721', '154')); //Help Right 160x600
ADDictionary.add('GlossaryTop', new AD('2018720', '225')); //Morningstar Glossary Top 728x90
ADDictionary.add('GlossaryRight', new AD('2018721', '154')); //Morningstar Glossary Right 160x600
ADDictionary.add('RSSTop', new AD('2018720', '225')); //RSS Top 728x90
ADDictionary.add('RSSRight', new AD('2018721', '154')); //RSS Right 160x600

ADDictionary.add('FundArchiveTop', new AD('2018720', '225')); //Archive Top 728x90
ADDictionary.add('FundArchiveRight', new AD('2018721', '154')); //Archive Right 160x600

ADDictionary.add('FundArticleTop', new AD('2018720', '225')); //Oeics Morningstar Articles Top 728x90
ADDictionary.add('FundArticleRight', new AD('2018721', '154')); //Oeics Morningstar Articles Right 160x600
ADDictionary.add('FundArticleMPU', new AD('2018723', '170')); //Oeics Morningstar Article MPU 300x250

ADDictionary.add('PortfolioLeaderboard', new AD('2018720', '225')); //Portfolio Leaderboard 728x60
ADDictionary.add('PortfolioSky', new AD('2018721', '154')); //Portfolio Sky 160x600
ADDictionary.add('PortfolioMPU', new AD('2018723', '170')); //Portfolio MPU
ADDictionary.add('PortfolioBottomLeft', new AD('2018719', '170')); //  NOT USED Portfolio Bottom Left 300x250
ADDictionary.add('PortfolioBottomRight', new AD('2018721', '186')); //Portfolio Bottom right 150

ADDictionary.add('InstantXRayTop', new AD('2018720', '225')); //Tools Instant X Ray Top 728x90
ADDictionary.add('InstantXRayRight', new AD('2018721', '154')); //Tools Instant X Ray Right 160x600
ADDictionary.add('FundCompareTop', new AD('2018720', '225')); //Tools Fund Compare Top 728x90
ADDictionary.add('FundCompareRight', new AD('2018721', '154')); //Tools Fund Compare Right 160x600

ADDictionary.add('FundScreenerTop', new AD('2018720', '225')); //Tools Fund Screener Top 728x90
ADDictionary.add('FundScreenerRight', new AD('2018721', '154')); //Tools Fund Screener Right 160x600

ADDictionary.add('FundQuickrankTop', new AD('2018720', '225')); //Tools Fund Quickrank Top 728x90
ADDictionary.add('FundQuickrankRight', new AD('2018721', '154')); //Tools Fund Quickrank Right 160x600


// for stock quicktake
ADDictionary.add('ToolsStockQuicktakeOverviewTop', new AD('2018720', '225')); //Tools Fund Overview Top 728x90
ADDictionary.add('ToolsStockQuicktakeRight', new AD('2018721', '154'));


ADDictionary.add('ToolsFundOverviewTop', new AD('2018720', '225')); //Tools Fund Overview Top 728x90
ADDictionary.add('ToolsFundOverviewRight', new AD('2018721', '154')); //Tools Fund Overview Right 160x600
ADDictionary.add('ToolsFundOverviewMPU', new AD('2018723', '170')); //Tools Fund Overview MPU 300x250

ADDictionary.add('ToolsFundGraphTop', new AD('2018720', '225')); //Tools Fund Graph Top 728x90
ADDictionary.add('ToolsFundGraphRight', new AD('2018721', '154')); //Tools Fund Graph Right 160x600
ADDictionary.add('ToolsFundGraphMPU', new AD('2018723', '170')); //Tools Fund Graph MPU 300x250

ADDictionary.add('ETFBottomLeaderboard', new AD('2018719', '1748')); //Bottom ETFLeaderboard 728x110

ADDictionary.add('UniverseSearchRightTop', new AD('2018720', '154')); //UniverseSearch Right Top 160x600

// Video Center page
ADDictionary.add('VideoCenterMPU', new AD('2018723', '170')); // Video MPU 300x250
ADDictionary.add('VideoCenterTop', new AD('2018720', '225')); // Video Top Leaderboard Banner 728x90

//***Investing Mastermind Landing Page
ADDictionary.add('IMMLandingTopHeader', new AD('3314194', '225'));
ADDictionary.add('IMMLandingBottomBanner', new AD('3314189', '1748'));

//***Investing Mastermind Category Page
ADDictionary.add('IMMCategoryTopHeader', new AD('3314191', '225'));
ADDictionary.add('IMMCategoryBottomBanner', new AD('3314192', '1748'));

//***Investing Mastermind Question, Finish and AnswerPage
//CEF
//ADDictionary.add('IMMTopHeaderCEF', new AD('3293130', '225'));
//ADDictionary.add('IMMBottomBannerCEF', new AD('3293129', '1748'));

//Emerging market
ADDictionary.add('IMMTopHeaderEMarket', new AD('3314190', '225'));
ADDictionary.add('IMMBottomBannerEMarket', new AD('3314196', '1748'));

//Equity
ADDictionary.add('IMMTopHeaderEquity', new AD('3314204', '225'));
ADDictionary.add('IMMBottomBannerEquity', new AD('3314200', '1748'));

//ETF
ADDictionary.add('IMMTopHeaderETF', new AD('3314205', '225'));
ADDictionary.add('IMMBottomBannerETF', new AD('3314206', '1748'));

//Fixed Income
ADDictionary.add('IMMTopHeaderFixedIncome', new AD('3314201', '225'));
ADDictionary.add('IMMBottomBannerFixedIncome', new AD('3314203', '1748'));

//RDR
//ADDictionary.add('IMMTopHeaderRDR', new AD('3314209', '225'));
//ADDictionary.add('IMMBottomBannerRDR', new AD('3314211', '1748'));

//***Investing Mastermind Profile Page
//ADDictionary.add('IMMProfileTopHeader', new AD('1257284', '225'));
//ADDictionary.add('IMMProfileTopRight', new AD('1257283', '154'));
//ADDictionary.add('IMMProfileBottomLeft', new AD('1257284', '225'));
//ADDictionary.add('IMMProfileBottomRight', new AD('1257288', '225'));

function WebAdsWriteTagSponsor(width, height, placementID, key1, key2)
{
    // ignore the keys for now on non-uk sites
    WebAdsWriteTag(width, height, placementID);
}

function WebAdsWriteTagSponsor(width, height, placementID, key1, key2) {
    var currentAD;
    currentAD = ADDictionary.getVal(placementID);

    if ((placementID != 'topADSmallDefault') && (placementID != 'BottomLeaderboard') && (placementID != 'FundQuickrankTop')) {
        WebAdsWriteTag(width, height, placementID);
        return;
    }
    if (!currentAD) {
        return;
    }

    if (window.adgroupid == undefined) {
        window.adgroupid = Math.round(Math.random() * 1000);
    }

    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|' + currentAD.networkID + '|' + currentAD.placementID + '|0|' + currentAD.sizeID + '|ADTECH;loc=100;target=_blank;key=' + key1 + '+' + key2 + '+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');
}


function WebAdsWriteTag(width, height, placementID) {
    var currentAD;
    currentAD = ADDictionary.getVal(placementID);

    if (!currentAD) {
        return;
    }

    if (window.adgroupid == undefined) {
        window.adgroupid = Math.round(Math.random() * 1000);
    }

    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|' + currentAD.networkID + '|' + currentAD.placementID + '|0|' + currentAD.sizeID + '|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');

}

function WebAdsWriteTagAdTechTags(width, height, placementID) {
    var currentAD;
    currentAD = ADDictionary.getVal(placementID);
    if (!currentAD) {
        return;
    }

    if (window.adgroupid == undefined) {
        window.adgroupid = Math.round(Math.random() * 1000);
    }
    if (width != '195') {
        document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|' + currentAD.networkID + '|' + currentAD.placementID + '|0|' + currentAD.sizeID + '|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');
    }
    else {
        document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|665|1595083|0|1653|ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=[group];misc=' + new Date().getTime() + '"></scri' + 'pt>');
    }
}

function WebQTSponsorTag(fundId, companyId) {
    //blank for now
}

function WebQTROSSponsor(fundId, companyId) {
    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|665|2018722|0|6|ADTECH;loc=100;target=_blank;key=' + fundId + '+' + companyId + '+key2+key3+key4;grp=[group];misc=' + new Date().getTime() + '"></scri' + 'pt>');
}

function WebAdsBottomTag() {

    var strHomePage = location.pathname.toLowerCase();

    if ((strHomePage.indexOf('/es/default')) != -1) {
        //Homepage
        WebAdsWriteTag('728', '90', 'BottomLeaderboard');
    }
    else if ((strHomePage.indexOf('/es/etfs/')) != -1) {
        //ETFs
        WebAdsWriteTag('728', '90', 'ETFDefaultBottom');
    }
    else {
        //rest of the site.
        WebAdsWriteTag('728', '90', 'BottomLeaderboard');
    }
}

function WebAdsBottomRightButtonTag(width, height, placementKey) {

	WebAdsWriteTagSponsor(width, height, placementKey);
}
