/*
     $Revision$
     $Id$
*/

$(function ()
{   // initialisatie
    $("#costlimit").change( checkLimit );
    $("#costgroup").change( change_costgroup );
});

function checkLimit(evt)
{
    evt = evt || window.event;
    var obj = evt.srcElement || evt.target;
    var limit = obj.value;
    var valid = limit == "" || (isGoodNumber(limit,true,false,8,-1)
                                && parseInt(limit, 10) >= 0
                                && parseInt(limit, 10) <= 99999999)
    validateField(obj, valid, L("lcl_prs_bad_budget"));
    return valid;
}

function change_costgroup()
{
    isMulti = $("[name=scf_multi]").length;
    if (!isMulti && $("#costgroup :selected").val() > -1)
    {
          var kpngrp_limperiode = $("#costgroup :selected")[0].getAttribute("prs_kostenplaatsgrp_limperiode");
          $("#limitperiod, #limitperiod_ro").closest("td").load("../prs/loadLimietPeriode.asp"
                                              , { fld: "limitperiod",
                                                  kpn_limietperiode: (kpngrp_limperiode > 0 ? kpngrp_limperiode : p_kpn_limietperiode),
                                                  readonly: (kpngrp_limperiode > 0 ? 1 : 0)
                                                });
    }
}
