function AD(_placementID, _sizeID) {
    this.networkID = 665; //Morningstar
    this.placementID = _placementID;
    this.sizeID = _sizeID;
}

var ADDictionary = new Dictionary();

ADDictionary.add('BottomLeaderboard', new AD('1694408', '1748')); //Bottom Leaderboard 728x110
ADDictionary.add('topADSmallDefault', new AD('1694410', '1653')); //Additional banner next to leaderboard 195x90


ADDictionary.add('HomepageSkyescraper', new AD('1694406', '154')); //Homepage Skyescraper 160x600
ADDictionary.add('HomepageTop', new AD('1694405', '225')); //Homepage Top 728x60
ADDictionary.add('HomepageMPU', new AD('1694407', '170')); //Homepage MPU 300x250
ADDictionary.add('HomepageOverlay', new AD('', '16')); //Homepage Overlay 1x1
ADDictionary.add('MembershipHomeTop', new AD('1694405', '225')); //Membership Home Top 728x60
ADDictionary.add('MembershipLoginTop', new AD('1694405', '225')); //Membership Login Top 728x90
ADDictionary.add('MembershipNewUserRegTop', new AD('1694405', '225')); //Membership New User Registration 728x60
ADDictionary.add('MembershipLogOutLeaderboard', new AD('1694405', '225')); //Membership Log Out Leaderboard 728x60
ADDictionary.add('MembershipMyProfileTop', new AD('1694405', '225')); //Membership My Profile Top 728x90
ADDictionary.add('MembershipMyProfileRight', new AD('1694406', '154')); //Membership My Profile Right 160x600
ADDictionary.add('OeicsHomeTop', new AD('1694405', '225')); //Oeics Home Top 728x90
ADDictionary.add('OeicsHomeMPU', new AD('1694407', '170')); //Oeics Home MPU 300x250
ADDictionary.add('OeicsHomeSquare', new AD('2561848', '6')); //Oeics Home Square 125x125 ; ETF Center Nav Bar - ad


ADDictionary.add('ETFsHomeTop', new AD('2561842', '225')); //ETFs Home Top 728x90

ADDictionary.add('ETFsNewsLetterTop', new AD('2827391', '225'));   // ETF 728x90
ADDictionary.add('ETFsNewsLetterMPU', new AD('2751051', '171'));   // ETF 336x280
ADDictionary.add('ETFsNewsLetterBottom', new AD('', '1748'));      // 728x110

ADDictionary.add('ETFArticleTop', new AD('2561842', '225'));       // ETF 728x90
ADDictionary.add('ETFArchiveTop', new AD('2561842', '225'));       // ETF 728x90
ADDictionary.add('ETFArchiveRight', new AD('', '154'));            // ETF 160x600

ADDictionary.add('ETFsHomeMPU', new AD('2751051', '171'));         // ETF Home MPU 300x250 ;
ADDictionary.add('ETFsHomeTop', new AD('2561838', '225'));         // ETF Home Top ;
ADDictionary.add('ETFsHomeSquare', new AD('1694411', '6'));        // ETF Home Square 125x125 ;
ADDictionary.add('ETFsHomeBottom', new AD('', '1748'));
ADDictionary.add('ETFDefaultButton', new AD('2885273', '1653')); //195x90
ADDictionary.add('ETFDefaultButtonBottom', new AD('2885273', '1653')); //195x90

ADDictionary.add('ETFQuickrankTop', new AD('2751217', '225'));     // ETF 728x90
ADDictionary.add('ETFQuickrankRight', new AD('2421707', '154'));   // ETF 160x600  (TBD: Swiss tags missing)
ADDictionary.add('ETFQuickRankBottomLeftMPU', new AD('', '171'));

ADDictionary.add('ETFsConferenceTop', new AD('2561838', '225'));   // ETF 728x90
ADDictionary.add('ETFConferenceMPU', new AD('2751049', '171'));    // ETF 336x280
ADDictionary.add('ETFCinferenceBottom', new AD('2561844', '1748'));// ETF 728x110

