var menuids=["menutree1"];
var submenuopened=null;
var submenutimeout=null;
var mousepressed=0;
var sizealignre=0;
var sizealigntimeout=null;


function mousedown(e)
{
  e=e||window.Event||window.event;
  if(e&&((e.button==1)||(e.which==1)))
    mousepressed=1;
  return true;
}

function mouseup(e)
{
  e=e||window.Event||window.event;
  if(e&&((e.button==1)||(e.which==1)))
    mousepressed=0;
  return true;
}

function submenuhide()
{
  if(submenuopened)
  {
    submenuopened.getElementsByTagName("ul")[0].style.display="none";
    submenuopened=null;
    if(submenutimeout)
      window.clearTimeout(submenutimeout);
    submenutimeout=null;
  }
}

function submenushow(obj)
{
  var t=obj.getElementsByTagName("ul")[0];
  if(t&&!mousepressed)
  {
    t.style.display="block";
    if(submenuopened==obj)
    {
      if(submenutimeout)
        window.clearTimeout(submenutimeout);
      submenutimeout=null;
    }
    else
    {
      submenuhide();
      submenuopened=obj;
    }
  }
}

function buildsubmenus()
{
  for(var i=0; i<menuids.length; i++)
  {
    var ultags=document.getElementById(menuids[i])
    if(ultags)
    {
      ultags=ultags.getElementsByTagName("ul");
      for(var t=0; t<ultags.length; t++)
      {
        ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle";
        if(ultags[t].parentNode.parentNode.id==menuids[i])
          ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px";
        else
          ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px";
        ultags[t].parentNode.onmouseover=function(){submenushow(this);};
        ultags[t].parentNode.onmouseout=function(){if(submenutimeout) window.clearTimeout(submenutimeout);submenutimeout=window.setTimeout(function(){submenuhide();}, 200)};
      }
      for(var t=ultags.length-1; t>-1; t--)
      {
        ultags[t].style.visibility="visible";
        ultags[t].style.display="none";
      }
    }
  }
}

if(window.addEventListener)
  window.addEventListener("load", buildsubmenus, false);
else
  if(window.attachEvent)
    window.attachEvent("onload", buildsubmenus);

if(window.captureEvents)
{
  window.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  window.onmousedown = mousedown;
  window.onmouseup = mouseup;
}
else
{
  document.onmousedown = mousedown;
  document.onmouseup = mouseup;
}

function getCook(name){
 cookie = document.cookie;
 var cname = name+'=';
 var from  = cookie.indexOf(cname);
 if ( from != -1 ) {
    from += cname.length;
    to    = cookie.indexOf( ';', from );
    if ( to == -1 ) to = cookie.length;
    return unescape( cookie.substring(from, to) );
 }
 return null;
}

var str_zak='';
str_zak=getCook('zakaz');
if (str_zak==null){str_zak='';}


function subm(){
f1=document.forms[0];
if(str_zak==''){alert('Ваша корзина пуста');return;}
f1.szak.value=str_zak;
f1.submit();
}

