/**
* @version		$Id: intersport-rent.js 2009-10-22 Frederic $
* @package		Intersport
* @subpackage	Rent
*/


/**
* Gère les informations sur les liens Intersport Rent.
*
* @param Integer resort Identifiant de la station
* @param Integer shop Identifiant du magasin
* @param String lang Langue en cours
* @access public
* @since 1.0
*/
function IntersportRent(resort, shop, lang) {
	/**
	 * Identifiant du partenaire.
	 *
	 * @var Integer
	 * @access private
	 * @since 1.0
	 */
	this.partner = 6;
	
	/**
	 * Identifiant de la station.
	 *
	 * @var Integer
	 * @access private
	 * @since 1.0
	 */
	this.resort = resort;
	
	/**
	 * Identifiant du magasin.
	 *
	 * @var Integer
	 * @access private
	 * @since 1.0
	 */
	this.shop = shop;
	
	/**
	 * Langue en cours.
	 *
	 * @var String
	 * @access private
	 * @since 1.0
	 */
	this.lang = lang;
	
	/**
	 * Date de début de location au format aaaammjj.
	 *
	 * @var String
	 * @access private
	 * @since 1.0
	 */
	this.sd = null;
	
	/**
	 * Date de fin de location au format aaaammjj.
	 *
	 * @var String
	 * @access private
	 * @since 1.0
	 */
	this.ed = null;
	
	/**
	* Initialise les dates de location.
	*
	* @param String sd Date de début de location au format aaaammjj
	* @param String ed Date de fin de location au format aaaammjj
	* @access public
	* @since 1.0
	*/
	this.setDate = function (sd, ed) {
		this.sd = sd;
		this.ed = ed;
	}
	
	/**
	* Renvoit l'URL du site Intersport Rent d'après la langue en cours.
	*
	* @param Boolean rootUrl Indique si on ne renvoit que l'URL de l'accueil d'Intersport Rent (true) ou pas (false)
	* @return String URL du site Intersport Rent vers laquelle faire un lien ou envoyer un formulaire
	* @access public
	* @since 1.0
	*/
	this.getURL = function (rootUrl) {
		url = '';
		
		if(rootUrl == undefined) {
			rootUrl = false;
		}
		
		if(lang == 'fr') {
			url += 'http://www.intersport-rent.fr/';
		}
		else if(lang == 'es') {
			url += 'http://www.intersport-rent-francia.es/';
		}
		else if(lang == 'nl') {
			url += 'http://www.intersport-rent-frankrijk.nl/';
		}
		/*else if(lang == 'dk') {
			url += 'http://www.intersport-rent-frankrig.dk/';
		}*/
		else {
			url += 'http://www.intersport-rent-france.co.uk/';
		}
		
		if(!rootUrl) {
			url += 'FrontOffice/rent/page/';
		}
		
		return url;
	}
	
	/**
	* Renvoit la partie d'URL vers une station Interpsort.
	*
	* @return String URL vers une station Interpsort
	* @access public
	* @since 1.0
	*/
	this.getResortURL = function () {
		if(this.resort == 0 || this.resort == undefined || !this.resort) {
			return this.getURL(true);
		}
		
		url = this.getURL() + 'station.aspx?station=' + this.resort;
		if(partner = this.getPartnerURL()) {
			url += '#' + partner;
		}
		
		return url;
	}
	
	/**
	* Renvoit la partie d'URL vers un magasin Interpsort.
	*
	* @return String URL vers un magasin Interpsort
	* @access public
	* @since 1.0
	*/
	this.getShopURL = function () {
		args = new Array();
		
		if(this.shop == 0 || this.shop == undefined || !this.shop) {
			return this.getURL(true);
		}
		
		url = this.getURL();
		if(this.sd || this.ed) {
			url += 'pack.aspx?magasin=' + this.shop;
			if(this.sd) {
				args.push('dd=' + this.sd);
			}
			if(this.ed) {
				args.push('df=' + this.ed);
			}
		}
		else {
			url += 'station.aspx?magasin=' + this.shop;
		}
		if(partner = this.getPartnerURL()) {
			args.push(partner);
		}
		
		return url + (args.length == 0 ? '' : '#' + args.join('&'));
	}
	
	/**
	* Renvoit la partie d'URL vers un partenaire Interpsort.
	*
	* @return String URL vers un partenaire Interpsort
	* @access public
	* @since 1.0
	*/
	this.getPartnerURL = function () {
		if(this.partner == 0) {
			return '';
		}
		
		return 'partenaire=' + this.partner;
	}
	
	/**
	* Renvoit les informations sur l'objet.
	*
	* @return String Information sur l'objet
	* @access public
	* @since 1.0
	*/
	this.toString = function() {
		lines = new Array();
		
		lines.push(this.getURL());
		lines.push(this.getShopURL());
		lines.push(this.getResortURL());
		
		return lines.join('<br />');
	}
}


/**
* http://www.intersport-rent.fr/
* http://www.intersport-rent-france.co.uk/
* 
* FrontOffice/rent/page/
* 
* station.aspx?partenaire=6
* station.aspx?station=57#partenaire=6
* station.aspx?magasin=1108#partenaire=6
* pack.aspx?magasin=1108#dd=aaaammjj&df=aaaammjj&partenaire=6
*/
