/*<![CDATA[*/
<!--

// ARXEION-XML
// Copyright (c) HYPERSYSTEMS Ltd.

var lovw;
var printWin;
var helpWin;
var panes = new Array();
var lovitem;
var lovform;
var lovchilditem;

var debugContent;
var debugTitle;

var dtree;

var highlightState = true;

var _checkedEntryId = 'entry_id-1';

var textPaging = '';

_d = function(e) { return(document.getElementById(e)); };
_c = function(e) { return(document.createElement(e)); };
_t = function(e) { return(document.getElementsByTagName(e)); };
_c_c = function(e) {return(String.fromCharCode(e)); };

var _vns = '0123456789' + _c_c(8) + _c_c(9) + _c_c(13) + _c_c(37) + _c_c(39) + _c_c(49) + _c_c(46);
var _vnsd = _vns + './-';

var _frm;
var _w = window;
var _doc = document;
var _p = window.parent;

var _d_b = '/arxeion-xml/';
var _d_s = _d_b + 'static/im/';

function scp(o, cp) 
{
  if (document.selection) 
  {
    o.focus();
    var s = document.selection.createRange();
    s.moveStart('character', -o.value.length);
    s.moveStart('character', cp);
    s.moveEnd('character', 0);
    s.select();
  }
  else if (o.selectionStart || o.selectionStart == '0') 
  {
    o.selectionStart = cp;
    o.selectionEnd = cp;
    o.focus ();
  }
}

function gcp(o) 
{
  var cp = 0;

  if (document.selection)
  {
    o.focus ();
    var s = document.selection.createRange();
    s.moveStart ('character', -o.value.length);
    cp = s.text.length;
  }
  else if (o.selectionStart || o.selectionStart == '0')
  {
    cp = o.selectionStart;
  }
  return(cp);
}

