/*
 * StackExchange Tags 
 *
 * Copyright (c) 2010 Marek Stój, Rafał Legięd
 * All rights reserved.
 * Wszelkie prawa zastrzeżone.
 */

var icon_tags = new Array();
icon_tags['linux'] = true;
icon_tags['windows'] = true;
icon_tags['windows-xp'] = true;

function addClassesToTagsWithIcons() {
  $('.post-tag').each(function() {
    var textNode = $(this).text();

    if (!icon_tags[textNode]) return;

    var newTextNode = '';
    for (i = 0; i < textNode.length; i++) {
      var ch = textNode[i];
      if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '_') {
        newTextNode += ch;
      } else {
        newTextNode += '_';
      }
    }

    $(this).prepend('<img style="vertical-align: text-top; padding-right: 4px;" alt="" src="http://cdn.immortal.pl/static/common/gfx/' + newTextNode + '.png">');
  });
}

// localization entry point
$(document).ready(function() {
  addClassesToTagsWithIcons();
});