$(document).ready(function () {//things to do on page load
$('li.menu_head').click(function () {
                            var myurl=$(this).children("ul:eq(0)");
                            if(myurl.css('display') == 'none')
                                $('ul.menu_body').hide();
                            myurl.slideToggle('medium');
});
$('h2').append('<img src="./images/blinking_cursor.gif" />');

});

function t(i) {
    return false;
  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 - 26;
  select = document.getElementById( select );
  select.options[select.selectedIndex].selected='';
  select.selectedIndex = index;
  select.options[index].selected="selected";
}


/*! \brief get coordinate and size of specified object */
function getPosition( obj )
{
  var left = 0;
  var top = 0;
  var height = obj.offsetHeight;
  var width = obj.offsetWidth;
  while( obj.offsetParent )
  {
    left += obj.offsetLeft;
    top += obj.offsetTop;
    obj = obj.offsetParent;
  }
  left += obj.offsetLeft;
  top += obj.offsetTop;
  return { x : left, y : top, height: height, width: width };
}


