_info = navigator.userAgent; var _ns = false;
_ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);

function gebi(id){
    return document.getElementById(id)
}
function interrogate(what) {
    var output = '';
    var j = 0;
    for (var i in what) {
      ee = eval('what.'+i);
      ee = ''+ee;
      if (ee.length > 40) ee = '[too long]';
      output += i + '='+ee+ '; \n';
      j++;
      if (j > 30) {
        if (!confirm(output)) return;
        output = '';
        j = 0;
      }
    }
    alert(output);
}
function getCoords(id){
    var o=gebi(id)
    var ret={'l':o.offsetLeft,'t':o.offsetTop,'w':o.offsetWidth,'h':o.offsetHeight}
    while(o.offsetParent != null){
        o = o.offsetParent
        ret.l+=o.offsetLeft
        ret.t+=o.offsetTop
    }
    return ret
}


function isDelete(){
    return confirm('Do you want to '+((arguments.length>0)?'\n'+arguments[0]:''))
}

var opendivs = {}
function display(s, s2, state, usecookie) {
    var o = gebi(s)
    if (!o) return
    if (!state) {
		  state = o.style.display == 'none' ? 'block' : 'none'
    }
    o.style.display = state
    
    if (state == 'block' && !s2) {
        for (var i in opendivs) {
            if (opendivs[i]) {
                var o2 = gebi(i)
                if (o2) {
                    o2.style.display = 'none'
                }
                opendivs[i] = 0
            }
        }
        opendivs[s] = 1
    }
    if (state == 'none') {
        opendivs[s] = 0
    }

    if (usecookie) {
      setCookie(s+'show', o.style.display == 'block' ? 1 : 0, 0);
    }
    
    if (s2) {
        var o2 = gebi(s2)
        if (!o2) return
        if (o.style.display == 'none') o2.src = '/prop/images/admin/icon_plus.gif'; else o2.src = '/prop/images/admin/icon_minus.gif'
    }
    return o.style.display == 'block'
}
function display2(s, s2, state, hide_these) {
    var o = gebi(s)
    if (!o) return
    if (!state) {
		  state = o.style.display == 'none' ? 'block' : 'none'
    }
    o.style.display = state
    if (s2) {
        var o2 = gebi(s2)
        if (!o2) return
        if (o.style.display == 'none') o2.src = '/prop/images/admin/icon_plus.gif'; else o2.src = '/prop/images/admin/icon_minus.gif'
    }

    if (o.style.display == 'block') {
      window.c_click_on_o = true
  	  window.c_display = document.onclick
      window.c_s = s
      window.c_s2 = s2
      o.onclick = new Function("window.c_click_on_o=true;")
      document.onclick = new Function("if (!window.c_click_on_o) display2(window.c_s, window.c_s2, 'none')")
      window.c_click = o.onclick
      document.onmouseover = new Function("window.c_click_on_o=false;")
      if (hide_these && hide_these.length > 0) {
        for (var ii=0; ii < hide_these.length; ii++) {
          var oo = gebi(hide_these[ii])
          if (oo) {
            oo.style.visibility = 'hidden'
          }
        }
        window.hide_these = hide_these
      } else {
        window.hide_these = null
      }
    } else {
      document.onclick = window.c_display
      o.onclick = window.c_click
      o.onmouseout = new Function("window.c_click_on_o=false;")
      if (window.hide_these && window.hide_these.length > 0) {
        for (var ii=0; ii < window.hide_these.length; ii++) {
          var oo = gebi(window.hide_these[ii])
          if (oo) {
            oo.style.visibility = 'visible'
          }
        }
        window.hide_these = null
      }
    }

    return o.style.display == 'block'
}

// params = {'onclick' => '', 'onmouseover' => '', etc}
// children - relative components
function expandedRow(id, idimg, hideimg, showimg, showDefault, params, children) {
  var show = getCookie(id+'show');
  if (show == null) {
    show = showDefault;
  }
  var defimg = hideimg;
  if (show && show == '1') {
    defimg = showimg;
  }

  var c = '';
  if (children)
  for (var i in children) {
    c = c+'display("'+children[i]+'");'
  } 
  
//  alert("<a href='#' onclick='display("+'"'+id+'"'+", null, null, 1);var o=gebi("+'"'+id+'"'+");var img=gebi("+'"'+idimg+'"'+");if(o && img && o.style.display=="+'"'+'none'+'"'+") img.src="+'"'+hideimg+'"'+"; else img.src="+'"'+showimg+'"'+"; "+(params && params.onclick? params.onclick : '')+";"+c+";return false'><img src="+'"'+defimg+'"'+" id="+'"'+idimg+'"'+" border=0 /></a>");
  document.write("<a href='#' onclick='display("+'"'+id+'"'+", null, null, 1);var o=gebi("+'"'+id+'"'+");var img=gebi("+'"'+idimg+'"'+");if(o && img && o.style.display=="+'"'+'none'+'"'+") img.src="+'"'+hideimg+'"'+"; else img.src="+'"'+showimg+'"'+"; "+(params && params.onclick? params.onclick : '')+";"+c+";return false'><img src="+'"'+defimg+'"'+" id="+'"'+idimg+'"'+" border=0 /></a>");
  setTimeout("display('"+id+"', '', '"+(show && show == '1'? 'block' : 'none')+"', 1)", 100);

  if (children && show != showDefault)
  for (var i in children) {
    display(children[i])
  } 
}

function box(s) {
    var o = gebi(s)
    if (!o) return
    if (o.style.display == 'none') o.style.display = 'block'; else o.style.display = 'none'
    var o = gebi(s+'img')
    if (!o) return
    if (o.src.indexOf('up') > 0) o.src = '/images/admin/title-down.gif'; else o.src = '/images/admin/title-up.gif'
}

function color(s, color1, color2) {
    var o = gebi(s)
    if (!o) return
    if (o.bgColor == color1) o.bgColor = color2; else o.bgColor = color1
}

function error_message(title, message) {
    document.writeln('    <div align=center style="margin:20px">')
    document.writeln('      <table border=0 cellpadding=1 cellspacing=0 bgcolor="#000000"><tr><td>')
    document.writeln('      <table border=0 cellpadding=5 cellspacing=0 bgcolor="#ffffff">')
    document.writeln('        <tr><td bgcolor="#cc0000" align=left><font color="#ffffff"><b>'+title+'</b></td></tr>')
    document.writeln('        <tr><td style="background-color:#ffffff;color:#000000;">'+message+'</td></tr>')
    document.writeln('      </table>')
    document.writeln('      </td></tr></table>')
    document.writeln('        </div>')
}

function selectAll(selected, w) {
    if (!w) {
        w = document
    }
    var p = w.getElementsByTagName? w.getElementsByTagName('INPUT') : document.getElementsByTagName('INPUT')
    var t = false
    for (i = 0; i < p.length; i++) {
        var o = p[i]
        if (o && (o.type == 'checkbox')) {
            if (!w.nodeName) {
                if (o.name.indexOf(w) > 0 || o.getAttribute('group') == w) {
                    o.checked = selected
                }
            } else {
                o.checked = selected
            }
        }
    }
}

function emptyField(f, s) {
  if (f.value == s) {
    f.value = ''
  }
}

function intval(data) {return isNaN(parseInt(data))? 0 : parseInt(data)}
