YAHOO.namespace('ui')

YAHOO.ui = function(el) {
  if (arguments) {
    return new ui.node(el);
  }
};

var UI = YAHOO.ui, ui = UI;

ui.node = function(el) {
  this.element = YAHOO.util.Selector.query(el, document, true);
};
ui.node.prototype = {
  plug: function(module, userConfig) {
    return ui.module(module,this.element,userConfig);
  }
};
    
ui.module = function(strMod) {
	var args = [].slice.call(arguments, 1),
		oModule = new UI.module[strMod]();
	
	return oModule.init.apply(oModule, args);
};

ui.data = function() {
  
};
YAHOO.lang.augmentObject(UI.data,{
  get: function() {
    if (this.el.__data) {
      return this.el.__data;
    }
    if (this.el.hasAttribute('data-items')) {
      try {
        return this.el.__data = YAHOO.lang.JSON.parse(this.el.getAttribute('data-items'));
      }
      catch (e) {
        
      }
    }
    if (this.el.hasAttribute('data-feed')) {
      alert('do fetch: ' + this.el.getAttribute('data-feed'));
    }
  }
});


ui.baseModule = function() {
  
};
YAHOO.extend(
  ui.baseModule, YAHOO.util.AttributeProvider, 
  {
    configAttributes: function() {
      for (var key in this.DEFAULT_CONFIG) {
        this.setAttributeConfig(key, this.DEFAULT_CONFIG[key], true);
      }
    }
  }
);

ui.create = function(module, methods) {
	var fn = new Function();
	YAHOO.extend(fn, ui.baseModule, methods(YAHOO));
	ui.module[module] = fn;
};
ui.tools = function(){
	
	var YUI = YAHOO.util, dom = ui.dom, Event = YUI.Event;
	
	return {
		flashObjects: function() {
			var knownObjects, isDirty = true;
			
			return {
				setOpaque: function() {
					dom.toggleAttribute(dom.getElementsByTagName('embed'), 'wmode', 'opaque');
					
					Dom.batch(
						dom.getElementsByTagName('embed'),
						function(el) {
							var id = el.id || Dom.generateId(el);
							
							var wmodes = el.getElementsByTagName('wmode');
							
							if (wmodes && wmodes.length > 0) {
								el.previousWmode = wmodes[0].getAttribute('value') || '';
								el.setAttribute('value', 'opaque');
							}
							else {
								var wmode = document.createElement('param');
								wmode.setAttribute('name','wmode');
								wmode.setAttribute('value','opaque');
								
								el.appendChild(wmode);
							}
						}
					);
				},
				
				reset: function() {
					
				}
			}
		}()
	};
	
}();
(function(){
	
var YUI = YAHOO.util,
	JS = YAHOO.lang,
	ui = YAHOO.ui,
	dom = JS.merge({}, YUI.Dom);
		
JS.augmentObject(dom,{
		
getElementsByTagName: function(tag) {
	var tags = [].slice.call(arguments),
			parent = document,
			elements = [];
	
	tags.forEach(
		function(tagName) {
			var els = parent.getElementsByTagName(tagName);
			
			if (els.length > 0) {
				elements = elements.concat([].slice.call(els));
			}
		}
	);
	
	return elements;
},

toggleAttribute: function(el, name, value) {
	var attrList = {},
		fn = function(el) {
			var id = el.id || ui.dom.generateId(el);
			
			if (!attrList[id]) {
				attrList[id] = {};
			}
			if (!attrList[id][name]) {
				attrList[id][name] = {
					current: el.getAttribute(name) || ''
				};
			}
			
			var conf = attrList[id][name];
			
			if (conf.current == value) {
				el.setAttribute(name, conf.previous);
				conf.current = conf.previous;
				delete conf.previous;
			}
			else {
				conf.previous = el.getAttribute(name);
				conf.current = value;
				el.setAttribute(name, value);
			}
		};
			
	return ui.dom.batch(YAHOO.lang.isArray(el) ? el : [el], fn);
}
});

YAHOO.ui.dom = dom;

		
})();
ui.create('accordion',function(Y){
  var util = Y.util, js = Y.lang, dom = util.Dom, event = util.Event;
  
  return {
    DEFAULT_CONFIG: {
      expandedClass : {
        value: 'expanded'
      },
      toggle : {
		value: false
	  }
    },
    
    /**
     * Assumes the provided el holds HTML with the structure
     *
     * <ul>
     *   <li>
     *     <div>Title</div>
     *     <ul>
     *       <li>Link</li>
     *       <li>Another Link</li>
     *     </ul>
     *   </li>
     *   <li>
     *     <div>Second Title</div>
     *     <ul>
     *       <li>One link</li>
     *     </ul>
     *   </li>
     * </ul>
     *
     */
    init: function(el, userConfig) {
      this.element = dom.get(el);
      
      this.configAttributes();
      
      if (js.isObject(userConfig)) {
        this.setAttributes(userConfig);
      }
      
      this.initDomEvents();
    },
    
    initDomEvents: function() {
      event.addListener(dom.getChildren(this.element), 'click', this.onClickEvent, this, true);
    },
    
    onClickEvent: function(evt) {
      var el = event.getTarget(evt);
      
      if (el.tagName.toUpperCase() == 'DIV') {
		if (this.get('toggle')) {
          this.toggle(el.parentNode);
        }
        else {
          this.hideAll();
          this.show(el.parentNode);
        }
      }
    },
    
    hideAll: function() {
      dom.removeClass(dom.getChildren(this.element), this.get('expandedClass'));
    },
    
    show: function(el) {
      dom.addClass(el, this.get('expandedClass'));
    },
    
    hide: function(el) {
      dom.removeClass(el, this.get('expandedClass'));  
    },
    
    toggle: function(el) {
      var className = this.get('expandedClass');
      if (dom.hasClass(el, className)) {
        this.hide(el);
      }
      else {
        this.show(el);
      }
    }
  };
  
});
ui.create('carousel', function(Y){
  
  return {
    init: function(el, userConfig) {
      var carousel = new Y.widget.Carousel(el, userConfig);

  		carousel.render();
  		carousel.show();

  		return carousel;
    }
  };
  
});
/**
 * 
 */
