// JavaScript Document
//when the dom is ready  
window.addEvent('domready', function() {  		
     //store titles and text  
     $$('a.tip').each(function(element,index) {  
         var content = element.get('title').split('::');  
         element.store('tip:title', content[0]);  
         element.store('tip:text', content[1]);  
     });  
       
     //create the tooltips  
     var tipz = new Tips('.tip', {  
		 maxOpacity: 0.8
     });
	 
     $$('a.artistTip').each(function(element,index) {  
         var content = element.get('title').split('::');  
         element.store('tip:title', content[0]);  
         element.store('tip:text', content[1]);  
     });  
	 
	 var tipz = new Tips('.artistTip', {
		className: 'artistTip',
		maxOpacity: 0.8
	 });
		
}); 


var Fader = new Class({
        Implements: Options,
        options: {
                pause: 6000,
                duration: 1000,
                loop: true,
                onComplete: Class.empty,
                onStart: Class.empty
        },
        initialize: function(container,options) {
                this.setOptions(options);
                this.container = $(container);
                this.links = this.container.getElements('a');
                
                this.imgs = this.container.getElements('img');
                this.imgs.setStyles({
                        'position':'absolute',
                        'top':0,
                        'left':0,
                        'opacity':0
                });
                this.imgs[0].setStyle('opacity',1);
                this.el = new Element('div',{'styles': {
                        'position':'relative'
            }});
            this.el.injectInside(this.container);
            this.el.adopt(this.links);
                this.next = 0;
        },
        start: function() {
                this.periodical = this.show.bind(this).periodical(this.options.pause);
        },
        stop: function() {
                $clear(this.periodical);
        },
        show: function() {

                this.next = (this.next==this.imgs.length-1)?0:this.next+1;
                var prev = (this.next==0)?this.imgs.length-1:this.next-1;
		this.imgs[this.next].set('tween', {duration: 'long'});
		this.imgs[prev].set('tween', {duration: 'long'});
		
                this.imgs[this.next].fade('in');
                this.imgs[prev].fade('out');
        }
}); 