/*
  Button transform
*/

var wButtons = Class.create();
var myButtons;

wButtons.prototype =
{
  buttonsBlocks:null,
  totalItems:0,

  initialize: function()
  {

    if(this.buttonsBlocks=$$(".wbutton"))
    {
      this.totalItems=this.buttonsBlocks.length;

      this.buttonsBlocks.each(function(item)
      {
        item.style.display="none";

        if(item.id=="")
        {
          item.id="wbutton_"+Math.floor(Math.random()*1000);
        }

        var result="";
        result+="<table border='0' cellpadding='0' cellspacing='0'>";
        result+="<tr>";
        result+="<td><img src='/static/project/wcmexchange/images/button_left1.gif' border='0' alt=''></td>";
        result+="<td class='buttonBg'><a ";
        result+="id='" + item.id + "' ";
        result+="href='" + item.href + "' ";
        result+=">";
        result+=item.firstChild.nodeValue;
        result+="</a>";
        result+="</td>";
        result+="<td><img src='/static/project/wcmexchange/images/button_right1.gif' border='0' alt=''></td>";
        result+="</tr>";
        result+="</table>";

        new Insertion.Before(item.id, result);

      }
      );

    }

  }
}



function initButtons()
{
  myButtons = new wButtons();
}

Event.observe(window, 'load', initButtons, false);
