function atins(a,b)
{
 mm=50;
 ns = (document.layers) ? true : false;
 ie = (document.all) ? true : false;
 ff = document.getElementById? true : false;
 if (ie) mm=50;
 
 if(b==14)
 {
  if(document.getElementById("div_susub_99_"+a).style.visibility=="visible")
  { document.getElementById("div_susub_99_"+a).style.visibility="hidden"; document.getElementById("div_susub_99_"+a).style.display="none"; }
   else
  { document.getElementById("div_susub_99_"+a).style.visibility="visible"; document.getElementById("div_susub_99_"+a).style.display="block"; }
 }
 
/* if(b==1)
 {
  if((men[a*1]==3)||(men[a*1]==1))
  {
   document.getElementById(a+"div").style.height=(10+cat[a]*19)+"px";
   men[a*1]=2;
  }
  else
  {
   document.getElementById(a+"div").style.height="5px";
   men[a*1]=1;
  }
 }*/
 if(b==1)
 {
  if(document.getElementById(a+"div").style.visibility=="visible")
  { 
   document.getElementById(a+"div").style.visibility="hidden"; 
   document.getElementById(a+"div").style.display="none"; 
  }
  else
  { 
   document.getElementById(a+"div").style.visibility="visible"; 
   document.getElementById(a+"div").style.display="block"; 
  }
 }

 if(b*1==2)
 { window.location="index.php?loc="+a+"&tiploc="+b; }
 if(b*1==3)
 { window.location="index.php?loc="+a+"&tiploc=3"; }
 if(b*1==7)
 { window.location="index.php?loc="+a+"&tiploc=1"; }

 if(b*1==3)
 { document.getElementById("div_subcateg_lst_"+a).className="text_meniu_mic2"; }
 if(b*1==4)
 { document.getElementById("div_subcateg_lst_"+a).className="text_meniu_mic"; }
 
 if(b*1==5)
 { document.getElementById("div_categ_lst_"+a).className="text_meniu_mare2"; }
 if(b*1==6)
 { document.getElementById("div_categ_lst_"+a).className="text_meniu_mare"; }
 
 if(b*1==10)
 { document.getElementById("pagg_"+a).className="text_pagini2"; }
 if(b*1==11)
 { document.getElementById("pagg_"+a).className="text_pagini"; }
 
 if(b*1==12)
 { document.getElementById("div_categ_lst_"+a).className="text_meniu_mare4"; }
 if(b*1==13)
 { document.getElementById("div_categ_lst_"+a).className="text_meniu_mare3"; }
 
}

function inchide_ecr_poz()
{
 document.getElementById("div_poz_t_ecr").style.visibility="hidden";
 document.getElementById("div_poz_t_ecr").style.display="none";
}

function inchide_messdummn()
{
 document.getElementById("acttt").value="0";
 document.getElementById("div_opn_dmv").style.visibility="hidden";
 document.getElementById("div_opn_dmv").style.display="none";
}


function deschide_messdummn()
{ 
 var xa,ya;
 if(self.innerHeight) 
 {
  xa=self.innerWidth;
  ya=self.innerHeight;
 }
 else if(document.documentElement && document.documentElement.clientHeight)
 {
  xa=document.documentElement.clientWidth;
  ya=document.documentElement.clientHeight;
 }
 else if(document.body)
 {
  xa=document.body.clientWidth;
  ya=document.body.clientHeight;
 }
 document.getElementById("acttt").value="1";
 document.getElementById("div_opn_dmv").style.height=ya+"px";
 document.getElementById("div_opn_dmv").style.width=xa+"px";
 document.formopndmv.action=window.location.pathname+window.location.search;
 document.getElementById("div_opn_dmv").style.visibility="visible";
 document.getElementById("div_opn_dmv").style.display="block";
}


function arata_ecr_poz()
{
 var xa,ya;
 if(self.innerHeight) 
 {
  xa=self.innerWidth;
  ya=self.innerHeight;
 }
 else if(document.documentElement && document.documentElement.clientHeight)
 {
  xa=document.documentElement.clientWidth;
  ya=document.documentElement.clientHeight;
 }
 else if(document.body)
 {
  xa=document.body.clientWidth;
  ya=document.body.clientHeight;
 }
 document.getElementById("div_poz_t_ecr").style.height=ya+"px";
 document.getElementById("div_poz_t_ecr").style.width=xa+"px";
 document.getElementById("div_poz_t_ecr").style.visibility="visible";
 document.getElementById("div_poz_t_ecr").style.display="block";
}

function aranjj()
{
 x=document.getElementById("div_reper").offsetLeft;
 par=document.getElementById("div_reper").offsetParent;
 while (par!=null)
 {
  x+=par.offsetLeft;
  par=par.offsetParent;
 }
 document.getElementById("chenar_reclama_mare1").style.left=(x+2)+"px";
 document.getElementById("chenar_reclama_mare1").style.visibility="visible";
}

function merg(a)
{ window.location="index.php?loc="+loc_id+"&tiploc="+tip_loc_id+"&pag="+(a*1-1); }

function merg2(a)
{ window.location="produs.php?loc="+a; }

function merg3(c,b,a)
{ window.location="administrare.php?loc="+c+"&tiploc="+b+"&pag="+(a*1-1); }

