//Change to support high level page
//1. expending the current level after expending the parent level;
//2. don't change the current level to plus/minus mask;
//3. remove all onClick and return from the menu links;(see sm.htm)
//4. add a new flag to identify this, it's called p7="true for all the links


//=====================
//b: link Element; og: flag 1-display, 0-hide
//get all brothers of the b
//expend/di-expend (or display/un-display) thr brothers of <div>
//set +/- and plus/minus
function P7_TMenu(b,og) {
	var i,s,c,k,j,tN,hh;
	if(document.getElementById){
		if(b.parentNode && b.parentNode.childNodes){
			tN=b.parentNode.childNodes;
		}else{
			return;
		}
		for(i=0;i<tN.length;i++){
			if(tN[i].tagName=="DIV"){
				s=tN[i].style.display;
				hh=(s=="block")?"none":"block";
				if(og==1){
					hh="block";
				}
				tN[i].style.display=hh;
			}
		}
		c=b.firstChild;
		if(c.data){
			k=c.data;
			j=k.charAt(0);
			if(j=='+'){
				k='-'+k.substring(1,k.length);
			}else if(j=='-'){
				k='+'+k.substring(1,k.length);
			}c.data=k;
		}
//if it's not current level
		if(b.className!='p7currentmark'){
			if(b.className=='p7plusmark'){
				b.className='p7minusmark';
			}else if(b.className=='p7minusmark'){
				b.className='p7plusmark';
			}
		}
	}
}

function P7_setTMenu(){ //v2.5 by Project Seven Development(PVII)
	var i,d='',h='<style type=\"text/css\">';
	if(document.getElementById){
		var tA=navigator.userAgent.toLowerCase();
		if(window.opera){
			if(tA.indexOf("opera 5")>-1 || tA.indexOf("opera 6")>-1){
				return;
			}
		}
		for(i=1;i<20;i++){
			d+='div ';
			h+="\n#p7TMnav div "+d+"{display:none;}";
		}
		document.write(h+"\n</style>");
	}
}


P7_setTMenu();


//check all menu for + or - sign

//======================
//in <div> of "p7TMnav
//get all link Elements
//if it's current link then
//  set to current 
//  expending the upper level <div>
//    by doing : get upper level <div>
//               expend (display) it <--|
//               get parent <div>     --|
//  expend (display) the current level 
function P7_TMopen(){ 
	var i,x,d,hr,ha,ef,a,ag;
	if(document.getElementById){
		d=document.getElementById('p7TMnav');
		if(d){
			hr=window.location.href;
			ha=d.getElementsByTagName("A");
			if(ha&&ha.length){
				for(i=0;i<ha.length;i++){
					if(ha[i].href){
//if it's current link
						if(hr.indexOf(ha[i].href)>-1){
							ha[i].className="p7currentmark";
							a=ha[i].parentNode.parentNode;
							b=ha[i].parentNode;
							while(a){
								if(a.firstChild && a.firstChild.tagName=="A"){
									if(a.firstChild.getAttribute("p7")){
										ag=a.firstChild.getAttribute("p7");
										if(ag&&ag.indexOf("true")>-1){
											// add + or - sign
											P7_TMenu(a.firstChild,1);
										}
									}
								}
								a=a.parentNode;
							}
//expending the current level
							if(b){
								if(b.firstChild && b.firstChild.tagName=="A"){
									if(b.tagName=="DIV"){
										if(b.firstChild.getAttribute("p7")){
											ag=b.firstChild.getAttribute("p7");
											if(ag&&ag.indexOf("true")>-1){
												// add + or - sign
												P7_TMenu(b.firstChild,1);
											}
										}

									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function P7_TMall(a){ //v2.5 by Project Seven Development(PVII)
	var i,x,ha,s,tN;
	if(document.getElementById){
		ha=document.getElementsByTagName("A");
		for(i=0;i<ha.length;i++){
			if(ha[i].getAttribute("p7")){
				ag=ha[i].getAttribute("p7");
				if(ag&&ag.indexOf("true")>-1){
					if(ha[i].parentNode && ha[i].parentNode.childNodes){
						tN=ha[i].parentNode.childNodes;
					}else{
						break;
					}
					for(x=0;x<tN.length;x++){
						if(tN[x].tagName=="DIV"){
							s=tN[x].style.display;
							if(a==0&&s!='block'){
								P7_TMenu(ha[i]);
							}else if(a==1&&s=='block'){
								P7_TMenu(ha[i]);
							}
							break;
						}
					}
				}
			}
		}
	}
}

function P7_TMclass(){ //v2.5 by Project Seven Development(PVII)
	var i,x,d,tN,ag;
	if(document.getElementById){
		d=document.getElementById('p7TMnav');
		if(d){
			tN=d.getElementsByTagName("A");
				if(tN&&tN.length){for(i=0;i<tN.length;i++){
					ag=(tN[i].getAttribute("p7"))?tN[i].getAttribute("p7"):false;
					if(ag&&ag.indexOf("true")>-1){
						tN[i].className='p7plusmark';
					}else{
						tN[i].className='p7defmark';
					}
				}
			}
		}
	}
}
