
/**
 * Common JavaScript functions
 *
 * @author Martin Wronski
 * @copyright Copyright &copy; 2005, Martin Wronski
 * @category script
 * @access public
 */


/**
 * array of HTML objects just to speed up getting object by ID.
 */
var OBJ = new Array();

/**
 * array of fields (edit/listbox/checkbox etc) on page.
 */
var FIELDS = new Array();

/**
 * true if confirm is shown
 */
var bConfirmUp = false;

/**
 * true to block setting sys_param (and form submition)
 */
var bBlockSysParam = false;

/**
 * true to block form submit, to prevent multiple form submiting
 */
var bBlockFormSubmit = false;

/**
 * true to block Ajax request, e.g. to prevent ajax call after 'more' link click
 */
var bBlockAjaxRequest = false;

/**
 * mouse X position captured after mouse click
 */
var iMouseX = null;

/**
 * mouse Y position captured after mouse click
 */
var iMouseY = null;

/**
 * key opcode captured after mouse click.
 * 0=zoom in, 1=zoom to extent (ctrl), 2=pan(shift)
 */
var iKeyOpcode = 0;

/**
  * old bg color of component, used on exit component to restore old bg color
  */
var sCompBgC = '';

/**
 * if current skin background color is white (= not dark)
 */
var bIsBgWhite = 1;

/**
 * handling Ajax requests
 */
var XmlReqs = new Array();

/**
 * URLs that have been already requested, do not request them again
 */
var XmlReqCache = new Array();


if(window.Event) {
  document.captureEvents(Event.MOUSEDOWN);
  document.captureEvents(Event.MOUSEMOVE);
}
document.onmousedown=OnMouseDown;
document.onmousemove=OnMouseMove;



//--------------------------------------------------------------------------------------- bIsOpera
function bIsOpera() {
  return (navigator.userAgent.indexOf("Opera") >= 0) ? 1 : 0;
}

//--------------------------------------------------------------------------------------- bIsFirefox
function bIsFirefox() {
  return (navigator.userAgent.indexOf("Firefox") >= 0) ? 1 : 0;
}

//--------------------------------------------------------------------------------------- bIsInternetExplorer
function bIsInternetExplorer() {
  return (navigator.userAgent.indexOf("MSIE") >= 0) ? 1 : 0;
}

//--------------------------------------------------------------------------------------- GetObj
function GetObj(sId) {
  var obj = OBJ[sId];
  if (obj != null) {
    return obj;
  } else {
    obj = document.getElementById(sId);
    OBJ[sId] = obj;
    return obj;
  }
}

//--------------------------------------------------------------------------------------- _ps
function _ps(s) {
  var Obj = GetObj('_ps_div');
  if (Obj != null) Obj.innerHTML = Obj.innerHTML + s + "|";
}

//--------------------------------------------------------------------------------------- Go
function Go(sUrl, bNewWnd) {
  if (bNewWnd) {
    window.open(sUrl);
  } else {
    document.location.href = sUrl;
//    window.location = sUrl;
  }
}

//--------------------------------------------------------------------------------------- sGetUrlDir
function sGetUrlDir(sUrl) {
  var j = sUrl.length - 1
  for (; j >= 0; j--) {
    if (sUrl[j] == "/" || sUrl[j] == "\\") break;
  }
  return sUrl.substring(0,j+1);
}

//--------------------------------------------------------------------------------------- ereg
function ereg(regExpr, testStr) {
  if (testStr == "") return false;

  var reg = new RegExp(regExpr);
  return reg.test(testStr);
}

//--------------------------------------------------------------------------------------- LTrim
function LTrim(str) {
 for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
 return str.substring(k, str.length);
}

//--------------------------------------------------------------------------------------- RTrim
function RTrim(str) {
 for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
 return str.substring(0,j+1);
}

//--------------------------------------------------------------------------------------- Trim
function Trim(str) {
 return LTrim(RTrim(str));
}

//--------------------------------------------------------------------------------------- replace
// Replaces text with by in string
function replace(string, text, by) {
  var strLength = string.length, txtLength = text.length;
  if ((strLength == 0) || (txtLength == 0)) return string;

  var i = string.indexOf(text);
  if ((!i) && (text != string.substring(0,txtLength))) return string;
  if (i == -1) return string;

  var newstr = string.substring(0,i) + by;

  if (i+txtLength < strLength) {
    newstr += replace(string.substring(i+txtLength,strLength),text,by);
  }

  return newstr;
}

