/*
 * Copyright (C) 2008-2010 APN, LLC. All rights reserved
 * References to any external sources are embedded in the code.
 * 
 * Author(s): Christine Hodges, Michael Mayfield
 * Description: Manages dynamic buttons in toolbar
 */
function ATB_DynamicButtonManager(){this.init()}ATB_DynamicButtonManager.prototype._dynamicButtons=[];ATB_DynamicButtonManager.prototype.init=function(){try{ATB.Logger.info("Start *Dynamic Button Manager* Init");ATB.Logger.info("Fetching ticker buttons.");this.initializeDynamicButtons(ATB.Constants.BTN_TYPE_CLASS_DYNAMIC_TICKER);ATB.Logger.info("Fetching simple buttons.");this.initializeDynamicButtons(ATB.Constants.BTN_TYPE_CLASS_DYNAMIC_SIMPLE);ATB.Logger.info("Found a total of ",this._dynamicButtons.length," buttons.")}catch(a){ATB.Logger.error("*Dynamic Button Manager* init failed to initialize dynamic buttons: ",a)}finally{ATB.Logger.info("End *Dynamic Button Manager* Init...")}};ATB_DynamicButtonManager.prototype.initializeDynamicButtons=function(d){var e=null;var b=document.getElementById("asktb");var c=ATB.Utils.getElementsByClassName(d,b);ATB.Logger.info("Dynamic button (",d,") XUL elements found: ",c.length);for(var a=0;a<c.length;a++){e=ATB_DynamicButton.getButtonInstance(d,c[a]);if(e){ATB.Logger.info("Dynamic button class (",e.getButtonType(),") instantiated successfully.");this._dynamicButtons.push(e);ATB.Logger.debug("Calling initButtonData");e.initButtonData()}}};ATB_DynamicButtonManager.prototype.getWrapperInstanceForButton=function(b){for(var a=0;a<this._dynamicButtons.length;a++){if(this._dynamicButtons[a].getXULElementId()==b){return this._dynamicButtons[a]}}return null};ATB_DynamicButtonManager.prototype.unload=function(a){this._dynamicButtons=[]};ATB_DynamicButtonManager.prototype.callRenderDataOnOtherWindowsForButton=function(c,a){ATB.Logger.debug("DynamicButtonManager: Checking for other FF windows to update. Current button: "+c);var b=ATB.Utils.getAllBrowserWindows();while(b.hasMoreElements()){var d=b.getNext();if(d&&(d!=window)&&d.ATB.DynamicButtonManager){ATB.Logger.debug("Calling the  renderData for window: ",d+" ,for the dynamic button with id:"+c);d.ATB.DynamicButtonManager.getWrapperInstanceForButton(c).renderData(a)}}};