function InitializeCPHToolbar(pMainObj){
    if (!arBXContents) 
        throw 'Toolbar should not be initialized when no content areas exists.';
    if (!pMainObj) 
        throw 'System level exception. pMainObj == null';
    if (!pMainObj.cphID) 
        throw 'this.pMainObj.cphID can`t have value not presented in contents list.';
    
    var cphtblist = oBXEditorUtils.createToolbar("ContentPlaceHolderTB", BX_MESS.ASPXP_TB_CPHAREAS, [], {
        show: true,
        docked: true,
        position: [0, 0, 2]
    });
    
    oBXEditorUtils.addToolbar(cphtblist);
     
    var ContentPlaceHolderList = ['BXList', {
        'width': '160',
        'height': '110',
        'field_size': '150',
        'title': '(template)',
        'bSetGlobalStyles': true,
        'disableOnCodeView'  : true,
        'values': arBXContents,
        'OnCreate': function(){
            this.pMainObj.pCPHListbox = this;
        },
        'OnInit': function(){
            this.SelectByVal(this.pMainObj.cphID);
        },
        'OnChange': function(selected){
            this.pMainObj.pASPXParser.SetCurrentCPH(selected['value']);
        }
    }];
    
    oBXEditorUtils.appendButton('ContentPlaceHolderList', ContentPlaceHolderList, 'ContentPlaceHolderTB');
    
    var pToolbar = new BXToolbar(pMainObj, BX_MESS.ASPXP_TB_CPHAREAS, 'ContentPlaceHolderTB');
    
    if (!SETTINGS[pMainObj.name].arToolbarSettings || !pMainObj.RS_toolbars) 
        SETTINGS[pMainObj.name].arToolbarSettings = arToolbarSettings_default;
    var arToolbarSettings = SETTINGS[pMainObj.name].arToolbarSettings;
    
    var arSet;
    if (!arToolbarSettings['ContentPlaceHolderTB']) {
        SETTINGS[pMainObj.name].arToolbarSettings['ContentPlaceHolderTB'] = arToolbarSettings_default['ContentPlaceHolderTB'];
        arSet = arToolbarSettings_default['ContentPlaceHolderTB'];
    }
    else 
        arSet = arToolbarSettings['ContentPlaceHolderTB'];
    
    for (var i = 0; i < arToolbars['ContentPlaceHolderTB'][1].length; i++) {
        var arButton = arToolbars['ContentPlaceHolderTB'][1][i];
        if (!arButton) 
            continue;
        
        if (navigator.appName == 'Netscape' && arButton[1].hideInFF) 
            continue;
        
        if (arButton != 'separator') 
            pToolbar.AddButton(pMainObj.CreateCustomElement(arButton[0], arButton[1]));
        else 
            pToolbar.AddButton(pMainObj.CreateCustomElement('BXButtonSeparator'));
    }
    
    if (arSet.docked && arSet.position) 
        arDefaultTBPositions['ContentPlaceHolderTB'] = arSet.position;
    
    try {
        if (arDefaultTBPositions['ContentPlaceHolderTB']) 
            pMainObj.arToolbarSet[arDefaultTBPositions['ContentPlaceHolderTB'][0]].AddToolbar(pToolbar, arDefaultTBPositions['ContentPlaceHolderTB'][1], arDefaultTBPositions['ContentPlaceHolderTB'][2]);
        else 
            pMainObj.arToolbarSet[0].AddToolbar(pToolbar, 100, 0);
    } 
    catch (e) {
        pMainObj.arToolbarSet[0].AddToolbar(pToolbar, 100, 0);
    }
    
    if (!arSet.docked && arSet.position) 
        pToolbar.SetPosition(arSet.position.x, arSet.position.y);
    
    if (!arSet.show) {
        pToolbar.Close();
        return null;
    }
    
    pToolbar = null;
    
    return 'ContentPlaceHolderTB';
}

function RefreshValuesCPHToolbar(pMainObj)
{
	if (pMainObj && pMainObj.pCPHListbox && arBXContents)
		pMainObj.pCPHListbox.SetValues(arBXContents);
}
