function refresh(focus) {
  if(focus) window.focus()
  if(window.name.substring(0,6)=='_back_' && window.name.substring(7,8)=='_') {
    var count = window.name.charCodeAt(6)-64
    window.name = window.name.substring(8,window.name.length)
    window.history.go(-count)
    return
  }
  if(window.name.substring(0,8)=='_reload_') {
    window.name = window.name.substring(8,window.name.length)
    top.window.location = top.window.location.href
    return
  }
  while(window.name.substring(0,4)=='_xy_' && window.name.substring(12,13)=='_') {
    var spos = window.name.substring(4,12)
    var xpos = (spos.charCodeAt(0)-65)*17576+(spos.charCodeAt(1)-65)*676+(spos.charCodeAt(2)-65)*26+spos.charCodeAt(3)-65
    var ypos = (spos.charCodeAt(4)-65)*17576+(spos.charCodeAt(5)-65)*676+(spos.charCodeAt(6)-65)*26+spos.charCodeAt(7)-65
    window.scrollTo(xpos,ypos)
    window.name = window.name.substring(13,window.name.length)
  }
}
function change(f) {
  if(f.name.substring(0,1)=='/') {
    f.name = 'data'+f.name
  }
}
function complete(f) {
  var more = true
  while(more) {
    more = false
    for(var i = 0; i<f.length; i++) {
      if(f.elements[i].name.substring(0,1)=='/') {
        if(f.elements[i].type=='select-one') {
          f.elements[i].options[0].value = ''
          f.elements[i].selectedIndex = 0
        } else {
          f.elements[i].value = ''
        }

        f.elements[i].name = ''
        more = true
      }
      if(f.elements[i].name.substring(0,12)=='file upload ') {
        if(f.elements[i].value!='') {
          document.pliant.encoding = 'multipart/form-data'
        }

      }
    }
  }
  f._pliant_x.value = window.pageXOffset
  f._pliant_y.value = window.pageYOffset
  return true
}
function button_pressed(context,target) {
  document.pliant._.name = context
  complete(document.pliant)
  if(target) document.pliant.target=target
  else document.pliant.target=window.name
  document.pliant.submit()
  if(target) window.setTimeout('document.pliant.target=window.name;',0)
}
function relative_x(x,id) {
  var o = document.getElementById(id);
  var a = x-o.offsetLeft;
  while(o != null) {
    if (o.nodeName == 'table' || o.nodeName == 'TABLE' || o.nodeName == 'td' || o.nodeName == 'TD') {
      a = a-o.offsetLeft
    }
    o = o.parentNode
  }
  return a;
}
function relative_y(y,id) {
  var o = document.getElementById(id);
  var a = y-o.offsetTop;
  while(o != null) {
    if (o.nodeName == 'table' || o.nodeName == 'TABLE' || o.nodeName == 'td' || o.nodeName == 'TD') {
      a = a-o.offsetTop
    }
    o = o.parentNode
  }
  return a;
}
