	var slideShow = new Class({
    	Implements: [Options, Events],
	
		container:null,
		slogan_container:null,
		timer:null,
		status:'playing',
		elements:[],
		slogan_elements:[],
		path:null,
		slider:null,
		buttons:null,
		path:null,
		s_slider:null,
		height:305,
		width:550,
    scrollname:"",
		scroller_speed:"",
		counter:0,
		total:0,
		cur:0,
		prev:0,
		imageno:0,
   
    
        
		initialize: function(container, slogan_container, images, slogans, links, path, buttons,scrollname,scroller_speed,width,height){
    	imageno = 0;
     
     this.container = $(container);
			this.slogan_container = $(slogan_container);
			this.path = path;
     this.buttons = $(buttons).getElements('a');
     this.scrollname = scrollname;
			this.scroller_speed =scroller_speed
     images.each(function(item,index){
			
				if (path != ""){imgpath = path+'/'+item}else{imgpath = item}
			 	var cElement = new Element('div',{
						'styles':{
        			'cursor':'pointer',
									'position':'absolute',
									'top':'0',
									'left':'0',
									'backgroundImage':'url('+imgpath+')',
									'height':height+'px',
									'width':width+'px',
									'opacity':'0'
								}
								
					})
     
       if (links != ""){cElement.addEvent('click', function(){parent.window.location=links[index];	})}
       
				cElement.inject(this.container);
				this.elements.extend([cElement]);
				this.total++;
			}, this);
			
			slogans.each(function(item,index){
								  
								var sElement = new Element('div', {
									'styles':{
											   'position':'absolute',
											   'top':'0',
											   'left':'0',
											   'font-size':'14px',
									     'opacity':'0'
										   },
									'html':item	   
							   })							  
 
					sElement.inject(this.slogan_container);	  
					this.slogan_elements.extend([sElement]);
								  
			}, this)
			
				this.elements[0].setStyle('opacity','100');
				this.cur = 0;
				this.slogan_elements[0].setStyle('opacity','100');
	    },
        
		startShow: function(){
				var els = this.container.getElements('div');
				var s_els = this.slogan_container.getElements('div');
				var slide = function(){
				
					if (this.cur == this.total) this.cur = 0;
					if (this.cur == 0) this.prev = this.total - 1; else this.prev = this.cur - 1;
					els[this.prev].fade('out');		
					els[this.cur].fade('in');
					s_els[this.prev].fade('out');
					s_els[this.cur].fade('in');
					this.buttons[this.prev].setStyle('background','url(/images/image_col'+this.scrollname+'_off.png) no-repeat 0 0');
					this.buttons[this.cur].setStyle('background','url(/images/image_col'+this.scrollname+'_on.png) no-repeat 0 0');
					this.cur++;
					this.counter++;
				}
			slide.bind(this);
			
			this.slider = slide.periodical(this.scroller_speed,this);
		},
		
		
		moveToSlide:function(move_to)
    {
    	 var els = this.container.getElements('div');
				var s_els = this.slogan_container.getElements('div');
   			for (i=0;i<=this.total-1;i++)
      {
      els[i].setStyle('opacity','0');
      s_els[i].setStyle('opacity','0');
      els[i].fade('out');
				s_els[i].fade('out');
      this.buttons[i].setStyle('background','url(images/image_col'+this.scrollname+'_off.png) no-repeat 0 0');
      }
     	this.buttons[move_to-1].setStyle('background','url(images/image_col'+this.scrollname+'_on.png) no-repeat 0 0');
      els[move_to-1].fade('in');
				s_els[move_to-1].fade('in');
      this.cur = move_to;
    
    },
  
		stopShow:function(){
			this.slider = $clear(this.slider);	
			this.s_slider = $clear(this.s_slider);	
		},
		
		log:function(){
		
			console.log(this.container);
			console.log(this.images);		
		}

	});
	
  
function startscroller(container, slogan_container,slides, slogans, links,  path, buttons,startslide,scrollname,speed,width,height){

  this.buttons = $(buttons).getElements('a');
  var buttclicked = function(){eval(container+".stopShow();");eval(container+".moveToSlide("+this.id+");");eval(container+".startShow();")};
  this.buttons.addEvent('click', buttclicked);
  eval("var "+container+" = new slideShow(container, slogan_container, slides, slogans, links, path, buttons,scrollname,speed,width,height);")
	eval(container+".startShow();")
}


