/* ---menu Tabs---  copyright:uieden@gmail.com
+---------------------------------------------------------------------------------------------------------------+
| api:
| var menu1 = new menutab();
| onmouseover="menu1.show(this,styles={over:'style1',out:'style2'},'opt',500)" onmouseout="menu1.hide(this,event)"
+---------------------------------------------------------------------------------------------------------------*/

var menutab = function () {
	var mm, cc, ss, _timer = null;
	this.show = function(m, s, c, d) {
		mm = this.$(m);
		cc = this.$(c);
		ss = s;
		if (mm) {
			if(d){
			  d = d ? d : 0;
			  clearTimeout(_timer);
			  _timer = setTimeout(function(){
				  mm.className = ss.over;
				  cc.style.display = "";
			  }, d);
			}else{
			  mm.className = ss.over;
			  cc.style.display = "";
			}
		} else {
			alert("["+m+"] is undefined!");
			return;
		}
	};
	this.hide = function(obj,e) {
		if (mm) {
			if(arguments.length==2){
				var Oid= obj.id;
				if(e.currentTarget){
				   if(e.relatedTarget != obj){obj = e.relatedTarget;}
				}else{
				   if(e.toElement != obj){obj = e.toElement;}
				}
				while(obj!=null && obj.id!=Oid){obj = obj.parentNode;}
				if(obj == null){
				   clearTimeout(_timer);
				   mm.className = ss.out;
				   cc.style.display = "none";
				}
			}else{
				mm.className = ss.out;
				cc.style.display = "none";
			}
		}
	};
	this.$ = function(d) {
         return "string" == typeof d ? document.getElementById(d) : d;
	};
};
menutab.prototype.toggle = function(d,i,l) {
	var tt, dd, ii;
	tt = this.$(d);
	if (tt) {
		dd = tt.style.display;
		if (dd == "") {
			tt.style.display = "none";
			if(i){ this.$(i).src = l.up; }
		}
		if (dd == "none") {
			tt.style.display = "";
			if(i){ this.$(i).src = l.down; }
		}
	}
};
