
function scJQGeneralAdd() {
  $('input:text.sc-js-input').listen();
  $('input:password.sc-js-input').listen();
  $('input:checkbox.sc-js-input').listen();
  $('select.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 (false == scSetFocusOnField($oField) && 0 < $("#id_ac_" + sField).length) {
    scSetFocusOnField($("#id_ac_" + sField));
  }
} // scFocusField

function scSetFocusOnField($oField) {
  if (0 < $oField.length && 0 < $oField[0].offsetHeight && 0 < $oField[0].offsetWidth && !$oField[0].disabled) {
    $oField[0].focus();
    return true;
  }
  return false;
} // scSetFocusOnField

function scEventControl_init(iSeqRow) {
  scEventControl_data["trans_title" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["trans_vat" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["env_regno" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["trans_address" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["site" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["companyphone" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["companyfax" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["response" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["responsephone" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["responsefax" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["mobile" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["email" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["remarks" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
  scEventControl_data["transperif" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": ""};
}

function scEventControl_active(iSeqRow) {
  if (scEventControl_data["trans_title" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["trans_title" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["trans_vat" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["trans_vat" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["env_regno" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["env_regno" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["trans_address" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["trans_address" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["site" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["site" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["companyphone" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["companyphone" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["companyfax" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["companyfax" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["response" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["response" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["responsephone" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["responsephone" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["responsefax" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["responsefax" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["mobile" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["mobile" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["email" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["email" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["remarks" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["remarks" + iSeqRow]["change"]) {
    return true;
  }
  if (scEventControl_data["transperif" + iSeqRow]["blur"]) {
    return true;
  }
  if (scEventControl_data["transperif" + iSeqRow]["change"]) {
    return true;
  }
  return false;
} // scEventControl_active

function scEventControl_onFocus(oField, iSeq) {
  var fieldId, fieldName;
  fieldId = $(oField).attr("id");
  fieldName = fieldId.substr(12);
  scEventControl_data[fieldName]["blur"] = true;
  scEventControl_data[fieldName]["change"] = false;
} // scEventControl_onFocus

function scEventControl_onBlur(sFieldName) {
  scEventControl_data[sFieldName]["blur"] = false;
  if (scEventControl_data[sFieldName]["change"]) {
        if (scEventControl_data[sFieldName]["original"] == $("#id_sc_field_" + sFieldName).val()) {
          scEventControl_data[sFieldName]["change"] = false;
        }
  }
} // scEventControl_onBlur

function scEventControl_onChange(sFieldName) {
  scEventControl_data[sFieldName]["change"] = false;
} // scEventControl_onChange

function scEventControl_onAutocomp(sFieldName) {
  scEventControl_data[sFieldName]["autocomp"] = false;
} // scEventControl_onChange

var scEventControl_data = {};

function scJQEventsAdd(iSeqRow) {
  $('#id_sc_field_trans_title' + iSeqRow).bind('blur', function() { sc_form_transporter_trans_title_onblur(this, iSeqRow) })
                                         .bind('focus', function() { sc_form_transporter_trans_title_onfocus(this, iSeqRow) });
  $('#id_sc_field_trans_address' + iSeqRow).bind('blur', function() { sc_form_transporter_trans_address_onblur(this, iSeqRow) })
                                           .bind('focus', function() { sc_form_transporter_trans_address_onfocus(this, iSeqRow) });
  $('#id_sc_field_trans_vat' + iSeqRow).bind('blur', function() { sc_form_transporter_trans_vat_onblur(this, iSeqRow) })
                                       .bind('focus', function() { sc_form_transporter_trans_vat_onfocus(this, iSeqRow) });
  $('#id_sc_field_companyphone' + iSeqRow).bind('blur', function() { sc_form_transporter_companyphone_onblur(this, iSeqRow) })
                                          .bind('focus', function() { sc_form_transporter_companyphone_onfocus(this, iSeqRow) });
  $('#id_sc_field_companyfax' + iSeqRow).bind('blur', function() { sc_form_transporter_companyfax_onblur(this, iSeqRow) })
                                        .bind('focus', function() { sc_form_transporter_companyfax_onfocus(this, iSeqRow) });
  $('#id_sc_field_site' + iSeqRow).bind('blur', function() { sc_form_transporter_site_onblur(this, iSeqRow) })
                                  .bind('focus', function() { sc_form_transporter_site_onfocus(this, iSeqRow) });
  $('#id_sc_field_response' + iSeqRow).bind('blur', function() { sc_form_transporter_response_onblur(this, iSeqRow) })
                                      .bind('focus', function() { sc_form_transporter_response_onfocus(this, iSeqRow) });
  $('#id_sc_field_responsephone' + iSeqRow).bind('blur', function() { sc_form_transporter_responsephone_onblur(this, iSeqRow) })
                                           .bind('focus', function() { sc_form_transporter_responsephone_onfocus(this, iSeqRow) });
  $('#id_sc_field_responsefax' + iSeqRow).bind('blur', function() { sc_form_transporter_responsefax_onblur(this, iSeqRow) })
                                         .bind('focus', function() { sc_form_transporter_responsefax_onfocus(this, iSeqRow) });
  $('#id_sc_field_mobile' + iSeqRow).bind('blur', function() { sc_form_transporter_mobile_onblur(this, iSeqRow) })
                                    .bind('focus', function() { sc_form_transporter_mobile_onfocus(this, iSeqRow) });
  $('#id_sc_field_email' + iSeqRow).bind('blur', function() { sc_form_transporter_email_onblur(this, iSeqRow) })
                                   .bind('focus', function() { sc_form_transporter_email_onfocus(this, iSeqRow) });
  $('#id_sc_field_remarks' + iSeqRow).bind('blur', function() { sc_form_transporter_remarks_onblur(this, iSeqRow) })
                                     .bind('focus', function() { sc_form_transporter_remarks_onfocus(this, iSeqRow) });
  $('#id_sc_field_env_regno' + iSeqRow).bind('blur', function() { sc_form_transporter_env_regno_onblur(this, iSeqRow) })
                                       .bind('focus', function() { sc_form_transporter_env_regno_onfocus(this, iSeqRow) });
  $('#id_sc_field_transperif' + iSeqRow).bind('blur', function() { sc_form_transporter_transperif_onblur(this, iSeqRow) })
                                        .bind('focus', function() { sc_form_transporter_transperif_onfocus(this, iSeqRow) });
} // scJQEventsAdd

function sc_form_transporter_trans_title_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_trans_title();
  scCssBlur(oThis);
}

function sc_form_transporter_trans_title_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_trans_address_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_trans_address();
  scCssBlur(oThis);
}

function sc_form_transporter_trans_address_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_trans_vat_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_trans_vat();
  scCssBlur(oThis);
}

function sc_form_transporter_trans_vat_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_companyphone_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_companyphone();
  scCssBlur(oThis);
}

function sc_form_transporter_companyphone_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_companyfax_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_companyfax();
  scCssBlur(oThis);
}

function sc_form_transporter_companyfax_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_site_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_site();
  scCssBlur(oThis);
}

function sc_form_transporter_site_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_response_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_response();
  scCssBlur(oThis);
}

function sc_form_transporter_response_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_responsephone_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_responsephone();
  scCssBlur(oThis);
}

function sc_form_transporter_responsephone_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_responsefax_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_responsefax();
  scCssBlur(oThis);
}

function sc_form_transporter_responsefax_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_mobile_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_mobile();
  scCssBlur(oThis);
}

function sc_form_transporter_mobile_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_email_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_email();
  scCssBlur(oThis);
}

function sc_form_transporter_email_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_remarks_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_remarks();
  scCssBlur(oThis);
}

function sc_form_transporter_remarks_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_env_regno_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_env_regno();
  scCssBlur(oThis);
}

function sc_form_transporter_env_regno_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function sc_form_transporter_transperif_onblur(oThis, iSeqRow) {
  do_ajax_form_transporter_validate_transperif();
  scCssBlur(oThis);
}

function sc_form_transporter_transperif_onfocus(oThis, iSeqRow) {
  scEventControl_onFocus(oThis, iSeqRow);
  scCssFocus(oThis);
}

function scJQUploadAdd(iSeqRow) {
} // scJQUploadAdd


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

