var VisibleLayer = '';

function showLayer(id, stp, maxAlph) {
  if (!stp) {stp = 6; }
  if (!maxAlph) {maxAlph = 100; }

  VisibleLayer = id;
  ElementVis(VisibleLayer, true, stp, maxAlph);
}


function wr(hs){
 document.write(hs);
}

function getObj(nm) {
 var obj;

 if (document.getElementById(nm)) {
  obj = document.getElementById(nm);
 } else {
  obj = document.all(nm);
 }

 return obj;
}

function divV(val){
  if (val == 0) return '0'; else
  if (val == 100) return '1'; else
  if (val < 10) return '.0'+val; else
  return '.'+val;
}

function SetAlpha(obj,val) {
 if (obj) {
   var xVal = divV(val);

   if (obj.filters && obj.filters.alpha) obj.filters.alpha.opacity = val;
   obj.style.filter = 'alpha(opacity='+val+')';
   obj.style.opacity = xVal;
   obj.style["-moz-opacity"] = xVal;
 }
}

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 = .75;
   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);
  }
 }
}

function fadeIn(nm) {
 ElementVis(nm, 100, 3, 100);
}

function fadeOut(nm) {
 ElementVis(nm, 1, 5, 1);
}

function grayOut(nm) {
 ElementVis(nm, 70, 4, 70);
}