function ARXCheckDate(e, field) 
{
  var f = _d(field);
  var key;
  
  if(window.event || !e.which) // IE
      key = e.keyCode; // IE
  else if(e)
      key = e.which;   // Netscape
  else
      return true;     // no validation 
    
  if (_vnsd.indexOf(_c_c(key)) < 0)
  {
    return(false);
  }

  if (key == 46 || key == 45 || key == 47)
  {
    var m = f.value.match(/\//g);
      
    if (m != null && m.length > 1)
    {
      return(false);
    }
    f.value += '/';
    return(false);
  }
}

function ARXTextCounter(field, countfield, maxlimit) 
{
  var f = _d(field);
  var c = _d(countfield);
  
  if (f.value.length > maxlimit)
  {
    f.value = f.value.substring(0, maxlimit);
    return;
  }
  if (countfield != '')
  {
    var t = document.createTextNode(f.value.length + ' / ' + maxlimit + ARX_MSG_07);
    var fc = c.firstChild;
    if (fc != null)
    {
      c.removeChild(fc);
    }
    c.appendChild(t);
  }
}

function ARXFilesObjectLoaded() 
{
  _d('activex-files').SetDocumentObject(document);
}

function ARXCreatePaging2(totalRows, totalPages, rowsPerPage, currentPage, selElement, from) 
{
  var option, text, t;
  var elm = document.getElementById(selElement);

  for (i = 1; i <= totalPages; i++)
  {
    option = document.createElement('option');
    option.setAttribute('value', i);
    if (currentPage == i)
    {
      option.setAttribute('selected', 'selected');
    }
    t = (i - 1)*rowsPerPage;
    if (i < totalPages)
    {
      option.appendChild(document.createTextNode((t + 1) + ' - ' + (t + rowsPerPage) + ' ' + from + ' ' + totalRows));
    }
    else
    {
      option.appendChild(document.createTextNode((t + 1) + ' - ' + totalRows + ' ' + from + ' ' + totalRows));      
    }
    elm.appendChild(option);
  }
}

function ARXCreatePaging(totalRows, totalPages, rowsPerPage, currentPage, selElement, from)
{
  var t = 0;
  var elm = _d(selElement);
  var text = '';
  
  if (textPaging != '') {
    document.write(textPaging);
    textPaging = '';
    return;
  }
  for (var i = 1; i <= totalPages; i++) {
    if (currentPage == i) text += '<option value="' + i + '" selected="selected">'; else text += '<option value="' + i + '">';
    t = (i - 1)*rowsPerPage;
    if (i < totalPages) text += (t + 1) + ' - ' + (t + rowsPerPage) + ' ' + from + ' ' + totalRows + '</option>'; else text += (t + 1) + ' - ' + totalRows + ' ' + from + ' ' + totalRows + '</option>';
  }
  document.write(text);
  textPaging = text;
}

function ARXShowMarkup() 
{
  ARXChangeCSS('SPAN.highlight', 'backgroundColor', 'yellow', window.frames['markup']);
  ARXChangeCSS('span.highlight', 'backgroundColor', 'yellow', window.frames['markup']);
  ARXChangeCSS('A.markup', 'display', 'inline', window.frames['markup']);
  ARXChangeCSS('a.markup', 'display', 'inline', window.frames['markup']);
  if (document.getElementById('img-markup-off'))
  {
    _d('img-markup-off').style.display = 'none';
    _d('img-markup-on').style.display = 'inline';
  }
  highlightState = true;
}

function ARXHideMarkup() 
{
  ARXChangeCSS('SPAN.highlight', 'backgroundColor', 'white', window.frames['markup']);
  ARXChangeCSS('span.highlight', 'backgroundColor', 'white', window.frames['markup']);
  ARXChangeCSS('A.markup', 'display', 'none', window.frames['markup']);
  ARXChangeCSS('a.markup', 'display', 'none', window.frames['markup']);
  
  if (document.getElementById('img-markup-off'))
  {
    _d('img-markup-off').style.display = 'inline';
    _d('img-markup-on').style.display = 'none';
  }
  highlightState = false;
}

function ARXHideDocument() {
  var ifrm = window.frames['markup'];
  ifrm.document.location = _d_s + 'nothing.html';
}

function ARXResizeIFRAME(frame, browser) {


  var frm = document.getElementById(frame);
  var ifrm = window.frames[frame];
  var getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
  var FFextraHeight = getFFVersion >= 0.1 ? 16 : 0;


  if (ifrm.document.location.pathname == _d_s + 'nothing.html')
  { 
    _d('img-markup-hide').style.visibility = 'hidden';
    frm.style.display = 'none';
    document.body.style.display = 'none';
    document.body.style.display = 'block';
    
    _d('img-markup-disable').style.display = 'inline';
    if (_d('img-markup-off'))
    {
      _d('img-markup-off').style.display = 'none';
      _d('img-markup-on').style.display = 'none';
    }
  }
  else
  {

    if (browser != 'msie')
    {
      frm.style.display = 'block';
      frm.style.height = (ifrm.document.body.scrollHeight + 25) + 'px';
      frm.style.display = 'none';
      document.body.style.display = 'none';
      document.body.style.display = 'block';
      frm.style.display = 'block';
    }
    else
    {
      frm.style.display = 'block';
      frm.style.height  = (ifrm.document.body.scrollHeight + 25) + 'px';
      document.body.style.display = 'none';
      document.body.style.display = 'block';
    }
    if (highlightState)
    {
      ARXShowMarkup();
    }
    else
    {
      ARXHideMarkup();
    }
    _d('img-markup-hide').style.visibility = '';
    _d('img-markup-disable').style.display = 'none';
  }
}

function ARXDataEntry(e, type, min, max) {
    var k;
  
    if(window.event || !e.which)
        k = e.keyCode;
    else if(e)
        k = e.which;
    else
        return(true);
    
    if (_vns.indexOf(_c_c(k)) < 0)
    {
      return(false);
    }
    return(true);    
}

function ARXDataEntryText(e, s, l) {
    var k;
  
    if(window.event || !e.which)
        k = e.keyCode;
    else if(e)
        k = e.which;
    else
        return(true);

    if (s == 'no' && k == 32)
    {
      return(false);
    }
    if (l == 'en' && k > 122)
    {
      return(false);
    } 
    if (c == 'upper')
    {
      return(String.fromCharCode(k).toUpperCase().charCodeAt(0));
    }

    return(true);    
}

function ARXDataEntryCase(e, c) {
    var f = _d(e);

    if (c == 'upper')
    {
      f.value = f.value.toUpperCase();
    }
    else if (c == 'lower')
    {
      f.value = f.value.toLowerCase();
    }
}

function isDateValid(f)
{
  var v = f.value;
  var matches = v.match(/\//g);
  
  if (matches == null || matches.length < 2)
  {
    return(false);
  }
  var a = v.split('/');
  if (a[0].length == 0 || a[1].length == 0 || a[2].length == 0)
  {
    return(false);
  }
  if (a[0].length > 2 || a[1].length > 2)
  {
    return(false);
  }
  
  if (parseInt(a[0], 10) > 31 || parseInt(a[1], 10) > 12 || parseInt(a[0], 10) == 0 || parseInt(a[1], 10) == 0 || parseInt(a[2], 10) == 0)
  {
    return(false);
  }
  
  if (v.length < 10)
  {
    if (a[0].length == 1)
    {
      f.value = '0' + a[0] + '/' + a[1] + '/' + a[2];
    }
    if (f.value.length < 10)
    {
      if (a[1].length == 1)
      {
        f.value = a[0] + '/0' + a[1] + '/' + a[2];
      }
    }
    if (f.value.length < 10)
    {
      if (a[2].length == 3)
      {
        f.value = a[0] + '/' + a[1] + '/0' + a[2];
      }
      else if (a[2].length == 2)
      {
        f.value = a[0] + '/' + a[1] + '/00' + a[2];
      }
      else if (a[2].length == 1)
      {
        f.value = a[0] + '/' + a[1] + '/000' + a[2];
      }        
    }    
  }
  var dt = new Date(a[1] + '/' + a[0] + '/' + a[2]);
  if((dt.getMonth() + 1) == parseInt(a[1], 10))
  {
    return(true);
  }
  else
  {
    return(false);
  }
}

function _rtrim(s)
{
  if (s == null || s.length == 0)
  {
    return('');
  }
  while(s.substring(s.length-1, s.length) == ' ')
  {
    s = s.substring(0, s.length - 1);
  }
  return(s);
}

function ARXCheckFormItems(func) {
  var type, e;

    
  if (func != null)
  {
    if (!func())
    {
        return(false);
    }
  }
  
  if (!window.ARXSetValidation)
    return(true);
  ARXSetValidation();
  
  for (i = 0; i < _frm.length; i++) 
  { 
    e = _frm.elements[i];
    e.value = _rtrim(e.value);
    t = e.type;
    
    if ((t == 'text') && e.value != '')
    {
      if (e.date) 
      {
        if (!isDateValid(e)) {
          alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_08);
          return(false);
        }
        else if (e.min && e.max)
        {
          var a = e.min.split('/');
          var d1 = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          var a = e.max.split('/');
          var d2 = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          var a = e.value.split('/');
          var d = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          if (!(d >= d1 && d <= d2))
          {
            alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_09 + e.min + ARX_MSG_05 + e.max + '!');
            return(false);            
          }
        }
        else if (e.min)
        {
          var a = e.min.split('/');
          var d1 = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          var a = e.value.split('/');
          var d = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          if (d < d1)
          {
            alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_10 + e.min + '!');
            return(false);            
          }
        }
        else if (e.max)
        {
          var a = e.max.split('/');
          var d1 = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          var a = e.value.split('/');
          var d = new Date(a[1] + '/' + a[1] + '/' + a[2]);
          if (d > d1)
          {
            alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_11 + e.max + '!');
            return(false);            
          }
        }          
      }
      else if (e.min && e.max) 
      {
        var __v = parseInt(e.value);
        if (__v < e.min || __v > e.max) {
          alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_04 + e.min + ARX_MSG_05 + e.max);
          return(false);
        }
      }
      else if (e.min) 
      {
        if (parseInt(e.value) < e.min) {
          alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_01 + e.min + ARX_MSG_02);
          return(false);
        }
      }
      else if (e.max) 
      {
        if (parseInt(e.value) > e.max) {
          alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_01 + e.min + ARX_MSG_03);
          return(false);
        }
      }
    }

    if(e.id != '' && !e.optional) {
      
      if ((t == 'text' || t == 'textarea' || t == 'select-one') && e.value == '') {
        alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_06);
        return(false);
      }
      if (t == 'select-multiple' && e.options.length == 0) {
        alert('[ ' + ARXGetLabelText(e.id) + ' ] ' + ARX_MSG_06);
        return(false);
      }      
    }
  }
  return(true);
}

