LT='\x3C', GT='\x3E', GTLT=GT+""+LT;


/* ======================================== */
function replaceCrossRefs(s) { return s; }
function shw(s0) {
  var s=s0
    .replace("JAVA_DOWNLOAD","http://java.com/download/")
    .replace("CYGWIN","http://www.cygwin.com/setup.exe")
    .replace("JDK_DOWNLOAD","http://java.sun.com/javase/downloads/");
  s=replaceCrossRefs(s);
  window.open(s,"Title", "height=300,width=500,scrollbars,status=yes, focus=yes").focus();

}
function javadoc(clazz) {
    var	addr="http://www.bioinformatics.org/strap/javadoc/"+clazz.replace(/[.]/g,"/")+".html";
    document.write(LT+"a href=\""+addr+"\""+GT+"*"+LT+"/a"+GT);
}


function wrteWikiLnk(id,value,icon) {
  document.write(LT+"a href=\"javascript:shw('"+id+":"+value+"')\"  "+GTLT+"IMG onmouseout=\"tt();\" onmouseover=\"tt('"+id+" "+value+
                 "');\" style=\"height: 1em; border: 0; vertical-align: bottom; \" SRC=\"http://www.bioinformatics.org/strap/images/"+icon+"\"   alt=\""+id+":\" "+GTLT+"/a"+GT);
}





function pubmed(txt) {  wrteWikiLnk("PUBMED",txt,"big_pubmed.jpg"); }
function wiki(txt)   {  wrteWikiLnk("WIKI",  txt,"big_wikipedia.jpg"); }
function WIKI(txt)   {  wiki(txt); document.write(txt.replace("_"," ")); }
function WIKIlc(txt)   {  wiki(txt); document.write(txt.replace("_"," ").toLowerCase()); }

function biowiki(txt)   {  wrteWikiLnk("BIOWIKI",  txt,"big_wikipedia.jpg");}
function alignEcClass(ecCode) {  document.write(LT+"a href=\"http://www.bioinformatics.org/strap/strap.php?separateInstance=t&load=UNIPROT_EC:"+ecCode+"\""+GT+ecCode+LT+"/a"+GT); }

function smartLnk(url, label) {
  document.write(LT+"a href=\"javascript:shw('"+url+"');\" onMouseOut=\"window.status='';\"  onmousemove=\"window.status='"+url+"';return true;\"   "+GT+label+LT+"/a"+GT);
}



// if (isIE()) document.body.style.overflow="hidden";

/* ======================================== */

function ttMoveToMousePosE(e) {
// window.status=" document.body.scrollTop="+ window.pageYOffset+" "+document.documentElement.scrollTop+"  "+document.body.scrollTop;
  if (isIE()) ttMoveToMousePosXY(event.clientX + document.documentElement.scrollLeft, event.clientY + document.documentElement.scrollTop);
  else ttMoveToMousePosXY(e.pageX,e.pageY);
  return true;
}

function ttMoveToMousePosXY(x,y) {
  var stle=document.getElementById("toolTipLayer").style;
  if (stle) {
    stle.left= (x-10)+'px';
    stle.top=  (y+10)+'px';
  }
}


function tt(msg, fgColor, bgColor) {

  var stle=document.getElementById("toolTipLayer").style;
  if (stle) {
    if(msg) {
      var borderColor=fgColor && !bgColor ? fgColor : "black";
      var fg=fgColor && bgColor ? fgColor : "black";
      var bg=fgColor && bgColor ? bgColor : "#eeEEee";
      content=LT+'div  class="toolTip" style="border: 2px solid '+borderColor+';   color:' + fg   + '; background-color:  ' + bg + '; "'+GT+msg+LT+'/div'+GT;
      document.getElementById("toolTipLayer").innerHTML=content;
      stle.position='absolute';
      stle.display='block';
      stle.visibility='visible'; 
      stle.zIndex=8;
      stle.opacity=1;
      document.onmousemove=ttMoveToMousePosE;
    }else {
      stle.visibility='hidden';
      stle.display='none';
      stle.left="-1000px";
      stle.top="-1000px";
      document.onmousemove=null;
    }

  }
}

/* ======================================== */

function showHideFigures(showHide) {
  var ee=document.getElementsByTagName('div');
  for( i=0;;i++) {
    if (i==ee.length) break;
    if ('figure'==ee[i].className) {
      ee[i].style.display= showHide ? 'block' : 'none';
    }
  }
}






function toggleVisible(button, id) {
    var e=document.getElementById(id); 
    if (e) {
        var show=e.style.display=='none';
        if (show) showEl(id); else hideEl(id);
        button.value=show ? "-" : "+";
        paragraphShown(button, id,show);
    }
}
function show(id) { showEl(id);}
function showEl(ids) {
    if (ids) {
        var list=ids.split(" ");
        for(var i=list.length; --i>=0;) showEl1(list[i]);                
    }
}

function showEl1(id) {
    var e=document.getElementById(id);  
    if (e && e.style.display=='none') {
        e.style.height="auto";
        e.style.visibility='visible';   
        e.style.display="block"; 
    } 
}
function hideEl(ids) { hide(ids); }
function hideEl(ids) {
    if (ids) {
        var list=ids.split(" ");
        for(var i=list.length; --i>=0;) {
            var e=document.getElementById(list[i]);  
            if (e) e.style.display='none'; 
        }
    }
}



function paragraphShown(button, id, shown) {
}


function writeToggle(id,txt, isInline) {
    document.write(LT+"form "+
                   (!isInline?"":"style=\"display:inline-table; margin:0;\"")+
                   " action=\"\""+GT+                     
                   LT+"input type=\"button\" onClick=\"toggleVisible(this, '"+id+"');\" value=\"+\" "+GT+(txt?txt:"Expand paragraph")+                                      
                   LT+"/form"+GT);
}


function os() {
    var av= navigator ? navigator.appVersion : "";     
    var os=
        av && av.indexOf("Windows")>=0 ? "WINDOWS" :    
        av && av.indexOf("Mac")>=0 ? "MAC" :
        "UNIX";    
    return os;
}

function forWindows(txt, txtElse) { if (os()=="WINDOWS") document.write(txt);  else if (txtElse) document.write(txtElse); }
function forMac(    txt, txtElse) { if (os()=="MAC")     document.write(txt);  else if (txtElse) document.write(txtElse); }
function forUnix(   txt, txtElse) { if (os()=="UNIX")    document.write(txt);  else if (txtElse) document.write(txtElse); }

function isIE() {
    if (navigator) {
        var agt=navigator.userAgent;
        return agt && agt.toLowerCase().indexOf("msie")!=-1;
    }
}
/*  
    scp ~/java/charite/christo/strap.js    ~/java/charite/christo/strap.css $STRAP_DIR_B
    
    scp ~/java/charite/christo/strap.js  ~/java/web/replaceCrossRefs.js ~/java/web/replaceCrossRefs.css $STRAP_DIR_B


*/

