

function nh_firstChild(thisobj)
{
    if(!thisobj) return null;
    for( var i=0; i < thisobj.childNodes.length; i++ )
    {
        if( thisobj.childNodes[i].nodeType == 1)
            return thisobj.childNodes[i];
    }        
}


function nh_lastChild(thisobj)
{
    if(!thisobj) return null;
    for( var i=thisobj.childNodes.length-1; i >=0 ; i-- )
    {
        if( thisobj.childNodes[i].nodeType == 1)
            return thisobj.childNodes[i];
    }        
}

function nh_ChildByIdx( thisobj, idx )
{
    if(!thisobj) return null;
    // index starts from 0
    var tagcount = 0; 
    for( var i=0; i < thisobj.childNodes.length; i++ )
    {
        if( thisobj.childNodes[i].nodeType == 1)
            tagcount++;
        if( tagcount-1 == idx )
        {
            return thisobj.childNodes[i];
        }
    } 
   return null;       
}

function nh_childCount( thisobj )
{
    if(!thisobj) return 0;
    // index starts from 0
    var tagcount = 0; 
    for( var i=0; i < thisobj.childNodes.length; i++ )
    {
        if( thisobj.childNodes[i].nodeType == 1)
            tagcount++;
    } 
   return tagcount;       
}

function nh_nextSibling(thisobj)
{
    if(!thisobj) return null;
    var pobj = thisobj.parentNode; 
    var thenext = false; 
    for(var i=0; i < pobj.childNodes.length; i++)
    {
        if( pobj.childNodes[i].nodeType == 1)
        {
            if(pobj.childNodes[i].id == thisobj.id)
            {
                thenext = true;
            } 
            else if (thenext)
                return pobj.childNodes[i];
         } 
    }
   return null;      
}


