// JavaScript Document
/*
	EXPANDABLE LIST CLASS
	----------------------
*/
var Expandable_List = Class.create({
	initialize: function(strId, intNoToShow){

		//attributes
		this.id 				= strId;			//ID of element
		this.noToShow			= intNoToShow;		//No of li's to show
		
		this.debug				= true;
		this.orig_height		= 0;
	},


	Expand:function(){
		
		//try{
		
			this.orig_height = $(this.id).getDimensions().height;
			var height = this.orig_height;
			
			$(this.id).style.height = this.orig_height + "px";
			me = this;
			$(this.id).childElements().each(function(s, index){
				//s.style.display = "block";
				if (index > me.noToShow - 1){
					height = height + s.getDimensions().height;
					Effect.Appear(s, {duration:2} );
				}
			});
			
			new Effect.Morph(this.id, {
			  style: {
				height: height + "px"
			  }, // CSS Properties
			  duration: 1 // Core Effect properties
			});
			
			this.HideExpandIcon();
			this.ShowCollapseIcon();
			
		//} catch (e) {
		//	this.DisplayError(e);
		//}
	},
	
	Collapse:function(){
			
		try{
			me = this;
			$(this.id).childElements().each(function(s, index){
				//s.style.display = "block";
				if (index > me.noToShow - 1){
					
					Effect.Fade(s, {duration:1.5} );
				}
			});
			
			new Effect.Morph(this.id, {
			  style: {
				height: this.orig_height + "px"
			  }, // CSS Properties
			  duration: 1.5 // Core Effect properties
			});
			
			
			this.HideCollapseIcon();
			this.ShowExpandIcon();
			
		} catch(e){
			this.DisplayError(e);
		}
	},
	
	ShowExpandIcon:function(){
		Effect.Appear($(this.id + "_expand"), {duration:2} );
	},
	
	HideExpandIcon:function(){
		Effect.Fade($(this.id + "_expand"), {duration:2} );
	},
	
	ShowCollapseIcon:function(){
		Effect.Appear($(this.id + "_collapse"), {duration:2} );
	},
	
	HideCollapseIcon:function(){
		Effect.Fade($(this.id + "_collapse"), {duration:2} );
	},
	
	DisplayError:function(e){
		if (this.debug){ alert(e);}	
	}

});


	




