var textDocBase = "http://cs.fit.edu/man/java/"

// Given an HTML form with an <select> option, update base of documentation
function updatePropertyDisplay(docObj) {
   var docInteger, docString
   docInteger=docObj.selectedIndex
   docString=docObj.options[docInteger].value
   textDocBase=docString + "/"
   window.status=textDocBase
   return textDocBase
}

function conBase(s) {
   return s + "  at  " + textDocBase}

function displayMessage(s) {
  window.status=s + "  at  " + textDocBase
  return true;
}

function pickJavaDocSource(path) {
   return textDocBase + path
}
function pickJavaClassDoc(path) {
   return textDocBase + "api/" + path.replace(/\./g,"/") + ".html"
}

function pickJavaPackageDoc(path) {
   return textDocBase + "api/" + path.replace(/\./g,"/") + "/package-summary.html"
}

function pickJavaMethodDoc(path, method) {
   return textDocBase + "api/" + path.replace(/\./g,"/") + ".html#" + method
}

//         '<a href="" onClick="this.href='+click+'" onMouseOver="return displayMessage(\''+over+'\')" >'+text+'</a>'
function writeLink(click,over,text) {
   document.write (
         '<a href="" onClick="this.href='+click+'" onMouseOver="return displayMessage(\''+over+'\')" >'+text+'</a>'
   );
}


function writeDocLink(click,over) {
   writeLink('pickJavaDocSource(\''+click+'\')', over, over);
}
function writeClassLink(path) {
   writeLink('pickJavaClassDoc(\''+path+'\')', 'Java class '+path, '<tt>'+path+'</tt>');
}
function writeClassLinkText(path) {
   writeLink('pickJavaClassDoc(\''+path+'\')', 'Java class '+path, '<tt>'+path.replace(/.+\./,"")+'</tt>');
}
function writeToolLink(click,over,text) {
   writeLink('pickJavaDocSource(\''+'tooldocs/index.html#'+click+'\')', over, text);
}
function writePackageLink(path) {
   writeLink('pickJavaPackageDoc(\''+path+'\')', 'Java package '+path, '<tt>'+path+'</tt>');
}
function writeMethodLink(path, ret, method) {
   writeLink ('pickJavaMethodDoc(\''+path+'\', \''+method+'\')',
              'Java method '+ret+' '+method+' of class '+path,
              '<tt>'+method+'</tt>');
}
function writeConstructorLink(path, method) {
   writeLink ('pickJavaMethodDoc(\''+path+'\', \''+method+'\')',
              'Java constructor '+method+' of class '+path,
              '<tt>'+method+'</tt>');
}

// Examples of use:
//    <script type="text/javascript">writeClassLink("java.lang.Math")</script>
//    <script type="text/javascript">writePackageLink("java.applet")</script>
//    <script type="text/javascript">writeMethodLink("java.text.RuleBasedCollator","CollationElementIterator","getCollationElementIterator(java.lang.String)")</script>
//    <script type="text/javascript">writeDocLink("guide/intl/encoding.doc.html","Encodings supported")</script> by Java.
//    <script type="text/javascript">writeToolLink("rmi","Java 2 SDK tool serialver", "Java 2 SDK tool <tt>serialver</tt>")</script>