var PACKAGE_CONSTANTS = {
		FICHES_EXT		:	".shtml",
		LISTES_EXT		:	".shtml"
};
function Package( id , _ctx ){
	var ctx = new Contexte();
	this.ctx = _ctx;	
	this.id = id;
	this.showLinks = false;
	if ( this.ctx.listPackageLoaded == true ){
		this.prev = this.getPrev(); // Identifiant du precedent
		this.next = this.getNext(); // Identifiant du suivant
		
		this.urlPrev = this.getURLPrev(); // url d'acces a l'element precedent selon le contexte de l'utilisateur
		this.urlNext = this.getURLNext(); // url d'acces a l'element suivant selon le contexte de l'utilisateur
		
		this.urlRetour = this.getURLRetour( ); // // url d'acces à la liste des packages selon le contexte de l'utilisateur
		
		if ( this.urlPrev != null || this.urlNext != null || this.urlRetour != null ){
			this.showLinks = true;
		}
	}
}

Package.prototype.getPrev = function(){
	if ( lp == null ) return null;
	for( var i = 0; i < lp.length; i++){
		if ( lp[i] == this.id && lp[i-1] != null ) return lp[i-1];
	}
	return null;
}
Package.prototype.getNext = function(){
	if ( lp == null ) return null;
	for( var i = 0; i < lp.length; i++){
		if ( lp[i] == this.id && lp[i+1] != null ){
			return lp[i+1];
		}
	}
	return null;
}

Package.prototype.getURLPrev = function(){
	var url = null;
	if ( this.prev != null ){
		if( C_MODE_PACKAGE != "PROD" ){
			url = this.getURLBasePreview();
			url += "&offre=" + this.prev;
		}else{
			url = this.getURLBase();
			url += "/packages/listes/fiche/" + this.prev + PACKAGE_CONSTANTS.FICHES_EXT;
		}
	}
	return url;
}

Package.prototype.getURLNext = function(){
	var url = null;
	if ( this.next != null ){
		if( C_MODE_PACKAGE != "PROD" ){
			url = this.getURLBasePreview();
			url += "&offre=" + this.next;
		}else{
			url = this.getURLBase();
			url += "/packages/listes/fiche/" + this.next + PACKAGE_CONSTANTS.FICHES_EXT;
		}
	}
	return url;

}

Package.prototype.getURLRetour = function(){
	var url = "";
	if ( C_MODE_PACKAGE != "PROD" ){
	
		url += this.getURLRetourBasePreview();
		url += "&ext=shtml&name=packages/listes";
		url += "&code=packages";
		url += "&type=" + this.ctx.filtre;
		url += "&" + this.ctx.filtre + "=" + this.ctx.valeur;
		url += "&page=" + this.ctx.pageCourante;
		
		if ( this.ctx.affinage != null && this.ctx.affinage.length > 0){
			url += "&fichier=" + this.ctx.filtre + "_" + this.ctx.valeur + "_" + this.ctx.affinage + "_" + this.ctx.pageCourante;
			url += "&aff=1";
			if ( this.ctx.filtre == 'theme' ){
				url += "&aff_destination=" + this.ctx.affinage;
			}else if ( this.ctx.filtre == 'destination' ){
				var testNbr = Number( this.ctx.affinage );
				if ( testNbr != null && testNbr > 0 ){
					url += "&aff_theme=" + this.ctx.affinage;	
				}else{
					url += "&aff_ville=" + this.ctx.affinage;
				}
				
			}
		}else{
			url += "&fichier=" + this.ctx.filtre + "_" + this.ctx.valeur + "_" + this.ctx.pageCourante;
		}
		
	}else{
		if (this.ctx.filtre != null &&  this.ctx.valeur != null)
		{
		url = this.getURLBase() + "/packages/listes/";
		if ( this.ctx.affinage != null && this.ctx.affinage.length > 0){
			url += this.ctx.filtre + "_" + this.ctx.valeur + "_" + this.ctx.affinage + "_" + this.ctx.pageCourante;
		}else{
			url += this.ctx.filtre + "_" + this.ctx.valeur + "_" + this.ctx.pageCourante;
		}
		url += PACKAGE_CONSTANTS.LISTES_EXT;		
		}
	}
	return ( url.length > 0) ? url : null;
}

/*  */
Package.prototype.getURLBasePreview = function(){
	var url = "ebn.ebn?";
	url +="pid=" + getUrlParam( "pid" );
	url += "&objet=" + getUrlParam( "objet" );
	url += "&prefix=" + getUrlParam( "prefix" );
	url += "&sitename=" + getUrlParam( "sitename" );
	url += "&site=" + getUrlParam( "site" );
	url += "&fichier=" + getUrlParam( "fichier" );
	url += "&name=" + getUrlParam( "name" );

	url += "&lang=" + getUrlParam( "lang" );
	url += "&langid=" + getUrlParam( "langid" );
	url += "&marque=" + getUrlParam( "marque" );
	url += "&code=" + getUrlParam( "code" );
	url += "&preview=" + getUrlParam( "preview" );
	
	return url;
}

Package.prototype.getURLBase = function (){
	//var url = "http://www." + this.ctx.site + ".com/hotel-cms/" + this.ctx.lang ;
	var url = "http://" + this.ctx.domain + "/hotel-cms/" + this.ctx.lang ;
	
	return url;
}
			
Package.prototype.getURLRetourBasePreview = function (){

	var url = "ebn.ebn?";	
	url += "pid=" + getUrlParam( "pid" );
	url += "&objet=" + getUrlParam( "objet" );
	url += "&prefix=accorhotels.packages.listes.selection";
	url += "&sitename=" + getUrlParam( "sitename" );
	url += "&site=" + getUrlParam( "site" );
	url += "&lang=" + getUrlParam( "lang" );
	url += "&langid=" + getUrlParam( "langid" );
	url += "&marque=" + getUrlParam( "marque" );
	url += "&preview=" + getUrlParam( "preview" );
	
	return url;

}




