function bindComboVeiculoFC(iCodMontadora)
{
    var newOption=null;
    var ddl=null;
    var arrInterna=null;

    oCabAno		= window.document.getElementById(strIdDDDLAnoFC);
    oCabMod		= window.document.getElementById(strIdDDDLModeloFC);
    oCabVeic	= window.document.getElementById(strIdDDDLVeiculoFC);
    
    ddl = document.getElementById(strIdDDDLVeiculoFC)
    if( oCabVeic != null)
    {
        limpaSelect(oCabVeic);
        limpaSelect(oCabAno);
        limpaSelect(oCabMod);
        if(V.length>0)
        {
            oCabVeic.options.add( new Option( "--Selecione--", 0 ) );
            for(i=0;i<V.length;i++)
            {
                arrInterna = V[i].split("|");
                if(arrInterna[4] == iCodMontadora)
                {
                    oCabVeic.options.add( new Option( arrInterna[0], arrInterna[1] + "-" + arrInterna[2] + "-" + arrInterna[3]) );
                }
            }
            //oCabVeic.options.add( new Option( "---Nao sei---", 0 ) );
        }
        oCabVeic.disabled = false;
        oCabAno.disabled = true;
        oCabMod.disabled = true;
    }
    
}

function bindComboAnoFC()
{
    oCabAno		= window.document.getElementById(strIdDDDLAnoFC);
    oCabMod		= window.document.getElementById(strIdDDDLModeloFC);
    oCabVeic	= window.document.getElementById(strIdDDDLVeiculoFC);
    
    oCabAno.length=0;
    oCabMod.length=0;
    oCabMod.options.add( new Option( "--Selecione--",0 ) )

    strValueVeic = oCabVeic[oCabVeic.selectedIndex].value
    
    if( strValueVeic.length > 0 && 
        strValueVeic.indexOf("-") != strValueVeic.lastIndexOf("-") )
    {
        oCabAno.disabled = false
        try
        {
            iAnoIni = 0;
            iAnoFim = 0;
            iAnoIni = parseInt( strValueVeic.substr( strValueVeic.indexOf("-")+1, 04 ) );
            iAnoFim = parseInt( strValueVeic.substr( strValueVeic.lastIndexOf("-")+1, 04 ) );
            if( iAnoFim == 9999 )
            {
                iAnoFim = parseInt( (new Date()).getFullYear() );
                oCabAno.options.add( new Option( "----", 0 ) );
            }
            else
            {
                oCabAno.options.add( new Option( "----", 0 ) );
            }
            if( iAnoIni > 0 )
            {
                for(i=iAnoFim; i>=iAnoIni; i--)
                {
                    oCabAno.options.add( new Option( i.toString(), i ) );
                }
            }
            
        }
        catch( Err )
        {
            oCabAno.options.add( new Option( "----", 0 ) );
        }
    }
    else
    {
        oCabAno.add( new Option( "----", 0 ) );
        oCabAno.disabled = true
    }

}

function bindComboModeloFC(arg, context)
{
    arrModelo = arg.split("||");
    oCabMod		= window.document.getElementById(strIdDDDLModeloFC);
    
    if(oCabMod != null)
    {
        limpaSelect(oCabMod);
        if(arrModelo.length>0)
        {
            oCabMod.options.add( new Option( "--Selecione--", 0 ) );
            for(i=0;i<arrModelo.length;i++)
            {
                if(arrModelo[i].split("|")[0] != "")
                {
                    oCabMod.options.add( new Option( arrModelo[i].split("|")[0], arrModelo[i].split("|")[1] ) );
                }
            }
            oCabMod.options.add( new Option( "--Nao sei--", 0 ) );
            oCabMod.disabled = false;
        }
        else
        {
            oCabMod.disabled = true;
        }
    }
}

function getParametroAJAXModeloFC()
{
    oCabAno		= window.document.getElementById(strIdDDDLAnoFC);
    oCabVeic	= window.document.getElementById(strIdDDDLVeiculoFC);
    oCabMod		= window.document.getElementById(strIdDDDLModeloFC);
    
    strReturn = "";
    strReturn += oCabVeic[oCabVeic.selectedIndex].value;
    strReturn += "|";
    strReturn += oCabAno[oCabAno.selectedIndex].value;
    strReturn += "|";
    strReturn += oCabMod[oCabMod.selectedIndex].value;
    
    return strReturn;

}

function TrataErroFC(arg, context)
{
    alert('Erro' + arg);
}

function textContador(w, x, y, z, limit)
{
    var txtarea = document.getElementById(w);
    var remtxtarea = document.getElementById(x);
    var divArea = document.getElementById(y);

    remtxtarea.value = txtarea.value.length;

    divArea.style.visibility = "visible"

    if (txtarea.value.length > limit) {
        //txtarea.value = txtarea.value.substring(0, limit);
        //remtxtarea.value = -(txtarea.value.length - limit);
        document.getElementById(z).innerHTML = "&nbsp;&nbsp;<span style=\'background-color: #FF0000; color: #FFFFFF; font-weight: bold\'>&nbsp;Limite de caracteres excedido !&nbsp;</span>";
    }
    else {
        //remtxtarea.value = limit - txtarea.value.length;
        document.getElementById(z).innerHTML = "&nbsp;";
    }
}

