/* original code by garry@ascii-turf.net
  * please feel free to use/mend/modify/destroy as the needs see fit
  * but please tell me what you did with it so's i know.
  * by making mrexcited into an array you should be able to make it handle any depth of
  * sub-navs. i just don't feel the need.
  * ta.
  */

var mrexcited = null;
var mrexcited2 = null;
var TimeoutDelay = 20; // delay between mouse leaving item and menu disappearing
var timer = 0; 
var timer2 = 0; 


function nav_over(d) {
	if (d.excited) return;
	if (mrexcited && d != mrexcited) _hide();
	var img = d.theimage;//d.firstChild.firstChild;
	if (!img) {	
		var a;
		for (var i = 0; a = d.childNodes[i], a.nodeType != 1; i++);
		for (var i = 0; img = a.childNodes[i], img.nodeType != 1; i++);
		d.theimage = img;
	}
	if (!img.overlight) {
		var u = new iurl(img.src);
		img.overlight = u.path + u.name+ '_o' + u.ext;
	}
	d.style.zIndex = 100;
	img.osrc = img.src;
	img.src =  img.overlight;
}
function nav_out(d) {
	var img = d.theimage; //firstChild.firstChild;
	img.src = img.osrc;
	d.style.zIndex = 0;
}

function menu_over(d) {
	d.hold = true;
	if (d.excited) return;
	if (mrexcited && d != mrexcited) _hide();
	var img = d.theimage; 
	if (!img) {	
	var a;
		for (var i = 0; a = d.childNodes[i], (a.nodeType != 1 && a.nodeName != 'a'); i++);
		for (var i = 0; img = a.childNodes[i], (img.nodeType != 1 && img.nodeName != 'img'); i++);
		d.theimage = img;
	}

	if (!img.overlight) {
		var u = new iurl(img.src);
		img.overlight = u.path + u.name+ '_o' + u.ext;
	}
	d.style.zIndex = 100;
	img.osrc = img.src;
	img.src =  img.overlight;
	var sub = d.bone;
	// find next node that ain't a text node
	if (!sub) {
	for (var i = 0; i < d.childNodes.length; i++) {
		if (d.childNodes[i].nodeName.toLowerCase() == 'div') {
			sub = d.childNodes[i];
			break;
		}
	}
	sub.dog = d;
	d.bone = sub;
	}
	sub.style.display = 'block';
	d.hold = true;
	d.excited = true;
	mrexcited = d;
}

function smenu_over(d) {
	d.hold = true;
	if (d.excited) return;
	if (mrexcited2 && d != mrexcited2) _hide2();
	d.style.zIndex = 100;
	var sub = d.bone;
	if (!sub) {
	for (var i = 0; i < d.childNodes.length; i++) {
		if (d.childNodes[i].nodeName.toLowerCase() == 'div') {
			sub = d.childNodes[i];
			break;
		}
	}
	d.bone = sub;
	sub.dog = d;
	}
	sub.style.display = 'block';
	d.hold = true;
	d.excited = true;
	mrexcited2 = d;
}
function smenu_out(d) {
	mrexcited2 = d;
	d.hold = false;
	_set2();
}

function menu_out(d) {
	mrexcited = d;
	d.hold = false;
	_set();
}

function snav_in(s) {
	_unset();
	s.dog.hold = true;
}

function snav_out(s) {
	s.dog.hold = false;
	_set();
}


function _set() {
	clearTimeout(timer);
	timer = setTimeout('_hide()', TimeoutDelay);
}

function _unset(){
	clearTimeout(timer);
}

function _hide() {
	d = mrexcited;
	if (d.hold) return;
	d.bone.style.display = 'none';
	var img = d.theimage; //firstChild.firstChild;
	img.src = img.osrc;
	d.style.zIndex = 0;
	d.excited = false;
}
function _set2() {
	clearTimeout(timer2);
	timer2 = setTimeout('_hide2()', TimeoutDelay);
}

function _unset2(){
	clearTimeout(timer2);
}

function _hide2() {
	d = mrexcited2;
	if (d.hold) return;
	d.bone.style.display = 'none';
	d.style.zIndex = 0;
	d.excited = false;
}


function iurl(s) {
	re = /http:\/\/([a-z0-9\:\.\-]+)\/(.+)/i;
	a = re.exec(s);
	this.host = a[1];
	p= a[2];
	re = /([a-z0-9_\/]+)\/([a-z0-9_]+)(\.(gif|jpg))/i;
	a = re.exec(p);
	this.name = a[2];
	this.file =a[2] + a[3];
	this.ext = a[3];
	this.path = '/' + a[1] + '/';
	re = /(nav\d\d_[a-z]+)(_(s|_o))?$/i; 
	a = re.exec(this.name);
	this.name = a[1];
}

function gebi(i) { 
	return  document.getElementById(i); 
}

/* except this, not by me, by them macromedia folks. thanks guys. */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



MM_preloadImages('/i/nav01_about_o.gif', '/i/nav02_congress_o.gif', '/i/nav03_awards_o.gif', '/i/nav04_edu_o.gif', '/i/nav05_memb_o.gif', '/i/nav06_inspi_o.gif', '/i/nav07_press_o.gif', '/i/nav08_shop_o.gif', '/i/nav09_talent_o.gif');

// ========= 



