function mostrar_establecimiento()
{
  $('frm_participante').style.display     = 'none';
  $('frm_imagen').style.display           = 'none';
  $('frm_grupo').style.display            = 'none';
  $('frm_establecimiento').style.display  = 'block';

  $('tab_participante').className     = 'fondo';
  $('tab_imagen').className           = 'fondo';
  $('tab_grupo').className            = 'fondo';
  $('tab_establecimiento').className  = 'frente';

  $('q_establecimiento').focus();
}

function mostrar_participante()
{
  $('frm_imagen').style.display           = 'none';
  $('frm_establecimiento').style.display  = 'none';
  $('frm_grupo').style.display            = 'none';
  $('frm_participante').style.display     = 'block';

  $('tab_imagen').className           = 'fondo';
  $('tab_establecimiento').className  = 'fondo';
  $('tab_grupo').className            = 'fondo';
  $('tab_participante').className     = 'frente';

  $('q_participante').focus();
}

function mostrar_imagen()
{
  $('frm_participante').style.display     = 'none';
  $('frm_establecimiento').style.display  = 'none' ;
  $('frm_grupo').style.display            = 'none' ;
  $('frm_imagen').style.display           = 'block';

  $('tab_participante').className     = 'fondo';
  $('tab_establecimiento').className  = 'fondo';
  $('tab_grupo').className            = 'fondo';
  $('tab_imagen').className           = 'frente';

  $('q_imagen').focus();
}

function mostrar_grupos()
{
  $('frm_participante').style.display     = 'none';
  $('frm_establecimiento').style.display  = 'none' ;
  $('frm_imagen').style.display           = 'none';
  $('frm_grupo').style.display            = 'block' ;

  $('tab_participante').className     = 'fondo';
  $('tab_establecimiento').className  = 'fondo';
  $('tab_imagen').className           = 'fondo';
  $('tab_grupo').className            = 'frente';

  $('q_grupo').focus();
}

function llenar_input(valor, id_1, id_2, id_3)
{
  $(id_1).value = valor;
  $(id_2).value = valor;
  $(id_3).value = valor;
}

var beh_buscar = {
  '#q_establecimiento' : function(f) {
    f.onkeyup  = function() { llenar_input(f.value, 'q_participante', 'q_imagen', 'q_grupo'); },
    f.onchange = function() { llenar_input(f.value, 'q_participante', 'q_imagen', 'q_grupo'); }
  },
  '#q_participante' : function(f) {
    f.onkeyup =  function() { llenar_input(f.value, 'q_establecimiento', 'q_imagen', 'q_grupo'); },
    f.onchange = function() { llenar_input(f.value, 'q_establecimiento', 'q_imagen', 'q_grupo'); }
  },
  '#q_imagen' : function(f) {
    f.onkeyup =  function() { llenar_input(f.value, 'q_participante', 'q_establecimiento', 'q_grupo'); },
    f.onchange = function() { llenar_input(f.value, 'q_participante', 'q_establecimiento', 'q_grupo'); }
  },
  '#q_grupo' : function(f) {
    f.onkeyup =  function() { llenar_input(f.value, 'q_participante', 'q_establecimiento', 'q_imagen'); },
    f.onchange = function() { llenar_input(f.value, 'q_participante', 'q_establecimiento', 'q_imagen'); }
  }
};

Behaviour.register(beh_buscar);

