function p19_alternar_categoria ( cat ) {

    // Armamos un array con las categorias actuales.
    c = new Array();

    ac = e('pag_categorias').value.split(',');

    // Les hacemos un trim, y nos fijamos si la cat existe
    existe = false;
    pos = -1;

    for ( var i in ac ) {

        v = ac[i].trim();

        // no procesamos vacios.
        if ( v != "" ) {
            c.push ( v );

            if ( v == cat ) {
                existe = true;
                pos = i;
            }
        }

    }

    // Si no existe, lo aņadimos
    if ( ! existe )
        c.push ( cat );
    else
        // Si existe, lo removemos
        c.splice ( pos, 1 );

    // regeneramos
    e('pag_categorias').value = c.join(',') + ', ';

}

function p19_borrar_categorias () {
    e('pag_categorias').value = '';
}

function p19_popup_retornar (nombre, descr, funcion ) {
    // Colocamos los datos en el padre, y ejecutamos la funcion que pide

    window.opener.document.getElementById('hlp_nombre').value = nombre;
    window.opener.document.getElementById('hlp_descr').value = descr;

    eval ('window.opener.' + funcion + '()' ) ;   

    window.close();

}