var _timeoutinterval = 0;

var _rootup_max_height = 1000;
var _rootup_current_height = 0;
var _rootup_speed = 10 ;
var _rootup = 0;
var _innerup = 0;
var _intervalup = 0;

var _rootdown_max_height = 100000;
var _rootdown_current_height = 0;
var _rootdown_speed = 10;
var _rootdown = 0;
var _innerdown = 0;
var _intervaldown = 0;

var firefox = (window.attachEvent)?false:true;

function down(){
	if(_rootdown_current_height < _rootdown_max_height){
		if(!firefox){
			_rootdown.style.height = _rootdown_current_height + "px";	
		}else{
			_rootdown.style.height = _rootdown_current_height + "pt";		
		}		
		_rootdown_current_height = Number(_rootdown_current_height) + Number(_rootdown_speed);
		//if(_rootdown_current_height > _rootdown_max_height-30){_rootdown_speed = 1;}				
	}else{
		clearInterval(_intervaldown);	
		_rootdown_current_height = _rootdown_max_height;
		_rootdown.style.height = _rootdown_max_height + "px";	
		_innerdown.style.display = "block";			
	}
}

function up(){					
	if(_rootup_current_height > 0){				
		if(!firefox){
			_rootup.style.height = _rootup_current_height + "px";
		}else{
			_rootup.style.height = _rootup_current_height + "pt";
		}
		_rootup_current_height = _rootup_current_height - _rootup_speed;

		//if(_rootup_current_height < 30){_rootup_speed = 1;}			
	}else{			
		clearInterval(_intervalup);		
		_rootup_current_height = 0;
		_rootup.style.height = 0 + "px";		
		_rootup.style.display = "none";
	}
}


function SlideDownMenuList(){		
	_innerdown.style.display = "none";
	_rootdown.style.display = "block";			
	_intervaldown = window.setInterval('down()',1);			
}

function SlideUpMenuList(){	
	_innerup.style.display = "none";	
	_intervalup = window.setInterval('up()',1);
}


//SLIDING MENU CLASS
SlideMenu.prototype.constructor = SlideMenu;

function SlideMenu(id,container,classname,opac){
	this._Id = id;
	this._Container = container;
	this._Class = classname;
	this._Opacity = opac;
	this._Height = 0;
	this._MaxHeight = 0;
}

SlideMenu.prototype.Draw = function Draw(){
	var div = document.createElement("DIV");	
	div.className = this._Class;
	div.id = this._Id;
	div.style.height = this._Height+"px";
	this.MenuContainer().style.opacity = this._Opacity;		
    this.MenuContainer().style.MozOpacity = (this._Opacity / 100);
    this.MenuContainer().style.KhtmlOpacity = (this._Opacity / 100);
    this.MenuContainer().style.filter = "alpha(opacity=" + this._Opacity + ")"; 
	this.MenuContainer().appendChild(div);
	this.MenuContainer().innerHTML = document.getElementById(this._Container).innerHTML;

}

SlideMenu.prototype.AddItem = function AddItem(content,url){
	var ul = document.createElement("UL");
	var li = document.createElement("LI");
	var a = document.createElement("A");
	a.appendChild(document.createTextNode(content));
	a.setAttribute("href",url);
	li.appendChild(a);
	ul.appendChild(li);
	this.MenuList().appendChild(ul);
	this._MaxHeight = this._MaxHeight + 40;
	this.MenuContainer().style.height = this._Height;  //MENU CONTAINER IS THE TOP LEVEL DIV THAT HOLDS THE MENU LIST DIV	
	this.MenuContainer().style.display = "none";
	this.MenuList().style.height = this._MaxHeight;    //MENU LIST IS THE BOX THAT HOLDS THE SUB MENU ITEMS
	this.MenuList().style.display = "none";
}

SlideMenu.prototype.MenuList = function MenuList(){
	return document.getElementById(this._Id);	
}

SlideMenu.prototype.MenuContainer = function MenuContainer(){
	return document.getElementById(this._Container);	
}



