var ident = "";
var curident=""
var cursubsection = "01";
var cursection = "aa";
var curarea = "zz";
var changelevel = "";
/*  area var = first tier, section var = second tier, subsection var = thrid tier */
var curStep = 1;
var prevcounter = 0;
var steps = new Array();

function init() {
 	steps = document.getElementById("topnav").getElementsByTagName("img");	
}

/*this function changes the actualvisibility of objects*/
function view(curelement,prevelement){
		elem = document.getElementById(curelement);
		prevElem = document.getElementById(prevelement); 
		
		if (curelement=="zz"){
			var curcounter = 0
			steps[prevcounter].className = "";
		steps[curcounter].className = "hi";
		prevcounter = curcounter;
		} else if (curelement=="yy"){
			var curcounter = 1
			steps[prevcounter].className = "";
		steps[curcounter].className = "hi";
		prevcounter = curcounter;
		}else if (curelement=="xx"){
			var curcounter = 2
			steps[prevcounter].className = "";
		steps[curcounter].className = "hi";
		prevcounter = curcounter;
		} else if(curelement=="ww"){
			var curcounter = 3
			steps[prevcounter].className = "";
		steps[curcounter].className = "hi";
		prevcounter = curcounter;
		}
		
		elem.style.display = "block";
		prevElem.style.display = "none";
		

}

/*this function should reset the area to cb*/
function resetcurarea(){
	if(curarea != "zz"){	
	var temparea = curarea;
	view(temparea);
	}
	}



/*this function resets the section to aa*/
function resetsection(){
	
	resetsubsection()
	if(cursection != "aa"){	
	var tempident = curarea+cursection;
	cursection = "aa";
	var tempsec = curarea+cursection;
	view(tempsec,tempident);
	
	}
	}

/*this function resets the subsection to 01*/
function resetsubsection(){

	if(cursubsection != "01"){	
	var tempident = curarea+cursection+cursubsection;
	cursubsection = "01";
	var tempchange = curarea+cursection+cursubsection;
	view(tempchange,tempident);
	
	}
	}



function stepimg(area,section,subsection) {
	if ( section == "na") {
		changelevel = "area";
		
	 		if(ident != ""){
		 		resetsection();
		 	}
		 
	 		ident = area;	
	 		
			curident = curarea;
			
	
		
	} else { 
	
		if (subsection == "na") {
			changelevel = "section";
				if(ident != ""){
		 	resetsubsection();
		 }
		 	 ident = area+section;
			 curident = curarea+cursection;
		} else {
			changelevel = "subsection";
		 	 ident = area+section+subsection;
			 curident = curarea+cursection+cursubsection;	 
				
		
		}
	}
	
	
	if (ident != curident) {
		if(changelevel == "area"){
	   		if(curarea != area){
				
		   		view(ident,curident);
		   	curarea = area;
		cursubsection = subsection;
		cursection = section ;
		if(subsection == "na") {
			cursubsection = "01";
		} 
		if(section == "na") {
			cursection = "aa";
		} 
			}
	   	} else if(changelevel == "section"){
			if(cursection != section){
		   		view(ident,curident);
		   	curarea = area;
		cursubsection = subsection;
		cursection = section ;
		if(subsection == "na") {
			cursubsection = "01";
		} 
		if(section == "na") {
			cursection = "aa";
		} 
			}
		} else if(changelevel == "subsection"){
			if(cursubsection != subsection){
		   		view(ident,curident);
		   	curarea = area;
		cursubsection = subsection;
		cursection = section ;
		if(subsection == "na") {
			cursubsection = "01";
		} 
		if(section == "na") {
			cursection = "aa";
		} 
			}
		}
		
		
		
		
	}
}