var temp;

	function toggleSubmenu(p, v){
		var num = 0, menu;

		if(p.className && p.className.split("menu_item item") && p.className.split("menu_item item")[1]) num = p.className.split("menu_item item")[1];
		if(p.blur) p.blur();
		
		if(num) menu = document.getElementById("sub_menu_"+num+"");
		if(menu){
			menu.innerDiv = menu.getElementsByTagName("DIV").item(0);
			if(v == 1){
				if(document.storeElement != null){
					toggleSubmenu(document.storeElement, 0);
					document.onclick = document.storeOnclick;
					document.storeElement = null;
				}
				menu.style.visibility = "visible";
				menu.style.zIndex = "50";
				toggleSize(menu,'h', 10, menu.innerDiv.offsetHeight, 1);
				document.storeOnclick = document.onclick;
				document.storeElement = p;
				window.setTimeout(function(){document.onclick = function(){
					toggleSubmenu(document.storeElement, 0);
					this.onclick = this.storeOnclick;
					document.storeElement = null;
				};}, 10);
				p.onclick = function(){
					toggleSubmenu(this, 0);
					return(false);
				};
			} 
			else{
				menu.style.zIndex = "9997";
				toggleSize(menu,'h', 10, 0, 1, "this.style.visibility = 'hidden';");
				p.onclick = function(){
					toggleSubmenu(this, 1);
					return(false);
				};
			}
		}

		var num = 0, info;

		if(p.className && p.className.split("info_item info") && p.className.split("info_item info")[1]) num = p.className.split("info_item info")[1];
		if(p.blur) p.blur();

		if(num) info = document.getElementById("sub_info_"+num+"");
		if(info){
			info.innerDiv = info.getElementsByTagName("DIV").item(0);
			if(v == 1){
				if(document.storeElement != null){
					toggleSubmenu(document.storeElement, 0);
					document.onclick = document.storeOnclick;
					document.storeElement = null;
				}
				info.style.visibility = "visible";
				info.style.zIndex = "50";
				toggleSize(info, 'h', 10, info.innerDiv.offsetHeight, 1);
				document.storeOnclick = document.onclick;
				document.storeElement = p;
				window.setTimeout(function(){document.onclick = function(){
					toggleSubmenu(document.storeElement, 0);
					this.onclick = this.storeOnclick;
					document.storeElement = null;
				};}, 10);
				p.onclick = function(){
					toggleSubmenu(this, 0);
					return(false);
				};
			}
			else{
				info.style.zIndex = "9998";
				toggleSize(info, 'h', 10, 0, 1, "this.style.visibility = 'hidden';");
				p.onclick = function(){
					toggleSubmenu(this, 1);
					return(false);
				};
			}		
		}
	}
	
	function toggleSlide(e, from, speed, total, increment, callback){
	var pos;
	
	if(from == "t"){ pos = e.style.top.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	else if(from == "b"){ pos = e.style.bottom.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	else if(from == "l"){ pos = e.style.left.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	else if(from == "r"){ pos = e.style.right.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	
	pos = parseInt(pos); e.mySl = pos;
	window.clearInterval(e.mySliding);
	e.mySlide = function(pos, from, total, increment, callback){
	
		if(total > pos && this.mySl < total) this.mySl = this.mySl + increment;
		else if(total < pos && this.mySl > total) this.mySl = this.mySl - increment;
		else{ this.mySl = total; window.clearInterval(this.mySliding); eval(callback); }
		
		if(from == "t") this.style.top = this.mySl+"px";
		else if(from == "b") this.style.bottom = this.mySl+"px";
		else if(from == "l") this.style.left = this.mySl+"px";
		else if(from == "r") this.style.right = this.mySl+"px";
		else if(from == "h") this.style.height = this.mySl+"px";
		else if(from == "w") this.style.width = this.mySl+"px";
		
		return(true);
	};
	e.mySliding = window.setInterval(function(){ e.mySlide(pos, from, total, increment, callback); }, speed);
}

function toggleSize(e, from, speed, total, increment, callback){
	var pos, temp;
	if(from == "h"){ pos = e.style.height.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	else if(from == "w"){ pos = e.style.width.split("px")[0].split("%")[0].split("em")[0].split(" ")[0];}
	
	pos = parseInt(pos); e.mySz = pos;
	window.clearInterval(e.mySizing);
	e.mySize = function(pos, from, total, increment, callback, speed){
	
		increment = (total - this.mySz) / speed;
		if(total > pos && this.mySz < total){ this.mySz = Math.ceil(this.mySz) + increment; }
		else if(total < pos && this.mySz > total){ this.mySz = Math.floor(this.mySz) + increment; }
		else{ this.mySz = total; window.clearInterval(this.mySizing); eval(callback); }
		
		if(from == "h"){
			temp = this.innerDiv.offsetHeight-this.mySz;
			if(temp > 0) this.innerDiv.style.marginTop = +-(temp)+"px";
			else this.innerDiv.style.marginTop = "0px";
			if(this.mySz > 0) this.style.height = this.mySz+"px";
			else this.style.height = "0px";
		}
		else if(from == "w") this.style.width = this.mySz+"px";
		
		return(true);
	};
	e.mySizing = window.setInterval(function(){ e.mySize(pos, from, total, increment, callback, speed); }, speed);
}

function toggleVisibility(e, from, speed, total, increment, callback){
	var pos = 0;
	if(e.filters){
		if(e.filters[0] && e.filters[0].opacity) pos = e.filters[0].opacity;
		if(pos) pos = pos/100;
	}
	else{
		if(e.style.opacity) pos = e.style.opacity;
		else if(e.style.MozOpacity) pos = e.style.MozOpacity;
	}
	
	pos = parseFloat(pos)*100; e.myVs = pos;
	window.clearInterval(e.myVisibility);
	e.myVis = function(pos, from, total, increment, callback){
	
		if(total > pos && this.myVs < total) this.myVs = this.myVs + increment;
		else if(total < pos && this.myVs > total) this.myVs = this.myVs - increment;
		else{ this.myVs = total; window.clearInterval(this.myVisibility); eval(callback); }
		
		if(this.filters){
			this.filters[0].opacity = this.myVs;
		}
		else{
			this.style.opacity = (this.myVs/100);
			this.style.MozOpacity = (this.myVs/100);
		}
		
		return(true);
		
	};
	e.myVisibility = window.setInterval(function(){ e.myVis(pos, from, total, increment, callback); }, speed);
}