function ARXGetLabelText(id) {
  var l = _d('label-' + id);
  var t = '';
  if (l) {
    for (z = 0; z < l.childNodes.length; z ++)
      if (l.childNodes[z].nodeValue)
        t += l.childNodes[z].nodeValue + ' ';
  }
  return(t);
}

function ARXList(el) {
  var td;
  var tr = el.parentNode.getElementsByTagName('tr');

  for (i = 0; i < tr.length; i ++) {
    if(tr[i].getElementsByTagName('td')[1].className == 'select-row') {
      tr[i].getElementsByTagName('td')[1].className = '';
      break;
    }
  }
  el.getElementsByTagName('td')[1].className = 'select-row';
}

function ARXListAdd(item_name) {
  var values = document.getElementById(item_name);
  var s1 = document.getElementById(item_name + '-selecting').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
  var s2 = document.getElementById(item_name + '-selected').getElementsByTagName('tbody')[0];
  var i;

  for (i = 0; i < s1.length; i ++) {
    if(s1[i].getElementsByTagName('td')[1].className == 'select-row' &&  s1[i].style.display != 'none') {
      var option = document.createElement('option');
      option.setAttribute('value', s1[i].getAttribute('id'));
      values.appendChild(option);      
      var el = s1[i].cloneNode(true);
      el.setAttribute('id', '_' + el.getAttribute('id'));
      s2.appendChild(el);
      ARXList(el);
      s1[i].style.display = 'none';
      break;
    }
  }
}

function ARXListDelete(item_name) {
  var values = document.getElementById(item_name);
  var selectedList = document.getElementById(item_name + '-selected').getElementsByTagName('tbody')[0];
  var s1 = selectedList.getElementsByTagName('tr');
  var i, y, id;
  
  for (i = 0; i < s1.length; i ++) {
    if(s1[i].getElementsByTagName('td')[1].className == 'select-row') {
      id = s1[i].getAttribute('id').substr(1, s1[i].getAttribute('id').length);
      ARXDomMakeEmptyElement(s1[i]);
      selectedList.removeChild(s1[i]);
      for (y = 0; y < values.options.length; y++) {
        if (values.options[y].value == id) {
          values.removeChild(values.options[y]);
          break;
        }
      }
      document.getElementById(id).style.display = '';
      break;
    }
  }
}

function ARXDomMakeEmptyElement(el) {
  var i;
  
    for (i = 0; i < el.childNodes.length; i++) {
      if (el.childNodes[i].hasChildNodes)
        ARXDomMakeEmptyElement(el.childNodes[i]);
      else
        el.removeChild(el.childNodes[i]);
  }
}

