/*
     $Revision$
     $Id$
*/

function pre_submit(params)
{
    var validation_message = "";

    var kto_perc = $("#satisfactionpercentage").val();
    var herfiat_perc = $("#deviationpercentage").val();
    var herfiat_marge = $("#deviationamount").val();
    var herfiat = $("#mutationallowed").val();

    if (kto_perc && ( (parseInt(kto_perc) > 100) || (parseInt(kto_perc) < 0) ))
        validation_message += L("mgt_validation_error_1").format(L("ins_discipline_ktopercentage")) + "\n";

    if (herfiat_perc && ((parseInt(herfiat_perc) > 100) || (parseInt(herfiat_perc) < 0)))
        validation_message += L("mgt_validation_error_1").format(L("bes_discipline_herfiatpct")) + "\n";

    if (herfiat == 1 && (!herfiat_perc && !herfiat_marge))
        validation_message += L("mgt_validation_error_2").format(L("bes_discipline_herfiatpct"), L("bes_discipline_herfiatmarge")) + "\n";

    if (validation_message != "")
    {
        FcltMgr.alert(validation_message);
        return false;
    }

    if (params.isClone)
    {
      if ( confirm( L("bes_discipline_copy_auth")) )
      {
        var url_action = $("form[name=u2]").attr("action");
        url_action += "&clone_auth=1";
        $("form[name=u2]").attr("action", url_action);
      }

      if ( confirm( L("bes_discipline_copy_art")) )
      {
        var url_action = $("form[name=u2]").attr("action");
        url_action += "&clone_art=1";
        $("form[name=u2]").attr("action", url_action);
      }
    }
    return true;
}