//daniel folder

var listObj
function doc_setup() {
	listObj = document.getElementById("drop_menu").getElementsByTagName("UL")[0]
	listObj.startMe = start_drop_ver1
	
	s=setTimeout("listObj.startMe()", 1000)
	

}


function start_drop_ver1(){
	this.play = -1
	var lastOpenLi = -1
	
	var Me = this
	this.firstLevel_LIS = new Array;
	// ************************** LI Level 2 Behavior
	function LI_firstLevelBehavior(){
		//var notLinkable = false
		//this.status = "CLOSE"
		var s , ancors, openMe
		this.play = false
		var myLis=  this.getElementsByTagName("LI")
		var MeLi = this
		if (myLis.length>0){
			 ancors = this.getElementsByTagName("A")
			var isSelected = false
			var n
			for(n = 0 ; n< ancors.length; n++){
				/*if (ancors[n].href == ancors[0].href && n > 0){
						notLinkable = true
				}*/
				if(ancors[n].className=="selected"){
					isSelected = true;
					
					//ancors[n].parentNode.style.backgroundColor = "#CCCCCC"
					break;
				}
			}
			var lastChild = myLis[myLis.length-1]	
			var maxOpen = lastChild.offsetTop + lastChild.offsetHeight
			var opener = document.createElement("IMG")
			var ul = this.getElementsByTagName("UL")[0]
			opener.src = "/images/sidemenu_open.gif"
			this.appendChild(opener)
			function openMe(){
				if(Me.play<0){
					Me.play = MeLi.inIndex
					MeLi.openPross1()
					if (lastOpenLi>-1){ Me.firstLevel_LIS[lastOpenLi].closeMe()}
					
				}	
				return false;
				
			}
			this.openPross1  = function(){
				
				if(Me.play == MeLi.inIndex){
					
					if(ul.offsetHeight < maxOpen){
						newHeight = ul.offsetHeight  + 30 
						if(newHeight>=maxOpen){
							newHeight = 	maxOpen
							Me.play = -1
							lastOpenLi = MeLi.inIndex 
							opener.onclick = MeLi.closeMe
							//if(notLinkable) ancors[0].onclick = MeLi.closeMe
							opener.src = "/images/sidemenu_close.gif"
						}else{
							clearTimeout(s)
							s = setTimeout('listObj.firstLevel_LIS[' +  MeLi.inIndex + '].openPross1()' , 30)	
						}
						ul.style.height =  newHeight + "px"
					
					}
				}
				
			}
			this.closeMe = function(){
				newHeight = ul.offsetHeight  - 60 
				if (newHeight < 1 ){
					newHeight = 1 
					opener.onclick = openMe
					//if(notLinkable) ancors[0].onclick = openMe
					opener.src = "/images/sidemenu_open.gif"
					
				}else{
					clearTimeout(s)
					s = setTimeout('listObj.firstLevel_LIS[' +  MeLi.inIndex + '].closeMe()' , 30)	
				}
				ul.style.height =  newHeight + "px"
				return false;
				
			}
			opener.onclick = openMe
			//if(notLinkable) ancors[0].onclick = openMe
			
			if(isSelected){
				newHeight = 	maxOpen
				Me.play = -1
				lastOpenLi = MeLi.inIndex 
				opener.onclick = MeLi.closeMe
				//if(notLinkable) ancors[0].onclick =  MeLi.closeMe
				
				opener.src = "/images/sidemenu_close.gif"
				ul.style.height =  newHeight + "px"
				
			}
			//if(notLinkable) ancors[0].onclick = openMe
		}
	}
	// ******************* end LI level 2 Behavior
	var myChildren = Me.childNodes
	for(i=0; i<myChildren.length; i++){
		if(myChildren[i].tagName == "LI"){
			inIndex = this.firstLevel_LIS.length
			this.firstLevel_LIS[inIndex] = myChildren[i]
			myChildren[i].startMe = LI_firstLevelBehavior
			myChildren[i].inIndex= inIndex
			if(inIndex== 0 ){myChildren[i].style.backgroundImage = 'url(/images/sidemenu_top.gif)';}
			myChildren[i].startMe()
		}
	}
	
	
	
}