function ARXDeleteText(e) 
{
  _d(e).value = '';
}

function ARXClearForm()
{
  var el = _frm.elements;
  var e;
  
  for (i = 0; i < el.length; i++)
  {
    if (el[i].type != 'hidden' && !el[i].getAttribute('readonly'))
    {
      if (el[i].type == 'select-multiple')
      {
        var l = el[i].options.length;
        
        for (j = 0; j < l; j++)
        {
          el[i].remove(0);
        }
      }
      else
      {
        el[i].value = '';
      }
    }
    else if (el[i].getAttribute('readonly') && _d(el[i].name + '-value') != null)
    {
        el[i].value = '';
        _d(el[i].name + '-value').value = '';
    }
  }
}

function ARXDeleteSelectOption(e) {
  var c = _d(e);
  var t = c.type;

  if (t == 'text') 
  {
    c.value = '';
    c = _d(e + '-value');
    c.value = '';
  }
  else if (t == 'textarea')
  {
    c.value = '';
  }
  else if (t == 'select-multiple') {
    if (c.selectedIndex > -1) {
      var t = c.selectedIndex;
      c.remove(c.selectedIndex);
      if (c.options.length > 0) {
        if (t > 0)
          c.selectedIndex = t - 1;
        else
          c.selectedIndex = 0;
      }
    }
  }
}

function ARXChecked(e) {
  var c = _d(e);
  var p = c.parentNode.childNodes;
  var n;
  
  _checkedEntryId = e;
  for (var i = 0; i < p.length; i++) {
    n = p[i];
    if (n.nodeType == 1 && n.tagName == 'INPUT' && n.getAttribute('type') == 'radio')
      n.checked = 'checked';
  }
}

function ARXSelectAll() {
  var e = _frm.getElementsByTagName('INPUT');
  var n;
  
  for (var i = 0; i < e.length; i++) {
    n = e[i];
    if ((n.getAttribute('type') == 'checkbox') && (n.getAttribute('id').indexOf('entry_id-') > -1))
      n.checked = true;
  }
}

function ARXSelectNone() {
  var e = _frm.getElementsByTagName('INPUT');
  var n;
  
  for (i = 0; i < e.length; i++) {
    n = e[i];
    if ((n.getAttribute('type') == 'checkbox') && (n.getAttribute('id').indexOf('entry_id-') > -1))
      n.checked = false;
  }
}

function ARXSetCookie(cookieName, cookieValue, expires, path, domain, secure) {
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}

function ARXOnLoad() 
{
  _frm = _d('frm-main');
  var d = _d('dtree-div');
  if (d != null) d.scrollTop = dtree.getCookie('csds');
  if (_d('container1')) setupPanes("container1", "tab1");
}

function ARXSort(t, o, c) {
  var e = _c('input');
  e.setAttribute('name', t + '-order-sort');
  e.setAttribute('type', 'hidden');
  e.setAttribute('value', o);
  _frm.appendChild(e); 

  e = _c('input');
  e.setAttribute('name', t + '-column-sort');
  e.setAttribute('type', 'hidden');
  e.setAttribute('value', c);
  _frm.appendChild(e);
  
  e = _d(t + '-table-page');
  
  if (e == null) {
    e = _c('input');
    e.setAttribute('name', t + '-table-page');
    e.setAttribute('type', 'hidden');
    e.setAttribute('id', t + '-table-page');
    e.setAttribute('value', '1');
    _frm.appendChild(e); 
  }
  else {
    e.setAttribute('name', t + '-table-page');
    e.setAttribute('type', 'hidden');
    e.setAttribute('value', '1'); 
  }
  
  var t = _d(_checkedEntryId);
  if (t != null) t.checked = '';
  
  _frm.submit();
}

function ARXOpenWindow(target, url) {
  printWin = window.open(url, target, 'menubar=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes');
  printWin.focus();
}
function ARXShowHelp(url) {
  helpWin = window.open(url, 'help', 'menubar=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes');
  helpWin.focus();
}

function ARXSubmitForm(a, t, cm, v, sd, func) {

  if(v == 'yes')
    if(!ARXCheckFormItems(func))
      return(false);
  if (cm != '')
    if(!confirm(cm))
      return;
  _frm.action = a;
  if (t != '') _frm.target = t;
  var l = _frm.getElementsByTagName('SELECT');
  var len = 0;
  var op;
  
  for (i = 0; i < l.length; i++) 
  {
    
    if (l[i].size > 1) 
    {
      len = l[i].options.length;
      
      if (len == 0)
      {
        op = _c('option');
        op.setAttribute('value', '');
        op.setAttribute('selected', 'selected');
        l[i].appendChild(op);
      }
      else
      {
        for (j = 0; j < len; j++) 
        {
          
          l[i].options[j].selected = true;
        }
      }
    }
  }
  
  if (sd != '') _d('activex-files').SaveDocs();
  _frm.submit();
}

