var SivmoFrontend = new Class({
  headings: null,

  initialize: function ()
  {
    this.headings = new Hash({
      'h1': new Hash({
        'color': '1693D7',
        'size':  '18'}),
      'h2': new Hash({
        'color': '000000',
        'size':  '18'}),
      'h3': new Hash({
        'color': '1693D7',
        'size':  '16'}),
      'h4': new Hash({
        'color': '000000',
        'size':  '16'})
    });
    this.imageize();
  },

  imageize: function ()
  {
    $each( $$('h1','h2','h3','h4'), function( element ) {
      var plainText = element.get('text');
      if ( plainText.match('<img') ) return; // Allready imageText
      plainText = plainText.replace(/'/g, "`"); // Used font has no quotes :P
      plainText = plainText.replace(/\//g, "%2f"); // Replace /'s
      plainText = escape( plainText );
      if ( plainText.length == 0 ) return;
      element.set('html', '<img src="/service/html/Image/text/' + plainText + '/' + this.headings[element.get('tag')].size + '/0/0/' + this.headings[element.get('tag')].color + '/FFFFFF" alt="' + plainText.replace(/\%20/g, ' ') + '"/>');
    }.bind(this));
  }
});
window.addEvent('domready', function(){ var sivmofrontend = new SivmoFrontend() });
