window.onload=initForm;
window.onunload=function(){};


function initForm(){
	document.getElementById("showDept").selectedIndex=0;
	document.getElementById("showDept").onchange=goSession;
}//end function initForm
 
function goSession(){//show specific session
	var newLoc=document.getElementById("showDept");
	var newSes=newLoc.options[newLoc.selectedIndex].value;//extract the name of option
	//alert(newSes);
	//hiding or showing rows
	if(newSes!=""){
		var sesRow=document.getElementsByTagName("tr");//extract the rows of table by tr
		//alert(sesRow[1].parentNode.tagName);	
		
		for(var i=0;i<sesRow.length;i++){
		//alert(sesRow[i].name);
			//if(combineName(sesRow[i].className)==newSes || sesRow[i].name=="head"){
				//alert(sesRow[i].parentNode.tagName);
			if(combineName(sesRow[i].className)==newSes || sesRow[i].parentNode.tagName=="THEAD"){
				sesRow[i].style.display="block";//show needed element 
				
				}
			else{
				sesRow[i].style.display="none";//hide unused element
				}
		}
	}
	
}//end function goSession





/*contact to be a name*/
function combineName(inName){
	var tempArray=inName.split(" ");
	
	var temp="";
	for(var i=0; i<tempArray.length;i++){
		temp+=tempArray[i];
	}
return temp;
}

/*
function initForm(){
	document.getElementById("showDept").selectedIndex=0;
	document.getElementById("showDept").onchange=goDept;
	
	document.getElementById("showCourse").onchange=goSession;
	
	document.getElementById("showSession").selectedIndex=0;
	document.getElementById("showSession").onchange=goSession;
}//end function initForm
 
function goSession(){//show specific session
	var newLoc=document.getElementById("showCourse");
	var newSes=newLoc.options[newLoc.selectedIndex].value;//extract the name of option
	
	//hiding or showing rows
	if(newSes!=""){
		var sesRow=document.getElementsByTagName("tr");//extract the rows of table by tr
		
		
		for(var i=0;i<sesRow.length;i++){
			//alert(sesRow[i].className);
			if(combineName(sesRow[i].className)==newSes || sesRow[i].className=="head"){
				sesRow[i].style.display="block";//show needed element 
				}
			else{
				sesRow[i].style.display="none";//hide unused element
				}
		}
	}
	
}//end function goSession
*/

function showAll(){//show all sessions 
	var sesRow=document.getElementsByTagName("tr");
	
	for(var i=0;i<sesRow.length;i++){
			sesRow[i].style.display="block";//show all elements 
	}
}