ADDictionary.add('ETFsSurveyTop', new AD('2561836', '225'));       // ETF 728x90 
ADDictionary.add('ETFSurveyMPU', new AD('2751051', '171'));        // ETF 336x280
ADDictionary.add('ETFSurveyBottom', new AD('2561843', '1748'));    // ETF 728x110

ADDictionary.add('ETFSolutionsTop', new AD('2827389', '225'));     // ETFs Solution Top 728x90
ADDictionary.add('ETFSolutionsMPU', new AD('2751051', '171'));     // ETFs Solution MPU
ADDictionary.add('ETFSolutionsBottom', new AD('', '1748'));        // ETFs solution Bottom leaderboard

ADDictionary.add('ETFScreenerTop', new AD('', '225'));             // ETF 728x90
ADDictionary.add('ETFScreenerRight', new AD('', '154'));           // ETF 160x600

ADDictionary.add('BottomLeaderboard', new AD('', '1748'));

ADDictionary.add('LnPQuickRankTop', new AD('1694405', '225')); //Life and Pension Quick Rank Top 728x90
ADDictionary.add('LnPQuickRankRight', new AD('1694406', '154')); //Life and Pension Quick Rank Right 160x600

ADDictionary.add('LnPQuickRankBottomLeft', new AD('1694407', '170')); //Life & Pensions Quick Rank Bottom Left 300x250
ADDictionary.add('LnPQuickRankBottomRightTop', new AD('1694409', '186')); //Life & Pensions Quick Rank Bottom right top 150
ADDictionary.add('LnPQuickRankBottomRightBottom', new AD('1694409', '186')); //Life & Pensions Quick Rank Bottom right bottom 150
ADDictionary.add('QuickRankBottomLeft', new AD('1694407', '170')); //Quick Rank Bottom Left 300x250
ADDictionary.add('QuickRankBottomRightTop', new AD('1694409', '186')); //Quick Rank Bottom right top 150
ADDictionary.add('QuickRankBottomRightBottom', new AD('1694409', '186')); //Quick Rank Bottom right bottom 150

ADDictionary.add('ToolsHomeTop', new AD('1694405', '225')); //Tools Home Top 728x90
ADDictionary.add('ToolsHomeRight', new AD('1694406', '154')); //Tools Home Right 160x600
ADDictionary.add('ToolsHomeSquare', new AD('1694411', '6')); //Tools Home Square 125x125
ADDictionary.add('AdvisorTop', new AD('1694405', '225')); //Advisor Top 728x90
ADDictionary.add('AdvisorRight', new AD('1694406', '154')); //Advisor Right 160x600
ADDictionary.add('AdvisorSquare', new AD('1694411', '6')); //Advisor Square 125x125

ADDictionary.add('EquitiesTop', new AD('1694405', '225')); //Equities Top 728x90
ADDictionary.add('EquitiesRight', new AD('1694406', '154')); //Equities Right 160x600
ADDictionary.add('EquityDefaultMPU', new AD('1694407', '170')); //Equities MPU 300x250
ADDictionary.add('EquitiesSquare', new AD('1694411', '6')); //Equities Square 125x125

ADDictionary.add('EquityDefaultTop', new AD('1694405', '225')); //Equities Top 728x90
ADDictionary.add('EquityDefaultRight', new AD('1694406', '154')); //Equities Right 160x600
ADDictionary.add('EquityDefaultButton', new AD('1694411', '6')); //Equities Square 125x125

