var lightBgColor='#000000';
var lightTextColor='#ffffff';
var lightCursor='pointer';
var isIE = window.navigator.userAgent.indexOf("MSIE")>-1; //true, если браузер - Internet Explorer
var glass=null;
var bigimg=null;

function hideLayer(elem) {
document.getElementById(elem).style.visibility = 'hidden';
lightOff();}

function showLayer(elem) {
document.getElementById(elem).style.visibility = 'visible';}

function lightOn(elem) {
memId = elem;
oldBgColor = document.getElementById(elem).style.background;
oldTextColor = document.getElementById(elem).style.color;
oldCursor = document.getElementById(elem).style.cursor;
document.getElementById(elem).style.background = lightBgColor;
document.getElementById(elem).style.color = lightTextColor;
document.getElementById(elem).style.cursor = lightCursor;
}

function lightOff() {
document.getElementById(memId).style.background = oldBgColor;
document.getElementById(memId).style.color = oldTextColor;
document.getElementById(memId).style.cursor = oldCursor;
}

function overButton(name,greyImage){
  document.images[name].src=greyImage;
}

function showGlass(show){
  if(glass==null){
    glass=document.createElement('DIV');
    glass.style.display='none';
    glass.style.position='absolute';
    glass.style.height=0;
    glass.style.width=0;
    glass.style.zIndex=1;
    if(isIE){
      glass.style.backgroundColor = '#FEE5BD';
      glass.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=60, Style=0)";
    }
    else{
      glass.style.backgroundImage = 'url("img/fon.png")';
    }
    document.body.appendChild(glass);
  }
  if(show){
    glass.style.left = 0;
    glass.style.top = document.body.scrollTop;
    glass.style.width = document.body.clientWidth+'px';
    glass.style.height = document.body.clientHeight+'px';
  }
  glass.style.display=show?'block':'none';
}

function loadBig(id){
  var s="_small";
  var r="_big"
  var oldstr=document.getElementById(id).src;
  var newstr="";
  var re=new RegExp(s,"g");
  
  showGlass(true);
  newstr=oldstr.replace(re,r);
  document.getElementById('bigimg').style.top  = (Math.round((document.documentElement.clientHeight - 525)/2)+document.documentElement.scrollTop)+'px';
  // + document.body.scrollTop document.body.client
  document.getElementById('bigimg').style.left = Math.round((document.documentElement.clientWidth  - 700)/2)+'px';
  if (document.getElementById(id).title==""){
      document.getElementById('bigimg').innerHTML='<img src="'+newstr+'" align="center">';
  }else{
      document.getElementById('bigimg').innerHTML='<table style="border-collapse:collapse"><tr><td align="center" colspan=3><img src="'+newstr+'" align="center"></td></tr><tr height="10px"><td width="25%"></td><td align="center" bgcolor="#FFCC00" width="50%" style="border: solid 1px #000000"><strong>'+document.getElementById(id).title+'</strong></td><td  width="25%"></td></tr></table>';
  }
  document.getElementById('bigimg').style.visibility="visible";
  document.getElementById('bigimg').style.display='block';
  document.getElementById('bigimg').focus();
}
function hideDiv(id){
  document.getElementById('bigimg').style.visibility="hidden";
  document.getElementById('bigimg').style.display="none";
  showGlass(false);
}
