var VisibleLayer = '';
document.cookie = "sc=1;";

function getObj(nm) {var obj;obj=document.getElementById(nm); if(!obj){return document.all(nm);} else {return obj;}}
function showLayer(id, stp, maxAlph) {
  if (!stp) {stp = 6; }
  if (!maxAlph) {maxAlph = 100; }

  VisibleLayer = id;
  ElementVis(VisibleLayer, true, stp, maxAlph);
}

function SetAlpha(obj,val) {
 if (obj) {
  if (val == 0 || val == 100) {
    if (!val) {
      obj.style.filter = 'alpha(opacity=0)';
      obj.style.opacity = '0';
      obj.style["-moz-opacity"] = '0';
      obj.style.visibility = 'hidden';
    }
    else {
      obj.style.filter = 'alpha(opacity=100)';
      obj.style.opacity = '1';
      obj.style["-moz-opacity"] = '1';
      obj.style.visibility = 'visible';
    }
  } else {
    obj.style.filter = 'alpha(opacity='+val+')';
    obj.style["-moz-opacity"] = '.'+val;
    obj.style.opacity = '.'+val;
  }
 }
}

function ChangeAlpha(nm) {
 var obj = getObj(nm);

 if (obj && obj.alphaAdd) {
   obj.alpha += obj.alphaAdd;
   obj.steps --;
   if (obj.steps>0 && obj.style.visibility != 'hidden') {
     SetAlpha(obj,parseInt(obj.alpha));
     setTimeout("ChangeAlpha('"+nm+"')",50);
   } else {
     SetAlpha(obj,obj.maxA);
   }
 }
}

function ElementVis(nm, val, steps, maxalpha) {  // if steps>0 - fade
 var obj = getObj(nm);

 if (obj) {

  if (!steps || steps == 1) {  // no fade
   SetAlpha(obj,obj.maxA);
   if (!val) {obj.alphaAdd = 0;}
  }
  else {  // fade
   if (!obj.style.opacity) obj.style.opacity = .7;
   obj.alpha = parseInt(obj.style.opacity*100);
   obj.steps = steps;
   obj.alphaAdd = (maxalpha-obj.alpha)/steps;
   obj.maxA = maxalpha;
   if (!val) {
     obj.alphaAdd = - obj.alphaAdd;
     SetAlpha(obj,100);
   }

    setTimeout("ChangeAlpha('"+nm+"')",10);
  }
 }
}


