<!-- (c) Julian Shulman 1999

function euro_object() {
	
   this.nCountries = 15;

   this.EUR =  0; this.ATS =  1; this.BEC =  2; this.DKK =  3; 
   this.FIM =  4; this.FRF =  5; this.DEM =  6; this.GRD =  7; 
   this.IEP =  8; this.ITL =  9; this.LUF = 10; this.NLG = 11; 
   this.PTE = 12; this.ESP = 13; this.SEK = 14; this.GBP = 15; 

   this.currencySymbols = new Array ("EUR", "ATS", "BEC", "DKK",
                                     "FIM", "FRF", "DEM", "GRD",
                                     "IEP", "ITL", "LUF", "NLG",
                                     "PTE", "ESP", "SEK", "GBP");

   this.countries       = new Array("&nbsp;&nbsp;",    "Austria",    "Belgium",        "Denmark",  
                                         "Finland",     "France",    "Germany",         "Greece",  
                                         "Ireland",      "Italy", "Luxembourg",    "Netherlands", 
                                        "Portugal",      "Spain",     "Sweden", "United Kingdom");

   this.nativeCountries = new Array ("&nbsp;&nbsp;", "&Ouml;sterreich",    "Belgique",        "Danmark",
                                            "Suomi",          "France", "Deutschland",         "Hellas", 
                                             "Eire",          "Italia",  "Luxembourg",      "Nederland", 
                                         "Portugal",   "Espa&ntilde;a",    "Sverige",  "United Kingdom");        

   this.currencies      = new Array(     "euro", "schilling", "franc",   "krone", 
                                       "markka",     "franc",  "mark", "drachma",
                                         "punt",      "lira", "franc", "guilder", 
                                       "escudo",    "peseta", "krone",   "pound");
	
   this.nationalities   = new Array(            "",   "Austrian",    "Belgian",  "Danish", 
                                         "Finnish",     "French",     "German",   "Greek",
                                           "Irish",    "Italian", "Luxumbourg",   "Dutch", 
                                      "Portuguese",    "Spanish",     "Sweden", "British");

   this.languageSymbols = new Array (  "", "DE", "FR", "DA",
                                     "FI", "FR", "DE", "EL",
                                     "GA", "IT", "FR", "NL",
                                     "PT", "ES", "SV", "EN");

   this.eurolands       = new Array( true,  true,  true, false,
                                     true,  true,  true, false,
                                     true,  true,  true,  true,
                                     true,  true, false, false);

   this.fixedRates      = new Array( 1.00000, 13.7603, 40.3399, -1.0000,
                                     5.94573, 6.55957, 1.95583, -1.0000,
                                    0.787564, 1936.27, 40.3399, 2.20371, 
                                     200.482, 166.386, -1.0000, -1.0000);

   this.varRates        = new Array(-1.0000, -1.0000, -1.0000,      1.,
                                    -1.0000, -1.0000, -1.0000,      1.,
                                    -1.0000, -1.0000, -1.0000, -1.0000,
                                    -1.0000, -1.0000,      1.,    0.67);

   this.values          = new Array(null, null, null, null,
                                    null, null, null, null,
                                    null, null, null, null,
                                    null, null, null, null);

   this.totalCountries  = totalCountries;
   this.currencySymbol  = currencySymbol;
   this.country         = country;
   this.nativeCountry   = nativeCountry;
   this.currency        = currency;
   this.nationality     = nationality;
   this.languageSymbol  = languageSymbol;
   this.isEuroland      = isEuroland;
   this.rate            = rate;
   this.convert         = convert;
   this.valueIn         = valueIn;
}

function totalCountries() {
   return this.nCountries;
}

function currencySymbol(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.currencySymbols[curCode] : "Error";
} 

function country(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.countries[curCode] : "Error";
} 

function nativeCountry(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.nativeCountries[curCode] : "Error";
} 

function currency(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.currencies[curCode] : "Error";
} 

function nationality(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.nationalities[curCode] : "Error";
} 

function languageSymbol(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.languageSymbols[curCode] : "Error";
} 

function isEuroland(curCode) {
   return (curCode >= 0 && curCode <= this.nCountries) ? this.eurolands[curCode] : "Error";
}

function rate(curCode) {
   if (curCode < 0 || curCode > this.nCountries) {
      return "Error";
   } else {
      return (this.eurolands[curCode]) ? this.fixedRates[curCode] : this.varRates[curCode]; 
   }
}

function convert(value, convFrom) {
   if (convFrom >= 0 && convFrom <= this.nCountries) {
	var euros = (this.eurolands[convFrom]) ? value/this.fixedRates[convFrom] : value/this.varRates[convFrom];
      for (var i=0; i<=this.nCountries; i++) {
          var convValue = (this.eurolands[i]) ? this.fixedRates[i]*euros : this.varRates[i]*euros; 
          this.values[i] = format(convValue);
      }
      this.values[convFrom] = format(value);
   }
}

function format(value) {
   var numval     = value;
   value          = value + "";
   var vLen       = value.length;
   var decPos     = value.indexOf('.');
   var nonZeroPos = null;

   var ePos  = value.indexOf('e');
   if (ePos >= 0) {
      return "too small";
   }

   if (decPos < 0) {
      return value + ".00";
   } else if (decPos == vLen-1) {
      return value + "00";
   }

   if (decPos == 0) {
      value = "0" + value;
      vLen++;
      decPos++;
   }
   
   nonZeroPos = null;
   for (var i=decPos+1; i<vLen; i++) {
      if (value.substring(i, i+1) != '0') {
         nonZeroPos = i;
         break;
      }
   }

   var rFact = Math.pow(10, nonZeroPos - decPos + 1);
   value = Math.round(numval*rFact)/rFact + "";

   var ePos  = value.indexOf('e');
   if (ePos >= 0) {
      return "too small";
   }

   vLen       = value.length;
   decPos     = value.indexOf('.');
   nonZeroPos = null;

   if (decPos < 0) {
      return value + ".00";
   } else if (decPos == vLen-1) {
      return value + "00";
   }

   for (var i=decPos+1; i<vLen; i++) {
      if (value.substring(i, i+1) != '0') {
         nonZeroPos = i;
         break;
      }
   }
   
   if (nonZeroPos == vLen-1 && value.substring(0, 2) == "0.") {
     value += "0";
     vLen++;
   }  

   if (decPos == vLen-2) {
     value += '0';
     vLen++;
   }  

   if (nonZeroPos == null || decPos > 1) {
      return value.substring(0, decPos+3);
   }

   if (decPos == 0) {
     value = "0" + value; 
   }

   return value;
}

function valueIn(curCode) {
   if (curCode < 0 || curCode > this.nCountries) {
      return "Error";
   } else {
      return this.values[curCode];
   }
}

// -->