/*!
  \brief open/close a submenu
*/
function t(i) {
  var elementi = [ "info", "hackit", "materiali" ];
  for ( elem in elementi )
  {
    if ( ! parseInt( elem ) >= 0 )
      break;
    var e = document.getElementById( elementi[elem] );
    var t = e.className;
    if ( ! t.match('invisible')) 
    { t = t.replace(/visible/gi, 'invisible'); }
    e.className = t;
  }

  var e = document.getElementById(i);
  var t = e.className;
  if (t.match('invisible')) { t = t.replace(/invisible/gi, 'visible'); }
  else { t = t.replace(/visible/gi, 'invisible'); }
  e.className = t;
}

//delete a content
function checkDel( title, id )
{
  msg = confirm( "Sicuro di voler eliminare '" + title + "'" );
  if ( msg )
  {
    xajax_Request( "delContent", id );
  }
}

//write a message in guestbook
function sendMessage( form )
{

  author  = escape( form.author.value );
  title   = escape( form.title.value );
  content = escape( form.content.value );

  xajax_newMessage( author, title, content );
}

//sposta in alto un contenuto di una pagina
function upRow( page, id )
{
  lista = document.getElementById('index').childNodes;
  length = lista.length;
  lastI = -1;
  for( i=0; i<length; i++)
  {
    if( lista[i].childNodes && lista[i].childNodes[0] && lista[i].childNodes[0].id )
    {
      if ( lista[i].childNodes[0].id==id )
        break;
      else
      {
        lastI = i;
        lastId = lista[i].childNodes[0].id;
      }
    }
  }
  if( lastI == -1 )
  {
    return;
  }
  tmp = lista[lastI].innerHTML;
  lista[lastI].innerHTML = lista[i].innerHTML;
  lista[i].innerHTML = tmp;
  xajax_Request( 'switchContent', id, lastId );
}

function selectOption( select, index )
{
  if( select == 'day' )
    index = index - 28;
  select = document.getElementById( select );
  select.options[select.selectedIndex].selected='';
  select.selectedIndex = index;
  select.options[index].selected="selected";
}

