/*
 * Copyright (C) 2008-2010 APN, LLC. All rights reserved
 *
 * Author: Michael Mayfield
 * Description: Manages new tab content.
 **/
function ATB_NewTab(){this.urlProcessingEnabled=false;this.init()}ATB_NewTab.prototype.init=function(){ATB.Logger.info("Start *NewTab* Init...");ATB.Logger.info("Checking for 'en' lang, opt-out pref, and pre-new-tabs build to determine if new_tabs should be enabled.");var a=true;if(ATB.Prefs.getToolbarLanguage()!="en"){ATB.Logger.debug("Toolbar language isn't 'en', so not enabling new tabs.");a=false}else{if(ATB.Prefs.getBoolPref(ATB.Constants.ATB_SILENT_UPGRADE_FROM_PRE_NEWTABS_BUILD)){ATB.Logger.debug("Silent upgrade from a pre newtabs build detected , so not enabling new tabs.");a=false}else{if(ATB.Prefs.getNewTabOptOut()){ATB.Logger.debug("The user has opted-out of new tabs in the past, so not enabling new tabs.");a=false}}}if(a){ATB.Logger.info("Enabling new tabs.");ATB.Prefs.setNewTabEnabled(true);this.enableNewTabUrlProcessing()}else{ATB.Logger.info("Disabling new tabs.");ATB.Prefs.setNewTabEnabled(false)}ATB.Logger.info("End *NewTab* Init...")};ATB_NewTab.prototype.onNewTab=function(){var a=true;try{if(ATB.Prefs.isNewTabEnabled()){if(!this.urlProcessingEnabled){this.enableNewTabUrlProcessing()}gBrowser.selectedTab=gBrowser.addTab(ATB.Constants.ATB_NEW_TAB_PAGE);a=false}}catch(b){if(ATB.Error.isErrorEnabled()){ATB.Logger.error("Error processing new tab command: "+b.toString())}}finally{if(a){BrowserOpenTab()}}};ATB_NewTab.prototype.enableNewTabUrlProcessing=function(){if(gURLBar){var c=this.originalValueSetter=gURLBar.__lookupSetter__("value");var b=this.originalValueGetter=gURLBar.__lookupGetter__("value");var d=false;var a="";function e(g){if(g.indexOf(ATB.Constants.ATB_NEW_TAB_PAGE)==0){c.call(this,"");d=true;a=g}else{c.call(this,g);d=false;a=""}}function f(){var g=b.call(this);if(d&&g==""){return a}else{return g}}gURLBar.__defineSetter__("value",e);gURLBar.__defineGetter__("value",f);this.urlProcessingEnabled=true}};ATB_NewTab.prototype.disableNewTabUrlProcessing=function(){if(gURLBar&&this.originalValueSetter&&this.originalValueGetter){gURLBar.__defineSetter__("value",this.originalValueSetter);gURLBar.__defineGetter__("value",this.originalValueGetter);this.urlProcessingEnabled=false}};document.getElementById("content").onTabBarDblClick=function(a){if(!this._blockDblClick&&a.button==0&&a.originalTarget.localName=="box"){ATB.NewTab.onNewTab()}};