//--------------------------------------------------------------------------------------- chr
function chr(n) {
  return String.fromCharCode(n);
}

//--------------------------------------------------------------------------------------- sJoin
function sJoin(sSep, arr) {
  var str = "";
  for (var i = 0; i < arr.length; i++) {
    if (str != "") str += sSep
    str = str + arr[i];
  }
  return str
}

//--------------------------------------------------------------------------------------- sGetValuePart
function sGetValuePart(s, sSep) {
  return s.substring(s.indexOf(sSep)+1, s.length);
}
//--------------------------------------------------------------------------------------- sGetNamePart
function sGetNamePart(s, sSep) {
  var i = s.indexOf(sSep);
  if (i == -1) i = s.length;
  return s.substring(0, i);
}

//--------------------------------------------------------------------------------------- ShowConfirm
function ShowConfirm(sMsg) {
  bConfirmUp = true;
  var result = confirm(sMsg);
  bConfirmUp = false;
  if (!result) bBlockSysParam = true;
  return result;
}

//--------------------------------------------------------------------------------------- EnableAllFields
function EnableAllFields() {
  var obj;
  for (var i = 0; i < FIELDS.length; i++) {
    obj = GetObj(FIELDS[i]);
    if (obj != null) obj.disabled = false;
  }

  GetObj('sys_param').disabled = false;
}

//--------------------------------------------------------------------------------------- DisableEmptyFields
function DisableEmptyFields() {
  var obj;
  for (var i = 0; i < FIELDS.length; i++) {
    obj = GetObj(FIELDS[i]);
    if (obj == null) continue;

    if (obj.tagName == 'INPUT' && obj.value == '') {
      obj.disabled = true;
    }
    if (obj.tagName == 'SELECT' && obj.value == '') {
      obj.disabled = true;
    }
  }

  obj = GetObj('sys_param');
  if (obj.value == '') obj.disabled = true;
}

//--------------------------------------------------------------------------------------- RunScriptTimer
function RunScriptTimer() {
  bBlockSysParam = false;
  EnableAllFields();
  setTimeout('RunScriptTimer()', 2000);
}

//--------------------------------------------------------------------------------------- OnFormSubmit
function SubmitForm(bValidate) {
  bValidate = typeof(bValidate) != 'undefined' ? bValidate : true;
  if (!bValidate) ClearSysParam();

  if (bBlockFormSubmit == true) return ;
  bBlockFormSubmit = true;

  DisableEmptyFields();
  document.frmMain.submit();
}

//--------------------------------------------------------------------------------------- OnFormSubmit
function OnFormSubmit() {
  if (bBlockFormSubmit == true) return false;
  bBlockFormSubmit = true;

  DisableEmptyFields();

  return true;
}

//--------------------------------------------------------------------------------------- ListColumnClick
function ListColumnClick(sField, sListId, bAllowSort) {
  if (bIsClickWithShift()) {
    var Collapsed = GetObj(sListId + 'collapsed');
    var FIELDS = Collapsed.value.split(',');
    var bFound = false;
    var sNew = '';
    for (var i = 0; i < FIELDS.length; i++) {
      if (FIELDS[i] == sField) {
        bFound = true;
      } else {
        if (FIELDS[i] != '') sNew = sNew + FIELDS[i] + ',';
      }
    }
    if (bFound == false) sNew += sField;
    Collapsed.value = sNew;
    SubmitForm();
  } else {
    if (bAllowSort) {
      var SortField = GetObj(sListId + 'sf');
      var SortOrder = GetObj(sListId + 'so');

      if (SortField.value != sField) {
        SortField.value = sField;
      } else {
        SortOrder.value = (SortOrder.value == 'desc') ? 'asc' : 'desc';
      }
      SubmitForm();
    }
  }
}

//--------------------------------------------------------------------------------------- ChangePage
function ChangePage(iSelPage, sListId) {
  var Page = GetObj(sListId + 'pg');
  Page.value = iSelPage;
  ClearSysParam();
  DisableEmptyFields();
  SubmitForm();
}