ADDictionary.add('HelpTop', new AD('1694405', '225')); //Help Top 728x90
ADDictionary.add('HelpRight', new AD('1694406', '154')); //Help Right 160x600
ADDictionary.add('GlossaryTop', new AD('1694405', '225')); //Morningstar Glossary Top 728x90
ADDictionary.add('GlossaryRight', new AD('1694406', '154')); //Morningstar Glossary Right 160x600
ADDictionary.add('RSSTop', new AD('1694405', '225')); //RSS Top 728x90
ADDictionary.add('RSSRight', new AD('1694406', '154')); //RSS Right 160x600

ADDictionary.add('FundArchiveTop', new AD('1694405', '225')); //Archive Top 728x90
ADDictionary.add('FundArchiveRight', new AD('1694406', '154')); //Archive Right 160x600
ADDictionary.add('FundArticleTop', new AD('1694405', '225')); //Oeics Morningstar Articles Top 728x90
ADDictionary.add('FundArticleRight', new AD('1694406', '154')); //Oeics Morningstar Articles Right 160x600
ADDictionary.add('FundArticleMPU', new AD('1694407', '170')); //Oeics Morningstar Article MPU 300x250

ADDictionary.add('PortfolioLeaderboard', new AD('1694405', '225')); //Portfolio Leaderboard 728x60
ADDictionary.add('PortfolioSky', new AD('1694406', '154')); //Portfolio Sky 160x600
ADDictionary.add('PortfolioMPU', new AD('1694407', '170')); //Portfolio MPU
ADDictionary.add('PortfolioBottomLeft', new AD('1694407', '170')); //Portfolio Bottom Left 300x250
ADDictionary.add('PortfolioBottomRight', new AD('1694409', '186')); //Portfolio Bottom right 150
ADDictionary.add('PortfolioBottomRight2', new AD('1694409', '186')); //Portfolio Bottom right 150
ADDictionary.add('InstantXRayTop', new AD('1694405', '225')); //Tools Instant X Ray Top 728x90

ADDictionary.add('InstantXRayRight', new AD('1694406', '154')); //Tools Instant X Ray Right 160x600
ADDictionary.add('FundCompareTop', new AD('1694405', '225')); //Tools Fund Compare Top 728x90
ADDictionary.add('FundCompareRight', new AD('1694406', '154')); //Tools Fund Compare Right 160x600

ADDictionary.add('FundScreenerTop', new AD('1694405', '225')); //Tools Fund Screener Top 728x90
ADDictionary.add('FundScreenerRight', new AD('1694406', '154')); //Tools Fund Screener Right 160x600
ADDictionary.add('FundQuickrankTop', new AD('1694405', '225')); //Tools Fund Quickrank Top 728x90
ADDictionary.add('FundQuickrankRight', new AD('1694406', '154')); //Tools Fund Quickrank Right 160x600

// for stock quicktake
ADDictionary.add('ToolsStockQuicktakeOverviewTop', new AD('1694405', '225')); //Tools Fund Overview Top 728x90
ADDictionary.add('ToolsStockQuicktakeRight', new AD('1694406', '154'));


ADDictionary.add('ToolsFundOverviewTop', new AD('1694405', '225')); //Tools Fund Overview Top 728x90
ADDictionary.add('ToolsFundOverviewRight', new AD('1694406', '154')); //Tools Fund Overview Right 160x600
ADDictionary.add('ToolsFundOverviewMPU', new AD('1694407', '170')); //Tools Fund Overview MPU 300x250

ADDictionary.add('ToolsFundGraphTop', new AD('1694405', '225')); //Tools Fund Graph Top 728x90
ADDictionary.add('ToolsFundGraphRight', new AD('1694406', '154')); //Tools Fund Graph Right 160x600
ADDictionary.add('ToolsFundGraphMPU', new AD('1694407', '170')); //Tools Fund Graph MPU 300x250

ADDictionary.add('NavText', new AD('2068738', '1013')); //Text  

ADDictionary.add('UniverseSearchRightTop', new AD('1694406', '154')); //UniverseSearch Right Top 160x600

