
function sliderportlet(container_id,content_id,next,prev,text_id,item_text,stop_on_element){var self=this;this.item_text=item_text;this.stop_on_element=(stop_on_element==null?'h1':stop_on_element);this.container_id=container_id;this.content_id=content_id;this.text_id=text_id;this.current=0;this.delay=5000;this.headers=$j('#'+container_id+' '+this.stop_on_element);if(this.headers.length==0)return;this.rotate=function(){if((self.current+1)<self.headers.length){self.current++;}else{self.current=0;}
self.update();self.timer=setTimeout(self.rotate,self.delay);};this.next=function(e){if((self.current+1)<self.headers.length){self.current++;}
self.update();clearTimeout(self.timer);self.timer=setTimeout(self.rotate,self.delay*4);};this.prev=function(e){if((self.current-1)>=0){self.current--;}
self.update();clearTimeout(self.timer);self.timer=setTimeout(self.rotate,self.delay*4);};this.update=function(){$j('#'+self.content_id).animate({marginTop:-self.headers[self.current].offsetTop});$j('#'+self.text_id).html(self.item_text+' '+(self.current+1)+' of '+self.headers.length);};$j('#'+next).bind('click',this.next);$j('#'+prev).bind('click',this.prev);this.update();this.timer=setTimeout(self.rotate,self.delay);};function timedSlideShow(image_list_container,title_container,page_container){var self=this;this.init=function(){if(!$j(image_list_container))
throw"timedSlideShow could not find the element: "+image_list_container;if(!$j(image_list_container))
throw"timedSlideShow could not find the element: "+title_container;self.delay=7000;self.title_container=title_container;self.image_list_container=image_list_container;self.activeImage=0;self.timer=false;self.imgs=$j("ul#image-candy li img");self.thumbs=$j("ul#page-candy li img");for(var i=0;i<self.imgs.length;i++){self.imgs[i].setAttribute("id","slide-image-"+i);self.thumbs[i].setAttribute("id","slide-page-"+i);$j(self.thumbs[i]).parent().attr('href','javascript:void(0);');$j(self.thumbs[i]).bind('click',{val:i},self.force);if(i>0){$j(self.imgs[i]).hide();}else{$j('#'+self.title_container).html($j('#slide-image-'+self.activeImage).attr("title"));$j('#slide-page-'+self.activeImage).addClass('current-page-candy');}}
self.timer=setTimeout(self.next,self.delay);}
this.next=function(){$j('#slide-page-'+self.activeImage).removeClass('current-page-candy');$j('#slide-image-'+self.activeImage).fadeOut(1000);(self.activeImage==self.imgs.length-1)?self.activeImage=0:self.activeImage++;$j('#slide-page-'+self.activeImage).addClass('current-page-candy');$j('#slide-image-'+self.activeImage).fadeIn(1000);$j('#'+self.title_container).html($j('#slide-image-'+self.activeImage).attr("title"));self.timer=setTimeout(self.next,self.delay);};this.force=function(e){clearTimeout(self.timer);if(self.activeImage!=e.data.val){$j('#slide-page-'+self.activeImage).removeClass('current-page-candy');$j('#slide-image-'+self.activeImage).fadeOut(1000);self.activeImage=e.data.val;$j('#slide-image-'+self.activeImage).fadeIn(1000);$j('#slide-page-'+self.activeImage).addClass('current-page-candy');$j('#'+self.title_container).html($j('#slide-image-'+self.activeImage).attr("title"));}
self.timer=setTimeout(self.next,self.delay);};self.init();}