//--------------------------------------------------------------------------------------- SetSysParam
function SetSysParam(sParam, sValue, Obj, bBlockSubmit) {
  bBlockSubmit = typeof(bBlockSubmit) != 'undefined' ? bBlockSubmit : true;
  if (bBlockSysParam) return;
  SetSysParamValue(sParam, sValue, Obj)
  DisableEmptyFields();
  SubmitForm();
  if (!bBlockSubmit) bBlockFormSubmit = false;
}

//--------------------------------------------------------------------------------------- SetSysParamValue
function SetSysParamValue(sParam, sValue, Obj) {
  var SysParam = GetObj('sys_param');
  SysParam.value = sParam +"="+ sValue;
//alert(Obj.tagName +"|"+ sParam +"="+ sValue);
}

//--------------------------------------------------------------------------------------- ClearSysParam
function ClearSysParam() {
  if (bConfirmUp) return;
  var Obj = GetObj('sys_param');
  Obj.value = "";
}

//--------------------------------------------------------------------------------------- ShowTableRows
function SetFormView(sFormId, sRows, sView) {
  if (sView == 'simple') {
    HideTableRows(sFormId + 'sep_ftr', sRows);
    HideTableRows(sFormId + 'ftr', sRows);
    GetObj(sFormId + 'trViewModeSimple').style.display = 'none';
    GetObj(sFormId + 'trViewModeFull').style.display = '';
    GetObj(sFormId + 'vm').value = 'simple';
  }
  if (sView == 'full') {
    ShowTableRows(sFormId + 'sep_ftr', sRows);
    ShowTableRows(sFormId + 'ftr', sRows);
    GetObj(sFormId + 'trViewModeSimple').style.display = '';
    GetObj(sFormId + 'trViewModeFull').style.display = 'none';
    GetObj(sFormId + 'vm').value = 'full';
  }
}

//--------------------------------------------------------------------------------------- ShowTableRows
// may be used not ony for table TRs
function ShowTableRows(sTrPrefix, sRows) {
  var ROWS = sRows.split('_');
  for (var i = 0; i < ROWS.length; i++) {
    var ob = GetObj(sTrPrefix + ROWS[i]);
    if (ob != null) ob.style.display = '';
  }
}

//--------------------------------------------------------------------------------------- HideTableRows
// may be used not ony for table TRs
function HideTableRows(sTrPrefix, sRows) {
  var ROWS = sRows.split('_');
  for (var i = 0; i < ROWS.length; i++) {
    var ob = GetObj(sTrPrefix + ROWS[i]);
    if (ob != null) ob.style.display = 'none';
  }
}

//---------------------------------------------------------------------------------------- iGetInt
function iGetInt(iNum) {
  str = new String(iNum);
  str = replace(str, ' ', '');
  return parseInt(str);
}

//--------------------------------------------------------------------------------------- checkdate
function checkdate(d, m, y) {
  if (y.length == 2)
    y = "20" + y;

  var yl=1950;   // least year to consider
  var ym=2020;   // most year to consider
  if (m<1 || m>12)  return(false);
  if (d<1 || d>31)  return(false);
  if (y<yl || y>ym) return(false);
  if (m==4 || m==6 || m==9 || m==11)
  if (d==31) return(false);
  if (m==2)
  {
    var b=parseInt(y/4);
    if (isNaN(b)) return(false);
    if (d>29)     return(false);
    if (d==29 && ((y/4)!=parseInt(y/4))) return(false);
  }
  return(true);
}

//--------------------------------------------------------------------------------------- MakeDate
function MakeDate(d, m, y) {
  if (y.length == 2)
    y = "20" + y;

  if (m.length == 1)
    m = "0" + m;

  if (d.length == 1)
    d = "0" + d;

  return y + "-" + m + "-" + d;
}

//--------------------------------------------------------------------------------------- MakeModeDate
/*
 mode:
 1 - isDate
 2 - Date2DB
 3 - DateFormat
 */
function MakeModeDate(mode, d, m, y) {
  if (checkdate(d, m, y))
    switch (mode) {
      case 1:return true;break;
      case 2:;
      case 3: return MakeDate(d, m, y); break;
      default: alert("Zly 'mode' w MakeModeDate: " + mode);
    }
  else {
    switch (mode) {
      case 1:return false;break;
      case 2:return "";  break;
      case 3:return "???";break;
      default: alert("Zly 'mode' w MakeModeDate: " + mode);
    }
  }
}

