/* JS file created by Evan
E-mail: evan.x.zhou@newegg.com
MSN: evan.x.zhou@newegg.net
Location: ChengDu
Version: Released
 */
 
 
 function popMenu() {
	if(!document.getElementById) return false;
	//parentLevel=document.getElementById("parent");
	//subMenu=document.getElementById("minorNav");
	navList=document.getElementById("mainNav").getElementsByTagName("li");
	//subMenuList=subMenu.getElementsByTagName("li");
	//childrenLink=parentLevel.childNodes;
	for(i=0;i<navList.length;i++) {
		navList[i].onmouseover=function() {
			this.style.background="url(images/bg/bgTopNavLI.gif) no-repeat left bottom";
			this.style.height="37px";
		}
		navList[i].onmouseout=function() {
			this.style.background="none";
		}
	}
	/*for(z=0;z<childrenLink.length;z++) {
		if(childrenLink[z].className=="solution") {
			childrenLink[z].onclick=function() {
				return false;
			}
		}
	}
	parentLevel.onmouseover=function() {
		subMenu.style.display="block";
		for(j=0;j<subMenuList.length;j++) {
			subMenuList[j].onmouseover=function() {
				this.style.background="none";
				this.style.height="auto";
			}
		}
		subMenu.parentNode.style.background="url(images/bg/bgTopNavLI.gif) no-repeat left bottom";
		subMenu.parentNode.style.height="37px";
	}
	subMenu.onmouseout=function() {
		subMenu.style.display="none";
	}
	page=document.getElementsByTagName("body")[0];
	if(!page.className) {
		subMenu.style.display="none";
	}
	if(page.className=="solution") {
		subMenu.onmouseout=function() {
			subMenu.style.display="block";
		}
		for(j=0;j<subMenuList.length;j++) {
			subMenuList[j].onmouseover=function() {
				this.style.background="none";
				this.style.height="auto";
			}
		}
	}
	getElementNode(parentLevel.nextSibling).onmouseover=function() {
		//subMenu.style.display="none";
		getElementNode(parentLevel.nextSibling).style.background="url(images/bg/bgTopNavLI.gif) no-repeat left bottom";
		getElementNode(parentLevel.nextSibling).style.height="37px";
	}
	getElementNode2(parentLevel.previousSibling).onmouseover=function() {
		//subMenu.style.display="none";
		getElementNode2(parentLevel.previousSibling).style.background="url(images/bg/bgTopNavLI.gif) no-repeat left bottom";
		getElementNode2(parentLevel.previousSibling).style.height="37px";
	}*/
	if(!document.getElementById) return false;
	if(!document.getElementsByTagName) return false;
	SPANs=document.getElementsByTagName("span");
	mapCD=document.getElementById("chengdu");
	mapSH=document.getElementById("shanghai");
	mapXA=document.getElementById("xian");
	for(b=0;b<SPANs.length;b++) {
		if(SPANs[b].className=="chengdu") {
			cd=SPANs[b];
			cd.onclick=function() {
				if(mapCD.className=="mapON") {
					mapCD.className="mapOFF";
					cd.lastChild.nodeValue="look for it on map";
				} else {
						mapCD.className="mapON";
						cd.lastChild.nodeValue="close map";
				}
			}
		}
		if(SPANs[b].className=="shanghai") {
			sh=SPANs[b];
			sh.onclick=function() {
				if(mapSH.className=="mapON") {
					mapSH.className="mapOFF";
					sh.lastChild.nodeValue="look for it on map";
				} else {
						mapSH.className="mapON";
						sh.lastChild.nodeValue="close map";
				}
			}
		}
		if(SPANs[b].className=="xian") {
			xa=SPANs[b];
			xa.onclick=function() {
				if(mapXA.className=="mapON") {
					mapXA.className="mapOFF";
					xa.lastChild.nodeValue="look for it on map";
				} else {
						mapXA.className="mapON";
						xa.lastChild.nodeValue="close map";
				}
			}
		}	
	}
 }
 
 function getElementNode(node) {
	if(node.nodeType==1) return node;
	if(node.nextSibling) {
		return getElementNode(node.nextSibling);
	}
 }
 
 function getElementNode2(node) {
	if(node.nodeType==1) return node;
	if(node.previousSibling) {
		return getElementNode2(node.previousSibling);
	}
 }
 
 window.onload=popMenu;


