TB.widget.SimpleScroll=new function(){var Y=PWPVK.util;var defConfig={delay:2,speed:20,startDelay:2,scrollItemCount:1}
this.decorate=function(container,config){container=$(container);config=TB.applyIf(config||{},defConfig);var handle={};var scrollTimeId=null,pause=false;var onScrollEvent=new Y.CustomEvent("onScroll",handle,false,Y.CustomEvent.FLAT);if(config.onScroll){onScrollEvent.subscribe(config.onScroll);}else{onScrollEvent.subscribe(function(){for(var i=0;i<config.scrollItemCount;i++){container.appendChild(container.getElementsByTagName('li')[0]);}});}
var scroll=function(){if(pause)return;container.scrollTop+=2;var lh=config.lineHeight||container.getElementsByTagName('li')[0].offsetHeight;if(container.scrollTop%lh<=1){clearInterval(scrollTimeId);onScrollEvent.fire();container.scrollTop=0;setTimeout(start,config.delay*1000);}}
var start=function(){var lh=config.lineHeight||container.getElementsByTagName('li')[0].offsetHeight;if(container.scrollHeight-container.offsetHeight>=lh)
scrollTimeId=setInterval(scroll,config.speed);}
$E.on(container,'mouseover',function(){pause=true;});$E.on(container,'mouseout',function(){pause=false;});setTimeout(start,config.startDelay*1000);TB.apply(handle,{subscribeOnScroll:function(func,override){if(override===true&&onScrollEvent.subscribers.length>0)
onScrollEvent.unsubscribeAll();onScrollEvent.subscribe(func);}});handle.onScroll=handle.subscribeOnScroll;return handle;}};

AE.widget.groupViewer=(function(){var currentHook,dropTimeId,dropTimeout=300,dropHeight=false;var canClose,classAllTimer,config;var aItem;var oDefConfig={dropHeight:false,dropTimeout:300,panelId:"BraPanel",tabClass:"groupViewerTab",contentClass:"groupViewerContent",plusClass:"groupViewerMouseHover"};var dropAnim=function(panel){YUD.setStyle(panel,'height',0);YUD.setStyle(panel,'display','block');var content=YUD.getElementsByClassName(config.contentClass,'div',panel)[0];var anim=new PWPVK.util.Anim(panel,{height:{from:0,to:panel.dropHeight}},0.3);anim.animate();};var closeAllDelay=function(){clearTimeout(classAllTimer);classAllTimer=setTimeout(closeAll,200);}
var drop=function(){var rel=YUD.get(this.getAttribute('rel'));YUD.addClass(this,config.plusClass);if(currentHook){var curRel=YUD.get(currentHook.getAttribute('rel'));var cpContent=YUD.getElementsByClassName(config.contentClass,'div',curRel)[0];var rel=YUD.get(this.getAttribute('rel'));if(this.parentNode.parentNode!=currentHook.parentNode.parentNode){}else{YUD.removeClass(currentHook,config.plusClass);YUD.addClass(this,config.plusClass);YUD.setStyle(curRel,'display','none');YUD.setStyle(rel,'display','block');YUD.setStyle(rel,'height',rel.dropHeight+'px');}}else{YUD.addClass(this,config.plusClass);dropAnim(rel);}
currentHook=this;}
var delayDrop=function(){cancelDrop();var hook=this;dropTimeId=setTimeout(function(){drop.call(hook);},dropTimeout);}
var cancelDrop=function(){clearTimeout(dropTimeId);}
return{init:function(oConfig){config=TB.applyIf(oConfig||{},oDefConfig);dropHeight=config.dropHeight;var bp=YUD.get(config.panelId);try{currentHook=YUD.getElementsByClassName(config.plusClass,'*',bp)[0];if(currentHook){rel=YUD.get(currentHook.getAttribute('rel'));}}catch(e){}
aItem=YUD.getElementsByClassName(config.tabClass,'*',bp);for(var i=0;i<aItem.length;i++){var itemContent=YUD.getElementsByClassName(config.contentClass,'div',get(aItem[i].getAttribute('rel')))[0];itemContent.parentNode.style.display='';get(aItem[i].getAttribute('rel')).dropHeight=(config.dropHeight)?config.dropHeight:itemContent.offsetHeight;itemContent.parentNode.style.display='none';YUE.on(aItem[i],'mouseover',delayDrop);}}};})();

