function format(nval)
{
      var ftmp = Math.round(nval * 10);
      ftmp = ftmp / 10;
      return ftmp;
}
function disallegrv()
// Copyright(c) 2000-2005, Blue Heron's Nest - all rights reserved
{		
      var allegr = [0.0,6.0,6.7,10.0,12.3,14.5,16.4,18.3,24.2,29.3,30.2,30.4,36.3,39.1,42.0,45.7,46.7,50.6,52.6,55.6,60.0,62.2,63.5,69.0,72.0];
	
        porta = parseInt (document.allegrports.fpid.value);
        portb = parseInt (document.allegrports.tpid.value);
        portc = porta;
        portd = portb;
                
//     alert("porta= " +porta+ " portb= " +portb+); 

        distanc = Math.abs(allegr[porta] - allegr[portb]);
        
        document.allegrports.distsm.value = format(distanc);   
        document.allegrports.distnm.value = format(0.86898 *                  distanc);
        document.allegrports.distkm.value = format(1.609344 *
           distanc);
          
}
function disarksrv()
// Copyright(c) 2000-2005, Blue Heron's Nest - all rights reserved
{		
      var arksr = 
[0,9.8,10.3,13.3,19,50.2,66,71.2,86.3,108.1,119.1,125.4,155.9,156,174,176.9,187,203.4,205.5,230.5,256.8,258,292.8,300.6,
308,308.7,319.6,336.2,342,366.6,393.2,394,395,401.4,421.6,445.3];
	
        porta = parseInt (document.arksrports.fpid.value);
        portb = parseInt (document.arksrports.tpid.value);
        portc = porta;
        portd = portb;
                
//     alert("porta= " +porta+ " portb= " +portb+); 

        distanc = Math.abs(arksr[porta] - arksr[portb]);
        
        document.arksrports.distsm.value = format(distanc);   
        document.arksrports.distnm.value = format(0.86898 *                  distanc);
        document.arksrports.distkm.value = format(1.609344 *
           distanc);
}
function disbwarrv()
// Copyright(c) 2000-2005, Blue Heron's Nest - all rights reserved
{		
      var bwarr = [0.0,2.0,2.0,15.0,35.3,44.1,45.1,48.2,50.7,50.8,57.3,59.2,60.8,86.3,103.5,104.0,109.4,121.1,121.7,121.8,121.9,122.0,122.0,124.4,130.0,133.8,139.9,140.5,140.7,146.5,148.2,148.5,148.5,151.4,152.6,154.1,156.2,159.4,160.4,162.7,163.9,163.9,164.4,166.4,168.4,168.4];
	
        porta = parseInt (document.bwarrports.fpid.value);
        portb = parseInt (document.bwarrports.tpid.value);
        portc = porta;
        portd = portb;
                
//     alert("porta= " +porta+ " portb= " +portb+); 

        distanc = Math.abs(bwarr[porta] - bwarr[portb]);
        
        document.bwarrports.distsm.value = format(distanc);   
        document.bwarrports.distnm.value = format(0.86898 *                  distanc);
        document.bwarrports.distkm.value = format(1.609344 *
           distanc);
          
}
function discumbrv()
// Copyright(c) 2000-2005, Blue Heron's Nest - all rights reserved
{		
      var cumbr =
[0,2,11,16,20,31,33,42,44,59,63,78,89,104,125,126,149,153,158,175,191,197,206,216,222,233,237,240,248,263,279,292,308,309,314,317,333,358,358, 381,381,385,400,423,461]; 
	
        porta = parseInt (document.cumbrports.fpid.value);
        portb = parseInt (document.cumbrports.tpid.value);
        portc = porta;
        portd = portb;
                
//     alert("porta= " +porta+ " portb= " +portb+); 

        distanc = Math.abs(cumbr[porta] - cumbr[portb]);
        
        document.cumbrports.distsm.value = format(distanc);   
        document.cumbrports.distnm.value = format(0.86898 *                  distanc);
        document.cumbrports.distkm.value = format(1.609344 *
           distanc);
}

var points = new Array(1);
points["Potomac"] = ["Potomac River mouth", "Coan River mouth, VA",
"Smith Creek mouth, MD", "St. Marys River mouth", "Yeocomico River mouth, VA", "Piney Point, MD", "Lower Machodoc Creek, VA", 
"Nomini Bay, VA", "Breton Bay Entrance, MD", "Wicomico River mouth, MD", "Colonial Beach, VA", "Dahlgren, VA", 
"Potomac R. (US 301) Bridge", "Quantico, VA", "Occoquan, VA", "Indian Head, MD", "Mount Vernon, VA", "Alexandria, VA", 
"Bladensburg, MD", "Washington, DC", "Key Bridge", "Chain Bridge"];

