function Cat() {

function show(id) {
  if (!document.getElementById) return ;
  var e=document.getElementById(id);
  if (!e) return;
  e.style.display="inline";
}
this.show=show;

function hide(id) {
  if (!document.getElementById) return ;
  var e=document.getElementById(id);
  if (!e) return;
  e.style.display="none";
}
this.hide=hide;

function showtarget(catname,target,option,selected){
  if (!document.getElementById) return ;
  if (selected) { 
    if (selected.search(/^selected/)!=-1) {
      alert("already active"); return; }
  }
  execute(catname,target,option);
}
this.showtarget=showtarget;

function execute(cat,target,option) {
  var f=document.getElementById('catform');
  if (f) f.parentNode.removeChild(f);

  f=document.createElement("form");
  f.setAttribute('id','catform');

  var e=document.createElement("input");
  e.setAttribute("type", "hidden");
  e.setAttribute("name", "cat");
  e.setAttribute("value",cat);
  f.appendChild(e);

  var e=document.createElement("input");
  e.setAttribute("type", "hidden");
  e.setAttribute("name", "target");
  e.setAttribute("value",target);
  f.appendChild(e);

  if (option) {
    var i;
    var l=option.split("&");
    for (i=0;i<l.length;i++) {
      var o=l[i].split("=");
      e=document.createElement("input");
      e.setAttribute("type", "hidden");
      e.setAttribute("name", o[0]);
      e.setAttribute("value",o[1]);
      f.appendChild(e);
    }
  }

  e=document.getElementById('CDScore');
  if (!e) { alert("element CDScore not found"); return ;}
  e.appendChild(f);
  f.submit();
}
this.execute=execute;

function upTabDisplay(id,tabid,template) {
  var s;
  if (!document.getElementById) return ;
  var elt=document.getElementById(id);
  if (elt.innerHTML.search(/[hH]ide/)!=-1) {
    s=elt.innerHTML.replace(/[hH]ide/,"Show");
    elt.innerHTML=s;
  }
  else {
    s=elt.innerHTML.replace(/[sS]how/,"Hide");
    elt.innerHTML=s;
  }
  elt=document.getElementById(tabid).getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  if (!elt) return;
  for (i=0;i<elt.length;i++) {
    if (elt[i].className.search(template)!=-1) {
      if (elt[i].className.search(/ *hidden/)!=-1) elt[i].className=elt[i].className.replace(/ *hidden/,"");
      else elt[i].className=elt[i].className+' hidden';
    }
  }
}
this.upTabDisplay=upTabDisplay;

function redirect(ftpserver,arg) {
  alert("not available at current server. You will be redirected to "+ftpserver);
  window.open(ftpserver+"/viz-bin/ftp-index?"+arg);
}
this.redirect=redirect;

function reloadpage(opt) {
  var url=window.location.href;
  if (! opt)
    url=url.replace(/.menu=on/,"");
  else {
    if (url.indexOf("?")!=-1)
       url+="&"+opt;
    else url+="?"+opt;
  }
  window.open(url, '_self');
}
this.reloadpage=reloadpage;

function updateWithText(id,txt) {
  var e=document.getElementById(id);
  if (!e) return;
  e.innerHTML=txt;
}
this.updateWithText=updateWithText;
}

var _cat=new Cat();
