var main_dropers = new Array
var all_menu_objects = new Array;
function startMenu(){
	tm = document.getElementsByTagName("DROPER")
	for(n=0; n < tm.length; n++){
		main_dropers[n]=tm[n].parentNode
		main_dropers[n].maxSize = 0
		main_dropers[n].s = null
		main_dropers[n].timer=0
		main_dropers[n].in_menu_index = all_menu_objects.length
		all_menu_objects[all_menu_objects.length]=main_dropers[n]
		
		main_dropers[n].childesInDroped = new Array; /// THE CHILDREN ARRAY IN 2 DROP MENUE
		main_dropers[n].drop_down = drop_down
		main_dropers[n].roll_up = roll_up
		main_dropers[n].onmouseover = main_dropers_over
		main_dropers[n].onmouseout = main_dropers_out
		
		/********* FIND THE  MENUE 2 DROP ***************/
		mDropChildes = main_dropers[n].childNodes
			
		for(i=0;i<mDropChildes.length;i++){
			
			if(mDropChildes[i].tagName=="DIV"){
				main_dropers[n].toDrop=mDropChildes[i]
				break;
			}else if(mDropChildes[i].tagName=="A"){
					main_dropers[n].initialBut = 	mDropChildes[i]
			}
		}
		/********* FIND THE  CHILDE IN toDROP  ***************/
		m2DropChildes = main_dropers[n].toDrop.childNodes
		for(i=0;i<m2DropChildes.length;i++){
			if(m2DropChildes[i].tagName){
				 main_dropers[n].childesInDroped[ main_dropers[n].childesInDroped.length]=m2DropChildes[i]
				 if(m2DropChildes[i].childNodes[0]){
					if(m2DropChildes[i].childNodes[0].offsetWidth>main_dropers[n].maxSize) main_dropers[n].maxSize = m2DropChildes[i].childNodes[0].offsetWidth
				}
			}
		}
		
		/********* SETS THE WIDTH OF THE DROPPED ELEMENTS  ***************/
		main_dropers[n].toDrop.style.borderWidth=0
		dropedWidth= main_dropers[n].initialBut.offsetWidth > main_dropers[n].maxSize ?  main_dropers[n].initialBut.offsetWidth :
																						 main_dropers[n].maxSize//)
		
		for(i=0;i< main_dropers[n].childesInDroped.length;i++)	main_dropers[n].childesInDroped[i].style.width = dropedWidth+6
			 main_dropers[n].toDrop.style.width=dropedWidth + 8
	
	}
}

main_dropers_out = function(){
	this.timer=0
	this.mOver = false
	this.roll_up()
	this.style.zIndex=1
	
}
main_dropers_over = function(){
		this.lastChildTop = this.childesInDroped[this.childesInDroped.length-1].offsetTop +  this.childesInDroped[this.childesInDroped.length-1].offsetHeight
		this.mOver = true
		this.drop_down()
		this.timerD=5
		this.style.zIndex=2
		
}
	
drop_down =function(){
	if(this.timer>3 || this.toDrop.offsetHeight>20){
		this.toDrop.style.visibility="visible"
		if(this.toDrop.offsetHeight< this.lastChildTop){
				this.toDrop.style.borderWidth=""
				this.toDrop.style.height = this.toDrop.offsetHeight+8
				clearTimeout(this.s)
				this.s=setTimeout("all_menu_objects["+this.in_menu_index+"].drop_down()",10)
		}else{
			this.toDrop.style.height = this.lastChildTop
		}
				
	}else if(this.mOver && this.toDrop.offsetHeight<= this.lastChildTop){
		clearTimeout(this.s)
		this.timer++
		this.s=setTimeout("all_menu_objects["+this.in_menu_index+"].drop_down()",40)
		window.status=this.timer
		this.toDrop.style.visibility="hidden"
	}
}
roll_up = function(){
	if(!this.mOver){
		if(this.timerD==0){
			if(this.toDrop.offsetHeight > 26){
					
					this.toDrop.style.height = this.toDrop.offsetHeight- 15
					clearTimeout(this.s)
					this.s=setTimeout("all_menu_objects["+this.in_menu_index+"].roll_up()",20)
			}else{
				this.toDrop.style.height =1		
				this.toDrop.style.borderWidth=0
			}
		}else{
			clearTimeout(this.s)
			this.timerD--
			this.s=setTimeout("all_menu_objects["+this.in_menu_index+"].roll_up()",30)
		}
	
	}
}

function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
    	      strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
	       return p1.toUpperCase();
        });
	 
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}
