var mess;
var debug=0;
doDropdown=function () {

	if (debug) { mess=document.createElement('div'); mess.style.position='absolute'; mess.style.width='200px'; mess.style.height='200px'; mess.style.backgroundColor='#ffffff'; mess.style.top='0px'; mess.style.left='0px'; mess.style.overflow='auto'; mess.appendChild(document.createTextNode('Mess')); document.body.appendChild(mess); }

	var dropDowns=new Array("dropDownMenu_0","dropDownMenu_1","dropDownMenu_2","dropDownMenu_3","dropDownMenu_4","dropDownMenu_5","dropDownMenu_6","dropDownMenu_7","dropDownMenu_8");
	//List of drop down element ID's
	var yoffset=58;  //Affect the vertical position of all drop downs
	var xoffset=10; //Horizontal offset position of all dropdowns

	var nav=document.getElementById('navDropdown');
	var dropDown=new Array();
	var dropDownLink=new Array();
	links=nav.getElementsByTagName("A");
	linksLength=links.length;
	for (i=0; i<dropDowns.length; i++) {
		dropDown[i]=document.createElement('div');
		if (document.getElementById(dropDowns[i])) {
			dd=document.getElementById("dropDownLink_"+i);
			if (!dd) {
				alert("missing dropDownLink_"+i);
				continue;
			}
			//dropDownLink[i]=dd.parentNode;
			dlink=dropDowns[i].replace(/Menu/,'Link');
			dropDownLink[i]=document.getElementById(dlink).parentNode;
			dropDownMenu=document.getElementById(dropDowns[i]).cloneNode(true);
			dropDown[i].style.display="none";
			dropDown[i].style.position="absolute";
			xp=findPosX(dropDownLink[i])+xoffset;
			yp=findPosY(dropDownLink[i])+yoffset;
			dropDown[i].style.left=xp+"px";
			dropDown[i].style.top=yp+"px";
			dropDown[i].appendChild(dropDownMenu);
		}
	}
	for (i=0; i<dropDowns.length; i++) {
		dropDownLink[i].onmouseover=function () { 
			this.childNodes[0].onmouseover();
			this.childNodes[1].style.display="block";
			return true;  
		}
		dropDownLink[i].onmouseout=function () {
			this.childNodes[0].onmouseout();
			this.childNodes[1].style.display="none";
			lastTarg=this;
			return true;
		}
		dropDownLink[i].appendChild(dropDown[i])
		addListener(dropDownLink[i],'mouseover',showDropDown,false);
		//addListener(dropDownLink[i],'mouseout',hideDropDown,false);
	}
	if (doProductPopup) doProductPopup();

}
function sendMess(t) {
	mess.childNodes[0].nodeValue+=' '+t;
}

function hideDropDown(e) {
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode;
	if (targ.tagName=='A') {
	}
	e.cancelBubble=true;
	return true;  
}

var lastTarg;
var subDropDown;
var isIE = document.all;
function showDropDown(e) {
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	var yoffset=-85;  //Affect the vertical offset of sub drop downs
	var xoffset=131//Horizontal offset position of sub dropdowns
	if(!checkIt('msie'))
	{ 
	    yoffset=-84;
	    xoffset=130;
	}
	if (isIE) {
		yoffset-=24;
	}
	getId=targ.id.replace(/dropDownLink/,"dropDownMenu");
	//submenus
	if (getId.indexOf('dropDown')==0) {
		//if (dd=document.getElementById(getId) && !subDropDown) {
		if (dd=document.getElementById(getId)) {
			if (subDropDown) {
				subDropDown.removeChild(subDropDown.childNodes[1]);
			}
			yp=findPosY(targ);
			clone=document.getElementById(getId).cloneNode(true);
			targ.appendChild(clone);
			targ.childNodes[1].style.position="absolute";
			targ.childNodes[1].style.left=xoffset+"px";
			targ.childNodes[1].style.top=yp+yoffset+"px";
			subDropDown=targ;
		}
	} else if (!getId) {
		if (targ.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id=='navDropdown') {
			if (subDropDown) {
				subDropDown.removeChild(subDropDown.childNodes[1]);
				//lastTarg.childNodes[1].style.display='none';
				//lastTarg.childNodes[1].style.display='none';
				subDropDown=false;
			}
		}
	}
	return true;  
}

function addListener(element, type, expression, bubbling){	bubbling = bubbling || false;		if(window.addEventListener)	{ element.addEventListener(type, expression, bubbling);		return true;	} else if(window.attachEvent) {	element.attachEvent('on' + type, expression);		return true;	} else return false;}

function findPosX(obj) 
{ 
    var moz=checkIt('msie'); 
    var curleft = 0; 
    if (obj.offsetParent) 
    { 
        while (obj.offsetParent) 
        { 
            curleft += obj.offsetLeft; 
            obj = obj.offsetParent; 
        } 
    } 
    else if (obj.x) 
    { 
        curleft += obj.x; 
    } 
    if (moz==0) curleft-=9; 
    return curleft; 
} 

function findPosY(obj) 
{ 
    var moz=checkIt('msie'); 
    var curtop = 0; 
    if (obj.offsetParent) 
    { 
        while (obj.offsetParent) 
        { 
            curtop += obj.offsetTop; 
            obj = obj.offsetParent; 
        } 
     } 
     else if (obj.y) 
     { 
        curtop += obj.y;
     } 
     if (moz==0) curtop-=16; 
     return curtop; 
} 

function checkIt(string) 
{ 
    place = detect.indexOf(string) + 1; 
    thestring = string; 
    return place; 
}

