/**
* Gère les informations sur une location.
*
* @access public
* @since 1.0
*/
function Rental() {
	/**
	 * Liste des produits à louer.
	 *
	 * @var Array
	 * @access private
	 * @since 1.0
	 */
	this.products = new Array();
	
	/**
	 * Date de début de location.
	 *
	 * @var Date
	 * @access private
	 * @since 1.0
	 */
	this.start = new Date();
	
	/**
	 * Durée de la location.
	 *
	 * @var String
	 * @access private
	 * @since 1.0
	 */
	this.duration = '';
	
	/**
	* Ajoute un produit à la location.
	*
	* @param Produit product   Produit à louer
	* @param String  selection Sélection faite sur ce produit
	* @param Integer quantity  Quantité choisie pour cette sélection
	* @param Float   price     Prix de la sélection
	* @access public
	* @since 1.0
	*/
	this.addProduct = function(product, selection, quantity, price) {
		this.products.push(new RentProduct(product, selection, quantity, price));
	}
	
	/**
	* Modifie la location d'un produit.
	*
	* @param Integer product Produit à louer
	* @param String  selection Sélection faite sur ce produit
	* @param String  quantity Quantité choisie pour cette sélection
	* @param String  price Prix de la sélection
	* @access public
	* @since 1.0
	*/
	this.modifyProduct = function(product, selection, quantity, price) {
		this.products[product].setSelection(selection);
		this.products[product].setQuantity(quantity);
		this.products[product].setPrice(price);
	}
	
	/**
	* Supprime la location d'un produit.
	*
	* @param Integer product Produit à louer
	* @access public
	* @since 1.0
	*/
	this.deleteProduct = function(product) {
		this.products.shiftElementByPosition(product);
	}
	
	/**
	* Modifie la date de début de location.
	*
	* @param Integer year Année
	* @param Integer month Mois
	* @param Integer day Jour
	* @access public
	* @since 1.0
	*/
	this.setStart = function(year, month, day) {
		if(month < 1) {
			month = 12;
			year--;
		}
		else if(month > 12) {
			month = 1;
			year++;
		}
		
		this.start = new Date(year, month - 1, day);
	}
	
	/**
	* Modifie la durée de début de location.
	*
	* @param String value Durée de location.
	* @access public
	* @since 1.0
	*/
	this.setDuration = function(value) {
		this.duration = value;
	}
	
	/**
	* Renvoit le total de la location.
	*
	* @return Float Montant de la location
	* @access public
	* @since 1.0
	*/
	this.getTotal = function() {
		value = 0.00;
		
		for(var i = 0; i < this.products.length; i++) {
			value += this.products[i].getTotal();
		}
		
		return value;
	}
	
	/**
	* Renvoit les informations sur l'objet.
	*
	* @return String Information sur l'objet
	* @access public
	* @since 1.0
	*/
	this.toString = function() {
		string = '';
		
		for(var i = 0; i < this.products.length; i++) {
			string +=  "----------------------\n" + 'products[' + i + '] = ' + this.products[i] + "\n----------------------\n";
		}
		string += "\n" + 'start     = ' + this.start + "\n";
		string += 'duration  = ' + this.duration;
		
		return string;
	}
}