function misc(a)
{
 if(men[a*1]==3)
 {
  document.getElementById(a+"div").style.height=(parseInt(document.getElementById(a+"div").style.height)-8)+"px"; 
  if(parseInt(document.getElementById(a+"div").style.height)<=5)
  { document.getElementById(a+"div").style.height=5+"px"; window.clearInterval(timp[a*1]); men[a*1]=1; }
 } 
 else
 {
  if(men[a*1]==2)
  {
   timp[a*1]=window.setInterval("misc("+a+")",10);
   men[a*1]=3;
  }
  else
  {
   if(men[a*1]==4)
   {
    document.getElementById(a+"div").style.height=(parseInt(document.getElementById(a+"div").style.height)+8)+"px";
    if(parseInt(document.getElementById(a+"div").style.height)>=(10+cat[a]*19))
    { document.getElementById(a+"div").style.height=(10+cat[a]*19)+"px"; window.clearInterval(timp[a*1]); men[a*1]=2; }
   }
   else 
   { 
    if(men[a*1]==1) { timp[a*1]=window.setInterval("misc("+a+")",10); men[a*1]=4; } 
   }
  }
 }
}

function colorFade(id,element,start,end,steps,speed) {
  var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;
  var target = document.getElementById(id);
  steps = steps || 20;
  speed = speed || 20;
  clearInterval(target.timer);
  endrgb = colorConv(end);
  er = endrgb[0];
  eg = endrgb[1];
  eb = endrgb[2];
  if(!target.r) {
    startrgb = colorConv(start);
    r = startrgb[0];
    g = startrgb[1];
    b = startrgb[2];
    target.r = r;
    target.g = g;
    target.b = b;
  }
  rint = Math.round(Math.abs(target.r-er)/steps);
  gint = Math.round(Math.abs(target.g-eg)/steps);
  bint = Math.round(Math.abs(target.b-eb)/steps);
  if(rint == 0) { rint = 1 }
  if(gint == 0) { gint = 1 }
  if(bint == 0) { bint = 1 }
  target.step = 1;
  target.timer = setInterval( function() { animateColor(id,element,steps,er,eg,eb,rint,gint,bint) }, speed);
}

function animateColor(id,element,steps,er,eg,eb,rint,gint,bint) {
  var target = document.getElementById(id);
  var color;
  if(target.step <= steps) {
    var r = target.r;
    var g = target.g;
    var b = target.b;
    if(r >= er) {
      r = r - rint;
    } else {
      r = parseInt(r) + parseInt(rint);
    }
    if(g >= eg) {
      g = g - gint;
    } else {
      g = parseInt(g) + parseInt(gint);
    }
    if(b >= eb) {
      b = b - bint;
    } else {
      b = parseInt(b) + parseInt(bint);
    }
    color = 'rgb(' + r + ',' + g + ',' + b + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
    target.r = r;
    target.g = g;
    target.b = b;
    target.step = target.step + 1;
  } else {
    clearInterval(target.timer);
    color = 'rgb(' + er + ',' + eg + ',' + eb + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
  }
}

function colorConv(color) {
  var rgb = [parseInt(color.substring(0,2),16), 
    parseInt(color.substring(2,4),16), 
    parseInt(color.substring(4,6),16)];
  return rgb;
}


function tranzz(a,id)
{
 dd=9;
 ns = (document.layers) ? true : false;
 ie = (document.all) ? true : false;
 ff = document.getElementById? true : false;
 if (ie) dd=4;
 else if (ff) dd=13;
 else if (ns) dd=13;
 if(a*1==1)
 {
  colorFade('div_categ_lst_'+id,'text','F1F1C0','FF0000',dd,dd);
  colorFade('div_categ_lst_ttm_'+id,'background','3E0000','3E0000',dd,dd); //onmouseout="colorFade('testdiv2','background','d8e6ee','ecf2f5',25,50)"
 }
 if(a*1==2)
 {
  colorFade('div_categ_lst_'+id,'text','FF0000','F1F1C0',30,30);
  colorFade('div_categ_lst_ttm_'+id,'background','3E0000','3E0000',30,30);
 }
 
 if(a*1==3)
 {
  colorFade('div_subcateg_lst_'+id,'text','F1F1C0','FF0000',dd,dd);
  colorFade('div_subcateg_lst_ttm_'+id,'background','330000','330000',dd,dd);
 }
 if(a*1==4)
 {
  colorFade('div_subcateg_lst_'+id,'text','FF0000','F1F1C0',30,30);
  colorFade('div_subcateg_lst_ttm_'+id,'background','330000','330000',30,30);
 }
 
 if(a*1==5)
 {
  colorFade('div_categ_lst_'+id,'text','F1F1C0','FF0000',dd,dd);
  colorFade('div_categ_lst_ttm_'+id,'background','3E0000','3E0000',dd,dd); //onmouseout="colorFade('testdiv2','background','d8e6ee','ecf2f5',25,50)"
 }
 if(a*1==6)
 {
  colorFade('div_categ_lst_'+id,'text','FF0000','F1F1C0',30,30);
  colorFade('div_categ_lst_ttm_'+id,'background','3E0000','3E0000',30,30);
 }
 
 if(a*1==7)
 {
  colorFade('div_subsubcateg_lst_'+id,'text','F1F1C0','FF0000',dd,dd);
  colorFade('div_subsubcateg_lst_ttm_'+id,'background','330000','330000',dd,dd);
 }
 if(a*1==8)
 {
  colorFade('div_subsubcateg_lst_'+id,'text','FF0000','F1F1C0',30,30);
  colorFade('div_subsubcateg_lst_ttm_'+id,'background','330000','330000',30,30);
 }
}