function AD(_placementID, _sizeID)
{
    this.networkID = 665; //Morningstar
    this.placementID = _placementID;
    this.sizeID = _sizeID;
}

var ADDictionary = new Dictionary();
    PortfolioBottomRightFlag = new Boolean();

ADDictionary.add( 'topADSmallDefault', new AD('1595073', '1653') );//Additional banner next to leaderboard 195x90
ADDictionary.add( 'ToolsHomeSquare', new AD('1625842', '6') ); // 1402894 Tools Home Square 125x125
ADDictionary.add( 'EquitiesSquare', new AD('1625842', '6') ); // 1496639 Equities Square 125x125

// Ishares
ADDictionary.add( 'ETFsHomeTop', new AD('2363070', '225') );
ADDictionary.add( 'ETFsConferenceTop', new AD('2363068', '225'));
ADDictionary.add( 'ETFsNewsLetterTop', new AD('2363285', '225'));
ADDictionary.add( 'ETFsSurveyTop', new AD('2363063', '225'));
ADDictionary.add( 'ETFArticleTop', new AD('2363068', '225') );
ADDictionary.add( 'ETFArchiveTop', new AD('2363070', '225') );
ADDictionary.add( 'ETFQuickrankTop', new AD('2363070', '225') );
ADDictionary.add( 'ETFArticleRight', new AD('2377276', '154') );
ADDictionary.add( 'ETFArchiveRight', new AD('2377276', '154') ); 
ADDictionary.add( 'ETFQuickrankRight', new AD('2377276', '154') ); 
ADDictionary.add( 'OeicsHomeSquare', new AD('2366671', '6') );
ADDictionary.add( 'ETFsHomeMPU', new AD('2363071', '171') ); 
ADDictionary.add( 'ETFQuickRankBottomLeftMPU', new AD('2363071', '171'));  
ADDictionary.add( 'ETFsNewsLetterMPU', new AD('2363287', '171') ); 
ADDictionary.add( 'ETFConferenceMPU', new AD('2363066', '171') ); 
ADDictionary.add( 'ETFSurveyMPU', new AD('2363067', '171') ); 
ADDictionary.add( 'ETFsHomeBottom', new AD('2363064', '1748') );
ADDictionary.add( 'ETFsNewsLetterBottom', new AD('2363288', '1748') );
ADDictionary.add( 'ETFSurveyBottom', new AD('2363062', '1748') );
ADDictionary.add( 'BottomLeaderboard', new AD('2363065', '1748') );

//Ishares Custom  
ADDictionary.add( 'ETFCustomSignup', new AD('2363069', '16') );


//TK: added to change position for PortfolioBottomRight 05/02/09
PortfolioBottomRightFlag  = false;

function WebAdsWriteTagSponsor(width, height, placementID, key1, key2)
{
    // ignore the keys for now on non-uk sites
    WebAdsWriteTag(width, height, placementID);
}

function WebAdsWriteTag(width, height, placementKey)
{
    // HZ: use the Adtech tag for this small banner in the top right
    if(placementKey=='topADSmallDefault')
    {
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
    }
    // MV: use the Adtech tag for button ad in left menu bar
    if(placementKey=='ToolsHomeSquare')
    {
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
    }   

	// Ishares - added 21/01/2010
    if((placementKey=='ETFsHomeTop') || (placementKey =='ETFArchiveTop') ||(placementKey =='ETFQuickrankTop')||(placementKey == 'ETFArticleTop') |(placementKey == 'ETFsNewsLetterTop') || (placementKey =='ETFsSurveyTop'))
	{
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
	}   

    if((placementKey=='ETFsHomeMPU')||(placementKey=='ETFConferenceMPU')||(placementKey=='ETFsConferenceTop')||(placementKey=='ETFsNewsLetterMPU')||(placementKey=='ETFSurveyMPU')||(placementKey=='ETFQuickRankBottomLeftMPU'))
    {
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
    }   
      
    if(placementKey=='OeicsHomeSquare')
    {
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
    }   
   
    if((placementKey=='ETFArticleRight')||(placementKey=='ETFArchiveRight') ||(placementKey=='ETFQuickrankRight'))
    {
        WebAdsWriteTagAdTechTags(width, height, placementKey);
        return;
    }   
    
	// Ishares - end 21/01/2010


    var size;
    var position;


    // TK: web adds - NL only
  
    if (width == '160')
    {
        size = '120X600';
        position = 'RIGHT';
    }

    //home page
    else if (placementKey == 'HomepageMPU')
    {
      size = '336X280';
      position = 'MIDDLE';   
    }   
	
	//portfolio cover page
    else if (placementKey == 'PortfolioMPU')
    {
      size = '336X280';
      position = 'MIDDLE';
    }
    
    //funds cover page
    else if (placementKey == 'OeicsHomeMPU')
    {
      size = '336X280';
      position = 'MIDDLE';
    }
    
    //equities cover page
    else if (placementKey == 'EquitiesMPU')
    {
      size = '336X280';
      position = 'MIDDLE';
    }
    
    //ETF cover page
    else if (placementKey == 'ETFsHomeMPU')
    {
		size = '336X280';
		position = 'MIDDLE';
    }
    
    else if (placementKey == 'PortfolioBottomRight')
    {
      if (PortfolioBottomRightFlag == false)
      {
        position = 'TOP';
        PortfolioBottomRightFlag = true;
      }  
      else
        position ='BOTTOM';
        
      size = 'TEXTBOX';     
    }

    else if (width == '728')
    {
        //size = '468X60';
        size = '728X90';
        position = 'TOP';
    }

 
	// added 16/12/09 - #17652 
     else if ((placementKey == 'QuickRankBottomLeft') || (placementKey =='ToolsFundOverviewMPU'))
    {
      size = '336X280';
      position = 'MIDDLE';   
    }   

 
     try
    {
        wbds_ads.qWrite(size, position);
    }
    catch(e){}    
}

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);
    }   
    
    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 WebAdsBottomTag()
{
    try
    {
		var strEtf = location.href; // for ETF section only

		// ETF cover page
		if (strEtf.match("ETFCover")){ 
				WebAdsWriteTagAdTechTags('728', '90', 'ETFsHomeBottom');
				return;
		}
		
		// Newsletter page
		if (strEtf.match("ETFNewsLetterSignup")){ 
				WebAdsWriteTagAdTechTags('728', '110', 'ETFsNewsLetterBottom');
				return;
		}
		
		// Survey page
		if (strEtf.match("ETFSurvey")){ 
				WebAdsWriteTagAdTechTags('728', '110', 'ETFSurveyBottom');
				return;
		}
		
    	if (strEtf.match("etf"))
			WebAdsWriteTagAdTechTags('728', '90', 'BottomLeaderboard');
		else 
		if(bIsSnapshot == true)         // HZ: Ticket #8475
        {        
            wbds_ads.qWrite('468X60','BOTTOM');
        }
        else
			wbds_ads.qWrite('728X90', 'BOTTOM'); // write the webadds default

    }
    catch(e){
		wbds_ads.qWrite('728X90', 'BOTTOM'); // write the default
	}
}

function WebQTSponsorTag(fundId, companyId)
{   
    try{
        wbds_ads.qWrite('TEXTBOX','RIGHT1');
    }catch(e){}
}
