select : true,
		  submit : '<?php 
    echo ucfirst(LABEL_Guardar);
    ?>
',
		  cancel : '<?php 
    echo ucfirst(LABEL_Cancelar);
    ?>
',
		  cssclass : "editable",
	  });
	  <?php 
    $arrayCustumRelations["3"]["0"] .= TG_acronimo;
    $arrayCustumRelations["4"]["0"] .= UP_acronimo;
    $arrayCustumRelations["2"]["0"] .= TR_acronimo;
    $SQLtypeRelations = SQLtypeRelations();
    while ($ARRAYtypeRelations = $SQLtypeRelations->FetchRow()) {
        $arrayCustumRelations["{$ARRAYtypeRelations['t_relation']}"]["{$ARRAYtypeRelations['rel_rel_id']}"] .= $ARRAYtypeRelations[rr_value];
    }
    //add reverse view or BT/NT relation
    $arrayCustumRelations["TE"] = $arrayCustumRelations["3"];
    $arrayCustumRelations["TE"]["0"] = TE_acronimo;
    ?>
	  $(".editable_selectTE").editable("searcher.php", {
		indicator : '<img src="<?php 
    echo T3_WEBPATH;
    ?>
images/indicator.gif">',
		data   : '<?php 
    print json_encode($arrayCustumRelations["TE"]);
    ?>
function HTMLformUserRelations()
{
    //ALTA
    if ($_POST['rr_value'] != '' and $_POST['t_relacion'] != '' and $_POST['rr_code'] != '' and $_POST['rr_id'] == '') {
        $arrayValues = array("rr_value" => $_POST['rr_value'], "t_relacion" => $_POST['t_relacion'], "rr_ord" => $_POST['rr_ord'], "rr_code" => $_POST['rr_code']);
        $task = abm_userRelations("A", $arrayValues);
        if ($task[cant] > 0) {
            echo "<script>javascript:alert('" . ucfirst(LABEL_saved) . "');</script>";
        }
    }
    //MOD
    if ($_POST['doAdminR'] == 'modUserRelations') {
        $arrayValues = array("rr_value" => $_POST['rr_value'], "t_relacion" => $_POST['t_relacion'], "rr_ord" => $_POST['rr_ord'], "rr_code" => $_POST['rr_code']);
        $task = abm_userRelations("M", $arrayValues, $_POST['rr_id']);
        if ($task[cant] > 0) {
            echo "<script>javascript:alert('" . ucfirst(LABEL_saved) . "');</script>";
        }
        $_POST['rr_value'] = '';
        $_POST['t_relation'] = '';
        $_POST['rr_code'] = '';
        $_POST['rr_ord'] = '';
        $_POST['ac'] = '';
    }
    //BAJA
    if ($_POST['doAdminR'] == 'deleteUserRelations') {
        $task = abm_userRelations("B", array(), $_POST['rr_id']);
    }
    $sql = SQLtypeRelations(0, 0, true);
    $LABEL_RT = TR_acronimo;
    $LABEL_BT = TG_acronimo . '/' . TE_acronimo;
    $LABEL_UP = UP_acronimo . '/' . USE_termino;
    $arrayLABEL = array("2" => $LABEL_RT, "3" => $LABEL_BT, "4" => $LABEL_UP);
    $rows .= '<form id="morerelations" name="morerelations" method="POST" action="admin.php?vocabulario_id=list#morerelations">';
    $rows .= '<input type="hidden" name="doAdminR" id="doAdminR" value=""> ';
    $rows .= '<input type="hidden" name="rr_id" id="rr_id"> ';
    $rows .= '<div class="table-responsive"> ';
    $rows .= '<h3>' . ucfirst(LABEL_relationEditor) . ' </h3>';
    $rows .= '<table class="table table-striped table-bordered table-condensed table-hover"  summary="' . ucfirst(LABEL_relationEditor) . '">';
    $rows .= '<thead>';
    $rows .= '<tr>';
    $rows .= ' <th>' . ucfirst(LABEL_relationSubType) . '</th>';
    $rows .= '<th>' . ucfirst(LABEL_relationSubTypeLabel) . ':</th>';
    $rows .= '<th>' . ucfirst(LABEL_relationSubTypeCode) . '</th>';
    $rows .= '<th>' . ucfirst(orden) . '</th>';
    $rows .= '<th></th>';
    $rows .= '</tr>';
    $rows .= '<tr>';
    $rows .= '<th class="izq">';
    $rows .= '<select id="t_relacion" name="t_relacion">';
    $rows .= doSelectForm(array("3#{$LABEL_BT}", "4#{$LABEL_UP}", "2#{$LABEL_RT}"), "{$_GET['t_relation']}");
    $rows .= '</select>';
    $rows .= '<th class="izq"><input type="text" name="rr_value" id="rr_value"/></td>';
    $rows .= '<th class="izq"><input type="text" name="rr_code" size="2" maxlength="2" id="rr_code"/></td>';
    $rows .= '<th class="izq"><input type="text" name="rr_ord" size="2" maxlength="2" id="rr_ord"/></td>';
    $rows .= '<th><a onclick="enviaRel()" href="#"><strong>' . ucfirst(LABEL_Enviar) . '</strong></a></td>';
    $rows .= '</tr>';
    $rows .= ' </thead>';
    $rows .= ' <tbody>';
    while ($array = $sql->FetchRow()) {
        $i = ++$i;
        $rows .= '<tr>';
        $rows .= '<td>' . $arrayLABEL[$array["t_relation"]] . '</td>';
        $rows .= ' <td class="izq"><a title="' . $array["rr_value"] . '"  href="javascript:recargaeditRel(\'' . $array["rr_value"] . '\',\'' . $array["t_relation"] . '\',\'' . $array["rr_code"] . '\',\'' . $array["rel_rel_id"] . '\',\'' . $array["rr_ord"] . '\')">' . $array["rr_value"] . '</a></td>';
        $rows .= '<td>' . $array["rr_code"] . '</td>';
        $rows .= '<td>' . $array["rr_ord"] . '</td>';
        $rows .= $array["cant"] > 0 ? '<td>' . $array["cant"] . '</td>' : '<td><a onclick=preparaborradoRel(\'' . $array["rel_rel_id"] . '\') title="' . ucfirst(borrar) . '" href="#")><strong>' . ucfirst(LABEL_relationDelete) . '</strong></a></td>';
        $rows .= '</tr>';
    }
    $rows .= ' </tbody>';
    $rows .= '<tfoot>';
    $rows .= '<tr><td colspan="5">' . $i . '</th></tr>';
    $rows .= '</tfoot>';
    $rows .= '</table></div> ';
    $rows .= '</form>';
    return $rows;
}
function ARRAYtypeRelations($t_relation = 0, $rrel_type_id = 0)
{
    $sql = SQLtypeRelations($t_relation, $rrel_type_id);
    if ($sql) {
        while ($array = $sql->FetchRow()) {
            $i = ++$i;
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["t_relation"] .= $array[t_relation];
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["r_code"] .= $array[r_code];
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["rr_id"] .= $array[rel_rel_id];
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["rr_value"] .= $array[rr_value];
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["rr_code"] .= $array[rr_code];
            $arrayRelations["{$array['t_relation']}"]["{$array['rr_id']}"]["rr_cant_rel"] .= $array[rr_cant_rel];
        }
    } else {
        $arrayRelations = array();
    }
    return $arrayRelations;
}
function HTMLformEditTerms($taskterm, $ARRAYtermino = "0")
{
    //SEND_KEY to prevent duplicated
    session_start();
    $_SESSION['SEND_KEY'] = md5(uniqid(rand(), true));
    switch ($taskterm) {
        case 'addTerm':
            // add term
            $nombre_pantalla = LABEL_AgregarT;
            $hidden = '<input type="hidden"  name="alta_t" value="new" />';
            $hidden .= '<div><input type="checkbox" name="estado_id" id="estado_id" value="12" alt="' . ucfirst(LABEL_Candidato) . '" /> <label for="estado_id" accesskey="e">' . ucfirst(LABEL_Candidato) . '</label></div>';
            $hidden .= '<div><input type="checkbox" name="isMetaTerm" id="isMetaTerm" value="1" alt="' . ucfirst(LABEL_meta_term) . '" /> <label for="isMetaTerm" accesskey="e">' . ucfirst(LABEL_meta_term) . '</label>
			<div class="alert alert-info" role="alert">' . NOTE_isMetaTermNote . '</div>
			</div>';
            $help_rows = '<p class="text-primary">' . HELP_variosTerminos . '</p>';
            $extra_button = '<a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=addTermSuggested" title="' . ucfirst(LABEL__getForRecomendation) . '">' . ucfirst(LABEL__getForRecomendation) . '</a>';
            break;
        case 'editTerm':
            //Edici�n de un t�rmino $edit_id
            $nombre_pantalla = LABEL_editT . ' <a href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>';
            $vista_titulo_tema = $ARRAYtermino["titTema"];
            $vista_desc_tema = $ARRAYtermino[descTema];
            $hidden = '<input type="hidden"  name="edit_id_tema" value="' . $ARRAYtermino["idTema"] . '" />';
            break;
        case 'addNT':
            // add narowwer term
            $nombre_pantalla = LABEL_AgregarTE . ' <a href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>';
            $hidden .= '<input type="hidden"  name="id_termino_sub" value="' . $ARRAYtermino["idTema"] . '" />';
            $help_rows = '<p class="text-primary">' . HELP_variosTerminos . '</p>';
            $extra_button = '<a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=addFreeNT&amp;tema=' . $ARRAYtermino["idTema"] . '" title="' . ucfirst(MENU_AgregarTEexist) . '">' . ucfirst(MENU_AgregarTEexist) . '</a>';
            $extra_button .= ' <a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=findSuggestionTargetTerm&amp;tema=' . $ARRAYtermino["idTema"] . '&amp;t_relation=3" title="' . ucfirst(LABEL__getForRecomendation) . '">' . ucfirst(LABEL__getForRecomendation) . '</a>';
            $t_relation = '3';
            break;
        case 'addUF':
            //Alta de un t�rmino no preferido a $id_uf
            $nombre_pantalla = LABEL_AgregarUP . ' <a href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>';
            $hidden = '<input type="hidden"  name="id_termino_uf" value="' . $ARRAYtermino["idTema"] . '" />';
            $help_rows = '<p class="text-primary">' . HELP_variosTerminos . '</p>';
            $extra_button = '<a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=addFreeUF&amp;tema=' . $ARRAYtermino["idTema"] . '" title="' . ucfirst(MENU_AgregarUPexist) . '">' . ucfirst(MENU_AgregarUPexist) . '</a>';
            $extra_button .= ' <a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=findSuggestionTargetTerm&amp;tema=' . $ARRAYtermino["idTema"] . '&amp;t_relation=4" title="' . ucfirst(LABEL__getForRecomendation) . '">' . ucfirst(LABEL__getForRecomendation) . '</a>';
            $t_relation = '4';
            break;
        case 'addRTnw':
            //Alta de un término RT
            $nombre_pantalla = LABEL_AgregarTR . ' <a href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>';
            $hidden = '<input type="hidden"  name="id_termino_rt" value="' . $ARRAYtermino["idTema"] . '" />';
            $help_rows = '<p class="text-primary">' . HELP_variosTerminos . '</p>';
            $extra_button = '<a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=addRT&amp;tema=' . $ARRAYtermino["idTema"] . '" title="' . ucfirst(MENU_selectExistTerm) . '">' . ucfirst(MENU_selectExistTerm) . '</a>';
            $extra_button .= ' <a class="btn btn-second btn-xs" role="button" href="index.php?taskterm=findSuggestionTargetTerm&amp;tema=' . $ARRAYtermino["idTema"] . '&amp;t_relation=2" title="' . ucfirst(LABEL__getForRecomendation) . '">' . ucfirst(LABEL__getForRecomendation) . '</a>';
            $t_relation = '2';
            break;
    }
    $rows .= '<div class="container" id="bodyText">';
    $rows .= '<div class="row">';
    $rows .= '<a class="topOfPage" href="index.php?tema=' . $ARRAYtermino["idTema"] . '" title="' . LABEL_Anterior . '">' . LABEL_Anterior . '</a>
		<h3>' . LABEL_EditorTermino . '</h3>';
    $rows .= '<form class="form-horizontal col-xs-12 col-md-8" role="form" id="alta_t" name="alta_t" action="index.php" method="post">
		<fieldset>
		<legend>' . $nombre_pantalla . '</legend>

		<div class="form-group form-group-chk">
		<label for="' . FORM_LABEL_termino . '" accesskey="t">' . LABEL_Termino . '</label>
		' . $extra_button . '
		<textarea class="form-control" type="text" required autofocus rows="2" cols="60" name="' . FORM_LABEL_termino . '" id="addTerms">' . $vista_titulo_tema . '</textarea>';
    $rows .= $help_rows;
    $rows .= $extra_tag;
    $rows .= '</div>';
    if (in_array($t_relation, array(2, 3, 4))) {
        $SQLtypeRelations = SQLtypeRelations($t_relation);
        if (SQLcount($SQLtypeRelations) > 0) {
            while ($ARRAYtypeRelations = $SQLtypeRelations->FetchRow()) {
                $arraySelectTypeRelations[] = $ARRAYtypeRelations[rel_rel_id] . '#' . $ARRAYtypeRelations[rr_value];
                $neutralLabel = LABELrelTypeSYS($ARRAYtypeRelations[t_relation]);
            }
            $rows .= '<div class="form-group"><label for="rel_rel_id" accesskey="r">' . ucfirst(LABEL_relationSubType) . '<span class="small">(' . LABEL_optative . ')</span></label>';
            $rows .= '<select class="form-control" id="t_rel_rel_id" name="t_rel_rel_id"><option>' . ucfirst(LABEL_seleccionar) . '</option>';
            $rows .= doSelectForm($arraySelectTypeRelations, "");
            $rows .= '</select>';
            $rows .= '</div>';
        }
    }
    $rows .= '<div class="text-center">';
    $rows .= '<input type="submit" class="btn btn-primary" role="button" name="boton" value="' . LABEL_Enviar . '"/>';
    $rows .= ' <input type="button" class="btn btn-default" role="button" name="cancelar" type="button" onClick="location.href=\'index.php?tema=' . $ARRAYtermino["idTema"] . '\'" value="' . ucfirst(LABEL_Cancelar) . '"/>';
    $rows .= '</div>';
    $rows .= $hidden;
    $rows .= '<input type="hidden"  name="ks" id="ks" value="' . $_SESSION["SEND_KEY"] . '"/>';
    $rows .= '  </fieldset>';
    $rows .= '</form>';
    $rows .= '		</div>';
    //row
    $rows .= '</div>';
    //container
    return $rows;
}