if (typeof Effect == 'undefined') 
	throw("modules.js requires including script.aculo.us' effects.js library!");
	
var modules = Class.create();
modules.prototype = {
modulesinst : [],

initialize: function(container, options) {
	 this.contain = $(container);
	 
	 	 this.options = Object.extend({
			placeholder: 'Logga in',
			classNames : {
				toggle : 'accordion_toggle',
				toggleActive : 'accordion_toggle_active',
				content : 'accordion_content'
			}
			
		}, options || {});
		
		
		var modarray = this.contain.select('.module');
		
	
		
		modarray.each(function(mods) {
		
			this.createModule(mods);
			
		}.bind(this));
		
	 
	},
	
	createModule: function(mod){
		
		if(mod.down('.moduleslideshow') != undefined)
		{
			this.createSlide(mod.down('.moduleslideshow'));
		}
		
	  
	  	var moduler = new viamod(mod);
		

		this.modulesinst.push(moduler)
	  
	  
	  },
	  createSlide: function(slidemods)
	  {
	  	this.array = slidemods.select('.slide');
	  	
	  	this.array.each(function(smods) {
			
			
			
			smods.hide();
		}.bind(this));
		
		this.pos = 0;
		
		this.array[0].appear();
		
		setInterval(this.nextSlide.bind(this), 5000);
	  	
	  	//alert(array.length);
	  },
	  
	  nextSlide: function()
	  {
	  	
	  	this.pos = this.pos + 1;
	  	
	  	if(this.pos > this.array.length-1)
	  	{
	  		this.pos = 0;
	  	}
	  	
	  	var temp;
	  	
	  	if(this.pos == 0)
	  	{
	  		temp = this.array.length-1;
	  	}
	  	else
	  	{
	  		temp = this.pos - 1;
	  	}
	  	
	  	
	  	
	  	
	  	
	  	this.array[temp].fade();
	  	this.array[this.pos].appear();
	  	
	  	

	  
	  }
	
}