window.addEvent('domready', function() {
	
/*	
	openFolderId = Cookie.read('openFolderId');
	if (openFolderId===null){
		openFolderId = -1;
	}
	openFolderId = openFolderId*1;
	// ACCORDION START
	var myAccordion = new Accordion($('accordion'),'a.atStart', 'ul.atStart',{
		opacity: true,
		show:openFolderId,
		alwaysHide:true,
		onActive: function(toggler, element){
			var myCookie = Cookie.write('openFolderId', toggler.id, {path:"/"});
		},
	 
		onBackground: function(toggler, element){
			toggler.removeClass('active');
			if (Cookie.read('openFolderId')*1 == toggler.id){
			var myCookie = Cookie.write('openFolderId', -1, {path:"/"});
			}
		}
	});
	
*/
	
	folderMenuArray = $$('li.foldmenu');

	for (i=0;i<folderMenuArray.length;i++){
		folderMenuArray[i].elementSize = folderMenuArray[i].getSize().y;
		folderMenuArray[i].startSize = $('starter').getSize().y;
		if (folderMenuArray[i].id != Cookie.read('openFolderId')){
			folderMenuArray[i].setStyle('height',folderMenuArray[i].startSize+'px');
		}
		folderMenuArray[i].addEvents({
			'mouseenter': function(){
				// Always sets the duration of the tween to 1000 ms and a bouncing transition
				// And then tweens the height of the element
				if (this.id != Cookie.read('openFolderId')){
					this.set('tween', {
						duration: 1000,
						transition: Fx.Transitions.Sine.easeOut // This could have been also 'bounce:out'
					}).tween('height', this.elementSize);
				}
			},
			'mouseleave': function(){
				// Resets the tween and changes the element back to its original size
				if (this.id != Cookie.read('openFolderId')){
					this.set('tween', {}).tween('height', this.startSize);
				}
			}
		});	
	}
	
		//alert(myelementSize.y);
	// The same as before: adding events

});

function openFolder(folderId){
	var myCookie = Cookie.write('openFolderId', folderId, {path:"/"});
	return true;
}
