﻿function onChangeDisabledField(controlName1, controlName2, stringCheck, strText)
{
    var control1 = document.all[controlName1];
    var control2 = document.all[controlName2];
    var x = 0;
    x = control2.length;

    if (control1.options[control1.selectedIndex].text != stringCheck)
    {
        for (i=0; i<control2.length; i++)
        {
            if (control2.options[i].text == strText)
            {
                control2.length = x-1;
                break;
            }
        }
        x = control2.length + 1;
        x = Number(x);
        control2.length = x;
        control2.options[x-1].value = "";
        control2.options[x-1].text = strText;
        control2.options[x-1].selected = true;
        control2.disabled = true;
    }
    else
    {
        for (i=0; i<control2.length; i++)
        {
            if (control2.options[i].text == strText)
            {
                x = control2.length-1;
                break;
            }
        }
        control2.length = x;
        control2.disabled = false;
    }
}

function hideVisTipoUtenteRegistrazione(str)
{
    if (str == "2")
    {
        document.getElementById('RagioneSociale').style.display = "none";
        document.getElementById('PIVA').style.display = "none";
        
        document.getElementById('CF').style.display = "block";
    }
    else
    {
        document.getElementById('RagioneSociale').style.display = "block";
        document.getElementById('PIVA').style.display = "block";
        
        document.getElementById('CF').style.display = "none";
    }
}

function EnableHtmlObj(buttonName, b)
{
    button = document.getElementById(buttonName);
    (b) ? button.disabled = false : button.enabled = true;
}