//Market section tag in Mercati
ADDictionary.add('MarketsTop', new AD('1694405', '225')); //leaderboard
ADDictionary.add('MarketsRight', new AD('1694406', '154')); //sky
ADDictionary.add('MarketsMPU', new AD('1694407', '170')); //MPU
ADDictionary.add('MarketsSquare', new AD('1694411', '6')); //Square

function WebAdsWriteTagSponsor(width, height, placementID, key1, key2)
{
    // for ETF section only
    var strEtf = location.href;
    var adId = placementID;
    
    // ETF Cover page
    if (strEtf.match("etfcover")) {

        if (width == '195' && height == '90') {
            adId = 'ETFDefaultButton';
        }
    }

    var currentAD;
    currentAD = ADDictionary.getVal(adId);
    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 WebQTSponsorTag(fundId, companyId) {
    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|665|1643265|0|12|ADTECH;loc=100;target=_blank;key=' + fundId + '+' + companyId + '+key3+key4;grp=[group];misc=' + new Date().getTime() + '"></scri' + 'pt>');
}

function WebQTSponsorTagLower(fundId, companyId) {
    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|665|1442133|0|6|ADTECH;loc=100;target=_blank;key=' + fundId + '+' + companyId + '+key3+key4;grp=[group];misc=' + new Date().getTime() + '"></scri' + 'pt>');
}

function WebQTSponsorTagUpper(fundId, companyId) {
    document.write('<scr' + 'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|665|2110087|0|6|ADTECH;loc=100;target=_blank;key=' + fundId + '+' + companyId + '+key3+key4;grp=[group];misc=' + new Date().getTime() + '"></scri' + 'pt>');
}

function WebAdsBottomTag() {
    // for ETF section only
    var strEtf = location.href;

    // ETF Newsletter page
    if (strEtf.match("ETFNewsLetterSignup")) {
        WebAdsWriteTag('728', '110', 'ETFsNewsLetterBottom');
        return;
    }
    // ETF Survey page
    else if (strEtf.match("ETFSurvey")) {
        WebAdsWriteTag('728', '110', 'ETFSurveyBottom');
        return;
    }

    // ETF Conference call pages
    else if (strEtf.match("ETFConferenceCall")) {
        WebAdsWriteTag('728', '110', 'ETFConferenceCallBottom');
        return;
    }

    // ETF Solutions call pages
    else if (strEtf.match("ETFSolutions")) {
        WebAdsWriteTag('728', '110', 'ETFSolutionsBottom');
        return;
    }

    else if (strEtf.match("etf") || strEtf.match("etfs"))
        WebAdsWriteTag('728', '90', 'ETFBottomLeaderboard');

    else
        WebAdsWriteTag('728', '90', 'BottomLeaderboard');
}

function WebAdsBottomTagSponsor(key1, key2) {
    // for ETF section only
    var strEtf = location.href;

    // ETF Newsletter page
    if (strEtf.match("ETFNewsLetterSignup")) {
        WebAdsWriteTag('728', '110', 'ETFsNewsLetterBottom');
        return;
    }

    // ETF Survey page
    else if (strEtf.match("ETFSurvey")) {
        WebAdsWriteTag('728', '110', 'ETFSurveyBottom');
        return;
    }

    // ETF Conference call pages
    else if (strEtf.match("ETFConferenceCall")) {
        WebAdsWriteTag('728', '110', 'ETFConferenceCallBottom');
        return;
    }

    // ETF Solutions call pages
    else if (strEtf.match("ETFSolutions")) {
        WebAdsWriteTag('728', '110', 'ETFSolutionsBottom');
        return;
    }

    else if (strEtf.match("etf") || strEtf.match("etfs"))
        WebAdsWriteTag('728', '90', 'ETFBottomLeaderboard');
    else
        WebAdsWriteTagSponsor('728', '90', 'BottomLeaderboard', key1, key2);

}

function WebAdsBottomRightButtonTag()
{ }
