﻿SLC = {
	DropDown: {
		DDSpeed: 5,
		DDTimer: 15,
		paddingBottom: 6,
		slide: function(c, dir) {
			var curHeight = c.offsetHeight;
			var distance;
			if (dir == 1) { distance = (Math.round((c.maxh - curHeight) / this.DDSpeed)); }
			else { distance = (Math.round(curHeight / this.DDSpeed)); }
			if (distance <= 1 && dir == 1) { distance = 1; }
			if (distance != 0) {
			    
			    var h = curHeight + ((distance * dir));
				c.style.cssText = "height:" + h + "px";
					
                if ((curHeight < 2 && dir != 1) || (curHeight > (c.maxh - 2) && dir == 1)) { clearInterval(c.timer); }
			} else {
				c.style.height = "0px";
				clearInterval(c.timer);
			}
		},
		collapse: function(c) {
			c.timer = setInterval(function() { SLC.DropDown.slide(c, -1); }, this.DDTimer);
		},
		cancelHiding: function(id) {
			var d = document.getElementById(id + "_dropdown");
			var c = document.getElementById(id + "_content");
			clearTimeout(d.timer);
			clearTimeout(c.timer);
			if (c.offsetHeight < c.maxh) { c.timer = setInterval(function() { SLC.DropDown.slide(c, 1); }, this.DDTimer); }
		},
		DDMenu: function(id, dir) {
			var d = document.getElementById(id + "_dropdown");
			var c = document.getElementById(id + "_content");
			clearInterval(c.timer);
			if (dir == 1) {
				clearTimeout(d.timer);
				if (c.maxh && c.maxh <= c.offsetHeight) { return; }
				else if (!c.maxh) {
					c.style.display = "block";
					c.style.height = "auto";
					c.maxh = c.offsetHeight + this.paddingBottom;
					c.style.height = "0px";
				}
				c.style.height = c.maxh + "px";
//				c.timer = setInterval(function() { SLC.DropDown.slide(c, 1); }, this.DDTimer);
			}
			else { d.timer = setTimeout(function() { SLC.DropDown.collapse(c); }, 50); }
		}
	}
}