marqui.ps.defineNs("marqui.ps.html");

if (typeof($) == "undefined")
{
    $ = function(id)
    {
        return document.getElementById(id);
    }
}

marqui.ps.html.findInput = function(partialId, inputType)
{
    var tags = document.getElementsByTagName("input");
    for (var i=0; i < tags.length; i++)
    {
        if (tags[i].id.toLowerCase().indexOf(partialId.toLowerCase()) != -1 && tags[i].type == inputType)
        {
            return tags[i];
        }
    }
}

marqui.ps.html.findChildByCssClassName = function (parent,cssClassName)
{
    for (var i =0; i < parent.childNodes.length; i++)
    {
        var node = parent.childNodes[i];
        if (typeof(node.className) != "undefined" && node.className != null &&  node.className.toLowerCase() == cssClassName.toLowerCase())
        {
            return node;
        }
        else
        {
            node = marqui.ps.html.findChildByCssClassName(node,cssClassName);
            if (node != null) return node;
        }
    }
    return null;
}

marqui.ps.html.findParentByTag = function (node,tagName)
{
    while(node.tagName.toLowerCase() != tagName)
    {
        node = node.parentNode;
    }
    return node;
}

marqui.ps.html.findRowIndex = function (row)
{
    var tbody = marqui.ps.html.findParentByTag(row,"tbody");
    for (var i =0; i < tbody.childNodes.length;i++)
    {
        if (tbody.childNodes[i] == row)
        {
            return i;
        }
    };
}

marqui.ps.html.getChildNodes = function(node)
{
    var children = node.childNodes;
    var list = new Array();
    for (var i=0; i < children.length;i++)
    {
        node = children[i];
        if (node.nodeType==null || node.nodeType!=3)
        {
            list.push(node);
        }
    }
   return list;
}

marqui.ps.html.stripWhiteSpaceNodes = function(container)
{
    for (var i=0;i < container.childNodes.length;i++)
    {
        var node = container.childNodes[i];
        if (node.nodeType!=null && node.nodeType==3)
        {
            container.removeChild(node);
            i--;
        }
    }
    return container.childNodes;
}