/**
* Gère l'affichage du formulaire de réservation d'un produit.
*
* @param Product product Produit pour lequel afficher le formulaire
* @access public
* @since 1.0
*/
function DisplayProductRental(product) {
	/**
	 * Produit pour lequel afficher le formulaire.
	 *
	 * @var Product
	 * @access private
	 * @since 1.0
	 */
	this.product = product;
	
	/**
	 * Liste des tailles disponibles.
	 *
	 * @var Array
	 * @access private
	 * @since 1.0
	 */
	this.size = new Array('S', 'M', 'L', 'XL');
	
	/**
	* Affiche les tarifs de location du produit sélectionné.
	*
	* @param String Identifiant du calque où afficher les informations
	* @param Integer Identifiant du produit
	* @access public
	* @since 1.0
	*/
	this.display = function(divId, productId) {
//alert('DisplayProductRental.display(' + divId + ', ' + productId + ')');
		var html = '';
		var th   = '';
		var td   = '';
		
		html += '<form method="post">';
		html += '<table class="tarif rental">';
		for(var i = 0; i < this.size.length; i++) {
			th += '<td>' + this.size[i] + '</td>';
			td += '<td><select id="' + divId + '-selection' + i + '">';
			for(var j = 0; j <= 10; j++) {
				td += '<option value="' + j + '">' + j + '</option>';
			}
			td += '</select></td>';
		}
		html += '<tr>' + '<th>' + messages['t-size'][rentalForm.lang] + '</th>' + th + '</tr>';
		html += '<tr>' + '<th>' + messages['t-quantity'][rentalForm.lang] + '</th>' + td + '</tr>';
		/*
		html += '<tr>';
		html += '<th>' + messages['t-size'][rentalForm.lang] + '</th>';
		html += '<th>' + messages['t-quantity'][rentalForm.lang] + '</th>';
		html += '</tr>';for(var i = 0; i < this.size.length; i++) {
			html += '<tr>';
			html += '<td>' + this.size[i] + '</td>';
			html += '<td><select id="' + divId + '-selection' + i + '">';
			for(var j = 0; j <= 10; j++) {
				html += '<option value="' + j + '">' + j + '</option>';
			}
			html += '</select></td>';
			html += '</tr>';
		}*/
		html += '</table>'
		html += '<p><input type="button" id="' + divId + '-button" class="product-rental-form-button ' + rentalForm.lang + '" onclick="rentalForm.forms[' + productId + '].buttonClick(\'' + divId + '\');" title="' + messages['t-rent'][rentalForm.lang] + '"></p>';
		html += '</form>';
		
		document.getElementById(divId).innerHTML = html;
	}
	
	/**
	* Traite le clic sur le bouton de réservation.
	*
	* @param String Identifiant du calque où afficher les informations
	* @access public
	* @since 1.0
	*/
	this.buttonClick = function(divId) {
		for(var i = 0; i < this.size.length; i++) {
			selection = document.getElementById(divId + '-selection' + i);
			if(selection.value != '0') {
				rentalForm.rental.addProduct(this.product, this.size[i], selection.value, 0.00);
				rentalForm.changeDuration(document.getElementById('duration').value);
				selection.selectedIndex = 0;
			}
		}
		rentalForm.display();
		document.getElementById('rental-header').onclick();
	}
	
	/**
	* Renvoit les informations sur l'objet.
	*
	* @return String Information sur l'objet
	* @access public
	* @since 1.0
	*/
	this.toString = function() {
		return 'product = ' + this.value;
	}
}