function ARXQuickSearch(a, t) {
  var p = t + '-table-page';
  var e = _d(p);

  if (e == null) {
    var n = _c('input');
    n.setAttribute('name', p);
    n.setAttribute('id', p);
    n.setAttribute('type', 'hidden');
    n.setAttribute('value', '1');
    _frm.appendChild(n);
  }
  _frm.action = a;
  _frm.submit();
}

function ARXDefaultSubmitForm(a, t, cm, v, sd) {
  if(v == 'yes')
    if(!ARXCheckFormItems())
      return(false);
  if (cm != '')
    if(!confirm(cm))
      return(false);

  _frm.action = a;
  if (t != '') _frm.target = t;
  var l = _frm.getElementsByTagName('SELECT');
  var n;
  for (var i = 0; i < l.length; i++) {
    n = l[i];

    if (n.size > 1) {
      for (var j = 0; j < n.options.length; j ++) {
        n.options[j].selected = true;
      }
    }
  }
  
  if (sd != '')
    _d('activex-files').SaveDocs();
    
  return(true);
}

function ARXPaging(t, p, o, c) {

  var e = t + '-table-page';
  var n = _d(e);
  if (n == null) n = _c('input');
  
  n.setAttribute('name', e);
  n.setAttribute('id', e);
  n.setAttribute('type', 'hidden');
  n.setAttribute('value', p);
  _frm.appendChild(n);   

  e = t + '-order-sort';
  n = _d(e);
  if (n == null) n = _c('input');
  
  n = _c('input');
  n.setAttribute('name', e);
  n.setAttribute('type', 'hidden');
  n.setAttribute('value', o);
  _frm.appendChild(n); 

  e = t + '-column-sort';
  n = _d(e);
  if (n == null) n = _c('input');

  n.setAttribute('name', e);
  n.setAttribute('type', 'hidden');
  n.setAttribute('value', c);
  _frm.appendChild(n);

  var g = _d(_checkedEntryId);
  if (g != null) g.checked = '';

  _frm.submit();

}

function ARXPagingView(a, r) {
  var n = _c('input');
  
  n.setAttribute('name', 'entry_id');
  n.setAttribute('type', 'hidden');
  n.setAttribute('value', r);
  _frm.appendChild(n);
  _frm.action = a;
  _frm.submit();
}

function ARXSaveSearch(action_guid) 
{
  var input =  document.createElement('input');
  input.setAttribute('name', '_form-save-items');
  input.setAttribute('value', 'yes');
  input.setAttribute('type', 'hidden');
  _frm.appendChild(input);
  
  var l = _frm.getElementsByTagName('SELECT');
  var len = 0;
  var op;
  
  for (i = 0; i < l.length; i++) 
  {
    if (l[i].size > 1) 
    {
      len = l[i].options.length;
      if (len == 0)
      {
        op = _c('option');
        op.setAttribute('value', '');
        op.setAttribute('selected', 'selected');
        l[i].appendChild(op);
      }
      else
      {
        for (j = 0; j < len; j++) 
        {
          l[i].options[j].selected = true;
        }
      }
    }
  }
  
  
  _frm.submit();
  _frm.removeChild(input);
  
  showPopWin('_form-new?_action_guid=' + action_guid, 650, 150, null);
}

function ARXResetForm()
{
  var input =  parent.document.createElement('input');
  input.setAttribute('name', '_form-reset');
  input.setAttribute('value', 'yes');
  input.setAttribute('type', 'hidden');
  _frm.appendChild(input);    
  _frm.submit();
}

function ARXSearchLoad()
{
  var el = _frm.getElementsByTagName('input');

  for(i = 0; i < el.length; i++)
    if(el[i].checked)
      break;

  var f = parent.document.getElementById('frm-main');
  var input =  parent.document.createElement('input');
  input.setAttribute('name', '_form-load-guid');
  input.setAttribute('value', el[i].value);
  input.setAttribute('type', 'hidden');
  f.appendChild(input);    
  f.submit();
}

function ARXSearchDirect(action)
{
  var el = _frm.getElementsByTagName('input');

  for(i = 0; i < el.length; i++)
    if(el[i].checked)
      break;

  var f = parent.document.getElementById('frm-main');
  var input =  parent.document.createElement('input');
  input.setAttribute('name', '_form-load-guid');
  input.setAttribute('value', el[i].value);
  input.setAttribute('type', 'hidden');
  f.appendChild(input);
  //input =  parent.document.createElement('input');
  //input.setAttribute('name', '_form-search-direct');
  //input.setAttribute('value', 'yes');
  //input.setAttribute('type', 'hidden');
  //f.appendChild(input);
  f.action = action;
  f.submit();
}

function ARXSelectSearch(action_guid, action) 
{
  showPopWin('_form-select?_action_guid=' + action_guid + '&_submit_action=' + action, 650, 400, null);
}

function ARXChangeRoleLov() 
{
  showPopWin('_role-change-select', 650, 400, null);
}

