function postItSlider() {};
postItSlider.prototype = {
    curElem: 0,
    
    initialize: function(mainDiv,divElems,margin,visibleElem){
	
	var dimensions = new Array();
	var totalDimensions = 0;
        var allDivs = document.getElementsByClassName(divElems);
	
	this.curElem = visibleElem;
	var totalElems = allDivs.length;
	
	for( var i=0; i<allDivs.length; i++){
		
		totalDimensions += allDivs[i].getWidth();
		totalDimensions += margin;
	}
	
	$(mainDiv).setStyle({
		width: totalDimensions + "px"
	});
  
	var move = totalDimensions/allDivs.length;
	
	allRightBtns = document.getElementsByClassName("rightsliderbtn");
	allLeftBtns = document.getElementsByClassName("leftsliderbtn");
	var self = this;
	for(var j=0; j<allRightBtns.length; j++){
	    allRightBtns[j].observe('click', function(){
		self.onClick(mainDiv,move,"right",totalElems,visibleElem);
	    });
	}
	
	for(var j=0; j<allLeftBtns.length; j++){
	    allLeftBtns[j].observe('click', function(){
		self.onClick(mainDiv,move,"left",totalElems,visibleElem);
	    });
	}
    },
    
    onClick: function(mainDiv,move,direction,totalElems,visibleElem){
	if(direction == "right"){
	    if(this.curElem!=totalElems){
		new Effect.MoveBy( mainDiv, 0, -move , {duration: 0.3,  transition: Effect.Transitions.slowstop});
		this.curElem++;
	    }
	}else if("Left"){
	    if(this.curElem != visibleElem){
		new Effect.MoveBy( mainDiv, 0, move , {duration: 0.3,  transition: Effect.Transitions.slowstop});
		this.curElem--;
	    }
	}
    }

};

Event.observe(window, 'load', function() {
   if($('kalendercontentdiv')){
   		var elem = new postItSlider();
		//Div elementet som innholder alle elementer, navn på alle elementer, marginer,Synlige elementer
		elem.initialize("kalendercontentdiv","tokt",10,9);
   }
});
