changeRectColor = function (){
  /**
  * HSV to RGB color conversion
  *
  * H runs from 0 to 360 degrees
  * S and V run from 0 to 100
  *
  * Ported from the excellent java algorithm by Eugene Vishnevsky at:
  * http://www.cs.rit.edu/~ncs/color/t_convert.html
  */
  hsvToRgb = function (h, s, v) {
    var r, g, b;
    var i;
    var f, p, q, t;

    // Make sure our arguments stay in-range
    h = Math.max(0, Math.min(360, h));
    s = Math.max(0, Math.min(100, s));
    v = Math.max(0, Math.min(100, v));

    // We accept saturation and value arguments from 0 to 100 because that's
    // how Photoshop represents those values. Internally, however, the
    // saturation and value are calculated from a range of 0 to 1. We make
    // That conversion here.
    s /= 100;
    v /= 100;

    if(s == 0) {
      // Achromatic (grey)
      r = g = b = v;
      return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
    }

    h /= 60; // sector 0 to 5
    i = Math.floor(h);
    f = h - i; // factorial part of h
    p = v * (1 - s);
    q = v * (1 - s * f);
    t = v * (1 - s * (1 - f));

    switch(i) {
      case 0:
        r = v;
        g = t;
        b = p;
        break;
      case 1:
        r = q;
        g = v;
        b = p;
        break;
      case 2:
        r = p;
        g = v;
        b = t;
        break;
      case 3:
        r = p;
        g = q;
        b = v;
        break;
      case 4:
        r = t;
        g = p;
        b = v;
        break;
      default: // case 5:
        r = v;
        g = p;
        b = q;
    }
    return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
  };
  
  toHex = function (r, g, b) {
    rs = r.toString(16);
    rs = (rs.length === 1) ? '0' + rs : rs;
    gs = g.toString(16);
    gs = (gs.length === 1) ? '0' + gs : gs;
    bs = b.toString(16);
    bs = (bs.length === 1) ? '0' + bs : bs;
    return '#' + rs + gs + bs;
  };

  var try_counter = 0;
  var object_element = document.getElementById('bloglogo');
  var try_change = function(){
    var svg;
    if (svg = object_element.getSVGDocument() || object_element.contentDocument) {
      var rect = svg.getElementById('box').getElementsByTagName('rect')[0];
      color = hsvToRgb(Math.random() * 360, 100, 90);
      rect.setAttribute('fill', toHex(color[0], color[1], color[2]));      
    } else {
      if (try_counter < 10) {
              window.setTimeout(try_change, 100);
        try_counter += 1;
      }
     }
  };
  try_change();
}

