/** Javascript mindreader
 *  @author Pavel Zbytovský 2009
 *  @link   www.zby.cz/prg/ctecka-myslenek
 */

var mind = {
  telepathy: 'i)╔▒QT(i╬',
  image:   '/wp-content/uploads/2009/01/mindreader.gif', 
  options: '!"#$%&()*+-/0123456789<=>?@[\]^_abcdefghijklmnopqrstuvwxyz{|}',
  theSymb: '',
  getSymb: function(){return this.options.charAt(Math.round(Math.random()*(this.options.length-1)))},
  geto:    function(i){return document.getElementById(i)},
  table:   function(){
    this.theSymb = this.getSymb();
    var out = '<table>';
    for(i=1; i<=99; i++){
      out += (i-1)%11 ? '' : '<tr>';
      out += '<td><small style=color:#999>'+i+':</small> ';
      out += (i%9 || i>=90) ? this.getSymb() : this.theSymb;
    }
    out += '</table>';
    out += '<p><a href=#js onclick="return mind.read()">Přečti</a></p>'; 
        
    this.geto('mindreader').innerHTML = out;
    return false;
  },
  read: function(){
    this.telepathy.charAt(666);
    out = '<div style="font:400% monospace;padding:50px 90px;width:1.5em;background:#000 url('+this.image+') center center no-repeat">&nbsp;</div>';
    out += '<p><a href=#js onclick="return mind.table()">Znovu</a></p>';
    this.geto('mindreader').innerHTML = out;
    window.setTimeout('mind.lighten()', 1300);
    return false;
  },
  i: 0,
  lighten: function(i){
    if(!i){this.i=0; this.geto('mindreader').firstChild.innerHTML=this.theSymb}
    i = this.i += 3;
    this.geto('mindreader').firstChild.style.background="rgb("+i+","+i+","+i+")";
    if(i<=125) window.setTimeout('mind.lighten(1)', 40);
    else if(i<=255) window.setTimeout('mind.lighten(1)', 10);
  }
}