ui.create('WhatsHot', function(Y){
	var dom = Y.util.Dom,
	    js = Y.lang;
			
	/**
	 * @class FeedItems
	 * @constructor
	 * @param {String/HTMLElement} el HTML element reference
	 * @param {Module} owner Parent object
	 */
	var FeedItems = function(el, owner) {
	  this.element = dom.get(el);
	  this.owner = owner;
	};
	
	FeedItems.prototype = {
		clear: function() {
			this.element.innerHTML = '';
		},
		setItems: function(items) {
		  this.clear();
		  for (var i = 0, len = items.length; i<len; i++) {
				this.addItem(items[i]);
			}
		},
		addItem: function(data) {
			var li = document.createElement('li'),
			    tmpl = this.owner.get('itemTemplate'),
			    maxLength = this.owner.get('maxLength');
			    
			if (!data.text && data.title) {
			  data.text = data.title;
			}

			if (data.text.length > maxLength) {
				data.text = data.text.substr(0, maxLength - 3).replace(/\s+\S{0,2}$/,'') + '...';
			}

			li.innerHTML = Y.lang.substitute(tmpl, data);

			this.element.appendChild(li);
		}
	};


  /*
	  Public interface
	 */
	return {
	  DEFAULT_CONFIG: {
  	  extended : {
  	    value: false
  	  },
  	  isCircular : { 
  	    value: true
  	  },
  	  itemTemplate : {
  	    value: '<a href="{url}">{text}</a>'
  	  },
  	  footerLink: {
  	    setter: function(value) {
  	      if (!this._footerLink) {
  	        this._footerLink = this.footer.getElementsByTagName('a')[0];
  	      }
  	      this._footerLink.setAttribute('href',value.url);

  	      if (!this._footerTitle) {
  	        this._footerTitle = this._footerLink.getElementsByTagName('em')[0];
  	      }
  	      this._footerTitle.innerHTML = value.text;
  	    }
  	  },
  	  title : {
  	    setter: function(value) {
  	      if (!this._title) {
  	        this._title = this._module.header.getElementsByTagName('h2')[0];
  	      }
  	      this._title.innerHTML = value;
  	    }
  	  },
  	  limit : {
  	    value: 7
  	  },
  	  prefix : {
  	    value: ''
  	  },
  	  maxLength: {
  	    value: 30,
  	    getter: function(varName, value) {
  	      if (!this._maxLength) {
  	        this._maxLength = value;
  	        if (dom.getAncestorByClassName(this.body, 'subchannel-layout')) {
  	          this._maxLength = 44;
  	        }
  	      }
  	      return this._maxLength;
  	    }
      }
  	},
	  
    _module: null,
    
    _carousel: null,
    _feedItems: null,
    
    cache: {},

		init: function(el, userConfig) {
			var container = new Y.widget.Module(el);
			
			this.configAttributes();
			
      if (Y.lang.isObject(userConfig)) {
			  this.setAttributes(userConfig);
		  }

			container.renderEvent.subscribe(this._onRender, this, true);

			this._module = container;

			// ArticleList is built from markup - so it's ready to be rendered.
			container.render();
		},
		
		handleSuccessResponse: function(response) {
		  
		  try {
		    var data = YAHOO.lang.JSON.parse(response.responseText);
		    
		    this.updateState(data.results,response.argument);
		  }
		  catch (e) {
		    // failed to load correct data
		    // alert(e.message);
		  }
		  
		},
		
		updateState: function(items, link) {
		  this.set('footerLink',{
				url: link.getAttribute('href'),
				text: link.innerHTML
			});

			if (this.get('extended')) {
				this.set('title', link.innerHTML);
			}

	    if (items) {
				if (items.length > this.get('limit')) {
				  items = items.slice(0, this.get('limit'));
				}
				this._feedItems.setItems(items);
				link._feedItems = items;
			}
		},

		onItemSelected: function(index) {
		  var el = this._carousel.getElementForItem(index),
			    link = el.getElementsByTagName('a')[0];

      if (link._feedItems && js.isArray(link._feedItems)) {
        return this.updateState(link._feedItems,link);
      }      
      try {
        var rawItems = link.getAttribute('data-items');
        if (rawItems && rawItems.length > 0) {
          var items = Y.lang.JSON.parse(rawItems);

          return this.updateState(items,link);
        }
      }
      catch (e) {
        // just continue on
        // alert(e.message);
      }
			Y.util.Connect.asyncRequest(
			  'GET', link.getAttribute('data-feed'),
				{ success: this.handleSuccessResponse,
				  scope: this,
				  argument: link
				}
			);
		},
		
		_onRender: function() {
		  var mod = this._module, 
		      children = dom.getChildren(mod.body);
		  
		  this.footer = mod.footer;
		  this.header = mod.header;
		  this.body   = mod.body;


  		this.elCarousel = children[0];
  		this.elList = children[1];

  		this._feedItems = new FeedItems(children[1], this);

  		/*
  				Carousel widget showing Sub-Channel list
  		*/
      this._initCarousel(children[0]);
  		
  		mod.element.style.display = '';
  		mod.renderEvent.unsubscribe(this._onRender);
		},
		
		_initCarousel: function(el) {
		  this._carousel = new Y.widget.Carousel(el, {
  			numVisible: 2,
  			isCircular: this.get('isCircular') || false
  		});
  		
  		
  		dom.batch(
  			el.getElementsByTagName('a'),
  			function(n) {
  				n.setAttribute('onclick', 'return false;');
  				n.onclick = function(){return false;};
  			}
  		);

  		this._carousel.on("itemSelected", this.onItemSelected, this, true);
  		this._carousel.render();
  		this._carousel.show();
  		
  		dom.setStyle(el,'width','');
		}

	};
			
});
ui.create('FlashPanel', function(Y){


var YU = Y.util, Dom = YU.Dom, JS = Y.lang,

	oConfig = {
		autoPlayInterval: 6000,
		numVisible: 4,
		//isCircular: true,
		//animation: { speed: 0.5 },
		scrollIncrement: 1
	},

	carousel, spotlight, oChildren, modules = {}, curModule;

/**
 * @event startAutoPlay
 * @description Fires when the auto play has started in the Carousel.  See
 * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a>
 * for more information on listening for this event.
 * @type YAHOO.util.CustomEvent
 */
var startAutoPlayEvent = "startAutoPlay";

/**
 * @event stopAutoPlay
 * @description Fires when the auto play has been stopped in the Carousel.
 * See
 * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a>
 * for more information on listening for this event.
 * @type YAHOO.util.CustomEvent
 */
var stopAutoPlayEvent = "stopAutoPlay";

/**
 * @event completeAutoPlay
 * @description Fires when the autoScroll function has completed
 * See
 * <a href="YAHOO.util.Element.html#addListener">Element.addListener</a>
 * for more information on listening for this event.
 * @type YAHOO.util.CustomEvent
 */
var completeAutoPlayEvent = "completeAutoPlay";

/*
 * Private helper functions used by the Carousel component
 */

/**
 * Automatically scroll the contents of the Carousel.
 * @method autoScroll
 * @private
 */
function autoScroll() {
	var currIndex = this._selectedItem,
		index;
		
	if (currIndex >= this.get("numItems") - 1) {
		index = 0;
	} else {
		index = currIndex + 1;
	}
	this.set('selectedItem', index);
	this.fireEvent(completeAutoPlayEvent);
}

function createCarousel(el, userConfig) {
	if (!createCarousel.module) {
		var Carousel = function(el,userConfig) {
			Carousel.superclass.constructor.call(this,el,userConfig);
		};
		YAHOO.extend(Carousel, YAHOO.widget.Carousel, {
			/**
			 * Start auto-playing the Carousel.
			 *
			 * @method startAutoPlay
			 * @public
			 */
			startAutoPlay: function () {
				var self  = this,
					timer = this.get("autoPlayInterval");
					
				if (timer > 0) {
					if (!JS.isUndefined(this._autoPlayTimer)) {
						return;
					}
					this.fireEvent(startAutoPlayEvent);
					this._autoPlayTimer = setTimeout(function () {
						delete self._autoPlayTimer;
						autoScroll.call(self); }, timer);
				}
			},

			/**
			 * Stop auto-playing the Carousel.
			 *
			 * @method stopAutoPlay
			 * @public
			 */
			stopAutoPlay: function () {
				if (!JS.isUndefined(this._autoPlayTimer)) {
					clearTimeout(this._autoPlayTimer);
					delete this._autoPlayTimer;
					this.set("autoPlayInterval", 0);
					this.fireEvent(stopAutoPlayEvent);
				}
			},
			
			focus: function() {
				// overrides default functionality which changes the browser
				// focus to the current carousel item
			}
		});
		createCarousel.module = Carousel;
	}
	return new createCarousel.module(el,userConfig);
};

function createOverlay(el) {
	var oOverlay = new Y.widget.Overlay(el, {
		visible:false,
		context:[spotlight,"tl","tl"],
		effect: { effect:Y.widget.ContainerEffect.FADE, duration:0.25 }
	});

	oOverlay.render();
	
	return oOverlay;
};


return {
	init: function(el, userConfig) {
		this.element = Dom.get(el);
		
		this._oConfig = YAHOO.lang.merge(oConfig, userConfig || {});

		var carousel = createCarousel(Dom.getFirstChild(this.element), this._oConfig);

		var spotlight = Dom.getLastChild(this.element);
		oChildren = Dom.getChildren( spotlight );

		Dom.addClass(oChildren, 'yui-overlay');


		carousel.on("itemSelected", this.carouselItemSelected, this, true);
		
		carousel.on(completeAutoPlayEvent, carousel.startAutoPlay);
		carousel.on("render", this._renderEvent);

		carousel.render();
		carousel.show();
		
		carousel.get('element').style.width = '';
		
		carousel.startAutoPlay();
		
		YU.Event.addListener(this.element.id, 'click', carousel.stopAutoPlay, carousel, true);
	},
	
	_renderEvent: function() {
		if (Dom.getAncestorByClassName(this._clipEl, 'subchannel-layout')) {
			this._clipEl.style.width = '';
		}
	},
	
	carouselItemSelected: function(index) {
		var oId = oChildren[index].id || Dom.generateId(oChildren[index]);

		if (!modules[oId]) {
			modules[oId] = createOverlay(oId);
		}

		// do nothing when same button is clicked twice
		if (curModule == modules[oId]) {
			return;
		}

		if (curModule) {
			curModule.hide();
		}

		curModule = modules[oId];

		curModule.show();
	}
};

});
ui.create('navbar',function(Y){
  var Dom = UI.dom,
      Event = Y.util.Event,
      Overlay;


  function get_article_feed(url, callback) {
    return Y.util.Connect.asyncRequest(
      'GET', url, {
        success: function(o) {
          var text = o.responseText;
        
          try {
            var data = YAHOO.lang.JSON.parse(text);
          
            callback.success.call(callback.scope || callback.success, o, data, callback.arguments);
          }
          catch(e) {
            callback.failure.call(callback.scope || this, o, callback.arguments);
          }
        },
        failure: function(o) {
          callback.failure.call(callback.scope || this, o, callback.arguments);
        }
      }
    );
  };



  /**
   * @class MenuManager
   * @singleton
   */
  var MenuManager = function() {
    var instances = {};

    return {
      hideEvent: new YAHOO.util.CustomEvent('hideEvent', MenuManager),
      showEvent: new YAHOO.util.CustomEvent('showEvent', MenuManager),
    
      getItemById: function(id) {
        if (instances[id]) {
          return instances[id];
        }
        return false;
      },
  
      registerItem: function(menuItem) {
        instances[menuItem.id] = menuItem;
      },
  
      forEach: function(fn, scope) {
        var method = false;
        if (typeof fn != 'string') {
          method = fn;
        }
        for (var id in instances) {
          if (!method) {
            instances[id][fn].call(scope || instances[id]);
          }
          else {
            method.call(scope || instances[id], instances[id]);
          }
        }
      },
    
      show: function(item) {
      
      },
  
      hideAll: function() {
        this.forEach('hide');
        this.hideEvent.fire();
      },
  
      showAll: function() {
        this.forEach('show');
      }
    };
  }();






  /**
   * @class MenuBar
   * @constructor
   */
  function MenuBarItem(el, userConfig) {
    if (arguments.length) {
      MenuBarItem.prototype.init.call(this, el, userConfig);
    }
  };

  MenuBarItem.CHANNEL_INDEX = 1;
  MenuBarItem.FEED_INDEX = 1;

  MenuBarItem.prototype = {
  
    root: null,

    hydrated: false,

    feedSrc: null,

    displayed: false,

    labelEl: null,

    init: function(el, userConfig) {
      this.element = Dom.get(el);
  
      this.id = this.element.id || Dom.generateId(this.element);
    
      this.labelEl = Dom.getFirstChild(this.element);
    
      this.overlayEl = Dom.getLastChild(this.element);
  
      Dom.addClass(this.element, 'ui-navbaritem');
      Dom.addClass(this.labelEl, 'ui-navbaritemlabel');
  
      this.initDOMEvents();
    },


    initDOMEvents: function() {
      var e = YAHOO.util.Event;
  
      e.addListener(Dom.getFirstChild(this.element), 'mouseover', this.mouseOverHandler, this, true);
    },
  
  
    syncUI: function() {
      if (this.labelEl == this.overlayEl) {
        return;
      }
    
      var containerWidth = 1000,
          offsetLeft     = this.element.offsetLeft,
          offsetWidth    = this.overlayEl.offsetWidth;
        
      if (containerWidth - offsetLeft < offsetWidth) {
        this.overlayEl.style.left = (containerWidth - offsetWidth - offsetLeft) + 'px';
      }
      else {
        this.overlayEl.style.left = '0';
      }
    },


    mouseOverHandler: function(evt) {
      if (!this.displayed) {
        this.show();
      }
    },

    mouseOutHandler: function(evt) {
      this.hide();
    },


    show: function() {
      this.displayed = true;
    
      MenuManager.hideAll();
    
      if (this.getSubMenu(MenuBarItem.FEED_INDEX)) {
        if (!this.hydrated) {
          this.hydrate();
        }
      }
  
      Dom.addClass(this.element, 'ui-navbaritem-selected');
    
      this.syncUI();
  
      MenuManager.showEvent.fire(this);
    },


    hide: function() {
      Dom.removeClass(this.element, 'ui-navbaritem-selected');
  
      this.displayed = false;
    
      if (this.labelEl != this.overlayEl) {
        this.overlayEl.style.left = '-9999px';
      }
    },


    getFeedURL: function() {
      if (this.feedSrc) {
        return this.feedSrc;
      }
  
      var link = Dom.getFirstChild(this.element);
  
      //if (link && link.hasAttribute('data-feed')) {
        this.feedSrc = link.getAttribute('data-feed');
      //}
  
      return this.feedSrc;
    },


    getSubMenu: function(index) {
      if (!this.submenus) {
        this.submenus = this.element.getElementsByTagName('ul');
      }
      if (this.submenus.length < index) {
        return false;
      }
      return this.submenus[index];
    },

    showLoading: function() {
      Dom.addClass(this.getSubMenu(MenuBarItem.FEED_INDEX).parentNode, 'feed-loading');
    },
  
    hideLoading: function() {
      Dom.removeClass(this.getSubMenu(MenuBarItem.FEED_INDEX).parentNode, 'feed-loading');
    },



    addItem: function(item, position) {
      var li = document.createElement('li'),
          a = document.createElement('a');
  
      a.setAttribute('href', item.url);
      a.innerHTML = item.text;
  
      li.appendChild(a);
  
      this.element.appendChild(li);
    },


    addItems: function(items) {
      for (var i = 0, len = items.length; i<len; i++)
        this.addItem(items);
    },


    requestSuccessHandler: function(request, response) {
      this.hideLoading();
    
      if (response.results.length == 0) {
        this.requestFailureHandler();
        return;
      }
  
      var elFeed = this.getSubMenu(MenuBarItem.FEED_INDEX),
      items  = response.results;
    
      elFeed.innerHTML = '';
  
      for (var i = 0, len = Math.min(items.length, 10); i<len; i++) {
        elFeed.innerHTML += '<li><a href="'+items[i].url+'">'+items[i].text+'</a></li>';
      }
    
    
      this.syncUI();
    },


    requestFailureHandler: function(request, response) {
      this.hideLoading();
    
      var feedEl = this.getSubMenu(1),
          colEl = feedEl.parentNode;
    
      colEl.parentNode.removeChild(colEl);
      Dom.removeClass(this.overlayEl, 'ui-navbar-overlay-feed');
    
      this.syncUI();
    },


    hydrate: function() {
      this.showLoading();

      this.hydrated = true;
    
      var url = this.getFeedURL();
    
      if (url && url.length > 0) {
        get_article_feed(
          url,
          {
            scope: this,
            success: this.requestSuccessHandler,
            failure: this.requestFailureHandler
          }
        );
      }
      else {
        this.hideLoading();
        this.requestFailureHandler();
      }
    }
  };



  return {
  
    DEFAULT_CONFIG: {

      hidedelay: {
        value: 750
      },

      maxArticles: {
    	  value: 10
      },

      showdelay: {
        value: 250
      },

      zIndex: {
        value: 11000 /* this is ridiculous... but so are advertisements */
      }

    },

    _oMenuItems: {},

    _menuItems: [],

    init: function(el, userConfig) {
      Overlay = YAHOO.widget.Overlay;
  
      this.container = Dom.get(el);
      this.config = userConfig || {};
    
      this.initElements();
    
      this.initEvents();
  
      this.initMenuItems();
	
  	  this.fixElements();
    },
  
    initElements: function() {
      var firstChild = Dom.getFirstChild(this.container);
      if (Dom.hasClass(firstChild, 'bd')) {
        this.body= firstChild;
        firstChild = Dom.getFirstChild(this.body);
      }
      if (firstChild.tagName.toUpperCase() == "UL") {
        this.menuEl = firstChild;
      }
    },

    initEvents: function() {
    
      Event.addListener(this.container, 'mouseout', this.mouseOutHandler, this, true);
    
      MenuManager.hideEvent.subscribe(this.stopInactiveListener, this, true);
      MenuManager.showEvent.subscribe(this.startInactiveListener, this, true);
    
    },

    initMenuItems: function() {
      var items = Dom.getChildren(this.menuEl);
  
      for (var i = 0, len = items.length; i < len; i++) {
        var item = new MenuBarItem(items[i]);
        item.root = this;
    
        MenuManager.registerItem(item);
      }
    },
  
    fixElements: function() {
  	  Dom.getElementsBy(
  		  function(el) {
    			if (el.tagName.toUpperCase() == 'iframe') {
    				if (!Dom.getStyle(el, 'zIndex')) {
    					Dom.setStyle(el, 'position', Dom.getStyle(el, 'position') || 'relative');
    					el.style.zIndex = 10;
    				}
    			}
    			var zIndex = parseInt(Dom.getStyle(el, 'z-index'), 10);
    			if (zIndex > 12001) {
    				el.style.zIndex = 11000;
    			}
    		},
    		'*'
    	);
    },

    startInactiveListener: function() {
      var self = this;
    
      Event.addListener(document, 'mousemove', this.recordMoveEvent, this, true);
    
      this._checkInactive = window.setInterval(
        function() {
          self.checkIfInactive();
        },
        750
      );
    },
  
    stopInactiveListener: function() {
      window.clearInterval( this._checkInactive );
      delete this._checkInactive;
    
      Event.removeListener(document, 'mousemove', this.recordMoveEvent);
    },
  
  
    recordMoveEvent: function(evt) {
      this._lastEvent = Event.getTarget(evt);
    },
  
  
    checkIfInactive: function() {
      if (!this._lastEvent) {
        return;
      }
      var target = this._lastEvent;
    
      if (Dom.getAncestorByClassName(target, 'ui-navbar')) {
        return;
      }
    
      MenuManager.hideAll();
      this.stopInactiveListener();
    }

  };
});
