/* **************************************
                Object : SiteServer
--------------------------------------------------
 Version :
     1.0 - 080218 - KIG
 Description :
    Permet d'associer à l'url d'un site, l'url eRepo par défaut 
 Attributes :
    + urlSite : l'url du site
    + eRepoUrl : l'url du serveur eRepo associé
************************************** */
function SiteServer(urlSite, eRepoUrl){
    this.urlSite = urlSite ;
    this.eRepoUrl = eRepoUrl ;
}

SiteServer.prototype.getUrlSite = function(){
    if(this.urlSite){
        return this.urlSite ;
    }
    else{
        return "" ;
    }
}

SiteServer.prototype.getERepoUrl = function(){
    if(this.eRepoUrl){
        return this.eRepoUrl ;
    }
    else{
        return "" ;
    }
}


/* **************************************
                Object : RayonObj
--------------------------------------------------
 Version :
     1.0 - 0800904 - KIG
 Description :
    Permet de creer l'objet Rayon 
 Attributes :
    + name : nom du rayon
    + url : l'url du rayon
    + multiName : mulitlingual categoy name du rayon
************************************** */
function RayonObj(name, url, multiName){
    this.name = name ;
    this.url = url ;
    this.multiName = multiName ;
}

function RayonObj(){
    this.name = "" ;
    this.url = "" ;
    this.multiName = "" ;
}

RayonObj.prototype.getName = function(){
    if(this.name){
        return this.name ;
    }
    else{
        return "" ;
    }
}

RayonObj.prototype.getUrl = function(){
    if(this.url){
        return this.url ;
    }
    else{
        return "" ;
    }
}

RayonObj.prototype.getMultiName = function(){
    if(this.multiName){
        return this.multiName ;
    }
    else{
        return "" ;
    }
}

RayonObj.prototype.setName = function(_name){
    this.name = _name ;
}

RayonObj.prototype.setUrl = function(_url){
    this.url = _url ;
}

RayonObj.prototype.setMultiName = function(_multiname){
    this.multiName = _multiname ;
}


/* **************************************
                Object : SSRayonObj
--------------------------------------------------
 Version :
     1.0 - 0800904 - KIG
 Description :
    Permet de creer l'objet Sous Rayon 
 Attributes :
    + name : nom du sous rayon
    + url : l'url du sous rayon
    + multiName : mulitlingual categoy name du sous rayon
************************************** */
function SSRayonObj(name, url, multiName){
    this.name = name ;
    this.url = url ;
    this.multiName = multiName ;
}

SSRayonObj.prototype.getName = function(){
    if(this.name){
        return this.name ;
    }
    else{
        return "" ;
    }
}

SSRayonObj.prototype.getUrl = function(){
    if(this.url){
        return this.url ;
    }
    else{
        return "" ;
    }
}

SSRayonObj.prototype.getMultiName = function(){
    if(this.multiName){
        return this.multiName ;
    }
    else{
        return "" ;
    }
}

SSRayonObj.prototype.setName = function(_name){
    this.name = _name ;
}

SSRayonObj.prototype.setUrl = function(_url){
    this.url = _url ;
}

SSRayonObj.prototype.setMultiName = function(_multiname){
    this.multiName = _multiname ;
}


/* **************************************
                Object : FamilleObj
--------------------------------------------------
 Version :
     1.0 - 0800904 - KIG
 Description :
    Permet de creer l'objet Famille
 Attributes :
    + name : nom de la famille
    + url : l'url de la famille
    + multiName : mulitlingual categoy name de la famille
    + codeExterne : Id masterdata de la famille
************************************** */
function FamilleObj(name, url, multiName, codeExterne, sousRayon){
    this.name = name ;
    this.url = url ;
    this.multiName = multiName ;
    this.codeExterne = codeExterne ;
    this.sousRayon = sousRayon ;
}

FamilleObj.prototype.getName = function(){
    if(this.name){
        return this.name ;
    }
    else{
        return "" ;
    }
}

FamilleObj.prototype.getUrl = function(){
    if(this.url){
        return this.url ;
    }
    else{
        return "" ;
    }
}

FamilleObj.prototype.getMultiName = function(){
    if(this.multiName){
        return this.multiName ;
    }
    else{
        return "" ;
    }
}

FamilleObj.prototype.getSousRayon = function(){
    if(this.sousRayon){
        return this.sousRayon ;
    }
    else{
        return "" ;
    }
}

FamilleObj.prototype.getCodeExterne = function(){
    if(this.codeExterne){
        return this.codeExterne ;
    }
    else{
        return "" ;
    }
}

FamilleObj.prototype.setName = function(_name){
    this.name = _name ;
}

FamilleObj.prototype.setUrl = function(_url){
    this.url = _url ;
}

FamilleObj.prototype.setMultiName = function(_multiname){
    this.multiName = _multiname ;
}

FamilleObj.prototype.setCodeExterne = function(_codeExterne){
    this.codeExterne = _codeExterne ;
}

