//############################## browser identification ################################################
//############################## browser identification ################################################
//############################## browser identification ################################################

 var agt=navigator.userAgent.toLowerCase();
 var is_major = parseInt(navigator.appVersion);
 var is_minor = parseFloat(navigator.appVersion);

 var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
 var is_nav2 = (is_nav && (is_major == 2));
 var is_nav3 = (is_nav && (is_major == 3));
 var is_nav4 = (is_nav && (is_major == 4));
 var is_nav4up = (is_nav && (is_major >= 4));
 var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
 var is_nav6 = (is_nav && (is_major == 5));
 var is_nav6up = (is_nav && (is_major >= 5));


 var isIE4=(!document.getElementById&&document.all);
 var isIE5=(document.getElementById&&document.all);
 var isNN4= is_nav4;
 var isNN6= is_nav6up;


 CurrentMenu = 0;
 Closing = 0;
 CanClose = 1;
 pradinis = 0;

 if (isNN4 ) pauze=700;
 else pauze = 10;

//################################### menu dropdown ################################################################
//################################### menu dropdown ################################################################
//################################### menu dropdown ################################################################

function getas(title, id)
{
  if (isIE4) objektas = document.all(title + id).style;
  if (isIE5 || isNN6) objektas = document.getElementById(title + id).style;
  if (isNN4) objektas = document[title + id];
  return objektas;
}

function showlayer(id)
{
  if (Closing!=0) clearTimeout(TimeOut);
  if (CurrentMenu!=0 && CurrentMenu!=id)
  {
//    off(CurrentMenu);
    tmp = getas("menu", CurrentMenu);
    tmp.visibility="hidden";
  }
  CurrentMenu=id;
//  onn(id);
  tmp = getas("menu", id);
  tmp.visibility="visible";
}

function hidelayer(id)
{
//   off(id);
   tmp = getas ("menu", id);
   tmp.visibility="hidden";
//   if(selected !=0 )   { pradinis=1; }
}

function trytohide(id)
{
  Closing=1;
  TimeOut=setTimeout("hidelayer("+id+")",pauze);
}


function rodom(id)   { showlayer(id); }
function nerodom(id)
{
 if (isNN4 || isNN6 )  trytohide(id);
 else   hidelayer(id);
}

function rodom2(id)
{
  if (isNN4){ showlayer(id);}
  return false;
}

function nerodom2(id)
{
  if (isNN4) trytohide(id);
}

function change_color2(id,color, color2 , nu )
{
  if (isNN4) return;
  if (selected==id ) return;
  change_color("td1_", id, color);
  change_color("td2_", id, color);
  if (nu)
    change_color("td3_", id, color2);
}

function change_color(title, id, color)
{
  tmp = getas(title, id );
  tmp.backgroundColor=color;
}


//############################################# menu expanded ######################################
//############################################# menu expanded ######################################
//############################################# menu expanded ######################################


//############################### spaudom meniu nuoroda ########################################
function goo(id,height)
{
 id = get_number(id);
  //isskliesim
  if (expanded[id]==0)
  {
   expanded[id]=1;
   expand_compress(id, 'expand', height);
  }
  //susklesim
  else
  {
   expanded[id]=0;
   expand_compress(id, 'compress', height);
  }
}

biski = 0;

//###################################### ar yra masyve ############################################
function in_array(value,mas)
{
  for (var i=0; i<mas.length; i++)
    if (mas[i] == value) return true;
 return false;
}

//#################################### isskliedziam reikiama ##################################

function expand_compress(id, action,height)
{
  for (var i=id+1; i<=layeriu_sk; i++)
  {
      topas = parseInt(document.all("menu_exp"+ expanded2[i]).style.top);
      if (action=='expand')
         topas +=  height * ( layers[id] ) + biski;
      else
         topas -=  height * ( layers[id] ) + biski;
      document.all("menu_exp"+ expanded2[i]).style.top=topas;

      if (layers[i]!=0)
      {
        topas = parseInt(document.all("menu_expv"+ expanded2[i]).style.top);
        if (action=='expand')
           topas +=  height * ( layers[id] ) + biski;
        else
           topas -=  height * ( layers[id] ) + biski;

        document.all("menu_expv"+ expanded2[i]).style.top=topas;
      }
  }
 if (action=='expand')
    document.all("menu_expv"+ expanded2[id]).style.visibility = "visible";
 else
    document.all("menu_expv"+ expanded2[id]).style.visibility = "hidden";
}

function get_number(id)
{
  for (i=1; i<=layeriu_sk; i++)
    if (expanded2[i]==id) return i;
  return 0;
}



