﻿var menuLastItem = null;
var linkClicked = false;

function menuOpenCloseById(Id){
	//menuOpenClose(document.getElementById(Id));
}

function menuOpenClose(menuItem){

if(menuItem == null)
	linkClicked = true;

 if(menuItem != null && !linkClicked){
		if (menuItem.id != menuLastItem){
			menuClose(menuLastItem);
			menuOpen(menuItem.id);
			menuLastItem = menuItem.id;
		}/* / Bülent / Aynı menüyü geri kapatmak için
		else{
			menuClose(menuItem.id);
			menuLastItem = null; 
		}
		*/
	}
}

function menuOpen(divName){
	if (divName != null){
		document.getElementById(divName).className = "tg tgselected";
		accordionOpen( document.getElementById('el_' + divName) );
	}
}


function menuClose(divName){
	if (divName != null){
		try
		{
			document.getElementById(divName).className = "tg";
			document.getElementById('el_' + divName).style.display = "none";
		}catch(E){}
	}
}

function accordionOpen(div){
		clearInterval(div.t);
		div.style.display = "block";
		div.style.visibility = "hidden";
		var endHeight = 0;
		
		if (div.maxHeight == null){
			endHeight = getHeight(div);
//			if(BrowserDetect.browser == "Explorer")
//				endHeight -= 24;
			
			div.maxHeight = endHeight;
		} else {
			endHeight = div.maxHeight;
		}
		
		div.style.visibility = "visible";
		//div.style.overflow='hidden';
	
		setHeight(div,0);
		
		div.t=setInterval(  "accordionTimer('" + div.id + "'," + endHeight + ")" , 6 );
}

function accordionTimer(divId , endHeight)
{
	div = document.getElementById(divId);
	var steps = 2;
	var curHeight = getHeight(div);
	var newOpacity;
	
	if(curHeight < endHeight){
		i = Math.round( (endHeight - curHeight ) / steps );
		setHeight(div, i + curHeight);
		newOpacity = Math.round(  curHeight * 100 / endHeight );
		div.style.opacity = newOpacity / 100;
		div.style.filter= 'alpha(opacity='+newOpacity+');';
	}else{
		setHeight(div, endHeight);
		clearInterval(div.t);
	}
}

function getHeight(div){
	r = parseInt(div.offsetHeight);
	return r;
}

function setHeight(div, i){
	 div.style.height = i + 'px';
}