// product functions
var Product = {}; // Products namespace

Product.condition = function(country, productType, property) {
  return eval('products.get(country, productType).' + property);  
}

Product.rate1 = function(productType) {
  return Product.condition(fb_country, productType, 'rate1'); 
}

Product.rate2 = function(productType) {
  return Product.condition(fb_country, productType, 'rate2'); 
}

Product.startDate = function(productType) {
  return Product.condition(fb_country, productType, 'startDate.' + fb_language); 
}

Product.endDate = function(productType) {
  return Product.condition(fb_country, productType, 'endDate.' + fb_language); 
}

function Products() {
  this.productList = new Array();
  Products.prototype.put = function(pCountry, pProduct) {
    this.productList.push({
      country: pCountry,
      product: pProduct
    });
  }  
  
  Products.prototype.get = function(country, productType) {
    for (var i = 0, product; prod = this.productList[i]; i++) {
      if (prod.country == country && prod.product.type == productType)
        return prod.product;
    }
    return undefined;
  }
}

function FixedInterestLoan(rate1, rate2, startDate, endDate) {
  this.type  = 'FixedInterestLoan';
  this.rate1 = rate1;         
  this.rate2 = rate2;
  this.startDate = startDate;
  this.endDate = endDate;   
}

function FlexibleLoan(rate1, rate2, startDate, endDate) {
  this.type  = 'FlexibleLoan';
  this.rate1 = rate1;         
  this.rate2 = rate2;
  this.startDate = startDate;
  this.endDate = endDate;   
}

function TimeDeposit(rate1, rate2, startDate, endDate) {
  this.type  = 'TimeDeposit';
  this.rate1 = rate1;         
  this.rate2 = rate2;
  this.startDate = startDate;
  this.endDate = endDate;   
}

function TopInterest(rate1, rate2, startDate, endDate) {
  this.type  = 'TopInterest';
  this.rate1 = rate1;         
  this.rate2 = rate2;
  this.startDate = startDate;
  this.endDate = endDate;   
}

var products = new Products();

