﻿/*GENERALES*/

function getChildWhitTagName(aoObjeto, asTag, asName) {
    //Obtenemos el hijo dependiendo del TAG y el atributo NAME
    var loChild = null;
    for (var i = 0; i < $(aoObjeto).children().length; i++) {
        loChild = ($(aoObjeto).children()[i]);
        if (loChild.tagName == asTag) {
            if ($(loChild).attr('name') == asName) {
                return loChild;
                //alert("spanColumnasMas");
            }
        }
    }
}

function getChildWhitTagClass(aoObjeto, asTag, asClass) {
    //Obtenemos el hijo dependiendo del TAG y la Clase
    var loChild = null;
    for (var i = 0; i < $(aoObjeto).children().length; i++) {
        loChild = ($(aoObjeto).children()[i]);
        if (loChild.tagName == asTag) {
            if ($(loChild).hasClass(asClass)) {
                return loChild;
                //alert("spanColumnasMas");
            }
        }
    }
}

function getChildWhitTag(aoObjeto, asTag) {
    //Obtenemos el hijo dependiendo del TAG y la Clase
    var loChild = null;
    for (var i = 0; i < $(aoObjeto).children().length; i++) {
        loChild = ($(aoObjeto).children()[i]);
        if (loChild.tagName == asTag) {
            return loChild;
            //alert("spanColumnasMas");
        }
    }
}

function getParentWithTag(aoObjeto, asTag) {
    //Obtenemos el padre dependiendo del TAG
    var i = 0;
    var loParent = null;

    loParent = $(aoObjeto).parent();
    do {
        if (loParent.get(0).tagName == asTag) {
            break;
        }
        loParent = $(loParent).parent();
        i++;
    } while (loParent.get(0).tagName != "HTML" && i < 9999999);

    return loParent;
}

function getParentWithTagClass(aoObjeto, asTag, asClass) {
    //Obtenemos el padre dependiendo del TAG y la Clase
    var i = 0;
    var loParent = null;

    loParent = $(aoObjeto).parent();
    do {
        //alert(loParent.get(0).tagName);
        if (loParent.get(0).tagName == asTag && $(loParent).hasClass(asClass)) {
            break;
        }
        loParent = $(loParent).parent();
        i++;
    } while (loParent.get(0).tagName != "HTML" && i < 9999999);

    return loParent;
}

function getParentWithTagName(aoObjeto, asTag, asName) {
    //Obtenemos el padre dependiendo del TAG y el Name
    var i = 0;
    var loParent = null;

    loParent = $(aoObjeto).parent();
    do {
        //alert(loParent.get(0).tagName);
        if (loParent.get(0).tagName == asTag && $(loParent).attr('name') == asName) {
            break;
        }
        loParent = $(loParent).parent();
        i++;
    } while (loParent.get(0).tagName != "HTML" && i < 9999999);

    return loParent;
}
