/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function setFocus()
{
    var l = document.forms[0].getElementsByTagName("input");
    for (var i = 0; i < l.length; i++)
    {
        var e = l[i];
        if (e.type == "text" && !e.readOnly) 
        {
            e.focus();
            return;
        }
    }
}

// En el form agregar onsubmit="return validateForm();"
function validateForm()
{
    var l = document.forms[0].getElementsByTagName("textarea");
    var error = false;
    for (var i = 0; i < l.length; i++)
    {
        var e = l[i];
        var largo = e.rows * e.cols;
        if (e.value.length > largo) {
            error = true;
            e.style.backgroundColor = "#eeb0b0";
        }
        else {
            e.style.backgroundColor = "";
        }
    }
    
    if (error) {
        alert("Se ha excedido del tamaño máximo en algún campo.\nEste o estos campos han sido marcados con un color diferente.")
        return false
    }
    //alert("bien");
    return true;
}

    function parsecampo(nombre, val) {
    	var cx=document.getElementsByName(nombre);
	if (val.lastIndexOf("1") >= 0)
		cx[0].checked = true;
	if (val.lastIndexOf("2") >= 0)
		cx[1].checked = true;
	if (val.lastIndexOf("3") >= 0)
		cx[2].checked = true;
	if (val.lastIndexOf("4") >= 0)
		cx[3].checked = true;
	if (val.lastIndexOf("5") >= 0)
		cx[4].checked = true;
	if (val.lastIndexOf("6") >= 0)
		cx[5].checked = true;
	if (val.lastIndexOf("7") >= 0)
		cx[6].checked = true;
	if (val.lastIndexOf("8") >= 0)
		cx[7].checked = true;
	if (val.lastIndexOf("9") >= 0)
		cx[8].checked = true;
    }
    function ver(campo, val) {
    	var c = document.getElementsByName(campo);
	if (c.length > 0)
	    c[0].value = val;
	var f = document.forms[0];
	if (f.action != null)
	    f.submit();
    }
    function ver_instr(url) {
	    window.open(url, '_blank', 'menubar=0,location=0,scrollbars=1,width=600,height=600');
    }
