/*
 function checkDefaultFormController(formId,force)
{
    if (formCtrler==null || force)
    {
        if(!formId)
        {
            formIdToUse = document.forms[0];
        }
        else
        {
            formIdToUse = formId;
        }

        formCtrler = new FormController(formIdToUse);
    }
}
**/

function existingForm(
	formId,
	actionUrl,
	blockToSubmit)
{
    tempForm = null;
	
	if(formId)
    {
        tempForm = $(formId);
    }
    else
    {
        tempForm = document.forms[0];
    }

    if(!tempForm)
    {
        alert("Form not found");
        return;
    }

	defaultFormController = checkDefaultFormController(formId, true);
	defaultFormController.updateBlocksToSubmit(formId, tempForm, blockToSubmit);

    if(actionUrl)
    {
        tempForm.action = actionUrl;
    }
    
    setBlocksToSubmit(blockToSubmit);
}

function setElAttribute(existingEl, attrName, attrValue)
{
    if(attrValue)
    {
        if(attrValue == '#remove')
        {
            existingEl.removeAttribute(attrName);
        }
        else
        {
            existingEl.setAttribute(attrName, attrValue);
        }
    }
}

function existingInput(elementName, tagAttributesMap)
{
    temp = document.getElementsByName(elementName);
    
    if(temp && temp.length > 0)
    {
        elToUpdate = temp[0];
    }
    
    if(!elToUpdate)
    {
        alert("Element named " + elementName + " not found");
    }
    
    for (property in tagAttributesMap)
    {
        elAttribute = tagAttributesMap[property];
        setElAttribute(elToUpdate, property, elAttribute);
    }
}
