  
var d=document, l = new Array(), p = new Array(), b = sniffMenu(), nsLayer, holdi, submenu = false, subbed = false, no, lastroll = false;
		
function  sniffMenu(){
	ver = navigator.appVersion;
	agent = navigator.userAgent;
	dom = d.getElementById?1:0;

	if(ver.indexOf("MSIE 5.5")>-1 && dom)state = 1;
	else if(ver.indexOf("MSIE 6")>-1 && dom)state = 1;
	else if(ver.indexOf("MSIE 7")>-1 && dom)state = 1;
	else if(d.all)state = 2;
	else if(agent.indexOf("Mac")>-1)state = 0;
	else if(dom && parseInt(ver)>=5)state = 3;
	else if(d.layers && !dom)state = 4;
	else state = 0;
	return state;
}

function buildMenu(){
    var a = buildMenu.arguments;
	if(a[1]==void(0))a = a[0];	
	
	if(a[0].indexOf(".")>-1){
		d.write("<a href=\""+a[2]+"\" target=\""+a[3]+"\" onmouseover=\"showMenu('"+a[4]+"', "+a[5]+")\"><img src=\""+a[0]+"\" lowsrc=\""+a[1]+"\" border=0 id=\""+a[4]+"_img\" name=\""+a[4]+"_img\"></a>");
	}else{
		d.write("<a href=\"#\" onmouseover=\"rollOver('"+no+"',1, 1);showMenu('"+a[4]+"', "+a[5]+")\">"+a[0]+"</a><img src=\"/images/tran.gif\" lowsrc=\"/images/tran.gif\" border=\"0\" id=\""+a[4]+"_img\" name=\""+a[4]+"_img\" align=\"top\">");
	}
	
    //return

	if(b){
		if(b==4){
			d.write("<layer visibility=\"hide\" z-index=\"1\"");
		}else{
			d.write("<div style=\"position:absolute;visibility:hidden;z-index:1;filter:progid:DXImageTransform.Microsoft.Fade(duration=0.25)\"");
		}

		d.write(" id=\""+a[4]+"\"");
		if(submenu)d.write(" class=\"submenu\"");
		d.write("><table cellspacing=0 cellpadding=4 border=0 id=\""+a[4]+"_table\" name=\""+a[4]+"_table\" class=\"menuTable\">");

		for(i=6;i<a.length;i=i+3){
		    d.write("<tr><td id=\""+a[4]+"_"+i+"\" name=\""+a[4]+"_"+i+"\" class=\"menuCell\"");
			if(b==3)d.write(" style=\"padding:4px\"");
			if(submenu){d.write(" ch=\"1\" dir=\"ltr\"")}else{d.write(" dir=\"0\"")};
			d.write(" nowrap>");
            
           	if(new String(a[i][0]).length>1 && new String(a[i][0]).toString()!="undefined"){
				holdi = i;
				submenu = true;
				no = a[4]+"_"+i
				buildMenu(a[i]);
				i = holdi;
				submenu = false;
			}else{
				d.write("<a href=\""+a[i+1]+"\" target=\""+a[i+2]+"\" onmouseover=\"rollOver('"+a[4]+"_"+i+"',1)\" onmouseout=\"rollOver('"+a[4]+"_"+i+"',0)\">"+a[i]+"</a>");
			}	

			d.write("</td></tr>");
		}

		d.write("</table>");

		if(b==4){
			d.write("</layer>");
		}else{
			d.write("</div>");
		}
	}
}

d.onclick = hideMenus;


function rollOver(which, state, clean){
    if(b&&b<4){
		
		if(b==3){
			tt = d.body.getElementsByTagName("TD")[which];
		}else{
			tt = d.all[which];
		}

		tt.className = (state==1)?"menuCellOver":"menuCell";
		
		//alert("'"+tt.dir+"'")
			
		if(tt.dir!="ltr"&&subbed){
		    if(b<4) subbed.style.visibility = "hidden";
			else subbed.visibility = "hide";
		}
		
		if(lastroll&&tt.dir!="ltr"){
			temp = lastroll;
			lastroll = false;
			rollOver(temp, 0);
		}
		if(clean)lastroll = which;
	}
}

