
function scJQGeneralAdd() {
  $('input:text.sc-js-input').listen();
  $('input:password.sc-js-input').listen();
  $('textarea.sc-js-input').listen();

} // scJQGeneralAdd

function scFocusField(sField) {
  var $oField = $('#id_sc_field_' + sField);

  if (0 == $oField.length) {
    $oField = $('input[name=' + sField + ']');
  }

  if (0 == $oField.length && document.F1.elements[sField]) {
    $oField = $(document.F1.elements[sField]);
  }

  if (0 < $oField.length && 0 < $oField[0].offsetHeight && 0 < $oField[0].offsetWidth && !$oField[0].disabled) {
    $oField[0].focus();
  }
} // scFocusField

function scJQEventsAdd(iSeqRow) {
  $('#id_sc_field_receivor_' + iSeqRow).bind('blur', function() { sc_yarns_form_receivor__onblur(this, iSeqRow) })
                                       .bind('change', function() { sc_yarns_form_receivor__onchange(this, iSeqRow) })
                                       .bind('focus', function() { sc_yarns_form_receivor__onfocus(this, iSeqRow) });
  $('#id_sc_field_from_' + iSeqRow).bind('blur', function() { sc_yarns_form_from__onblur(this, iSeqRow) })
                                   .bind('change', function() { sc_yarns_form_from__onchange(this, iSeqRow) })
                                   .bind('focus', function() { sc_yarns_form_from__onfocus(this, iSeqRow) });
  $('#id_sc_field_date_' + iSeqRow).bind('blur', function() { sc_yarns_form_date__onblur(this, iSeqRow) })
                                   .bind('change', function() { sc_yarns_form_date__onchange(this, iSeqRow) })
                                   .bind('focus', function() { sc_yarns_form_date__onfocus(this, iSeqRow) });
  $('#id_sc_field_trucker_' + iSeqRow).bind('blur', function() { sc_yarns_form_trucker__onblur(this, iSeqRow) })
                                      .bind('change', function() { sc_yarns_form_trucker__onchange(this, iSeqRow) })
                                      .bind('focus', function() { sc_yarns_form_trucker__onfocus(this, iSeqRow) });
  $('#id_sc_field_blading_' + iSeqRow).bind('blur', function() { sc_yarns_form_blading__onblur(this, iSeqRow) })
                                      .bind('change', function() { sc_yarns_form_blading__onchange(this, iSeqRow) })
                                      .bind('focus', function() { sc_yarns_form_blading__onfocus(this, iSeqRow) });
  $('#id_sc_field_comments_' + iSeqRow).bind('blur', function() { sc_yarns_form_comments__onblur(this, iSeqRow) })
                                       .bind('change', function() { sc_yarns_form_comments__onchange(this, iSeqRow) })
                                       .bind('focus', function() { sc_yarns_form_comments__onfocus(this, iSeqRow) });
  $('#id_sc_field_gross_' + iSeqRow).bind('blur', function() { sc_yarns_form_gross__onblur(this, iSeqRow) })
                                    .bind('change', function() { sc_yarns_form_gross__onchange(this, iSeqRow) })
                                    .bind('focus', function() { sc_yarns_form_gross__onfocus(this, iSeqRow) });
  $('#id_sc_field_tare_' + iSeqRow).bind('blur', function() { sc_yarns_form_tare__onblur(this, iSeqRow) })
                                   .bind('change', function() { sc_yarns_form_tare__onchange(this, iSeqRow) })
                                   .bind('focus', function() { sc_yarns_form_tare__onfocus(this, iSeqRow) });
  $('#id_sc_field_net_' + iSeqRow).bind('blur', function() { sc_yarns_form_net__onblur(this, iSeqRow) })
                                  .bind('change', function() { sc_yarns_form_net__onchange(this, iSeqRow) })
                                  .bind('focus', function() { sc_yarns_form_net__onfocus(this, iSeqRow) });
  $('#id_sc_field_merge_' + iSeqRow).bind('blur', function() { sc_yarns_form_merge__onblur(this, iSeqRow) })
                                    .bind('change', function() { sc_yarns_form_merge__onchange(this, iSeqRow) })
                                    .bind('focus', function() { sc_yarns_form_merge__onfocus(this, iSeqRow) });
  $('#id_sc_field_units_' + iSeqRow).bind('blur', function() { sc_yarns_form_units__onblur(this, iSeqRow) })
                                    .bind('change', function() { sc_yarns_form_units__onchange(this, iSeqRow) })
                                    .bind('focus', function() { sc_yarns_form_units__onfocus(this, iSeqRow) });
  $('#id_sc_field_cases_' + iSeqRow).bind('blur', function() { sc_yarns_form_cases__onblur(this, iSeqRow) })
                                    .bind('change', function() { sc_yarns_form_cases__onchange(this, iSeqRow) })
                                    .bind('focus', function() { sc_yarns_form_cases__onfocus(this, iSeqRow) });
} // scJQEventsAdd

