Amazonas = {
     init : function() {
     	new YAHOO.widget.TabView('amazonas-container');
        var slider3 = new amazonaslider();
        slider3.setControlId("slider-control");
        slider3.setContainerId("slider-container");
        slider3.initSlider();
        
     }
       
     
}//end Amazonas

 YAHOO.util.Event.onDOMReady(Amazonas.init)

      
/*********************************************
Slider Object
Author: Edward Lee
July 2008
Yahoo UI Dependancies
yahoo-min.js	
event-min.js
dom-min.js
animation-min.js
**********************************************/
var amazonaslider = function() {
		var Control = "";
		var Container = "";
		var Slider = "slider";
		var Expanded = "expanded";
		var Collapsed = "collapsed";
		var StatusId = "open";
		var Sliders = "";
		var Controls = "";
		var MaxHeight = "";
	  	var MinHeight = 0;
	  	var Duration = .3;

		var Target = function(i, a, b){ this.i = i; this.a = a; this.b = b;}
		
		var ElementRegion = function(obj) {
				var region = YAHOO.util.Dom.getRegion(obj);
				this.getHeight = function () { return region.bottom - region.top; }
				this.getWidth = function () { return region.right - region.left; }
		}

		var GenericSlider = function(i, a) {
			this.index = i;
			this.duration = Duration;
			this.maxHeight = MaxHeight;
			this.minHeight = MinHeight;
			if (a != null) { this.duration = a; }
			if (Sliders[this.index].height){ this.maxHeight = Sliders[this.index].height; }
	        this.toggleSlider = function() {
	            var attributes = {height: { to: this.maxHeight }};
	            if(Controls[this.index].className == Expanded) {
	              var attributes = {height: { to: this.minHeight }};
	              Controls[this.index].className = Collapsed;
	            }
	            else {
	              Controls[this.index].className = Expanded;
	            }
	          this.animate(Sliders[this.index], attributes, this.duration);
	        }
	        this.closeSlider = function() {
	        	if(Controls[this.index].className != Collapsed) {
	         		var attributes = {height: { to: this.minHeight }};
	          		Controls[this.index].className = Collapsed;
	          		this.animate(Sliders[this.index], attributes, this.duration);
	          	}
	        }
	        this.openSlider = function() {
	        	if(Controls[this.index].className != Expanded) {
	          		var attributes = {height: { to: this.maxHeight }};
		          	Controls[this.index].className = Expanded;
		          	this.animate(Sliders[this.index], attributes, this.duration);
	          	}
	        }
	        this.animate = function(target, attributes, duration) {
	          var anim = new YAHOO.util.Anim(target, attributes, duration);
	          anim.animate();
	        }
		}

		/*----------------------------------------------
		@param a - optional int 0-infinity (transition speed)
			- !null indicates exclusive drop down functionality
		@param b - optional boolean
			- true indicates at least one dropdown remains open at all times
		@param fn - function obj 
			- function template fn(e, args){}
			- @param e = Event Handler
			- @param args = Slider Args object with control and params attributes
			- attach an additional listener event
		@param d - parameter to pass into the listener event
		------------------------------------------------*/
		this.initSlider = function(a, b, fn, d) {
			Sliders = YAHOO.util.Dom.getElementsByClassName(Container);
			Controls = YAHOO.util.Dom.getElementsByClassName(Control);
			for(var i = 0; i<Controls.length; i++) {
				if(Sliders[i]) {
					var region = new ElementRegion(Sliders[i]);
					var obj = new Target(i, a, b);
					YAHOO.util.Event.addListener(Controls[i], "click", this.toggle, obj);
					if(fn){this.attachEvent(Controls[i], fn, d)}
			        Sliders[i].height = region.getHeight();
			        this.setCanvas(Sliders[i], Controls[i]);
		    	}
		    }
		}
		this.attachEvent = function(obj, fn, d) {
				YAHOO.util.Event.addListener(obj, "click", fn, d); 
		}
		this.setCanvas = function(slider, control) {
				 slider.className = Slider;
			    if(slider.id == StatusId) {
				    control.className = Expanded;
			    } else {
				    slider.style.height = 0;
				    control.className = Collapsed;
			    }
		}
		this.toggle = function(e, obj) {			
	        if(obj.a != null) {
	          for(i=0; i<Controls.length;i++) {
	          	var slider = new GenericSlider(i, obj.a)
	          	if(obj.i != i) {
		             slider.closeSlider();
	            }
	          }
	        }
	        var slider = new GenericSlider(obj.i);
	        if(obj.b) {
	        	slider.openSlider()
	        }
	        else {
        		slider.toggleSlider();
        	}
	    }
		this.closeAll = function(e, a)
		{
			for(i=0; i<Controls.length;i++) {
				var slider = new GenericSlider(i, a)
				slider.closeSlider();
			}
		}
		this.openAll = function(e, a)
		{
			for(i=0; i<Controls.length;i++) {
				var slider = new GenericSlider(i, a)
				slider.openSlider();
			}
		}
	    this.setControlId = function(val) {
	       Control = val;
	    }
	    this.setContainerId = function(val) {
	       Container = val;
	    }
	    this.setSliderClosed = function(val) {
	       SliderClosed = val;
	    }
	    this.setSliderOpen = function(val) {
	       SliderOpen = val;
	    }
	    this.setOpenStyle = function(val) {
	       Expanded = val;
	    }
	    this.setClosedStyle = function(val) {
	       Collapsed = val;
	    }
	    this.setMinHeight = function(val) {
	       MinHeight = val;
	    }
	    this.setMaxHeight = function(val) {
	       MaxHeight = val;
	    }
	    this.setDuration = function(val) {
	       Duration = val;
	    }
		this.setStatusId = function(val) {
	       StatusId = val;
	    }
	    this.getElementRegion = function(obj) {
	       return new ElementRegion(obj);
	    }
	    this.getGenericSlider = function(i, a) {
	       return new GenericSlider(i, a);
	    }
	    this.returnVal = function (val) {
	    	return eval(val);
	    }
}