function ARXChangeRole()
{
  var el = _frm.getElementsByTagName('input');

  for(i = 0; i < el.length; i++)
    if(el[i].checked)
      break;

  /*var f = parent.document.getElementById('frm-main');
  var input = parent.document.createElement('input');
  input.setAttribute('name', '_form-load-guid');
  input.setAttribute('value', el[i].value);
  input.setAttribute('type', 'hidden');
  f.appendChild(input);    
  f.submit();*/
  parent.document.location = '_role-change?entry_id=' + el[i].value;
}

function ARXShowLov(url, fld, parent, child, width, height) 
{
  var x = 10;
  var y = 10;
  
  if (parent != '') 
  {
    var parentElement = document.getElementById(parent);
    if (parentElement.value == '')
    {
      return;
    }
  }
  
  lovchilditem = child;
  lovitem = fld;
  
  var w = 500;
  var h = 430;
  
  if (width != '')
  {
    w = parseFloat(width);
  }
  
  if (height != '')
  {
    h = parseFloat(height);
  }
  
  var elm = document.getElementById(fld);
  
  if (elm.tagName == 'SELECT')
  {
    if (elm.size > 1) {
      var len = elm.options.length;
      var values = '';
      for (y = 0; y < len; y++) {
        if (y == (len - 1))
        {
          values = values + elm.options[y].value;
        }
        else
        {
          values = values + elm.options[y].value + ',';
        }
      }
    }
  }
  showPopWin(url + '&lov-selected-list-values=' + values, w, h, null);
}

function ARXShowModal(url, w, h) 
{
    if (w == null) w = 550;
    if (h == null) h = 400;
    showPopWin(url, w, h, null); 
}

function ARXStdChoices(url) 
{
  showPopWin(url, 750, 500, null); 
}

function ARXChangePasswd(url) {
  showPopWin(url, 520, 230, null);
}

function ARXSelectLovSubmit(a, f)
{
    var el = _frm.getElementsByTagName('input');
    
    var t = '';
    
    for(i = 0; i < el.length; i++)
    {
      if(el[i].checked)
      {
        t = t + f + '=' + el[i].value + '&amp;';
      }
    }
    
    if (t == '')
    {
        parent.hidePopWin(false);
    }
    else
    {
        parent.document.location = a + '?' + t;
    }
}

function ARXSelectLov(retLabelId, image) {
  var el = _frm.getElementsByTagName('input');
  //var callWin = top.opener.document;
  var callWin = window.parent.document;
  var selectElement = callWin.getElementById(parent.lovitem);
  var childElement = callWin.getElementById(parent.lovchilditem);

  var childValueElement = callWin.getElementById(parent.lovchilditem + '-value');
  var i, label, textNode;

  for(i = 0; i < el.length; i++)
    if(el[i].checked)
      break;
  
  var ret = document.getElementById(retLabelId + '-' + el[i].value);
  label = ret.firstChild.nodeValue;
  if (!label || label == '')
    label = document.getElementById(retLabelId + '-' + el[i].value).firstChild.firstChild.nodeValue;

  if (selectElement.type == 'select-one' || selectElement.type == 'select-multiple') {
    
    for(i = 0; i < el.length; i++)
    {
      if(el[i].checked)
      {
        var optionElement =  callWin.createElement('option');  
        textNode = callWin.createTextNode(document.getElementById(retLabelId + '-' + el[i].value).firstChild.nodeValue);
        optionElement.appendChild(textNode);
        optionElement.value = el[i].value;
        if (image != null && image != '')
        {
          img = document.getElementById(image + '-' + el[i].value).firstChild.getAttribute('src');
          
          optionElement.setAttribute('style', 'background-image: url(' + img + ');');
        }

        selectElement.appendChild(optionElement);
      }
    }
  }
  else if (selectElement.type == 'textarea')
  {
    selectElement.value += label + ', ';
  }
  else {
    
    selectElement.value = label;
    var selectElementValue = callWin.getElementById(parent.lovitem + '-value');
    selectElementValue.value = el[i].value;
    if (childElement) {
      childElement.value = '';
      childValueElement = '';
      document.location = '/arxeion-xml/pages/internal/arxeion/set-session-param?name=' + 
        parent.lovitem + '-value&value=' + selectElementValue.value;

    }    
  }
  parent.hidePopWin(false);
}

function ARXSelectLovTree(retLabel, retValue) {

 
  var callWin = window.parent.document;
  var selectElement = callWin.getElementById(parent.lovitem);
  var childElement = callWin.getElementById(parent.lovchilditem);
  var childValueElement = callWin.getElementById(parent.lovchilditem + '-value');
  var textNode;
 
  if (selectElement.type == 'select-one' || selectElement.type == 'select-multiple') 
  {
    var optionElement =  callWin.createElement('option');  
    textNode = callWin.createTextNode(retLabel);
    optionElement.appendChild(textNode);
    optionElement.value = retValue;
    selectElement.appendChild(optionElement);
  }
  else 
  {
    selectElement.value = retLabel;
    var selectElementValue = callWin.getElementById(parent.lovitem + '-value');
    selectElementValue.value = retValue;
    if (childElement) {
      childElement.value = '';
      childValueElement = '';
      ARXSetCookie(parent.lovitem + '-value', selectElementValue.value);
    }    
  }
  parent.hidePopWin(false);
}