//--------------------------------------------------------------------------------------- GetModeDate
function GetModeDate(i, mode) {
  if (i == "") {
    switch (mode) {
      case 1:return true; break;
      case 2:return "";   break;
      case 3:return "???";break;
    }
  }

  if (ereg("^[0-9]{4}[.-][0-9]{1,2}[.-][0-9]{1,2}$", i)) {  // 2005-01-22
    var tab = i.split(i.substr(4, 1));
    return MakeModeDate(mode, tab[2], tab[1], tab[0]);
  }
  if (ereg("^[0-9]{1,2}[.-][0-9]{1,2}[.-][0-9]{4}$", i)) {  // 22-01-2005
    var tab = i.split(i.substr(i.length-5, 1));
    return MakeModeDate(mode, tab[0], tab[1], tab[2]);
  }
  if (ereg("^[0-9]{2}[.-][0-9]{1,2}[.-][0-9]{1,2}$", i)) {  // 05-01-22
    var tab = i.split(i.substr(2, 1));
    return MakeModeDate(mode, tab[2], tab[1], tab[0]);
  }
  if (ereg("^[0-9]{8}$", i)) {                // 20050122
    y = i.substr(0, 4);
    m = i.substr(4, 2);
      d = i.substr(6, 2);
    return MakeModeDate(mode, d, m, y);
  }

  switch (mode) {
    case 1:return false; break;
    case 2:return "";    break;
    case 3:return "???"; break;
  }
}

//--------------------------------------------------------------------------------------- sFormatDate
function sFormatDate(sDate) {
  return GetModeDate(sDate, 3);
}
//--------------------------------------------------------------------------------------- bIsDateValid
function bIsDateValid(sDate) {
  return GetModeDate(sDate, 1);
}

//--------------------------------------------------------------------------------------- bIsLeapYear
function bIsLeapYear(iYear) {
  if ((iYear % 400) == 0 ) {
    return true;
  } else {
    if ((iYear % 100) == 0) {
      return false;
    } else {
      if ((iYear % 4) == 0) {
        return true;
      } else {
        return false;
      }
    }
  }
}

//--------------------------------------------------------------------------------------- bIsNumber
function bIsNumber(n) {
  var RegExp = /^[0-9\.\-\ ]+$/g;
  var sNum = new String(n);
  return RegExp.test(sNum);
}

//--------------------------------------------------------------------------------------- bIsClickWithCtrl
function bIsClickWithCtrl() {
  return ((iKeyOpcode & 1) > 0) ? true : false;
}
//--------------------------------------------------------------------------------------- bIsClickWithShift
function bIsClickWithShift() {
  return ((iKeyOpcode & 2) > 0) ? true : false;
}

//--------------------------------------------------------------------------------------- GetMousePos
function GetMousePos(e) {
  if(typeof(e)=='undefined') e=window.event||window.Event;

/*
  if ( typeof(e.offsetX)!='undefined' ) {
    iMouseX = e.offsetX;
    iMouseY = e.offsetY;
  } else if(typeof(e.layerX)!='undefined') {
   iMouseX = e.layerX;
   iMouseY = e.layerY;
  }*/

  if (document.all) { // grab the x-y pos.s if browser is IE
    iMouseX = event.clientX + document.body.scrollLeft
    iMouseY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    iMouseX = e.pageX
    iMouseY = e.pageY
  }

  if (iMouseX < 0) iMouseX = 0;   // catch possible negative values in NS4
  if (iMouseY < 0) iMouseY = 0;
}

//--------------------------------------------------------------------------------------- OnMouseMove
function OnMouseMove(e) {
  if(typeof(e)=='undefined') e=window.event||window.Event;
  GetMousePos(e);
}

//--------------------------------------------------------------------------------------- OnMouseDown
function OnMouseDown(e) {

  iKeyOpcode = 0;

  if(typeof(e)=='undefined') e=window.event||window.Event;

  GetMousePos(e);

  if (typeof(e.ctrlKey) != 'undefined') {
    if (e.ctrlKey)  iKeyOpcode |= 1;
    if (e.shiftKey) iKeyOpcode |= 2;
  } else {
   if (e.modifiers & Event.CONTROL_MASK) iKeyOpcode |=1;
   if (e.modifiers & Event.SHIFT_MASK) iKeyOpcode |= 2;
  }
//alert("iKeyOpcode="+iKeyOpcode+" "+iMouseX+ "x"+iMouseY);
}

