﻿
// -- AJAX -----------------------------------------------------------------------------------
var ui_wrap = null;

function ui_init() {
  if (ui_wrap) {
    return true;
  } else {
    ui_wrap = Bashneft.Controls.Scripts;
    if (ui_wrap) {
      return true;
    } else {
      alert("ui_init(): admin UI not avaiable");
    }
  }
}

function ui_status(method, data, status) {
  if (status=="success") {
    if (data) {
      if (data.Succeed) {
        return true;
      } else {
        alert(method+"(): " + data.Exception.Message);
        return false;
      }
    } else {
      alert(method+"(): AJAX data have not received");
      return false;
    }
  } else {
    alert(method+"(): AJAX status '" + status + "' have received");
    return false;
  }
}

function ui_set_pager_size(pager_name, size) {
    if(ui_init()) {
      function __callback(data, status) {
        if (ui_status("ui_set_pager_size", data, status)) {
           var url=window.location.toString();
           var reg=/&?[a-z]*page=[0-9]+/;
           window.location=url.replace(reg, "");
        }
      }
      ui_wrap.SetPagerSize(pager_name, size, __callback);
    }
}


// -- TABLE ----------------------------------------------------------------------------------
jQuery(document).ready(function() {
  jQuery(".table_alt > tbody > tr:odd").each(function() {
    jQuery(this).addClass("alt");
  });

  //jQuery("table.table2 tr").removeClass("alt");
  jQuery("table tr.title").removeClass("alt");
  jQuery("table tr.spacer").removeClass("alt");
});
//#div_pager_items

// -- HEIGHT FIX -----------------------------------------------------------------------------
jQuery(document).ready(function() {
  function fix_height() {
    j_h = jQuery(document).height() - 202;
    j_ie = jQuery(document).height() - 208;
    jQuery("div.maincontent").css("min-height",j_h)
    window.setTimeout(fix_height, 500);
    if ((jQuery.browser.msie) && (jQuery.browser.version == 6)) {
      j_h_maincontent = 0;
      jQuery("div.maincontent > div").each(function() {
        j_h_temp = jQuery(this).height();
        j_h_maincontent = j_h_maincontent + j_h_temp;
      });
      if (j_ie > j_h_maincontent)
        jQuery("div.maincontent").css("height",j_ie)
    }
  }
  fix_height();
});
