/**
 * Slider user interface component.
 * 
 * @author Mike Hart
 * 
 * @version 0.3
 * 
 * @copyright DM Design Studios
 * 
 * @package framework
 * @subpackage ui
 */

var Slider = new Class({
    
    Implements : [Options, Events],
    
    options : {  
        links_area : "links", // Where the image links are held 
        image_area : "image_area", // Where the image is
    },

    initialize : function( options )
    {
        this.setOptions( options );
        
        this.addEventListeners();
        
        $( 'links' ).getElementsByTagName( "a" )[0].fireEvent( "click" );
    },
    
    addEventListeners : function(){
    	var links = $(this.options.links_area).getElementsByTagName( "a" );

    	for( i = 0; i < links.length; i++ ){
    		links[i].addEvent( "click", this.clickHandler );
    	};
    },
    
    clickHandler : function( e ){
    	
    	if( e ){
    		e.stop();
    	}

    	$( 'info' ).innerHTML = "";

    	$('on-show').set( "src", this.href );

    	paragraph = new Element( "span" );
    	$( 'info' ).grab( paragraph );
    	paragraph.set( "html", this.rel );
    }
});

window.addEvent("domready", function(){
	slider = new Slider();
});
