//admin

function doc_setup() {	
	setTimeout('run_js()', 200)
}




function run_js() {	
	
	var main_anchor = document.getElementById('drop_menu').getElementsByTagName('UL')[0];
	var li_arr = main_anchor.getElementsByTagName('LI');	
	for (var j = 0; j < li_arr.length; j ++) {
		if (li_arr[j].className == "lev1") {
			li_arr[j].startMe = startMe_but
			li_arr[j].startMe()			
		}
	}

	function startMe_but(){	
		var counter = 0
		var mOverStat = false
		var s
		var isSelected
		isSelected = false
		var myAnchor = this.getElementsByTagName("A")[0]
		
		this.sub_ul = this.getElementsByTagName("UL")[0] 
		this.childObjs = this.getElementsByTagName("LI")
		
		if(this.childObjs.length){
			this.lastChil = this.childObjs[this.childObjs.length -1]  
			var openHeightTo = this.lastChil.offsetTop + this.lastChil.offsetHeight + 3
			if(myAnchor.className =="selected"){
				this.sub_ul.style.height = (openHeightTo+1).toString() + 'px'
				return
				
			}
			this.openDwn = function(){			
				if(counter>3 && mOverStat){
					if(this.sub_ul.offsetHeight < openHeightTo ){
						newHeight = this.sub_ul.offsetHeight+10
						if(newHeight>openHeightTo+1){
							this.sub_ul.style.height = (openHeightTo+1).toString() + 'px'
							return
						}
						this.sub_ul.style.height = (newHeight).toString() + 'px'
						clearTimeout(s) 
						s=setTimeout('window.document.getElementById("'+this.id+'").openDwn()',30) 
						return
					}
					
				}
				else if(mOverStat){
					counter++
					clearTimeout(s)
					s=setTimeout('window.document.getElementById("'+this.id+'").openDwn()',60)
				}
				if(this.sub_ul.offsetHeight > openHeightTo && mOverStat ){
					this.sub_ul.style.height  = openHeightTo
				}
			}			
			this.closeUp = function(){
				if(this.sub_ul.offsetHeight < 80 && counter>4) 
					this.sub_ul.style.height  = "1px"
				if(counter>4 && !mOverStat){
					if(this.sub_ul.offsetHeight > 70 ){
						this.sub_ul.style.height = (this.sub_ul.offsetHeight-20).toString() + 'px'
						clearTimeout(s)
						s=setTimeout('window.document.getElementById("'+this.id+'").closeUp()',10)
					}
				
				}else if(!mOverStat){
					counter++
					clearTimeout(s)
					s=setTimeout('window.document.getElementById("'+this.id+'").closeUp()',60)
				}
			}
			for(i=0; i<	this.childObjs.length;	i++ ){			
				if(this.childObjs[i].className=="selected"){
					isSelected = true
					break;
				}
			}
			if(!isSelected){
				this.onmouseover = function(){
					counter = 0
					mOverStat = true
					this.openDwn()				
				}
				this.onmouseout = function(){
					counter = 0
					mOverStat = false
					this.closeUp()
				}
			}else{
				//this.style.backgroundImage = 'url(images/left_but_menu_s.gif)'
				this.style.color = '#ffffff'
				this.subObj.style.height = openHeightTo
			}		
		}	
	}
}