points["Alleg"] = ["Allegheny & Ohio River Junction","Sharpsburg, PA","Lock & Dam No. 2","Blawnox, PA","Oakmont, PA",
"Lock & Dam No. 3","Springdale, PA","New Kensington, PA","Lock & Dam No. 4","Freeport, PA","Kiskiminetas r. mouth",
"Lock & Dam No. 5","Lock & Dam No. 6","Cadogan, PA","Ford City, PA","Lock & Dam No. 7","Kittanning, PA","Mosgrove, PA",
"Lock & Dam No. 8","Mahoning Creek","Rimer, PA","Lock & Dam No. 9","Wattersonville, PA","East Brady, PA","Head of Navigation (tows)"];

points["Arks"] = ["White & Mississippi River Junction","Arkansas Post Canal & White r. Junction","Norrell Lock & Dam",
             "Lock No. 2","Arkansas Post Canal & Arkansas r. Junction","Lock & Dam No. 3","Lock & Dam No. 4",
             "Lake Langhofer Entrance","Lock & Dam No. 5","David D. Terry Lock & Dam","Little Rock - No. Little Rock, AR",
             "Murray Lock & Dam","Toad Suck Ferry Lock & Dam","Conway, AR","Morrilton, AR","Lock & Dam No. 9",
             "Petit Jean River mouth","Dardanelle, AR","Dardanelle Lock & Dam","Clarksville, AR","Ozark - Jeta Taylor Lock & Dam",
             "Ozark, AR","Lock & Dam No. 13","Van Buren, AR","Fort Smith, AR","Poteau River mouth","W.D. Mayo Lock & Dam",
             "Robert S. Kerr Lock & Dam","Sans Bois Creek mouth","Webbers Falls Lock & Dam","Muskogee, OK","Grand River mouth",
             "Verdigris River mouth","Chouteau Lock","Newt Graham Lock & Dam","Catoosa, OK (head of navigation)"];

points["Bwar"] = ["0.0-Black Warrior & Tombigbee River Junction",
              "2.0-Bridge, U.S. Hwy 43",
              "2.0-Bridge, St. Louis & San Francisco R.R.",
              "15.0L-Ramp, Old Lock 5, concrete",
              "35.3L-Ramp, Old Lock 6, paved",
              "44.1-Warrior Lock",
              "45.1L-Ramp, Public",
              "48.2-Bridge, AL State Hwy 14",
              "50.7R-Ramp, Public",
              "50.8-Bridge, A.G.S. Railroad",
              "57.3R-Ramp, Merriweather Ldg., paved",
              "59.2R-Ramp, paved",
              "60.8L-Ramp, Old Lock 8, public paved",
              "86.3L-Ramp, O.T. Princess Ldg., public paved",
              "103.5-Bridge, I-59 Hwy",
              "104.0-Bridge, U.S. Hwys 11 & 43",
              "109.4R-Ramp, Sanders Ferry",
              "121.1-Oliver Lock & Dam",
              "121.7-Bridge, G.M.&O. Railroad",
              "121.8R-Ramp, public paved",
              "121.9-Bridge, U.S. Hwys 82 & 43",
              "122.0R-Ramp, paved",
              "122.0L-Marina, Ramp",
              "124.4-Bridge, U.S. Hwy 82 By-Pass",
              "130.0-Holt Lock & Dam",
              "133.8R-Ramp, boat",
              "139.9L-Ramp, boat",
              "140.5R-Ramp, boat",
              "140.7R-Ramp, boat",
              "146.5R-Ramp, boat",
              "148.2L-Ramp, boat",
              "148.5-Bankhead Lock & Dam",
              "148.5R-Ramp, Public boat",
              "151.4L-Ramp, boat",
              "152.6L-Ramp, boat",
              "154.1L-Ramp, boat",
              "156.2L-Ramp, boat",
              "159.4L-Ramp, boat",
              "160.4L-Ramp, boat (gas?)",
              "162.7L-Ramp, Hurricane Creek",
              "163.9-Bridge, County Road No. 21",
              "163.9L-Ramp, Franklin Ferry",
              "164.4L-Ramp, boat",
              "166.4L-Ramp, boat",
              "168.4L-Ramp, boat (gas?)",
              "168.4-Junction, Locust & Mulberry Forks"];

