// UWAGA: poprawki w nazwach/lokalizacjach wzgledem oryginalu
function makeImg(img)
{
  var style = '';
  var id = '';
  var extra = '';

  if ( img.width )
    style += 'width:' + img.width + 'px;';
  if ( img.height )
    style += 'height:' + img.height + 'px;';
  if ( img.style )
    style += img.style;

  if ( img.id )
    id = 'id="' + img.id + '"';

  if ( img.extra )
    extra = img.extra;

  if ( /MSIE (5\.5|6\.)/.test(navigator.userAgent) && /\.png$/.test(img.src) )
  {
    return '<img ' + id + ' style="' + style + 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + 
      img.src + '\', sizingMethod=\'scale\')" src="img/blank.gif" ' + img.extra + '/>';
  }
  else
  {
    return '<img ' + id + ' style="' + style + '" src="' + img.src + '" ' + extra + '/>';
  }
}

function putImg(img)
{
  document.write(makeImg(img));
}

function initButton(obj, index)
{
  obj.addEvent('mousedown', function(event) {
    this.setStyle('background-image', 'url(button_down.gif)');
  });
  obj.addEvent('mouseup', function(event) {
    this.setStyle('background-image', 'url(button_up.gif)');
  });
  obj.addEvent('mouseout', function(event) {
    this.setStyle('background-image', 'url(button_up.gif)');
  });
}

function initBox(obj, index)
{
  obj.childNodes[1].FX = $(obj.childNodes[1]).effect('opacity', {wait: false, duration: 300}).set(0);
  obj.addEvent('mouseover', function(event) {
    this.childNodes[1].FX.start(1);
  });
  obj.addEvent('mouseout', function(event) {
    this.childNodes[1].FX.start(0);
  });
}

function onReady()
{
  $$('div.TmoreButton').forEach(initButton);
  $$('div.TmenuBox').forEach(initBox);
}