function sc_yarns_form_receivor__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_receivor_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_receivor__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_receivor__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_from__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_from_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_from__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_from__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_date__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_date_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_date__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_date__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_trucker__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_trucker_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_trucker__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_trucker__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_blading__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_blading_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_blading__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_blading__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_comments__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_comments_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_comments__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_comments__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_gross__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_gross_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_gross__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_gross__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_tare__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_tare_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_tare__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_tare__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_net__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_net_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_net__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_net__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_merge__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_merge_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_merge__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_merge__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_units__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_units_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_units__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_units__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

function sc_yarns_form_cases__onblur(oThis, iSeqRow) {
  do_ajax_yarns_form_validate_cases_(iSeqRow);
  scCssBlur(oThis, iSeqRow);
}

function sc_yarns_form_cases__onchange(oThis, iSeqRow) {
  nm_check_insert(iSeqRow);
}

function sc_yarns_form_cases__onfocus(oThis, iSeqRow) {
  scCssFocus(oThis, iSeqRow);
}

var sc_jq_calendar_value = {};

function scJQCalendarAdd(iSeqRow) {
  $("#id_sc_field_date_" + iSeqRow).datepicker({
    beforeShow: function(input, inst) {
      var $oField = $(this),
          aParts  = $oField.val().split(" "),
          sTime   = "";
      sc_jq_calendar_value["#id_sc_field_date_" + iSeqRow] = $oField.val();
    },
    onClose: function(dateText, inst) {
    },
    showWeek: true,
    numberOfMonths: 1,
    changeMonth: true,
    changeYear: true,
    yearRange: 'c-5:c+5',
    dayNames: ['<?php        echo html_entity_decode($this->Ini->Nm_lang['lang_days_sund']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_mond']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_tued']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_wend']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_thud']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_frid']);        ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_days_satd']);        ?>'],
    dayNamesMin: ['<?php     echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_sund']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_mond']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_tued']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_wend']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_thud']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_frid']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_substr_days_satd']); ?>'],
    monthNamesShort: ['<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_janu']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_febr']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_marc']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_apri']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_mayy']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_june']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_july']);   ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_augu']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_sept']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_octo']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_nove']); ?>','<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_mnth_dece']); ?>'],
    weekHeader: "<?php echo html_entity_decode($this->Ini->Nm_lang['lang_shrt_days_sem']); ?>",
    firstDay: <?php echo $this->jqueryCalendarWeekInit("" . $_SESSION['scriptcase']['reg_conf']['date_week_ini'] . ""); ?>,
    dateFormat: "<?php echo $this->jqueryCalendarDtFormat("" . str_replace(array('/', 'aaaa', $_SESSION['scriptcase']['reg_conf']['date_sep']), array('', 'yyyy', ''), $this->field_config['date_']['date_format']) . "", "" . $_SESSION['scriptcase']['reg_conf']['date_sep'] . ""); ?>",
    showOtherMonths: true,
    showOn: "button",
    buttonImage: "<?php echo $this->jqueryIconFile('calendar'); ?>",
    buttonImageOnly: true
  });

} // scJQCalendarAdd

function scJQUploadAdd(iSeqRow) {
} // scJQUploadAdd


function scJQElementsAdd(iLine) {
  scJQEventsAdd(iLine);
  scJQCalendarAdd(iLine);
  scJQUploadAdd(iLine);
} // scJQElementsAdd

