if (typeof Effect == 'undefined') 
	throw("viamod.js requires including script.aculo.us' effects.js library!");
	
var viamod = Class.create();
viamod.prototype = {


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 || {});
		
		this.isOpen = true;
		this.realHeight = 0;
		
		this.minimize = new Element("div", {'class': "minimize"}).update(
			this.minbutton = new Element("a", {href: '#', 'class': "minbutton"}).update("MINIMIZE THIS FIELD [-]")
		);
		
		var toogleSize = this.toggle.bindAsEventListener(this);
		Event.observe(this.minbutton, 'click', toogleSize, false);
		
		this.contain.insert({'bottom':this.minimize});
		
	 
	},
	toggle: function(e) {
		
		this.realHeight = (this.realHeight == 0) ? this.contain.getHeight() : this.realHeight;
		
		this.isOpen = (this.isOpen == true) ? this.isOpen = false : this.isOpen = true;
		
		var newheight = (this.isOpen == true) ? this.realHeight : 20;
		
		var update = (this.isOpen == true) ? "MINIMIZE THIS FIELD [-]" : "MAXIMIZE THIS FIELD [+]";
		
		this.minbutton.update(update);
		
		new Effect.Morph(this.contain,{
	style:'height:' + newheight + 'px;',
	transition: Effect.Transitions.EaseFromTo,
	duration:1.0,
	beforeStart: function(fx){
					fx.element.setStyle({overflow:"hidden"}); // Fix for MSIE 6 to resize correctly
					
				},
	afterFinish: function(fx) {
				
				
				fx.element.setStyle({overflow: (this.isOpen == true) ? 'visible' : 'hidden'});
			}.bind(this)
	});
	
	Event.stop(e);
	}
	
}