//--------------------------------------------------------------------------------------- iGetControlKeyCode
function iGetControlKeyCode(e) {
  e = e || window.event;
  var code = e.keyCode || e.which;
  return code;
}

//--------------------------------------------------------------------------------------- ClearSelect
function ClearSelect(SelectId) {
  var elSel = GetObj(SelectId);
  while (elSel.length > 0) {
    elSel.remove(elSel.length - 1);
  }
}

//--------------------------------------------------------------------------------------- RemoveOptionLastEmpty
function RemoveOptionLastEmpty(SelectId) {
  var elSel = GetObj(SelectId);
  if (elSel.length > 0 && elSel.options[elSel.length - 1].key == '') {
    elSel.remove(elSel.length - 1);
  }
}

//--------------------------------------------------------------------------------------- AppendOptionLast
function AppendOptionLast(SelectId, Key, Text) {
  var sSelKey = eval(SelectId + '_key');
  var elOptNew = document.createElement('option');
//  if (sSelKey == Key) elOptNew.selected = true;     // doesnt work in Opera
  elOptNew.text = Text;
  elOptNew.value = Key;

  var elSel = GetObj(SelectId);
  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }

  if (sSelKey == Key) elSel.selectedIndex = 1*elSel.length - 1;

}


//--------------------------------------------------------------------------------------- XmlReqCreate
function XmlReqCreate(freed) {
  this.freed = freed;
  this.xmlhttp = false;
  if (window.XMLHttpRequest) {
    this.xmlhttp = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
}

//--------------------------------------------------------------------------------------- XmlReqGet
function XmlReqGet(url, sPanelName, bUseCache) {
  bUseCache = typeof(bUseCache) != 'undefined' ? bUseCache : true;

  if (bUseCache) {
    if (XmlReqCache[url]) return;
    XmlReqCache[url] = true;
  }

  var pos = -1;
  for (var i=0; i < XmlReqs.length; i++) {
    if (XmlReqs[i].freed == 1) { pos = i; break; }
  }
  if (pos == -1) { pos = XmlReqs.length; XmlReqs[pos] = new XmlReqCreate(1); }
  if (XmlReqs[pos].xmlhttp) {
    XmlReqs[pos].panel = (sPanelName != "") ? GetObj(sPanelName) : null;
    XmlReqs[pos].freed = 0;
    XmlReqs[pos].xmlhttp.open("GET",url,true);
    XmlReqs[pos].xmlhttp.onreadystatechange = function() {
      if (typeof(XmlHttpChange) != 'undefined') { XmlHttpChange(pos); }
    }
    if (window.XMLHttpRequest) {
      XmlReqs[pos].xmlhttp.send(null);
    } else if (window.ActiveXObject) {
      XmlReqs[pos].xmlhttp.send();
    }
  }
}

//--------------------------------------------------------------------------------------- XmlReqPost
function XmlReqPost(url, data, sPanelName, bUseCache) {
  bUseCache = typeof(bUseCache) != 'undefined' ? bUseCache : true;

  if (bUseCache) {
    if (XmlReqCache[url]) return;
    XmlReqCache[url] = true;
  }

  var pos = -1;
  for (var i=0; i < XmlReqs.length; i++) {
    if (XmlReqs[i].freed == 1) { pos = i; break; }
  }
  if (pos == -1) { pos = XmlReqs.length; XmlReqs[pos] = new XmlReqCreate(1); }
  if (XmlReqs[pos].xmlhttp) {
    XmlReqs[pos].panel = (sPanelName != "") ? GetObj(sPanelName) : null;
    XmlReqs[pos].freed = 0;
    XmlReqs[pos].xmlhttp.open("POST",url,true);
    XmlReqs[pos].xmlhttp.onreadystatechange = function() {
      if (typeof(XmlHttpChange) != 'undefined') { XmlHttpChange(pos); }
    }
    XmlReqs[pos].xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    XmlReqs[pos].xmlhttp.send(data);
  }
}

//--------------------------------------------------------------------------------------- XmlHttpChange
function XmlHttpChange(pos) {
  if (typeof(XmlReqs[pos]) != 'undefined' && XmlReqs[pos].freed == 0) {
    if (XmlReqs[pos].panel == null) alert('No Ajax panel');
    if (XmlReqs[pos].xmlhttp.readyState == 4) {
      if (XmlReqs[pos].xmlhttp.status == 200 || XmlReqs[pos].xmlhttp.status == 304) {

        XmlReqs[pos].panel.style.textAlign = "";
        XmlReqs[pos].panel.style.height = "";
        XmlReqs[pos].panel.style.paddingTop = "";
        XmlReqs[pos].panel.innerHTML = XmlReqs[pos].xmlhttp.responseText;
/* how to exec returned JS ?!
        var Scripts = XmlReqs[pos].panel.getElementsByTagName("script");
        for (var i = 0; i < Scripts.length; i++) {
          eval(Scripts[i].text);
        }
*/
      } else {
//        alert('Ajax error');
      }
      XmlReqs[pos].freed = 1;

    } else if (XmlReqs[pos].xmlhttp.readyState <= 2) {  // 2 for Opera
      XmlReqs[pos].panel.style.textAlign = "center";
      XmlReqs[pos].panel.style.paddingTop = "100";
      XmlReqs[pos].panel.style.height = "300px";
      XmlReqs[pos].panel.innerHTML = "<IMG src='pub/graph/"+(bIsBgWhite ? "def":"dark")+"/loading_big.gif'>";
    }
  }
}

function TrHlOn(v) {
  v.className = 'list_tr_over';
}

function TrHlOff(v, n) {
  v.className = (n % 2) ? 'list_tr_dark' : 'list_tr';
}

function ThHlOn(v) {
  v.className = 'list_th_over';
}

function ThHlOff(v) {
  v.className = 'list_th';
}

//--------------------------------------------------------------------------------------- SliderEditOnChange
function SliderEditOnChange(edit) {
  var Slider = eval("Slider"+ edit.id);
  if (bIsNumber(edit.value)) {
    if (Slider.old_value != edit.value) {
      Slider.setValue(iGetInt(edit.value));
      Slider.old_value = edit.value;
    }
  }
}

//--------------------------------------------------------------------------------------- SliderChangeValue
function SliderChangeValue(id, iDelta) {
  var Slider = eval("Slider"+id);
  Slider.setValue(Slider.value + iDelta);
}

//--------------------------------------------------------------------------------------- SliderOnChange
function SliderOnChange(value) {
  GetObj(this.edit_id).value = Math.round(iGetInt(value));
}

//--------------------------------------------------------------------------------------- SliderOnSlide
function SliderOnSlide(value) {
  GetObj(this.edit_id).value = Math.round(iGetInt(value));
}

//--------------------------------------------------------------------------------------- ClearSelection
function ClearSelection() {
  if (bIsInternetExplorer()) {
    document.selection.clear();
  } else {
    window.getSelection().removeAllRanges();
  }
}

//--------------------------------------------------------------------------------------- *** MAPBOX ***
var iMapBoxMouseX = 0;
var iMapBoxMouseY = 0;
var bMapBoxIsDown = 0;

//--------------------------------------------------------------------------------------- MapBoxMouseDown
function MapBoxMouseDown(o) {
//  bMapBoxIsDown = (bMapBoxIsDown == 1) ? 0 : 1;
  bMapBoxIsDown = 1;

  o.className = (bMapBoxIsDown == 1) ? 'mapbox_move' : 'mapbox';

  if (!bIsFirefox()) {
    e=window.event||window.Event;
    GetMousePos(e);
  }

  iMapBoxMouseX = iMouseX;
  iMapBoxMouseY = iMouseY;
}

//--------------------------------------------------------------------------------------- MapBoxMouseUp
function MapBoxMouseUp(o) {
  bMapBoxIsDown = 0;
  o.className = 'mapbox';
}

//--------------------------------------------------------------------------------------- MapBoxMouseMove
function MapBoxMouseMove(o, Speed) {
  var X = 0;
  var Y = 0;
  if (bMapBoxIsDown == 1) {
    if (!bIsFirefox()) {
      e=window.event||window.Event;
      GetMousePos(e);
    }

    o.scrollTop += (iMapBoxMouseY - iMouseY) * Speed;
    o.scrollLeft += (iMapBoxMouseX - iMouseX) * Speed;
    iMapBoxMouseX = iMouseX;
    iMapBoxMouseY = iMouseY;

    ClearSelection();
  }
}
