/*
 * Copyright 2006 OST-SYSTEMS. All rights reserved.
 */

function Favourites() {
  this.favs = new Array();
}

Favourites.prototype.check = function(path) {
  for (var i = 0; i < this.favs.length; i++) {
  	if (this.favs[i].path == path) {
  	  return i;
  	}
  }
  return -1;
}

Favourites.prototype.add = function(title, path) {
  if (this.check(path) < 0) {
    var obj = new Object();
    obj.title = title;
    obj.path = path;
    this.favs.push(obj);
    this.saveAll();
    return true;
  }
  return false;  
}

Favourites.prototype.remove = function(path) {
  var index = this.check(path);
  if (index >= 0) {
    this.favs.splice(index, 1);
    this.saveAll();
  }  
}

Favourites.prototype.getAll = function() {
  return this.favs;
}

Favourites.prototype.setAll = function(array) {
  this.favs = array;
}

Favourites.prototype.saveAll = function() {
  //to be overwritten
}

    