function setLocation() {
  var argv = setLocation.arguments;
  var argc = argv.length;
  var i, j;
  var tmp = '';
  var a = -1;
  var query = location.search.substring(1, location.search.length);
  var pairs = query.split('&');
  
  for (j = 0; j < argc; j++) {
    a = -1;
    for (i = 0; i < pairs.length; i++) {
      if(pairs[i].substring(0, pairs[i].indexOf('=', 1)) ==  argv[j].substring(0, argv[j].indexOf('=', 1))) {
        pairs[i] = argv[j];
        a = j;
        break;
      }
    }
    if (a == -1)
      tmp = tmp + argv[j] + '&';
  }
  for (i = 0; i < pairs.length; i++)
    tmp = tmp + pairs[i] + '&';
  document.location = document.location.pathname + '?' + tmp.substring(0, tmp.length - 1);
}

function HS_lovFind() {
  var f = document.getElementsByTagName('form')[0];
  
  f.submit();
}

function getDim(el){
  for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly};
}
function listDeleteItem() {
}

function HS_onunload() {
  if(lovw)
    lovw.close();
}

function ARXPageOnMouseDown() {
  if(lovw)
    lovw.focus();
}

function setupPanes(containerId, defaultTabId) {
  panes[containerId] = new Array();
  var maxHeight = 0; var maxWidth = 0;
  var container = document.getElementById(containerId);
  var paneContainer = container.getElementsByTagName("div")[0];
  var paneList = paneContainer.childNodes;

  for (var i=0; i < paneList.length; i++ ) 
  {
    var pane = paneList[i];
    if (pane.nodeType != 1) continue;

    if (pane.offsetHeight > maxHeight) maxHeight = pane.offsetHeight;
    if (pane.offsetWidth  > maxWidth ) maxWidth  = pane.offsetWidth;
    panes[containerId][pane.id] = pane;
    
  }


    if (!paneContainer.style.height)
        paneContainer.style.height = maxHeight + "px";
    if (!paneContainer.style.width)
        paneContainer.style.width  = (maxWidth + 2) + "px";

    if (p = getCookie('pane'))
    {
        showPane(p, _d(p.replace('pane', 'tab')));
    }
    else
    {
        showPane('pane1', _d(defaultTabId));
    }
}

function showPane(paneId, activeTab) 
{
    var b;
    var pane;
    var tab;
    
    setCookie('pane', paneId);

    for (var con in panes) 
    {
        activeTab.className = 'lioff';
        if (panes[con][paneId] != null) 
        {
            pane = _d(paneId);
            pane.style.display = 'block';
            b = _d(pane.id + '-buttons-up');
            if (b) b.style.display = 'block';
            b = _d(pane.id + '-buttons-down');
            if (b) b.style.display = 'block';            
        }      
        var container = document.getElementById(con);
        var tabs = container.getElementsByTagName('table')[0];
        var tabList = tabs.getElementsByTagName('td');
        for (var i=0; i<tabList.length; i++ ) 
        {
            tab = tabList[i];
            if (tab != activeTab) tab.className = 'lion';
        }
        for (var i in panes[con]) 
        {
            pane = panes[con][i];
            if (pane == undefined) continue;
            if (pane.id == paneId) continue;
            pane.style.display = 'none';
            b = _d(pane.id + '-buttons-up');
            if (b) b.style.display = 'none';
            b = _d(pane.id + '-buttons-down');
            if (b) b.style.display = 'none';            
        }
    }
    return(false);    
}

function getCookie(cookieName) 
{
	var cookieValue = '';
	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));
	}
	return (cookieValue);
}

function setCookie(cookieName, cookieValue, expires, path, domain, secure) 
{
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}

//function HS_resetForm() {
//  var f = document.getElementsByTagName('form')[0];  
//  f.reset();
//}

function HS_HideShowLeftPane(hide, action) {

  if (hide == 'hide')
    HS_setCookie('arxeion-left-pane' + action.replace('/', ''), 'hide', '','/');
  else
    HS_setCookie('arxeion-left-pane' + action.replace('/', ''), 'show', '', '/');
  document.location.reload();
}
function HS_getCookie(cookieName) {
	var cookieValue = '';
	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));
	}
	return (cookieValue);
}

function HS_setCookie(cookieName, cookieValue, expires, path, domain, secure) {
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}

function ARXChangeCSS(theClass, element, value, win) {
  var cssRules;
  if (win.document.all)
    cssRules = 'rules';
  else if (win.document.getElementById)
    cssRules = 'cssRules';
  for (var S = 0; S < win.document.styleSheets.length; S++){
    for (var R = 0; R < win.document.styleSheets[S][cssRules].length; R++) {
      if (win.document.styleSheets[S][cssRules][R].selectorText == theClass)
        win.document.styleSheets[S][cssRules][R].style[element] = value;
    }
  }	
}

/* Privileges */
function partySelected(o, p)
{
  _d('party_guid').setAttribute('value', p);
  _frm.submit();
}