/* **************************************
                Object : EnseigneSiteObj
--------------------------------------------------
 Version :
     1.0 - 0800919 - KIG
 Description :
    Permet de creer l'objet EnseigneSiteObj
 Attributes :
    + centrale : la centrale du pays
    + url : l'url du site enseigne
    + repository : le repository itool
************************************** */
function EnseigneSiteObj(centrale, url, repository){
    this.centrale = centrale ;
    this.url = url ;
    this.repository = repository ;
}

EnseigneSiteObj.prototype.getCentrale = function(){
    if(this.centrale){
        return this.centrale ;
    }
    else{
        return "" ;
    }
}

EnseigneSiteObj.prototype.getUrl = function(){
    if(this.url){
        return this.url ;
    }
    else{
        return "" ;
    }
}

EnseigneSiteObj.prototype.getRepository = function(){
    if(this.repository){
        return this.repository ;
    }
    else{
        return "" ;
    }
}

EnseigneSiteObj.prototype.getIdRepository = function(){
    if(this.repository){
        return this.repository.split('.')[0] ;
    }
    else{
        return "" ;
    }
}

EnseigneSiteObj.prototype.setCentrale = function(_centrale){
    this.centrale = _centrale ;
}

EnseigneSiteObj.prototype.setUrl = function(_url){
    this.url = _url ;
}

EnseigneSiteObj.prototype.setRepository = function(_repository){
    this.repository = _repository ;
}


/* **************************************
                Object : BuGdbc
--------------------------------------------------
 Version :
     1.0 - 090223 - KIG
 Description :
    Permet d'associer à l'id d'un produit, le BU et la valeur du BU 
 Attributes :
    + _codeModele : Le code modèle
    + _cleBu : la clé du BI
    + _valeurBu : La valeur du BU
    + _imgBu : L'image du BU
    + _etoileBu : La note etoile du BU
************************************** */
function BuGdbc(_codeModele, _cleBu, _valeurBu, _imgBu, _etoileBu){
    this.codeModele = _codeModele ;
    this.cleBu = _cleBu ;
    this.valeurBu = _valeurBu ;
    this.imgBu = _imgBu ;
    this.etoileBu = _etoileBu ;    
}

BuGdbc.prototype.getCodeModele = function(){
    if(this.codeModele){
        return this.codeModele ;
    }
    else{
        return "" ;
    }
}

BuGdbc.prototype.getCleModele = function(){
    if(this.cleBu){
        return this.cleBu ;
    }
    else{
        return "" ;
    }
}

BuGdbc.prototype.getValeurModele = function(){
    if(this.valeurBu){
        return this.valeurBu ;
    }
    else{
        return "" ;
    }
}

BuGdbc.prototype.getImgModele = function(){
    if(this.imgBu){
        return this.imgBu ;
    }
    else{
        return "" ;
    }
}

BuGdbc.prototype.getEtoileModele = function(){
    if(this.etoileBu){
        return this.etoileBu ;
    }
    else{
        return "" ;
    }
}

BuGdbc.prototype.setCodeModele = function(_codeModele){
    this.codeModele = _codeModele ;
}

BuGdbc.prototype.setCleModele = function(_cleBu){
    this.cleBu = _cleBu ;
}

BuGdbc.prototype.setValeurModele = function(_valeurBu){
    this.valeurBu = _valeurBu ;
}

BuGdbc.prototype.setImgModele = function(_imgBu){
    this.imgBu = _imgBu ;
}

BuGdbc.prototype.setEtoileModele = function(_etoileBu){
    this.etoileBu = _etoileBu ;
}


/* **************************************
                Object : ItemSite
--------------------------------------------------
 Version :
     1.0 - 080702 - KIG
 Description :
    Permet d'associer a l'url d'un site, l'url eRepo par defaut 
 Attributes :
    + _codeModel : le code modele du produit
    + _url : l'url de ce produit
    + _imageMedium : l'image en 120x120
    + _altImage : la description de l'image
    + _libelle : Le libelle du produit
    + _pictoSelection : Le picto de mise en avant
    + _descSelection : Description de ce picto
    + _prixMag : Prix central magasin
    + _prixCom : Prix en ligne
************************************** */
function ItemSite(_codeModel, _url, _imageMedium, _altImage, _libelle, _typo, _pictoSelection, _descSelection, _prixMag, _prixCom){
    this._codeModel = _codeModel ;
    this._url = _url ;
    this._imageMedium = _imageMedium ;
    this._altImage = _altImage ;
    this._libelle = _libelle ;
    this._typo = _typo ;
    this._pictoSelection = _pictoSelection ;
    this._descSelection = _descSelection ;    
    this._prixMag = _prixMag ;
    this._prixCom = _prixMag ;
    this._isNew = false ;
}

