 /*
Copyright (c) 2008, Joseph McGranagan.
Portions Copyright (c) 2008, Yahoo!, Inc. All rights reserved.
Code licensed under the BSD License:
http://intrepidws.com//animtabview/
version: 1.0
*/
 
YAHOO.namespace("YAHOO.widget.AnimTabView");
     
     
YAHOO.widget.AnimTabView.NAME = "AnimTabView";

YAHOO.widget.AnimTabView = function (el, attr, pauseSeconds, focusPauseSeconds) {var pause = pauseSeconds * 1000;var focusPause = focusPauseSeconds * 1000;var tv = new YAHOO.widget.TabView(el, attr);var timer = null;var event = YAHOO.util.Event;var dom = YAHOO.util.Dom;var thisHook = this;var handleTabClicked = function (e, t) {event.preventDefault(e);this.doFocusPause();};this.init = function () {for (var i = 0; i < tv.get("tabs").length; i++) {tv.get("tabs")[i].subscribe("click", handleTabClicked, this, true);}};this.getTabCount = function () {return tv.get("tabs").length;};this.getActiveIndex = function () {return tv.get("activeIndex");};this.setActiveTab = function (index) {tv.get("activeIndex").length;};this.focusNextTab = function () {var index = tv.get("activeIndex");var tabCount = tv.get("tabs").length;if (index == tabCount - 1) {tv.set("activeIndex", 0);} else {tv.set("activeIndex", index + 1);}};this.beginAnimation = function () {timer = thisHook.later(true, pause, "focusNextTab");};this.stopAnimation = function () {if (timer != null) {timer.cancel();timer = null;}};this.doFocusPause = function (e) {this.stopAnimation();timer = this.later(false, focusPause, "beginAnimation");};this.later = function (interval, millis, callback) {var args = Array.prototype.slice.apply(arguments, [3]);if (typeof callback === "string") {callback = this[callback];}if (interval === true) {var t = setInterval(function () {callback.apply(this, args);}, millis);} else {var t = setTimeout(function () {callback.apply(this, args);}, millis);}return {cancel:function () {if (this.interval) {clearInterval(t);} else {clearTimeout(t);}}};};this.init();this.beginAnimation();return true;};

YAHOO.register("animtabview", YAHOO.widget.AnimTabView, {version:"1.0", build:"1"});