function changeForm(sezione,autogo)
{ 
    var ind;
    var aIdTab = new Object();
    aIdTab['studenti'] = 'mdrGenerale';
    aIdTab['appunti'] = 'mdrAppunti';
    aIdTab['enciclopedia'] = 'mdrEnciclopedia';
    //aIdTab['forum'] = 'mdrForum';
  
    var myForm = document.getElementById('mdr');
    var myText = document.getElementById('mdrTesto');
    var dominio = 'http://doc.studenti.it/index.php';
    
    if(document.getElementById('tipo'))
        { myForm.removeChild(document.getElementById('tipo')); }
    
    if(document.getElementById('pag'))
        { myForm.removeChild(document.getElementById('pag')); }
    
    if(document.getElementById('index'))
        { myForm.removeChild(document.getElementById('index')); }
    
    for (ind in aIdTab)
      { document.getElementById(aIdTab[ind]).className = ''; }
    document.getElementById(aIdTab[sezione]).className = 'mdrActive'; 
  
    switch(sezione)
    {
        case "appunti":
            myForm.action = dominio;
            myText.name='testo';
            myText.value='';
        
            myForm.appendChild(addHiddenImput('tipo','1'));
            myForm.appendChild(addHiddenImput('pag','1'));
            myForm.appendChild(addHiddenImput('index','default'));
            
            break;
        case "enciclopedia":
            myForm.action = dominio;
            myText.name='testo';
            myText.value='';
        
            myForm.appendChild(addHiddenImput('tipo','5'));
            myForm.appendChild(addHiddenImput('pag','1'));
            myForm.appendChild(addHiddenImput('index','default'));
            
            break;
        case "studenti":
            myForm.action = 'http://www.studenti.it/ricerca/';
            myText.value = '';
            myText.name='q';
            break;
        case "forum":
            myForm.action = dominio+'';
            break;
            
    }
    if(autogo == true) { myForm.submit(); }
}

function addHiddenImput(nome,val)
{
  var obj = document.createElement('input');
  obj.type='hidden';
  obj.name=nome;
  obj.id=nome;
  obj.value=val;
  return obj;
}

function aggiornaCampoCerca(val)
{
  var myText = document.getElementById('mdrTesto');
  myText.value = val;
}