function privilegesSelect(el, priv, a)
{
  var p = _d('privileges-permissions').getElementsByTagName('input');
  var ar = new Array();
  var j = 0;
  var c = '';
  
  ar[0] = '';
  for (i = 0; i < a.length; i++) {
    c = a.substr(i, 1);
    if (c == ',')
    {
      j++;
      ar[j] = '';
    }
    else
      ar[j] += c;
  }
        
  if (el.checked && ar[0] != '') {
    for (i = 0; i < ar.length; i++) {
      if (_d('priv-' + ar[i]) != null)
      {
        _d('priv-' + ar[i]).checked = true;
        _d('privileges-' + ar[i]).value = 't';
      }
    }
  }
  document.getElementById('privileges-' + priv).value = ((el.checked) ? 't' : 'f');
}

function securityInherit(p)
{
  var h = 'f';
  if (p.checked) h = 't';
  
  p.checked = (!p.checked);
  showPopWin('permissions-inherit?_arx_inherit_permissions=' + h, 550, 213, null);
}

function selectParties(url, values)
{
  showPopWin(url + '?lov-selected-list-values=' + values, 650, 400, null);
  //lovw = window.open(url + '?lov-selected-list-values=' + values, 'lovw', 'top=10,left=10,height=430,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
  //lovw.focus();
}

function addParty(o, a) {
  var e = _frm.getElementsByTagName('input');
  for(i = 0; i < e.length; i++)
    if(e[i].checked)
      break;
  parent.hidePopWin(false);
  window.parent.document.location = a + '?object_guid=' + o + '&party_guid=' + e[i].value;
}

/* Modal Dialog */
function addEvent(obj, evType, fn)
{
  if (obj.addEventListener)
  {
    obj.addEventListener(evType, fn, true);
    return true;
  } 
  else if (obj.attachEvent)
  {
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } 
  else 
  {
    return false;
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

var _pm = null;
var _pc = null;
var _pf = null;
var gReturnFunc;
var _pis = false;
var _phs = false;
var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	

// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {
	document.onkeypress = keyDownHandler;
}

function initPopUp() 
{
	_pm = _d('pm_');
	_pc = _d('pc_');
	_pf = _d('pf_');	
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) 
  {
		_phs = true;
	}
}

addEvent(window, "load", initPopUp);

function showPopWin(url, w, h, returnFunc) 
{
    _pis = true;
    disableTabIndexes();
	_pm.style.display = 'block';
	_pc.style.display = 'block';
	centerPopWin(w, h);
	
	var tbh = parseInt(_d('ptb_').offsetHeight, 10);
	
	_pc.style.width = w + "px";
	_pc.style.height = (h + tbh) + "px";
	// need to set the width of the iframe to the title bar width because of the dropshadow
	// some oddness was occuring and causing the frame to poke outside the border in IE6
	_pf.style.width = parseInt(_d('ptb_').offsetWidth, 10) + 'px';
	_pf.style.height = (h) + 'px';
	_pf.src = url;
	gReturnFunc = returnFunc;
	if (_phs == true)
		hideSelectBoxes();
	window.setTimeout('setPopTitle();', 600);
  
  var o = _d('activex-files');
  
  if (o != null)
  {
    o.style.visibility = 'hidden';
  }
}

//
var gi = 0;
function centerPopWin(width, height) {
	if (_pis == true) {
		if (width == null || isNaN(width)) {
			width = _pc.offsetWidth;
		}
		if (height == null) {
			height = _pc.offsetHeight;
		}
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		var theBody = document.documentElement;
		
		var scTop = parseInt(theBody.scrollTop,10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		
		_pm.style.height = fullHeight + "px";
		_pm.style.width = fullWidth + "px";
		_pm.style.top = scTop + "px";
		_pm.style.left = scLeft + "px";
		
		var titleBarHeight = parseInt(_d('ptb_').offsetHeight, 10);
		
		_pc.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px";
		_pc.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
	}
}
addEvent(window, "resize", centerPopWin);
//addEvent(window, "scroll", centerPopWin);
window.onscroll = centerPopWin;
function hidePopWin(callReturnFunc) {
	_pis = false;
	restoreTabIndexes();
	if (_pm == null) {
		return;
	}
	_pm.style.display = "none";
	_pc.style.display = "none";
	if (callReturnFunc == true && gReturnFunc != null) {
		gReturnFunc(window.frames["pf_"].returnVal);
	}
	_pf.src = '/arxeion-xml/res/themes/oracle/html/loading.html';
	// display all select boxes
	if (_phs == true) {
		displaySelectBoxes();
	}
  
  var obj = _d('activex-files');
  
  if (obj != null)
  {
    obj.style.visibility = 'visible';
  }

}

function setPopTitle() 
{
    var wf = window.frames['pf_'].document.title;
    if (wf == null || wf == 'Loading Modal Content') 
    {
        _w.setTimeout('setPopTitle();', 10);
    } 
    else 
    {
        _d('pt_').innerHTML = wf;
    }
}

function keyDownHandler(e) 
{
  if (_pis && e.keyCode == 9)  return false;
}
function disableTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
}
function restoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}
function hideSelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}
function displaySelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
			document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}
// -->
/*]]>*/

