submenu_state = "off";
menu_over = false;
submenu_over = false;
var c;
var m_int;
var tm;
sHeight = 5;
cHeight = sHeight;
dHeight = 50;
speed = 0.5;
duration = 15;

function showSubmenu()
{
	clearTimeout(c);
	m = document.getElementById("menu");
	s = document.getElementById("sub_menu");
	
	m.style.backgroundPosition = "0px -93px";
	s.style.display = "block";

	submenu_state = "on";
	
	clearInterval(m_int);
	m_int = setInterval("moveSubmenu()", 31);
	
}

function hideSubmenu()
{
	clearTimeout(c);

	submenu_state = "off";
	
	tm = 10;
	
	clearInterval(m_int);
	m_int = setInterval("moveSubmenu()", 31);
}

function moveSubmenu()
{
	dh = submenu_state == "on" ? dHeight : sHeight;
	cHeight +=  (dh - cHeight)  * (submenu_state == "on" ?  speed : Math.pow(tm/duration, 1.5)) ;
	tm++;
	e = document.getElementById("sub_menu").style;
	e.top = cHeight + "px";
	if (Math.abs(dh - cHeight) < 1 || cHeight < 0)
	{
		if (submenu_state != "on")
		{
			m = document.getElementById("menu");
			s = document.getElementById("sub_menu");
			
			m.style.backgroundPosition = "0px 0px";
			s.style.display = "none";
			cHeight = sHeight;
		}
		else
		{
			cHeight = dHeight;
			
		}
		e.top = cHeight + "px";
		clearInterval(m_int);
	}
}

function outMenu()
{
	clearTimeout(c);
	c = setTimeout("check()", 5);
	menu_over = false;
}

function overMenu()
{
	menu_over = true;
}

function overSubmenu()
{
	submenu_over = true;
}

function outSubmenu()
{
	clearTimeout(c);
	c = setTimeout("check()", 5);
	submenu_over = false;
}

function showVars()
{
	e = document.getElementById('message');
	e.innerHTML = "menu_over: " + menu_over + ", submenu_over: " + submenu_over + ", cHeight: " + cHeight + ", dHeight: " + dHeight;
}

function check()
{
	if(!submenu_over && !menu_over)
	{
		hideSubmenu();
	}
}
/************************   HTTP REQUEST **********************************/
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
function zmien_zawartosc(id)
{
	el = document.getElementById("opakowania_zawartosc");
	el.innerHTML = "";
	el.style.height = "100px";
	el.style.background = "url('_img/loader.gif') center center no-repeat";
	 xmlhttp.open("GET", "_html/" + lang + "/" + id + "_" + lang + ".php",true);
	 xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		
	   el = document.getElementById("opakowania_zawartosc");
	   el.style.height = "auto";
	   el.style.background = "";
	   el.innerHTML = xmlhttp.responseText;
	  }
	 }
	 xmlhttp.send(null)
}



