/* Original script by Michael Leigeber http://www.leigeber.com/2008/11/drop-down-menu/
   Original work licensed from the author and modified by DesignByMoonlight Website Services
   under the Creative Commons License (http://creativecommons.org/licenses/by/3.0/us/) */

var menujs=function() {
	var t=15,z=50,s=6,a; /*comma op: execute left to right, return right result */
	function dd(n) {
		this.n=n; /* 'this' always refers to the OWNER of the function we're executing, or rather, to the object that a function is a method of. */
		this.h=[]; /* h is a property of 'this', 'this' being the owner of dd(n), and is an array of unspecified size. */
		this.c=[]
//		alert(this); gives object Object
	}
	dd.prototype.init=function(p,c) { /* anonymous function; with this syntax, may use dd.prototype.init() to invoke function. c is 'menuhover' */
		a=c; /* c is the passed css parameter like 'menuhover' */
		var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0; /* for id p, find its ul tag, write ul length l, and zero i */
		/* p represents element ID (but see prototype fn below); c represents css class*/
		for(i;i<l;i++){ /* for all elements in ul */
			var h=s[i].parentNode; /* ul of id p's parent node */
			this.h[i]=h; /* array of parent nodes by index i */
			this.c[i]=s[i]; /* make c[i] for this object's owner match s[i] */
			h.onmouseover=new Function(this.n+'.st('+i+',true)'); /* n is the argument of dd(), which is the menu id.  This calls the dd.prototype.st! */
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f) { /* called by h.onmouse above */
//		alert(this); lots of object Objects, but timing of alerts may be instructive
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0]; /* local variable scope */
		clearInterval(c.t); /* var t=15 above */
		c.style.overflow='hidden'; /* This may be able to clip the arrow image */
		if(f) { /* onmouseover */
			p.className+=' '+a;
			if(!c.mh){
				c.style.display='block';
				c.style.height='';
				c.mh=c.offsetHeight;
				c.style.height=0
			}
			if(c.mh==c.offsetHeight) { /* whether or not f is true above! */
				c.style.overflow='visible'
			} else {
				c.style.zIndex=z;
				z++;
				c.t=setInterval(function() { sl(c,1) },t) /* onmouseover */
			}
		} else { /* onmouseout */
			p.className=p.className.replace(a,'');
			c.t=setInterval(function(){sl(c,-1)},t)
		}
	}
	function sl(c,f) { /* called a few lines above */
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)) {
			if(f==1) {
				c.style.filter='';
				c.style.opacity=1;
				c.style.overflow='visible'
			}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o;
		c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
} ();