﻿function recursiveReadOnly(rootElt, newValue)
{
    if(rootElt != null)
	{
	    for(var i=0; i < rootElt.children.length; i++)
		{
		    if(rootElt.children[i].readOnly != newValue)
		    {
	            rootElt.children[i].readOnly = newValue;
		    }
            if(rootElt.children[i].children.length >= 0)
		    {
		        recursiveReadOnly(rootElt.children[i], newValue);
		    }
        }
    }
}
            


function recursiveDisabled(rootElt, newValue, newClass, eltName)
{
    if(rootElt != null)
	{
        for(var i=0; i < rootElt.children.length; i++)
        {
            if((rootElt.children[i].id.indexOf(eltName))>=0)
            {
                if(rootElt.children[i].disabled != newValue)
                {
                    rootElt.children[i].disabled = newValue;
                }
                rootElt.children[i].setAttribute("class", newClass);
                rootElt.children[i].className = newClass;
            }
            if(rootElt.children[i].children.length >= 0)
            {
		        recursiveDisabled(rootElt.children[i], newValue, newClass, eltName);
		    }
        }
    }
}

function recursiveFind(rootElt, endId)
{
    if(rootElt != null)
	{
	    for(var i=0; i < rootElt.children.length; i++)
		{
		    if((rootElt.children[i].id.indexOf(endId))>=0)
		    {
	            return rootElt.children[i];
		    }
		                
            if(rootElt.children[i].children.length >= 0)
            {
                var result = recursiveFind(rootElt.children[i], endId);
                if(result != null) return result;
            }
        }
    }
    else
    {
        return null;
    }
}    
		
function getElementByEndId(rootName, endId)
		    {
		        var elt = null;
		        var rootElt = document.getElementById(rootName);
		        if(rootElt != null)
		        {
		            return recursiveFind(rootElt, endId);
		        }
		        return elt;
		    }            