ItemSite.prototype.getCodeModel = function(){
    if(this._codeModel){
        return this._codeModel ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getUrl = function(){
    if(this._url){
        return this._url ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getImageMedium = function(){
    if(this._imageMedium){
        return this._imageMedium ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getAltImage = function(){
    if(this._altImage){
        return this._altImage ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getLibelle = function(){
    if(this._libelle){
        return this._libelle ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getTypo = function(){
    if(this._typo){
        return this._typo ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getPictoSelection = function(){
    if(this._pictoSelection){
        return this._pictoSelection ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getDescSelection = function(){
    if(this._descSelection){
        return this._descSelection ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getPrixMag = function(){
    if(this._prixMag){
        return this._prixMag +"*" ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.getPrixCom = function(){
    if(this._prixCom){
        return this._prixCom ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.isNew = function(){
    if(this._isNew){
        return this._isNew ;
    }
    else{
        return "" ;
    }
}

ItemSite.prototype.setPrixMag = function(prixMag){
    this._prixMag = prixMag ;
}

ItemSite.prototype.setPrixCom = function(prixCom){
    this._prixCom = prixCom ;
}

ItemSite.prototype.setIsNew = function(isNew){
    this._isNew = isNew ;
}


/* **************************************
                Object : LinkVideo
--------------------------------------------------
 Version :
     1.0 - 090731 - KIG
 Description :
    Permet de creer l'objet Lien vers une fiche produit associe a une video
 Attributes :
    + _url : l'url de la fiche
    + _title : le titre de la fiche
    + _target : le target du lien
    + _tag : le tag google
************************************** */
function LinkVideo(_url, _title, _target, _tag){
    this._url = _url ;
    this._title = _title ;
    this._target = _target ;
    
    if(_tag == "3"){
        this._tag = "_top" ;
    }
    else{
        this._tag = "_blank" ;
    }    
}

LinkVideo.prototype.getUrl = function(){
    if(this._url){
        return this._url ;
    }
    else{
        return "" ;
    }
}

LinkVideo.prototype.getTitle = function(){
    if(this._title){
        return this._title ;
    }
    else{
        return "" ;
    }
}

LinkVideo.prototype.getTarget = function(){
    if(this._target){
        return this._target ;
    }
    else{
        return "" ;
    }
}

LinkVideo.prototype.getTag = function(){
    if(this._tag){
        return this._tag ;
    }
    else{
        return "" ;
    }
}


/* **************************************
                Object : Video
--------------------------------------------------
 Version :
     1.1 - 090914 - VVE
 Description :
    Permet de creer l'objet Video
 Attributes :
    + _imageVideo : l'image associee a la video
    + _titreVideo : le titre de la video
    + _urlVideo : l url de la video
    + _descVideo : la description de la video
    + _timeVideo : duree de la video
************************************** */
function VideoObj(_imageVideo, _titreVideo, _urlVideo, _descVideo, _timeVideo){
    this._imageVideo = _imageVideo ;
    this._titreVideo = _titreVideo ;
    this._urlVideo = _urlVideo ;
    this._descVideo = _descVideo ;
    this._timeVideo = _timeVideo ;
}

VideoObj.prototype.getUrlVideo = function(){
    if(this._urlVideo){
        return this._urlVideo ;
    }
    else{
        return "" ;
    }
}

VideoObj.prototype.getTitreVideo = function(){
    if(this._titreVideo){
        return this._titreVideo ;
    }
    else{
        return "" ;
    }
}

VideoObj.prototype.getImageVideo = function(){
    if(this._imageVideo){
        return this._imageVideo ;
    }
    else{
        return "" ;
    }
}

VideoObj.prototype.getDescVideo = function(){
    if(this._descVideo){
        return this._descVideo ;
    }
    else{
        return "" ;
    }
}

VideoObj.prototype.getDureeVideo = function(){
    if(this._timeVideo){
        return this._timeVideo ;
    }
    else{
        return "" ;
    }
}


/* **************************************
                Object : LinkStore
--------------------------------------------------
 Version :
     1.0 - 100305 - KIG
 Description :
     Permet de creer l'objet de liage vers le site enseigne
 Attributes :
    + _language : La langue du site
    + _idModel : Le code modele pour lequel on fait un liage
************************************** */

/**
* Permet d'associer une URL de liage vers l'enseigne en fonction du code pays
*/
function setMapUrlEnseigne(){
    var map = new Map() ;
    
    map.put("FR", "http://www.decathlon.fr/-id_") ;
	map.put("ES", "http://www.decathlon.es/-id_") ;
    //map.put("EN", "http://www.decathlon.co.uk/-id_") ;    
    //map.put("IT", "http://www.decathlon.it/-id_") ;
    
    return map ;
}

//Variable global avec la map contenant l'url de liage en fonction du code pays
var _mapUrlLiageEnseigne = setMapUrlEnseigne() ;

function LinkStore(_language, _idModel){
    this._idModel = _idModel ;
    this._language = _language ;
}

LinkStore.prototype.getUrlLiage = function(){        
    if(this._idModel){
        var currentUrlLiage = "" ; 
        var valueCookieCountry = getCookie("country") ;
        
        if(valueCookieCountry){
            currentUrlLiage = _mapUrlLiageEnseigne.get(valueCookieCountry) ;
        }
        else{
            currentUrlLiage = _mapUrlLiageEnseigne.get(this._language) ;
        }
        
        if(currentUrlLiage != null && currentUrlLiage != ''){
            return currentUrlLiage + this._idModel + ".html" ;
        }
        else{
            return null ;
        }
    }
    else{
        return null ;
    }
}
