//stuff for expand/collapse

 var listitems= document.getElementsByTagName("*");

 
 function init() {	
	for(i = 0;i < listitems.length;i++) {
			w = listitems[i].id;
			wo = listitems[i];
			if (w.substring(0,8) == 'showHide') {
				wo.className="itemhidden";
			}
		}
 }
 
 function closeExcept(po) {
	for(i = 0;i < listitems.length;i++) {
			w = listitems[i].id;
			wo = listitems[i];
			if (w.substring(0,8) == 'showHide') {
				//hide everything not at the same 1st level of indentation
				if(w.substring(0,10)!=po.substring(0,10)) {
					wo.className="itemhidden";
				}
				//hide everything not at the same 2nd level of indentation
				if(w.length == 13) {
					if(w.substring(0,13)!=po.substring(0,13)) {
					wo.className="itemhidden";
					}
				}
				//hide everything not at the same 3rd level of indentation
				if (w.length ==16) {
					if(w.substring(0,16)!=po.substring(0,16)) {
					wo.className="itemhidden";
					}
				}
				//hide everything not at the same 4th level of indentation
				if (w.length ==19) {
					if(w.substring(0,19)!=po.substring(0,19)) {
					wo.className="itemhidden";
					}
				}
			}
		}
 }

 function expandcollapse(postid) { 
    var whichpost = document.getElementById(postid); 
   	closeExcept(postid);
 	if (whichpost.className=="itemshown") { 
    	  whichpost.className="itemhidden"; 
    	} 
 
   	else { 
     	 whichpost.className="itemshown"; 
     	} 
    } 
	



// stuff for navigation


function page() {
	//get pagename
	init();
	l = document.location.href;
	l.toString();
	b = l.lastIndexOf('/')+1;
	dl = l.lastIndexOf('.');
	dl = l.length-dl;
	e = l.length-dl;
	l = l.substring(b,e);
	
	//current directory	stuff
	c = 0;	
	cs=new Array();
	
	//change style of hyperlinks to current page anywhere on the page
	
	//the next two lines set up what we're checking here: if it's IE we can just run through all the objects in the document and check out their properties.  If it is something standards based, like Firefox, we have to use document.anchors, and also we have to make sure to name our links so we can find them (even thought we aren't USING the name to find them (argh!).  In other words, the script will work in ie with or without named links, but needs the names for the others
	
	if (document.all) {itot = document.all.length} else {itot = document.anchors.length};
	if (document.all) {al = document.all} else {al = document.anchors};
	
	
	
	for (i=0;i<itot;i++) {
		dis = (al[i].id);
		if(al[i].href) {
			lin = al[i].href;
			
			if(lin==document.location.href) {
				if(dis.indexOf('subNav')>=0) {
					//al[i].style.backgroundImage = 'url(../images/navHover.gif)';
					//al[i].style.fontWeight = 'bold';
					al[i].style.color = '#ffffff';
					al[i].style.backgroundColor = '#94c3ee';
				};
				if(dis.indexOf('twoRows')>=0) {
					al[i].style.backgroundImage = 'url(../images/hoverBgroundLong.gif)';
					al[i].style.color = '#969689';
				};
				if(dis.indexOf('itemNav')>=0) {
//					al[i].style.fontWeight = 'bold';
					//al[i].style.fontStyle = 'italic';
					al[i].style.textDecoration = 'none';
					//al[i].style.paddingRight = '5px';
					al[i].style.backgroundColor = '#94c3ee';
				};
//				if(dis.indexOf('thirdLevel')>=0) {
//			        al[i].style.fontWeight = 'bold';   
//			    }
//			   };
			  // alert(subsection);
//			 if(subsection!='none') {
			    //alert(subsection);
//			    if (dis.indexOf(subsection)>=0) {
//			        if (dis.indexOf('twoRows') < 0 ) {
//			            al[i].style.backgroundImage = 'url(../images/hoverBground.gif)';
//			            }
//			         if (dis.indexOf('twoRows') >= 0 ) {
//			            al[i].style.backgroundImage = 'url(../images/hoverBgroundLong.gif)';
//			            }
//			    }

			}
		}
		}
//		section = 'mainNav' + section;
//		section = document.getElementById(section);
//		section.style.backgroundColor = '#381605';
//		section.style.color = '#fff';
//		section.style.textDecoration = 'none';
	
	for (j=0;j<=document.location.href.length;j++) {
		if (document.location.href.substring(j,j+1)=="/") {
			c=c+1;
			cs[c]=j;
			}
	}
	dirBegin = cs[c-1]+1;
	dirEnd = cs[c];
	dirName = document.location.href.substring(dirBegin,dirEnd);
	
	for (m=0;m<itot;m++) {
		if(al[m].href) {
			huruf = al[m].href;
			if(huruf.indexOf(dirName)>0) {
				if (huruf.substring(cs[c],huruf.length) == '/index.htm') {
//					al[m].style.color = '#442717';
				}
			}
		}
	}
	
}
	
//catch function to manually turn something on - this is a temporary solution for third level pages that are currently in 2nd level directories.  Eventually we'll add the ability for the script to recognize both the section and the subsection via directories the current page is in
	
function manual(whichLink) {

	document.getElementById(whichLink).style.color = '#FFA500';
	
}

window.onload = page
