// Devuelve el "value" de un "input" en funcion de su tipo
// NOTA:    faltan tipos por definir
function obtenerValor(formulario, campo) {
    var s
    if (input = document.forms[formulario].elements[campo]) {
        if (input.type == undefined)
            tipo = document.forms[formulario].elements[campo][0].type
        else
            tipo = input.type
        switch (tipo) {
            case "text":
            case "password":
            case "textarea":
            case "hidden":            return input.value
                                        break
            case "checkbox":        if (input.checked)
                                            return input.value
                                        break
            case "radio":            if (input.length) {
                                            for (s = 0; s < input.length; s++) {
                                                if (input[s].checked) {
                                                    return input[s].value
                                                }
                                            }
                                        } else {
                                            return input.value
                                        }
                                        break
            case "select-one":    return input.options[input.selectedIndex].value
                                        break
            
            case "file":         return input.value
                                        break                            
                                                    
            default:             return false
        }
    } else {
        return false
    }
}

// Establece (o selecciona) el valor de un "input" en funcion de su tipo
// NOTA:    faltan tipos por definir
function cambiarValor(formul, elem, valor) {
    var i
    if (input = document.forms[formul].elements[elem]) {
        if (input.type == undefined)
            tipo = document.forms[formulario].elements[campo][0].type
        else
            tipo = input.type
        switch (tipo) {
            case "text":
            case "hidden":
            case "textarea":    input.value = valor
                                break
            case "checkbox":    input.checked = (input.value == valor)
                                break
            case "radio":
            case "select-one":    for (i = 0; i < input.length; i++) {
                                    if (input.options[i].value == valor) {
                                        input.selectedIndex = i
                                    }
                                }
                                break
            default:            return false
        }
    } else {
        return false
    }
}

// Asigna el foco a un "input" teniendo en cuenta su tipo
// NOTA:    faltan casos por definir
function foco(formulario, campo) {
    if (input = document.forms[formulario].elements[campo]) {
        if (input.type == undefined)
            tipo = document.forms[formulario].elements[campo][0].type
        else
            tipo = input.type
        switch (tipo) {
            case "radio":    if (input[0])
                                    input[0].focus()
                                break
            default:            input.focus()
        }
    } else {
        return false
    }
}

// Devuelve un vector con los nombre de todos los campos del formulario
function nombres_elementos(formulario) {
    var e
    var res = new Array()
    for (e = 0; e < document.forms[formulario].elements.length; e++) {
        res[res.length] = document.forms[formulario].elements[e].name
    }
    return res
}

function clear_email() {
    objEmail = document.getElementById('email');
    if (objEmail.value.indexOf("@",0) < 2) {
        objEmail.value = '';
    }
}

