function writeArquivo()
{
  var container = $("barra-dias");
  var re_day = /.*dia([0-9]{2}).*/;
  var thatDay = (!isNaN( location.href.replace(re_day,"$1") ))?parseInt( location.href.replace(re_day,"$1") ):today;
  var weekday = [
    { "abreviado":"qui", "completo":"Quinta" },
    { "abreviado":"sex", "completo":"Sexta" },
    { "abreviado":"sab", "completo":"Sábado" },
    { "abreviado":"dom", "completo":"Domingo" },
    { "abreviado":"seg", "completo":"Segunda" },
    { "abreviado":"ter", "completo":"Terça" },
    { "abreviado":"qua", "completo":"Quarta" }
  ];
  var weekdayStart = 3;

  var h2 = document.createElement("h2");
  var ul = document.createElement("ul");
  var li;
  var h3;
  var a;
  var text;

  function getWeekday( i )
  {
    return weekday[ i%7 ];
  }
  
  function isOlder( i )
  {
    return (parseInt( datas[i] ) < today)?true:false;
  }
  
  function isThatDay( i )
  {
    return ( datas[i] == thatDay )?true:false;
  }

  function isToday( i )
  {
    return ( datas[i] == today )?true:false;
  } 

  for( var i in datas )
  {
    li = document.createElement("li");
    
    if( !isThatDay( i ) )
    {
      h3 = document.createElement("h3");
      
      text = getWeekday( i ).abreviado + " ";
      text = document.createTextNode( text );
      li.appendChild( text );
      
      text = datas[i];
      text = document.createTextNode( text );
      
      a = document.createElement("a");
      a.appendChild( text );
      
      if( isOlder( i ) )
      {
        a.href = "/pan/2007/arquivo/dia" + datas[i] + "/";
        li.className = "old";
        
      }
      else if( isToday( i ) ) // Today
      {
        a.href = "/pan/";
        li.className = "today";
      }
      else // After
      {
        a.href = "http://pan.uol.com.br/pan/2007/calendario/dia.jhtm?dia=" + datas[ i ];
        li.className = "after";
      }
      
      h3.appendChild( a );
      li.appendChild( h3 );
    }
    else // That Day
    {
      li.className = "thatday";
      text = getWeekday( i ).completo + ", " + thatDay + " de julho";
      text = document.createTextNode( text );
      h2.appendChild( text );
      li.appendChild( h2 );
    }
    
    ul.appendChild( li );
  }
  
  container.appendChild( ul );
}