function showMenu(which, direction, nofade){
	if(b){
	    if(b==4){
			t = d[which];
			i = d.images[which+"_img"];
			nsLayer = t;
		}else if(b==3){
			t = d.body.getElementsByTagName("DIV")[which];
			i = d.body.getElementsByTagName("IMG")[which+"_img"];
		}else{
			t = window[which];
			i = window[which+"_img"];
			e = window.event;
			//e.clientY
		}
		
		if(t.className!="submenu"){
			hideMenus();
			s = true;
		}else{
			subbed = t;
			s = false;
		}
		
		i.osrc = i.src;
		if (new String(i.lowsrc).toString()!="undefined")
		    i.src = i.lowsrc;

		if(t.state!="assigned"){
			l[l.length] = t;
			p[p.length] = i;
            if(direction==1){
				if(b==4){
					t.left = i.x + i.width;
					if(s)t.top = i.y;
				}else if(b==3){
					t.style.left = parseInt(i.offsetLeft) + parseInt(d.body.style.marginLeft) + parseInt(i.offsetWidth);
					if(s)t.style.top = parseInt(i.offsetTop) + parseInt(d.body.style.marginTop);
				}else{
					t.style.left = (e.clientX - e.offsetX - 2) + i.clientWidth;
					if(s)t.style.top = (e.clientY - e.offsetY - 2);		
				}
			}else if(direction==2){
				if(b==4){
					t.left = i.x;
					if(s)t.top = i.y;
				}else if(b==3){
					t.style.left = parseInt(i.offsetLeft) - parseInt(t.offsetWidth);
					if(s)t.style.top = parseInt(i.offsetTop);
				}else{
					t.style.left = (e.clientX - e.offsetX - 2) - t.clientWidth;
					if(s)t.style.top = (e.clientY - e.offsetY - 2);
				}
			}else{
				if(b==4){
					t.left = i.x;
					if(s)t.top = i.y + i.height;
				}else if(b==3){
				    if (parseInt(i.offsetLeft)>0)
				        t.style.left=parseInt(i.offsetLeft)
					//t.style.left = NaN //parseInt(i.offsetLeft) + parseInt(d.body.style.marginLeft);
					if(s){t.style.top = parseInt(i.offsetTop) + parseInt(d.body.style.marginTop) + parseInt(i.offsetHeight);}
				}else{
					t.style.left = (e.clientX - e.offsetX - 2);
					if(s)t.style.top = (e.clientY - e.offsetY - 2) + i.clientHeight;
				}
			}

			t.state = "assigned";
		}

		if(b<4){
			if(!nofade && b==1)t.filters[0].apply();
			t.style.visibility = "visible";
			if(!nofade && b==1)t.filters[0].play();
		}else{
			t.visibility = "show";
		}
	}
}

function hideMenus(){
    if(b){
		for(tt in p){
			p[tt].src = p[tt].osrc;
		}
		for(tt in l){
			if(b<4)l[tt].style.visibility = "hidden";
			else l[tt].visibility = "hide";
		}
	}
}

function debug(what){
	var en = 0;
	var plop = "";
	for(each in what){
		en++;
		plop += each+" = "+what[each]+"        ";
		if(en%4==0)plop += "\n";
	}
	alert(plop);
}

function alertArray(what){
	plop = "";
	for(i=0;i<what.length;i++){
		plop += "["+i+"]="+what[i]+"\n";
	}
	alert(plop);
}

function highlightNavRow(obj, over) {
   if (b)
   {
    if (b==1)
    {
       rowObj = obj.parentElement;
      
       for (i = 0; i < rowObj.childNodes.length; i++) {
          rowObj.childNodes[i].style.color = (over) ? '#ffffff' : '#ffffff';
          rowObj.childNodes[i].style.backgroundColor = (over) ? '#0E6EB0' : '#DDE5ED';
       }
    }
    else if (b==3)
    {
        obj.className = (over==1)?"menuCellOver":"menuCell";
    }
   }
}

//-->