points["Cumb"] = ["Cumberland & Ohio River Junction",
             "Smithland, KY",
             "Vicksburg,KY",
             "Pinckneyville, KY",
             "Dycusburg, KY",
             "Barkley Lock & Dam",
             "Barkley Canal Entrance",
             "Kuttawa, KY",
             "Eddyville, KY",
             "Little River mouth",
             "Canton, KY",
             "Bumpus Mills, TN",
             "Dover, TN",
             "Cumberland City, TN",
             "Red River mouth",
             "Clarksville, TN",
             "Cheatham Lock & Dam",
             "Harpeth River mouth",
             "Ashland City, TN",
             "Rock Harbor Marina",
             "Nashville, TN",
             "Opryland USA",
             "Stones River mouth",
             "Old Hickory Lock & Dam",
             "Drakes Creek",
             "Cedar Creek",
             "Station Camp & Spencer Creek",
             "Gallatin, TN",
             "Cairo, TN",
             "Hunters Point",
             "Hartsville, TN",
             "Rome, TN",
             "Carthage, TN",
             "Caney Fork River mouth",
             "Cordell Hull Lock & Dam",
             "Defeated Creek",
             "Granville, TN",
             "Gainsboro, TN",
             "Roaring River mouth",
             "Celina, TN",
             "Obey river mouth",
             "Head of Navigation (tows)",
             "Ferry at Hwy 214",
             "Traces on the Cumberland",
             "Wolf Creek Dam (no Lock)"];

var cvalus = new Array(1);
cvalus["Potomac"] = 
["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21"];

cvalus["Alleg"] = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"];

cvalus["Arks"] = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24",
                  "25","26","27","28","29","30","31","32","33","34","35"];
                  
cvalus["Bwar"] = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24",
                  "25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45"];
                  
cvalus["Cumb"] = ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24",
                  "25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44"];
                                    
function dispot()
// Copyright(c) 2005, Blue Heron's Nest - all rights reserved
{
      var potom  =  [ [101,98,96,101,91,84,76,80,68,44,43,38,31,26,27,23,16,13,12,11,11,0], 
      [96,93,90,96,86,79,70,75,63,38,37,33,26,22,22,18,11,6,8,17,0], 
[95,92,89,95,85,78,69,74,62,37,36,32,25,21,21,17,10,8,3,0], 
[93,90,87,93,83,76,68,72,60,35,34,30,23,19,19,15,8,7,0],
[94,91,88,94,84,76,68,72,61,36,35,31,24,19,20,16,9,0],
[85,82,80,85,75,68,60,64,52,28,27,22,15,11,11,7,0],
[80,77,75,80,70,63,55,59,47,22,21,17,10,6,5,0],
[78,75,72,78,68,60,52,57,45,20,19,15,8,6,0],
[79,76,74,79,69,62,54,58,46,21,20,16,9,0],
[71,68,66,71,61,53,45,50,38,13,12,9,0],
[68,65,63,68,58,51,43,47,35,11,10,0],
[63,60,58,63,53,46,38,42,30,6,0],
[58,55,52,58,48,40,32,36,24,0],
[33,30,28,34,24,16,8,12,0],
[33,30,27,33,23,15,7,0],
[26,23,20,26,16,8,0],
[19,16,13,19,9,0],
[10,7,4,10,0],
[14,11,8,0],
[8,5,0],
[3,0],
[0]] ;
        var21 = 21;
        porta = parseInt (document.potomports.fpid.value);
        portb = parseInt (document.potomports.tpid.value);
//       alert("porta= " +porta+ " portb= " +portb) 

        if (porta == portb) 
         { 
           document.potomports.distsm.value = 0
           document.potomports.distnm.value = 0 
           document.potomports.distkm.value = 0  
         }
	else
         {
	   if (porta < portb)
	    {
	      portb = var21 - portb
//       alert("porta= " +porta+ " portb= " +portb)
        document.potomports.distsm.value = Math.round(1.15078 * (potom [porta][portb]))
        document.potomports.distnm.value =  potom [porta][portb]
        document.potomports.distkm.value = Math.round(1.852 * (potom [porta][portb]))
            }
           else
            {
              portc = porta 
              porta = portb 
              portb = var21 - portc
//       alert("porta= " +porta+ " portb= " +portb)
        document.potomports.distsm.value = Math.round(1.15078 * (potom [porta][portb]))
        document.potomports.distnm.value =  potom [porta][portb]
        document.potomports.distkm.value = Math.round(1.852 * (potom [porta][portb]));
            }
      	  }

}
function removeOptions(optionMenu)
{
       optionMenu.options.length = 0;
}

function addOptions(optionList, valueList, optionMenu)
{
 var i=0; var j=-1;
 removeOptions(optionMenu);  // clear out the options
 for (i=0; i < optionList.length; i++)
    {
      j++ 
      optionMenu[j] = new Option(optionList[i], valueList[i]);
    }
}


