  
    var MW = (MW)?MW:{};    
    MW.UI = {};     
    
    
    //Date
    Date.prototype.toDisplayString = function(pDisplayTime){
        var year = this.getFullYear().toString();
        var month = (this.getMonth() + 1).toString(); 
        if(month.length == 1) month = "0" + month;
        var day = (this.getDate()).toString();  
        if(day.length == 1) day = "0" + day;        
               
        return day+"/"+month+"/"+year;
        
    };    
    
    
    MW.IE = (navigator.appName == "Microsoft Internet Explorer");
    MW.Netscape = (navigator.appName == "Netscape");   
   
    
    //Event management
    MW.EventManager_Class = function(){
       this.addListener = function (element, baseName, handler){      
            if (element != null ){ 
                if (element.addEventListener){
                    element.addEventListener(baseName,handler,false);
                }    
                else if (element.attachEvent){
                    element.attachEvent('on' + baseName, handler);
                    
                }
             }
         };
         
         this.removeListener = function (element, baseName, handler){      
            if (element != null ){ 
                if (element.removeEventListener){
                    element.removeEventListener(baseName,handler,false);
                }    
                else if (element.detachEvent){
                    element.detachEvent('on' + baseName, handler);
                    
                }
             }
         };
    };
    MW.EventManager = new MW.EventManager_Class();
    
    //QueryString Management    
    MW.QueryString = 
    {
        getValue: function(name)
        {
            var params = window.location.search.substring(1).split('&');
            
            for ( QueryString_i = 0 ; QueryString_i < params.length ; QueryString_i++ )
            {
                if ( params[QueryString_i].split('=')[0].toUpperCase() == name.toUpperCase() )
                    return params[QueryString_i].split('=')[1];
            }
            return null;
        },
		
		getString: function(){
			return window.location.search.substring(1);
		}
    }  
    
/**
*
*  UTF-8 data encode / decode
*  http://www.webtoolkit.info/
*
**/

    MW.UTF8 = {
        // public method for url encoding
        encode : function (string) {
            string = string.replace(/\r\n/g,"\n");
            var utftext = "";

            for (var n = 0; n < string.length; n++) {

                var c = string.charCodeAt(n);

                if (c < 128) {
                    utftext += String.fromCharCode(c);
                }
                else if((c > 127) && (c < 2048)) {
                    utftext += String.fromCharCode((c >> 6) | 192);
                    utftext += String.fromCharCode((c & 63) | 128);
                }
                else {
                    utftext += String.fromCharCode((c >> 12) | 224);
                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                    utftext += String.fromCharCode((c & 63) | 128);
                }

            }

            return utftext;
        },

        // public method for url decoding
        decode : function (utftext) {
            var string = "";
            var i = 0;
            var c = c1 = c2 = 0;

            while ( i < utftext.length ) {

                c = utftext.charCodeAt(i);

                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++;
                }
                else if((c > 191) && (c < 224)) {
                    c2 = utftext.charCodeAt(i+1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2;
                }
                else {
                    c2 = utftext.charCodeAt(i+1);
                    c3 = utftext.charCodeAt(i+2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3;
                }

            }

            return string;
        }

    }    
    
    
    MW.Display_Class = function(){
        this.executeScript = function(pElement){
          var allscript = pElement.getElementsByTagName('script');
          for(var i=0;i< allscript.length;i++){
            globaleval(allscript[i].text);
          } 
        };
        
         this.integrateContent = function(pElement, pContent){
            pElement.innerHTML = pContent;
            this.executeScript(pElement);
        };       
    
    }
    MW.Display = new MW.Display_Class();   

    
   //ToolTip Manager
    MW.ToolTipManager_Class = function(){
       this.currentToolTip = null;
    
       this.show = function (toolTipID){     
           this.currentToolTip =  document.getElementById(toolTipID); 
           this.currentToolTip.style.display = 'block'; 
       };
       
       this.hide = function (){      
            this.currentToolTip.style.display = 'none'; 
            this.currentToolTip = null;
       };       
    };
    MW.ToolTipManager = new MW.ToolTipManager_Class();   
    
    
    //Mail management
    MW.Mail_Class = function(){
       this.askMailTo = function (memberID){                
            MW.VYDO.HTMLEditor.getHTMLText("Messagerie", "", "", "", "",["mailto",  memberID],{CallBack:"action",ToolBarSet:'Default',EditTitle:true, Title:"Titre du message"});    
       };  
    

    };
    MW.Mail = new MW.Mail_Class();

    
    MW.VYDO = {};


    //Authentification
    MW.VYDO.Authentification_Class = function(){
       this.authentified = function (){
            var RsltElem = document.getElementById("OwnerID");
            var Owner = RsltElem.innerText;
            if (Owner.length > 0)  return true;
            return false;           
        }    
       this.getUserID = function (){
      
            if(UserID) return UserID;
            return document.getElementById("UserID").innerText;
       }    
       this.getOwnerID = function (){
            if(OwnerID) return OwnerID;
            return document.getElementById("OwnerID").innerText;
       }   
    };
    MW.VYDO.Authentification = new MW.VYDO.Authentification_Class();



 //Sliding
    MW.UI.Sliding_Class = function(){
        
        this.direction = 'H';
        this.min = null;
        this.max = null;    
        this.target = null;  
        this.mouseX0 = null;    
        this.mouseY0 = null;    
        this.width0 = null; 
        this.height0 = null;       
        this.drag=false;                           

        
        this.startSlide = function(event, pTargetName, pMin, pMax, pDirection)
        {           
            this.drag=true;            
            if(!pDirection)this.direction='H';
            else this.direction=pDirection;
            
            this.min = pMin;
            this.max = pMax;
            this.mouseX0 = event.x;    
            this.mouseY0 = event.y;   
            this.target = document.getElementById(pTargetName);
            this.width0 =  this.target.width; 
            this.height0 = this.target.height; 
            
            if(this.target){
                MW.EventManager.addListener(document, "mousemove", MW.UI.Sliding.slide); 
                MW.EventManager.addListener(document, "mouseup",  MW.UI.Sliding.endSlide); 
                MW.EventManager.addListener(window, "mouseup",  MW.UI.Sliding.endSlide); 
            }                    
        }  
        
        this.slide = function(event)
        {
            if(MW.UI.Sliding.drag){
                var pX=500;
                var pY=500;
       
                
                if (MW.UI.Sliding.direction == 'H')
                {
                    if (pX < MW.UI.Sliding.max && pX > MW.UI.Sliding.min)
                    {  
                        try{
                            if((new Number(MW.UI.Sliding.width0) + new Number(event.x)- new Number(MW.UI.Sliding.mouseX0))>0)
                            MW.UI.Sliding.target.style.width = new Number(MW.UI.Sliding.width0) + new Number(event.x)- new Number(MW.UI.Sliding.mouseX0);
                        }catch(err){
                        
                            alert(new Number(MW.UI.Sliding.width0) + new Number(event.x)- new Number(MW.UI.Sliding.mouseX0));
                        }
                        
                     }
                }
                else
                {

                    if (pX < MW.UI.Sliding.max && pX > MW.UI.Sliding.min)
                    {      
                       MW.UI.Sliding.target.style.width = MW.UI.Sliding.width0 + event.x- MW.UI.Sliding.mouseX0;
                    }
                }
            }
        }   
        
        this.endSlide = function()
        {   
            MW.UI.Sliding.drag = false;   
            alert(MW.UI.Sliding.drag);
            MW.EventManager.removeListener(document,"mousemove", MW.UI.Sliding.slide);
            MW.EventManager.removeListener(document,"mouseup", MW.UI.Sliding.endSlide);
        }
    
    }
    MW.UI.Sliding = new MW.UI.Sliding_Class();    

    

    //EDITEUR HTML
    MW.VYDO.HTMLEditor_Class = function(){
      // this.paramList = new Array();
       this.COUNTER = 0;
       this.INTERVALID = 0;
       this.CONTENT = "";
       this.CALLBACK_KIND = "";   
       this.CALLBACK_METHOD = null;   
       this.EDIT_TITLE= false;      
       this.scrollTop=0;       
       this.titleContainer='TitleEditorContainer';
       this.fckContainer='FCKeditorContainer';     
       this.couche1 = 'Notecouche1'; 
       this.couche2 = 'Notecouche2';   
       this.unshow = false;      
       this.height = null;   
       this.fck='FCKeditor1'; 
       this.editor;        
    
       this.getHTMLText = function (Title, Content, moduleContainerID, moduleCode, moduleID, params, config)
        { 
           
            paramList = params;
            Paramposition = undefined;
            ModuleContainerID = moduleContainerID;
            ModuleCode = moduleCode;
            ModuleID = moduleID;
            
            if(config.titleContainer) this.titleContainer=config.titleContainer;  else this.titleContainer='TitleEditorContainer';
            if(config.fckContainer) this.fckContainer=config.fckContainer;  else this.fckContainer='FCKeditorContainer';
            
            if(config.couche1) this.couche1=config.couche1;  else this.couche1='Notecouche1';
            if(config.couche2) this.couche2=config.couche2;  else this.couche2='Notecouche2';
            if(config.unshow) this.unshow = config.unshow;  else this.unshow = false; 
            if(config.height) this.height = config.height;  else this.height = null;             
                                    
            try{
                //var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; 	oEditor.SetHTML("");            
                //if(!oEditor.EditingArea) throw new Error("");
                if(!this.unshow){
	                FP_changeProp(this.couche1,0,'style.display','block');
	                FP_changeProp(this.couche2,0,'style.display','block');
	            }
    	       
	            if(config.EditTitle){
	                 this.EDIT_TITLE= true;  
	                if(!this.unshow){ FP_changeProp(this.titleContainer,0,'style.display','block');}
                }else{
                   this.EDIT_TITLE = false;  
                }
     
                this.CALLBACK_KIND = config.CallBack;  
                if(!this.CALLBACK_KIND || this.CALLBACK_KIND =="")    this.CALLBACK_KIND="editmodule";   
                this.CALLBACK_METHOD = config.CallBackMethod;      
                
                if(this.EDIT_TITLE) document.getElementById('NoteTitleID').value = config.Title;
                if(!FCKeditor.ToolbarSet ) FCKeditor.ToolbarSet='Unknow';
                //if(!config.ToolbarSet ) 
                config.ToolbarSet='Default';
                 
                
              if(!config.fck) config.fck="FCKeditor1";
              if(this.fck!=config.fck ||(config.ToolbarSet && FCKeditor.ToolbarSet != config.ToolbarSet)){
        
                   this.editor=null;
                     var sBasePath = '' ;       
                    if(config.fck) this.fck=config.fck;  else this.fck='FCKeditor1';
                    FCKeditor.ToolbarSet = 'Default'; // config.ToolbarSet;
                    var oEditor;
                    oEditor = new FCKeditor( this.fck,undefined, undefined, FCKeditor.ToolbarSet ) ; 
                    oEditor.BasePath = sBasePath ;
                    
                    oEditor.Value	= '' ;
                     if(this.EDIT_TITLE) document.getElementById('NoteTitleID').value = config.Title;
                    document.getElementById(this.fckContainer).innerHTML = "Veuillez Patienter" ;
                    
                    oEditor.CreateInElement(document.getElementById(this.fckContainer)) ; 
                                 
                  
                    //this.display();
               }
                 if(config.fck) this.fck=config.fck;  else this.fck='FCKeditor1';
                 this.scrollTop=document.body.scrollTop;
                 MW.ScrollBar.hide();
                
                 //Titre
                 document.getElementById("editHTMLtitle").innerHTML = Title;                
        
                  this.CONTENT = Content;
                  this.COUNTER = 0;               
                  this.INTERVALID = setInterval("try{if(MW.VYDO.HTMLEditor.COUNTER>4){alert('Un problème a eu lieu, veuillez réessayer.'); clearInterval(MW.VYDO.HTMLEditor.INTERVALID); }  ;if(!MW.VYDO.HTMLEditor.editor)MW.VYDO.HTMLEditor.editor= FCKeditorAPI.GetInstance('"+MW.VYDO.HTMLEditor.fck+"') ; MW.VYDO.HTMLEditor.editor.SetHTML( MW.VYDO.HTMLEditor.CONTENT);  MW.VYDO.HTMLEditor.display(); clearInterval(  MW.VYDO.HTMLEditor.INTERVALID);     }catch(err){MW.VYDO.HTMLEditor.COUNTER=MW.VYDO.HTMLEditor.COUNTER+1;} ",1000);
            }catch(err){
						alert(err.message);
                        alert("L'éditeur de texte n'est pas prêt, veuillez réessayer."); 
                        this.closeHTMLText();           
            }    
        
        };  
        
        
        this.closeHTMLText = function ()
        {
            if(!this.unshow){
                FP_changeProp(this.couche1,0,'style.display','none');
                FP_changeProp(this.couche2,0,'style.display','none');
                FP_changeProp(this.titleContainer,0,'style.display','none');
            }
            MW.ScrollBar.show();   

            document.body.scrollTop = this.scrollTop; 
             
        }

        this.endEditHTMLText = function ()
        {
          
            var oEditor = FCKeditorAPI.GetInstance(this.fck) ;
            var description = oEditor.GetXHTML(true);
            if(Paramposition) paramList[Paramposition-1] = description;
            else (paramList.push(description));
            if(this.EDIT_TITLE) paramList.push(document.getElementById('NoteTitleID').value);
          
            
            this.closeHTMLText();
            
                 
            switch(this.CALLBACK_KIND){
                case "editmodule":  
                    MW.Waiter.show();                
                    MWMyPageService.editModule(OwnerID, ModuleContainerID, ModuleCode, ModuleID, paramList, this.editModuleComplete);
                    break;
                case "action":
                    MW.Waiter.show();                    
                    var action = paramList[0];   
                    var params = paramList.slice(1);     
                    MWMyPageService.action(action, params, this.actionComplete);
                    break;   
                case "custom":
                    var params = paramList;     
                    this.CALLBACK_METHOD(params);
                    break;   
            }
        }

        this.editModuleComplete = function (result)
        { 
            MW.Waiter.hide();  
            if (result.isInfoMsg)
                alert(result.infoMsg);
            if (result.isModuleInnerHTMLContent)
            {
                var RsltElem = document.getElementById(result.containerID);
                RsltElem.innerHTML = result.moduleInnerHTMLContent;
            }
        }       
        
        this.actionComplete = function (result)
        {
            MW.Waiter.hide();            
            if (result.isInfoMsg)
                alert(result.infoMsg);
            if (result.isModuleInnerHTMLContent)
            {
                var RsltElem = document.getElementById(result.containerID);
                RsltElem.innerHTML = result.moduleInnerHTMLContent;
            }
        }           
        
        this.display = function(){               
            var window_top;
            if (window.innerHeight) window_top = window.innerHeight;
            else window_top = document.documentElement.scrollHeight;
            
            document.body.scrollTop = 0;

            var RsltElem = document.getElementById("Notecouche1");    
            if(RsltElem){     
                 
                RsltElem.style.height = window_top; 
                RsltElem.style.top = document.body.scrollTop;
            }

            RsltElem = document.getElementById("Notecouche2");
            RsltElem.style.top = document.body.scrollTop+20;

            
            RsltElem = document.getElementById(this.fck+"___Frame");
            if(RsltElem){
               if(this.height) RsltElem.style.height =this.height;
               else RsltElem.style.height = window_top*90/100-150;                 
            }           
                          
        };  
        
    };
    MW.VYDO.HTMLEditor = new MW.VYDO.HTMLEditor_Class();
    
    
    //Alert
    MW.VYDO.Alert = function(pText){
        alert(pText);
    };
    
    
    //Modules
    MW.VYDO.Module = {};
    
    //Module_Comments
    MW.VYDO.Module.Module_Comments_Class = function(){
        this.test = function(pContainerInnerID, pModuleCode, pModuleID){
           alert(pContainerInnerID+" - "+pModuleCode+" - "+ pModuleID);       
        };
        
        this.askForAddComment = function(pContainerInnerID, pModuleCode, pModuleID){
             
            if(MW.VYDO.Authentification.authentified()){
                MW.VYDO.HTMLEditor.getHTMLText("Texte du commentaire", '', pContainerInnerID, pModuleCode, pModuleID,["insert"],{CallBack:"editmodule", ToolbarSet:'Default'});
                
            }else{
                new MW.VYDO.Alert("Vous ne pouvez pas ajouter de commentaire sans être connecté.");
            }
        };  
    };
    MW.VYDO.Module.Module_Comments = new MW.VYDO.Module.Module_Comments_Class();
    
    //Module_MyFriends    
    MW.VYDO.Module.Module_MyFriends_Class = function(){
        
        this.addAFriend = function(pFriendID){
            MW.Waiter.show();
            MWMyPageService.action("addAFriend",[pFriendID],this.addAfriendComplete);             
        } ;  
        this.subscribeToBeFriend = function(pFriendID){
            MW.Waiter.show();
            MWMyPageService.action("subscribeToBeFriend",[pFriendID],this.subscribeToBeFriendComplete);             
        } ;        
        
        this.subscribeToBeFriend2 = function(pFriendID){
            MW.Waiter.show();
            MWMyPageService.action("subscribeToBeFriend2",[pFriendID],this.subscribeToBeFriendComplete);             
        } ;      
        
        this.addAfriendComplete = function(result){
            MW.Waiter.hide();
            alert(result.infoMsg);                 
        } ;     
        
        this.subscribeToBeFriendComplete = function(result){
            MW.Waiter.hide();
            alert(result.infoMsg);          
        } ;                         
    };
    MW.VYDO.Module.Module_MyFriends = new MW.VYDO.Module.Module_MyFriends_Class();
    
    
    //Module_Article   
    MW.VYDO.Module.Module_Article_Class = function(){   
        this.askForUpdate = function(moduleContainerID, moduleCode, moduleID){
            MW.VYDO.HTMLEditor.getHTMLText("Edition de l'article", document.getElementById(moduleContainerID+'_Content').innerHTML, moduleContainerID, moduleCode, moduleID,["update"],{CallBack:"editmodule", ToolbarSet:'Blog',EditTitle:true, Title:document.getElementById(moduleContainerID+'_Title').innerHTML});
       };    
    }
    MW.VYDO.Module.Module_Article = new MW.VYDO.Module.Module_Article_Class();   
    
    //Module_Note  
    MW.VYDO.Module.Module_Note_Class = function(){   
       this.askForUpdate = function(moduleContainerID, moduleCode, moduleID,code, content){
 
            MW.VYDO.HTMLEditor.getHTMLText("Edition du post-it", content, moduleContainerID, moduleCode, moduleID,["updateNote",code],{CallBack:"editmodule", ToolbarSet:'Default'});
       };    
       this.askForInsert= function(moduleContainerID, moduleCode, moduleID){
 
            MW.VYDO.HTMLEditor.getHTMLText("Edition du post-it", "", moduleContainerID, moduleCode, moduleID,["insertNote"],{CallBack:"editmodule", ToolbarSet:'Default'});
       };    
    }
    MW.VYDO.Module.Module_Note = new MW.VYDO.Module.Module_Note_Class();   

    //Module_Travel  
    MW.VYDO.Module.Module_Travel_Class = function(){   
        this.update = function(pContainerInnerID, pModuleCode, pModuleID, pLat, pLong, pType, pQuery, pPage) 
        {
            MWMyPageService.editModule(OwnerID, pContainerInnerID, pModuleCode, pModuleID, ["update",pType, pQuery, pPage], editModuleComplete);             
            if(document.getElementById(pContainerInnerID+'_myMap')){
             this.panMap(pContainerInnerID,pLat,pLong); 
            }
        }; 
        
        this.panMap = function(pContainerInnerID,pLat,pLong){
         
            if(pLat != 0 && pLong != 0 && pLong != "" && pLat != ""  )
            {
            var myMap = window[pContainerInnerID+"_map"];
    
               var points = new VELatLong(pLat.replace(",","."),pLong.replace(",","."));

               myMap.SetCenter(points);
   
               if (CDVFlag)
                {
                    CDVFlag = false;
                    try {
                    myMap.DeletePushpin(1001);
                    } catch (exp) {}
                }
 
                var pin = new VEPushpin(1001, new VELatLong(pLat.replace(",",".") , pLong.replace(",",".")), "images/pointer2.gif",
                          "","");
                    
                myMap.AddPushpin(pin);

                CDVFlag = true;
            }
           }
           
           this.askSendToFriend = function(pType,pCode,pLatitude,pLongitude){
                MW.Popup.open("sendTravelToFriend",[pType,pCode,pLatitude,pLongitude]);        
           };  
           
           this.sendToFriendByMail = function(pEMail,pType,pCode,pLatitude,pLongitude){
                MWMyPageService.action('sendTravelToFriendByMail', [OwnerID,pEMail,pType,pCode,pLatitude,pLongitude],this.onSendToFriend);    
                MW.Waiter.show();                  
           };
           
           this.sendToFriendByLogin= function(pLogin,pType,pCode,pLatitude,pLongitude){
                MWMyPageService.action('sendTravelToFriendByLogin', [OwnerID, pLogin,pType,pCode,pLatitude,pLongitude],this.onSendToFriend);  
                MW.Waiter.show();            
           };           
       
           this.onSendToFriend= function(pResult){
                MW.Waiter.hide();     
                alert(pResult.infoMsg);   
                MW.Popup.close();
           };            
           
    }
    
    MW.VYDO.Module.Module_Travel = new MW.VYDO.Module.Module_Travel_Class();   
    
    //DIAPORAMA
    MW.VYDO.Diaporama_Class = function(){   
    
        this.prefix = "";
           
        this.show = function (pImgStart,pImgCount, pModuleContainer)
        {   

        
	        if(pModuleContainer && pModuleContainer!="") this.prefix = pModuleContainer+"_";
	        else this.prefix="";

            if(!pImgStart) pImgStart = document.getElementById(this.prefix+'imageIndex'+ 1 + 'ID').value

            document.body.style.overflow = "visible";
       
	        var RsltElem = document.getElementById("couche1");
	    	
	    	
	        RsltElem.style.display = 'block' ;
                
	        RsltElem = document.getElementById("couche2"); 
	        RsltElem.style.display = 'block' ;

            this.display();
	       
            this.setImage(pImgStart,pImgCount); 
            
   
        }
        
        this.next = function ()
        {
            var indImage = document.getElementById(this.prefix+"imageIndex"+ 1 + "ID").value;
            indImage++;	
            var maxImage = document.getElementById(this.prefix+"imagesCount"+ 1 + "ID").value;
            if (indImage > maxImage-1) indImage=maxImage-1;
            this.setImage(indImage,maxImage);
        }    
        
        this.previous = function ()
        {
            var indImage = document.getElementById(this.prefix+"imageIndex"+ 1 + "ID").value;
            indImage--;	
            var maxImage = document.getElementById(this.prefix+"imagesCount"+ 1 + "ID").value;
            if (indImage < 0) indImage=0;
            this.setImage(indImage,maxImage); 
        }  


        
        this.setImage = function (pImgIndex,pImgCount)
        {	 
      
            document.getElementById(this.prefix+"imageIndex"+ 1 + "ID").value = pImgIndex ;
          
            var RsltElem = document.getElementById("panorama_r3_c3");	
    	    RsltElem.src = document.getElementById( this.prefix+"imagesList"+ 1 + "_"+ pImgIndex + "ID").value;
             var RsltElem = document.getElementById("indexImage");
            
             pImgIndex=new Number(pImgIndex);
             
            RsltElem.value = (pImgIndex+1) + "/" + pImgCount;  
	        RsltElem = document.getElementById("legendePhoto");
	        RsltElem.innerHTML = document.getElementById( this.prefix+"imagesLegend"+ 1 + "_"+ pImgIndex + "ID").value;
        }            
               
 
        this.close = function (pImgStart,pImgCount,pModuleContainer)
        {
	        FP_changeProp('couche1',0,'style.display','none');
	        FP_changeProp('couche2',0,'style.display','none');
	        MW.ScrollBar.show();
	        this.prefix="";
	    }           
	    
	    
	    this.display = function(){
            var window_top;
            if (window.innerHeight) window_top = window.innerHeight;
            else window_top = document.documentElement.scrollHeight;
	    
            var RsltElem = document.getElementById("couche1");
            if(RsltElem.style.display != "none"){          
                RsltElem.style.height = window_top; 
                RsltElem.style.top = document.body.scrollTop;
                RsltElem = document.getElementById("couche2");
                RsltElem.style.top = document.body.scrollTop+20;  
            }
        };   
    }   

    MW.VYDO.Diaporama = new MW.VYDO.Diaporama_Class();   
    
    //Favorites   
    MW.VYDO.Favorites_Class = function(){
        
        this.add = function(pObjectCode, pObjectType,pTitle,pLatitude,pLongitude,pOwnerID){
            var owner;
            if(pOwnerID) owner=pOwnerID; else owner=OwnerID;
            MWMyPageService.action('addToFav',[owner,UserID,pObjectCode,pObjectType,pTitle,'',pLatitude,pLongitude],this.addComplete); 
        } ;  

        this.addComplete = function(result){
             alert(result.infoMsg);         
        } ;                      
             
		
		this.onDrop = function(x,y,theDraggedObject,receiverList){	
		    var receiver = 	receiverList.split(";")[0];

			//alert("x :"+ document.getElementById(receiverList+"_ObjectCode").value);
			var folderID = receiver.split("TreeFolder_")[1];
            var draggedObject = document.getElementById(theDraggedObject);            
            /*var text =  draggedObject.outerHTML;
            draggedObject.outerHTML ="";          			
			document.getElementById(folderID+"_Contents").innerHTML += text;*/			
			var favoritesIDtarget= document.getElementById(folderID+"_ObjectCode").value;	
	
			var tempArray= document.getElementById(theDraggedObject+"_ObjectCode").value.split(";");	
	
			var favoritesIDsource = tempArray[1];
			var elementCode = tempArray[0];	
	
			
            var containerID = folderID.split("_")[0];
            var moduleTypeCode = document.getElementById(containerID+"_moduleTypeCode").value; 
                  
            callUIModule(containerID, moduleTypeCode,'moveFavorite', favoritesIDsource,elementCode, favoritesIDtarget)

		}	;	
		
		this.deleteFav = function(pContainerID,pModuleTypeCode,pFavoritesID,pElementCode){	
	        if(confirm("Voulez vous effacer ce favoris ?"))
	            callUIModule(pContainerID, pModuleTypeCode, 'removeFavorite', pFavoritesID, pElementCode);
		};
		
		this.deleteGroup = function(pContainerID,pModuleTypeCode,pFavoritesID){
		    if(confirm("Voulez vous effacer ce groupe de favoris ?"))
		        callUIModule(pContainerID, pModuleTypeCode, 'removeFavorites', pFavoritesID);
		};
	
    };
    MW.VYDO.Favorites = new MW.VYDO.Favorites_Class();
    
    
    //Tree
    MW.VYDO.Tree_Class = function(){
	
		this.folderStatus = {};
		
        this.restoreStatus = function ()
        {
			for(var i in this.folderStatus){		
				if(this.folderStatus[i] == true)  this.openFolder(i);
				else this.closeFolder(i);
			}
        };		
        
        this.openFolder = function (pFolderID)
        {        	
			this.folderStatus[pFolderID]=true;
			if(document.getElementById(pFolderID+"_CONTENT")){
                document.getElementById(pFolderID+"_OPEN").style.display = "none";
                document.getElementById(pFolderID+"_CLOSE").style.display = "inline";
                document.getElementById(pFolderID+"_CONTENT").style.display = "block"; 
            }               
        };
        
        this.closeFolder = function (pFolderID)
        {
			this.folderStatus[pFolderID]=false;
            document.getElementById(pFolderID+"_OPEN").style.display = "inline";
            document.getElementById(pFolderID+"_CLOSE").style.display = "none";
            document.getElementById(pFolderID+"_CONTENT").style.display = "none"; 
            //FIREFOX FIX
            document.getElementById("TreeFolder_"+pFolderID).innerHTML = document.getElementById("TreeFolder_"+pFolderID).innerHTML;                
        };
        
        this.editFolder = function (pFolderID)
        {               
/*          document.getElementById(pFolderID+"_TITLE").style.display = "inline";
            document.getElementById(pFolderID+"_EDITTITLE").style.display = "none";    */          
        };
        
        this.askEditFolder = function (pFolderID)
        {
            document.getElementById(pFolderID+"_TITLE").style.display = "none";
            document.getElementById(pFolderID+"_EDITTITLE").style.display = "inline";              
        };
        
        
                      
    };
    MW.VYDO.Tree = new MW.VYDO.Tree_Class();  
    
      
     
   //Popup
    MW.Popup_Class = function(){
	
	    this.afterClosingFunction = null;
	
        this.open = function (pPageID, pParams, pFunction)
        {           
           MW.ScrollBar.hide();
           document.getElementById("PopupBack").style.top = document.body.scrollTop;          
           document.getElementById("Popup").style.top = document.body.scrollTop+20;  
           document.getElementById("PopupBack").style.display = "block";  
           document.getElementById("PopupContent").innerHTML ="";

           document.getElementById("Popup").style.display = "block";          
           this.afterClosingFunction = pFunction;   
           MWMyPageService.popup(OwnerID, pPageID, pParams, this.onOpen);              
        };
           
        this.onOpen = function (pResult)
        {             
           if(pResult.isInfoMsg){
                alert(pResult.infoMsg);
                MW.Popup.close();
           }else
           var popupContent =  document.getElementById("PopupContent");
           if(pResult.moduleInnerHTMLContent) popupContent.innerHTML = pResult.moduleInnerHTMLContent;  
           else {popupContent.innerHTML = pResult}
           MW.Display.executeScript(popupContent);
           

        };   
        
		this.showWithIFrame = function(iFrame, pFunction) 
		{
			this.openWithContent(iFrame, pFunction);
		};
		
        this.show = function(pElement, pFunction){
			this.openWithContent(jQuery(pElement).html() , pFunction);
        };
        
        this.openWithContent = function (pContent, pFunction){
           MW.ScrollBar.hide();
               
           document.getElementById("PopupBack").style.top = document.body.scrollTop;          
           document.getElementById("Popup").style.top = document.body.scrollTop+50;  
           document.getElementById("PopupBack").style.display = "block";  
           document.getElementById("Popup").style.display = "block";  
               
           this.afterClosingFunction = pFunction;  
                 
           this.onOpen(pContent);                 
        };  
        
        this.close = function ()
        {
           MW.ScrollBar.show();
           document.getElementById("PopupBack").style.display = "none";   
           document.getElementById("Popup").style.display = "none";   
           if(this.afterClosingFunction) this.afterClosingFunction();
        };  
        
        this.onValidation = function (pResult)
        {
       
        };   
                      
    };
    MW.Popup = new MW.Popup_Class();      
    
    
        
    //UserGroup 
    MW.VYDO.UserGroup_Class = function(){   
       this.askInviteFriend = function(){
            MW.Popup.open("invite",[]);        
       };    
       
       this.askInviteToT2U = function(){
            MW.Popup.open("inviteToT2U",[]);        
       };   
       
       this.inviteByLogin= function(pLogin){
            MWMyPageService.action('inviteByLogin', [OwnerID, pLogin],this.onInvite);  
            MW.Waiter.show();            
       };
       
       this.inviteByMail= function(pEMail){
            MWMyPageService.action('inviteByMail', [OwnerID, pEMail],this.onInvite);    
            MW.Waiter.show();                 
       };     
       
       this.inviteToT2U= function(pEMail){
            MWMyPageService.action('inviteToT2U', [pEMail],this.onInvite);    
            MW.Waiter.show();                  
       };           
       
       this.onInvite= function(pResult){
            MW.Waiter.hide();     
            alert(pResult.infoMsg);   
            MW.Popup.close();
       };          
    }
    MW.VYDO.UserGroup = new MW.VYDO.UserGroup_Class();   
    
    
    //Contact
    MW.VYDO.Contact_Class = function(){   
       this.contactus = function(){
            MW.VYDO.HTMLEditor.getHTMLText("Contactez nous", "", null, null, null,["contactus",UserID],{CallBack:"action", ToolbarSet:'Default',EditTitle:true, Title:""});  
       };    

              
    }
    MW.VYDO.Contact = new MW.VYDO.Contact_Class();    
    
    //DatePicker
    MW.VYDO.DatePicker_Class = function(){   
       this.set = function(pSuffix){
         //   jQuery('#Mediawelcome_Working_'+pSuffix).tabs( { fxSlide: true, fxFade: true, fxSpeed: 'normal',disabled: [2, 3, 4]  }).enableTab(1).triggerTab(1);
                   
                //jQuery('.date-pick').datePicker()
                if(pSuffix && pSuffix!='')pSuffix='*'+pSuffix;
                else pSuffix ='';
        
                jQuery('#DateDebut'+pSuffix).datePicker();
                jQuery('#DateFin'+pSuffix).datePicker();   
                
	        /*    jQuery('#DateDebut'+pSuffix).bind(
		            'dpClosed',
		            function(e, selectedDates)
		            {
			            var d = selectedDates[0];
			            if (d) {
				            jQuery('#DateFin'+pSuffix).dpSetStartDate(d.addDays(1).asString());
			            }
		            }
	            );
	            jQuery('#DateFin'+pSuffix).bind(
		            'dpClosed',
		            function(e, selectedDates)
		            {
			            var d = selectedDates[0];
			            if (d) {
				            jQuery('#DateDebut'+pSuffix).dpSetEndDate(d.addDays(-1).asString());
			            }
		            }
	            );  
              jQuery("ul#gvUl_"+pSuffix).jqGalView({appendTo:"#jqGalViewHolder_"+pSuffix,items: 9});          */
                     
          };   
          
          this.linkDatePickers = function(start,end, offset){            
        	    //var d = new Date(start.value);
        	    if(!start || !end) return;
        	    
        	    var d = start.value;
        	    if(!offset) offset = 0;
		        if (d) {
			        jQuery(end).dpSetStartDate(d);//.addDays(1).asString());
		        }
			        
               jQuery(start).unbind('dpClosed').bind(
		        'dpClosed',
		        function(e, selectedDates)
		        {
			        var d = selectedDates[0];
			        if (d) {
				        jQuery(end).dpSetStartDate(d.addDays(offset).asString());
				        if(!jQuery(end).dpGetSelected()[0] || jQuery(end).dpGetSelected()[0].getTime() < d.getTime())
				        {
				            var month = d.getMonth() + 1;
				            if (month < 10)
				                month = "0" + month;
				            var day = d.getDate();
				            if (day < 10)
				                day = "0" + day;
				            jQuery(end).val(day+"/"+(month)+"/"+d.getFullYear());
				        }
			        }
		        }
	        );
	        /*jQuery(end).bind(
		        'dpClosed',
		        function(e, selectedDates)
		        {
			        var d = selectedDates[0];
			        if (d) {
				        jQuery(start).dpSetEndDate(d.addDays(-1).asString());
			        }
		        }
	        );    */          
          }                    
    }
    MW.VYDO.DatePicker = new MW.VYDO.DatePicker_Class();     
    
    
    //Waiter
    MW.Waiter_Class = function(){   
        this.scrollTop = null;
        this.timer = null;
        this.show = function ()
        {           
           //document.getElementById("WaitBack").style.top = document.body.scrollTop;          
           //document.getElementById("Wait").style.top = document.body.scrollTop; 
           var ScrollBar_visible = MW.ScrollBar.visible;
           if(!ScrollBar_visible) MW.ScrollBar.show();
           
           document.getElementById("WaitBack").style.display = "block"; 
           document.getElementById("WaitBack").style.height = window.document.body.scrollHeight+'px';
           document.getElementById("Wait").style.display = "block";   
           document.getElementById("Wait").style.top = document.body.scrollTop;  
           this.scrollTop = document.body.scrollTop;
          
           //FAB gene le flash: FOR RESATAR //MW.ScrollBar.hide(); 
           //document.body.scrollTop = this.scrollTop;    
           
           if(!ScrollBar_visible) MW.ScrollBar.hide();
           
           clearTimeout(this.timer);
           this.timer = setTimeout("MW.Waiter.hide();", 60000);              
        };
        
        this.hide = function ()
        {      
           
           document.getElementById("WaitBack").style.display = "none";   
           document.getElementById("Wait").style.display = "none";           
          
           //FAB gene le flash: FOR RESATAR //if(this.scrollTop!=null) MW.ScrollBar.show();
           if(this.scrollTop) document.body.scrollTop = this.scrollTop;                      
           clearTimeout(this.timer);
           this.timer = setTimeout("MW.Waiter.forceToTop();", 200);
           
        };     
        
        this.forceToTop = function (){
            if(this.scrollTop) document.body.scrollTop = this.scrollTop;  
        }
    }
    MW.Waiter = new MW.Waiter_Class();   
    
    
    //UserGroup 
    MW.ScrollBar_Class = function(){   
        this.AvailableInPage = true;
        this.visible = true;
        this.scrollTop = null

        this.show = function (forced)
        {           
            if( this.AvailableInPage || forced){
             document.body.style.overflow = 'scroll';  
             this.visible = true;
            }
        };
        
        this.hide = function ()
        {
           this.scrollTop = document.body.scrollTop;
           document.body.style.overflow = 'hidden';  
           document.body.scrollTop = this.scrollTop;
           this.visible = false;
        };     
    }
    MW.ScrollBar = new MW.ScrollBar_Class(); 
    

    MW.Booking={};
    MW.Booking.POBookingDisplay_Class = function(){   
        var me = this;
    
       this.launchScript = function (pStep, pPOBCode){
            var suffix = ((pPOBCode)?('*'+pPOBCode):'');   
            
            switch(pStep){
                case "FirstHotelStep":  
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").show();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                break;
                
                case "Availabilities" :
                    /* Gestion des tabs */
                    var isInit=true;
                    var from='';
                    
                    workingPanel=jQuery('#Mediawelcome_Working_Panel_Avail'+suffix);
                    if (typeof(NotFirstEval)!='undefined'){
                      isInit=!NotFirstEval;
                    }       
                    if (isInit){
                        
                    /* Gestion de l'affichage de la popup de détail des prix */
                   /* workingPanel.find('.Mediawelcome_Popup_Price').unbind().bind('click',function(){          
                    xPopupPlanning('Détail des prix:', "test",250,350,null,jQuery('#' + this.id + '_Cible')[0].innerHTML,this);
                    });*/
                    /* Gestion des show / hide pour les détails produit */
                    jQuery('.Mediawelcome_Link_Info_Product').unbind().bind('click',function(){ 
                      var index = this.id.lastIndexOf("_");      
                      var position = this.id.substring(index + 1, this.id.length); 
                      jQuery('.Div_Avail_Product_' + position).show();     
//                      currentPanel=$(this.id);          
//                      currentPanel.show();         
                      jQuery(this).hide().parent().find('.Mediawelcome_Link_Info_Product_Hide').show();
                    });
                    jQuery('.Mediawelcome_Link_Info_Product_Hide').unbind().bind('click',function(){ 
                      var index = this.id.lastIndexOf("_");      
                      var position = this.id.substring(index + 1, this.id.length); 
                      jQuery('.Div_Avail_Product_' + position).hide();              
//                      currentPanel=$(this.id);         
//                      currentPanel.hide(); 
                      jQuery(this).hide().parent().find('.Mediawelcome_Link_Info_Product').show();
                    });
                    }
//                   if (from=='' && from!='tabs'){
//                       jQuery('#Mediawelcome_Working'+suffix).tabs({ disabled: [ 3, 4] } ).enableTab(2).triggerTab(2); 
//                   }
                   Recap=workingPanel.find('.Mediawelcome_Panel_Recap_Ghost').html();       
                   jQuery('#Mediawelcome_Recap_Inner_Content'+suffix).empty().append(Recap);
                   workingPanel.remove('.Mediawelcome_Panel_Recap_Ghost');    
                    if (typeof(NotFirstEval)!='undefined'){
                      NotFirstEval=false;
                    }
                    
                    /* Gestion des arrondies pour les rooms */
                    jQuery('.Mediawelcome_Product_Inner').corner("round 8px top");
                    jQuery('.Mediawelcome_Product_Inner2').corner("round 8px bottom");
                    jQuery('.Mediawelcome_Product_Outer').css('padding', '2px').corner("round 10px");           

                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").show();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    this.BindAndUpdateStepImages(2);
                    this.UpdateImagesSrc(2,2);
                break;
            
                case "Quote" : 
                    workingPanel=jQuery('#Mediawelcome_Working_Panel_Quote'+suffix);
                    
                    Recap=workingPanel.find('.Mediawelcome_Panel_Recap_Ghost').html();                       
                    jQuery('#Mediawelcome_Recap_Inner_Content'+suffix).empty().append(Recap);
                    workingPanel.remove('.Mediawelcome_Panel_Recap_Ghost');   
                    jQuery('#diagramItemPrice'+suffix).text(jQuery('#totalPrice').text());       
                    if(jQuery('#ProductToBook_CB'+suffix)[0])
                        jQuery('#ProductToBook_CB'+suffix)[0].disabled = false;  
                    if(jQuery('#ProductToBook_CB2'+suffix)[0])   
                     jQuery('#ProductToBook_CB2'+suffix)[0].disabled = false;  
                     
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").show();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    this.BindAndUpdateStepImages(3);
                    this.UpdateImagesSrc(3,3);
                break;               
                
                case "Book" : 
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").show();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                break;   
                
                case "Ticketing":
                    //Mise à jour du titre en haut
                    jQuery('.Mediawelcome_Title')[0].innerHTML = "R&eacute;servation de vos billets";
                    //on bind les évènements sur les descriptions de billeterie à afficher en popup
                    jQuery('.Mediawelcome_Link_Info_Ticketing').unbind().bind('click',function(){ 
                      var index = this.id.lastIndexOf("_");      
                      var productCode = this.id.substring(index + 1, this.id.length); 
                      //var popupContent = jQuery('div[@id$=Mediawelcome_Info_Ticketing_]')[0].innerHTML;
                      //var popupContent = document.getElementById('Mediawelcome_Info_Ticketing_' + productCode).innerHTML;
                      var popupContent = jQuery('#Mediawelcome_Info_Ticketing_' + productCode)[0].innerHTML;   
                      MW.Popup.openWithContent(popupContent);
                    });

                    //On affiche la div correspondant à la nouvelle étape
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').show();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    this.BindAndUpdateStepImages(4);
                    this.UpdateImagesSrc(4,4);
                break;  
                
                case "Tick_Availabilities":
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').show();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    this.BindAndUpdateStepImages(5);
                    this.UpdateImagesSrc(5,5);
                break;   
                
                case "Tick_Quote":
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').show();
                    
                    this.BindAndUpdateStepImages(5);
                    this.UpdateImagesSrc(5,5);
                break;  
            }
       };
       
       this.BindAndUpdateStepImages = function(pCurrentStepInteger)
       {                    
            jQuery("#myImgStep1").unbind().bind('click',function(){ 
                jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").show();
                jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                jQuery('#MediaWelcome_Ticketing_Avail').hide();
                jQuery('#MediaWelcome_Ticketing_Quote').hide();
                
                me.UpdateImagesSrc(pCurrentStepInteger,1);  
            });
            
            if (pCurrentStepInteger >= 2)
            {                   
                jQuery("#myImgStep2").unbind().bind('click',function(){   
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").show();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    me.UpdateImagesSrc(pCurrentStepInteger,2);  
                }); 
            } 
            
            if (pCurrentStepInteger >= 3)
            {                   
                jQuery("#myImgStep3").unbind().bind('click',function(){ 
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").show();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    me.UpdateImagesSrc(pCurrentStepInteger,3);  
                });
            }  
             
            if (pCurrentStepInteger >= 4)
            {                    
                jQuery("#myImgStep4").unbind().bind('click',function(){ 
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').show();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').hide();
                    
                    me.UpdateImagesSrc(pCurrentStepInteger,4);  
                }); 
            }
            
            
            if (pCurrentStepInteger >= 5)
            {                     
                jQuery("#myImgStep5").unbind().bind('click',function(){ 
//                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
//                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
//                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
//                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
//                    jQuery('#MediaWelcome_Ticketing_Avail').show();
//                    jQuery('#MediaWelcome_Ticketing_Quote').hide();

                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').show();
                    
                    me.UpdateImagesSrc(pCurrentStepInteger,5);  
                }); 
            }
            
          /*  if (pCurrentStepInteger >= 6)
            {                     
                jQuery("#myImgStep6").unbind().bind('click',function(){  
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Description*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Avail*]").hide();
                    jQuery("div").filter("[@id^=Mediawelcome_Working_Panel_Quote*]").hide();
                    jQuery('#MediaWelcome_Ticketing_Choice_Panel').hide();
                    jQuery('#MediaWelcome_Ticketing_Avail').hide();
                    jQuery('#MediaWelcome_Ticketing_Quote').show();
                    
                    me.UpdateImagesSrc(pCurrentStepInteger,6);  
                }); 
            }*/
       }; 
       
        this.UpdateImagesSrc = function(pCurrentStep,pFromStep)
        {
            var langSuffix = jQuery('#hdfLangSuffix')[0].value;
            
            var isTicketing = 'false';
            if (jQuery('#hdfIsTicketing'))
                isTicketing = jQuery('#hdfIsTicketing')[0].value;                
            if (isTicketing == 'false')
            {
                jQuery("#myImgStep4").hide();
                jQuery("#myImgStep5").hide();
             //   jQuery("#myImgStep6").hide();
            }
            
            
            var isHotel = 'false';
            if (jQuery('#hdfIsHotel'))
                isHotel = jQuery('#hdfIsHotel')[0].value;                
            if (isHotel == 'false')
            {
                jQuery("#myImgStep1").hide();
                jQuery("#myImgStep2").hide();
                jQuery("#myImgStep3").hide();
            }
            
            var version = "V";
            if (isHotel == 'true')
                version = version + "H";
            if (isTicketing == 'true')
                version = version + "B";
            
            if (pFromStep == 1)
            {
                jQuery("#myImgStep1")[0].src = "img/filAriane_" + version + "_on_1" + langSuffix + ".gif";
                jQuery("#myImgStep1")[0].style.cursor = 'pointer';
            }
            else
            {
                jQuery("#myImgStep1")[0].src = "img/filAriane_" + version + "_off_1" + langSuffix + ".gif";
                jQuery("#myImgStep1")[0].style.cursor = 'pointer';
            }
            
            if (pFromStep == 2)
            {
                jQuery("#myImgStep2")[0].src = "img/filAriane_" + version + "_on_2" + langSuffix + ".gif";
                jQuery("#myImgStep2")[0].style.cursor = 'pointer';
            }
            else if (pCurrentStep >= 2)
            {
                jQuery("#myImgStep2")[0].src = "img/filAriane_" + version + "_off_2" + langSuffix + ".gif";
                jQuery("#myImgStep2")[0].style.cursor = 'pointer';
            }  
            else
            {
                jQuery("#myImgStep2")[0].src = "img/filAriane_" + version + "_dis_2" + langSuffix + ".gif";
                jQuery("#myImgStep2")[0].style.cursor = 'default';
            }  
            
            if (pFromStep == 3)
            {
                jQuery("#myImgStep3")[0].src = "img/filAriane_" + version + "_on_3" + langSuffix + ".gif";
                jQuery("#myImgStep3")[0].style.cursor = 'pointer';
            }
            else if (pCurrentStep >= 3)
            {
                jQuery("#myImgStep3")[0].src = "img/filAriane_" + version + "_off_3" + langSuffix + ".gif";
                jQuery("#myImgStep3")[0].style.cursor = 'pointer';
            }  
            else
            {
                jQuery("#myImgStep3")[0].src = "img/filAriane_" + version + "_dis_3" + langSuffix + ".gif";
                jQuery("#myImgStep3")[0].style.cursor = 'default';
            } 
            
            if (pFromStep == 4)
            {
                jQuery("#myImgStep4")[0].src = "img/filAriane_" + version + "_on_4" + langSuffix + ".gif";
                jQuery("#myImgStep4")[0].style.cursor = 'pointer';
            }
            else if (pCurrentStep >= 4)
            {
                jQuery("#myImgStep4")[0].src = "img/filAriane_" + version + "_off_4" + langSuffix + ".gif";
                jQuery("#myImgStep4")[0].style.cursor = 'pointer';
            }  
            else
            {
                jQuery("#myImgStep4")[0].src = "img/filAriane_" + version + "_dis_4" + langSuffix + ".gif";
                jQuery("#myImgStep4")[0].style.cursor = 'default';
            } 
            
            if (pFromStep == 5)
            {
                jQuery("#myImgStep5")[0].src = "img/filAriane_" + version + "_on_5" + langSuffix + ".gif";
                jQuery("#myImgStep5")[0].style.cursor = 'pointer';
            }
            else if (pCurrentStep >= 5)
            {
                jQuery("#myImgStep5")[0].src = "img/filAriane_" + version + "_off_5" + langSuffix + ".gif";
                jQuery("#myImgStep5")[0].style.cursor = 'pointer';
            }  
            else
            {
                jQuery("#myImgStep5")[0].src = "img/filAriane_" + version + "_dis_5" + langSuffix + ".gif";
                jQuery("#myImgStep5")[0].style.cursor = 'default';
            } 
        };  

    }
     MW.Booking.POBookingDisplay = new  MW.Booking.POBookingDisplay_Class();
     
     
     MW.ResaStar = {};
    
     
     
     MW.WebPlanning_Class = function(){
     
         this.MWProduct = new Array();
         this.currentDate = new Date();
     
         this.onClick = function(pWebPlanningContentRef){
              var JQ_Planning = jQuery('#Planning');
               jQuery('#'+pWebPlanningContentRef).append(JQ_Planning); 
               JQ_Planning.show();

              this.displayAtMonth(new Date());      
              
         };
         
         this.gotoPreviousMonth = function(){
             if(this.currentDate.getMonth() == 0)
                this.displayAtMonth(new Date(this.currentDate.getFullYear()-1, 11, 1));
             else
                this.displayAtMonth(new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()-1, 1));               
         };
         
         this.gotoNextMonth = function(){
             if(this.currentDate.getMonth() == 12)
                this.displayAtMonth(new Date(this.currentDate.getFullYear()+1, 11, 1));
             else
                this.displayAtMonth(new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()+1, 1));       
         };
         
          this.displayAtMonth = function(pDate){ 
               this.currentDate = pDate;
               
               var today = new Date();
               today.setTime(today.getTime()-24*60*60*1000);
          
               var JQ_Planning = jQuery('#Planning');               
               var dispos = eval(jQuery("#Planning_Data").html());
               
               //Mise en forme navigateur
               if(pDate.getMonth()>new Date().getMonth() || pDate.getFullYear()>new Date().getFullYear()) 
                    JQ_Planning.find("table tr").eq(0).find("#PreviousMonth").show();
               else 
                      JQ_Planning.find("table tr").eq(0).find("#PreviousMonth").hide();            
               JQ_Planning.find("table tr").eq(0).find("#CurrentDate").html((pDate.getMonth()+1)+"/"+pDate.getFullYear());
                
               var tdlist;
               //Mise en forme du calendrier
               JQ_Planning.find("table tr").eq(0).each(function(){
                       
                       tdlist = jQuery(this).find("td");

                            for(t=1; t < tdlist.length; t++){
                                var date = new Date(pDate.getFullYear(), pDate.getMonth(), t);
                                if(date.getTime()>= today.getTime()  && date.getMonth()==pDate.getMonth()){
                                    if(date.getDay()==0 || date.getDay()==6) tdlist[t].className = "HCF";
                                    else tdlist[t].className = "HC";
                                }else{
                                    tdlist[t].className = "HC_NONE";
                                }
                            }                        
                          
               });  
               
               //Mise en forme des dispos et de prix
               //pour chaque ligne on effectue l'opération
               JQ_Planning.find("table tr").each(function(){
                    if(jQuery(this).attr("availCode")){
                       tdlist = jQuery(this).find("td");
                       for(var di=0; di < dispos.length; di++){
                            //On affiche les dispo pour l'annee correspondante
                           if(dispos[di].Year == pDate.getFullYear()){   
                            //Dispos                 
                               for(var d=0; d<dispos[di].AvailList.length; d++){  
                                var disp = dispos[di].AvailList[d];  
                                                                                       
                                if(disp.Code == jQuery(this).attr("availCode")){
                                    var availList = disp.Avail[pDate.getMonth()].split("|");
                                    for(t=1; t < tdlist.length; t++){                                                                        
                                        var date = new Date(pDate.getFullYear(), pDate.getMonth(), t);
                                        if(date.getTime() >= today.getTime()  && date.getMonth()==pDate.getMonth()){
                                            if(date.getDay()==0 || date.getDay()==6){
                                                if(availList[t-1] > 0) tdlist[t].className = "D_F";
                                                else tdlist[t].className = "DR_F";
                                            }
                                            else {
                                                if(availList[t-1] > 0) tdlist[t].className = "D";
                                                else tdlist[t].className = "DR";
                                            }
                                         }else{
                                            tdlist[t].className = "D_NONE";
                                         }                                        
                                    }
                                    break;
                                }
                               }
                               
                                for(t=1; t < tdlist.length; t++){                                                                        
                                    tdlist[t].innerHTML = "";                                      
                                }
                               //Prix
                               for(var pg=0; pg<dispos[di].PriceGridList.length; pg++){  
                                var priceGrid = dispos[di].PriceGridList[pg];  
                                if (priceGrid.Code == null)
                                {
                                    if (di == 1)
                                    {
                                        dispos[di].PriceGridList = dispos[0].PriceGridList;
                                        priceGrid = dispos[di].PriceGridList[pg];
                                    }
                                }                                                  
                                if(priceGrid.Code == jQuery(this).attr("priceGridCode")){
                                    //On teste sur chaque période correspondant au mois
                                    var startDateDay = new Number(priceGrid.StartDate.substr(0,2));
                                    var startDateMonth = new Number(priceGrid.StartDate.substr(3,2)-1);                                    
                                    var startDateYear = new Number(priceGrid.StartDate.substr(6,4));   
                                    var startDate = new Date(startDateYear, startDateMonth, startDateDay);
                                    
                                    var endDateDay = new Number(priceGrid.EndDate.substr(0,2));
                                    var endDateMonth = new Number(priceGrid.EndDate.substr(3,2)-1);                                    
                                    var endDateYear = new Number(priceGrid.EndDate.substr(6,4));   
                                    var endDate = new Date(endDateYear, endDateMonth, endDateDay);                                    
                                    
                                    var startMonthDate = new Date(pDate.getFullYear(), pDate.getMonth(), 1);
                                    var endMonthDate = new Date(pDate.getFullYear(), pDate.getMonth()+1, 1);
                                    
                                    if(startDate >= endMonthDate || endDate <= startMonthDate){                                    
                                    }                                    
                                    else if(startDate <= startMonthDate &&
                                        endDate >= endMonthDate
                                    ){                              
                                        for(t=1; t < tdlist.length; t++){                                                                        
                                            tdlist[t].innerHTML = priceGrid.Amount;                                      
                                        }
                                    }
                                    else                                     
                                    {
                                        if(startDate <= startMonthDate) startDateDay = 1;
                                        if(endDate >= endMonthDate) endDateDay = 31; 
                                         for(t=startDateDay; t <= endDateDay; t++){                                                                        
                                            if(tdlist[t].className != "D_NONE") tdlist[t].innerHTML = priceGrid.Amount;                                      
                                        }                                        
                                    }
                                    //break;
                                }
                               } 
                               
                            }
                       }
             
                       
                    }
               });  
          };
     }
     MW.WebPlanning = new  MW.WebPlanning_Class();  
     
     
     
     
     MW.Travel_Class = function(){
         this.insertLAV = function(pType, pLattitude, pLongitude, pCode, pName, pPays, pVille, pMode){    
            if(!pMode) pMode = MW.AppConfig.travelMode;
            switch(pMode){
                case "CB":
                    insertElementInSelectionCB(pType, pLattitude, pLongitude, pCode, pName, pPays, pVille); 
                    break;
                case "RES":
                    var searchParametersGROUPE = new Object();
                    searchParametersGROUPE.Type = Type;
                    searchParametersGROUPE.Code = Code;
                    searchParametersGROUPE.Name = Name;
                    searchParametersGROUPE.Pays = Pays;
                    searchParametersGROUPE.Ville = Ville;
                    searchParametersGROUPE.Lattitude = Lattitude;
                    searchParametersGROUPE.Longitude = Longitude;
                    searchParametersGROUPE.Position = 0;
                    MWTravelService.InsertLAV(searchParametersGROUPE,this.onInsert);
                    break;            
            }
         };
         
        this.insertProduct = function(pItem){
			jQuery("#diagramWaiter").show();
			//WARNING : THE STARTING DATE SHOULD BE PASSED IN PARAMETERS (Gotta change the display Product booking XSLT so that it calls this method with the right parameters)
			/*var startingDate = document.getElementById("ctbDepartureDateInput").value;
			var duration = document.getElementById("ddDurationInput").value;
            MWTravelService.AddProductToTravel(pItem, startingDate, duration, this.onDiagramUpdate);*/
            MWTravelService.AddProductToTravel(pItem, this.onDiagramUpdate);
        };    
        
        this.insertProductFromProductInfo  = function(pCatalogCode, pProductCode, pProductTypeCode){
			jQuery("#diagramWaiter").show();
            MWTravelService.AddProductToTravelByProductInfo(pCatalogCode, pProductCode, pProductTypeCode, this.onDiagramUpdate);
        };           
        
        this.deleteItem = function(pItemCode){
			jQuery("#diagramWaiter").show();
            MWTravelService.DeleteItem(pItemCode,this.onDiagramUpdate);
        };
        
        this.incDuration = function(pBlockId){
			jQuery("#diagramWaiter").show();
            MWTravelService.IncrementDuration(pBlockId,this.onDiagramUpdate);
        };
        
        this.decDuration = function(pBlockId){
			jQuery("#diagramWaiter").show();
			MWTravelService.DecreaseDuration(pBlockId,this.onDiagramUpdate);
        };
        
        this.setDuration = function(pBlockId, duration){
			
			if(isNaN(duration))
			{
				alert("Veuillez saisir un nombre");
			}
			else
				if(duration >= 0)
				{
					jQuery("#diagramWaiter").show();
					MWTravelService.SetDuration(pBlockId, duration,this.onDiagramUpdate);
				}else{
					alert("la durée doit être positive");
				}
        };
        
        this.switchUp = function(pBlockId){
			jQuery("#diagramWaiter").show();
            MWTravelService.SwitchBlockUp(pBlockId,this.onDiagramUpdate);
        };
        
        this.switchDown = function(pBlockId){
			jQuery("#diagramWaiter").show();
			MWTravelService.SwitchBlockDown(pBlockId,this.onDiagramUpdate);
        };
        
        this.switchItemUp = function(pItem){
			jQuery("#diagramWaiter").show();
            MWTravelService.SwitchItemUp(pItem,this.onDiagramUpdate);
        };
        
        this.switchItemDown = function(pItem){
			jQuery("#diagramWaiter").show();
			MWTravelService.SwitchItemDown(pItem,this.onDiagramUpdate);
        };
                
        this.changeDate = function(newDate){
			jQuery("#diagramWaiter").show();
            MWTravelService.ChangeDate(newDate,this.onDiagramUpdate);
        };
        
        
        
        
        this.insertScenario = function()
        {
	        jQuery("#diagramWaiter").show();
			hidePopup();
			MWTravelService.GenerateScenarioFromFile(jQuery("#SearchScenarioPath")[0].value,this.onDiagramUpdateLocalize);
        };
        
        this.insertScenarioFromFile = function(file)
        {
	        jQuery("#diagramWaiter").show();
			hidePopup();
			MWTravelService.GenerateScenarioFromFile(file,this.onDiagramUpdateLocalize);
        };
        
        
        
        
        this.insertBlock = function(pId_block, pCode, pName){
			jQuery("#diagramWaiter").show();
			hidePopup();
            MWTravelService.InsertBlock(pCode, pName,pId_block,this.onDiagramUpdateLocalize);
        };   
        
        this.insertMove = function(pId_block1, pCode1, pName1, pId_block2, pCode2, pName2){
            jQuery("#diagramWaiter").show();
			MWTravelService.InsertMove(pCode1, pName1,pId_block1,   pCode2, pName2,pId_block2,this.onDiagramUpdate);
        };
        
        this.removeMove = function(pId_block1, pId_block2){
            jQuery("#diagramWaiter").show();
			MWTravelService.RemoveMove(pId_block1, pId_block2 ,this.onDiagramUpdate);
        };
        
        this.deleteBlock = function(pBlockId){
			jQuery("#diagramWaiter").show();
			MWTravelService.DeleteBlock(pBlockId ,this.onDiagramUpdate);
        };
        
        this.resetTravel = function(){
			jQuery("#diagramWaiter").show();
			MWTravelService.ResetTravel(this.onDiagramUpdate);
        };


        this.refreshTravel = function(){
			if (MWTravelService)
			{
			    jQuery("#diagramWaiter").show();
			    MWTravelService.RefreshTravel(this.onDiagramUpdate,this.onDiagramFailed);
			}
        };
        
        this.onDiagramUpdateLocalize = function(pResult){
            MW.Travel.onDiagramUpdate(pResult);
            MW.Map.setViewFromLAVList(pResult.specificContent.elements);
        };
        
        this.onDiagramUpdate = function(pResult){
			if(pResult.content){
				jQuery("#ctl00_ContentPlaceHolder1_diagram").html(pResult.content);
				 
				 //Mise à jour de la date aller vols
				if(pResult.specificContent.lastUpdatedBlockEndDate && pResult.specificContent.lastUpdatedBlockEndDate != ''){
				    jQuery(".SearchProductFlightDepartureDate").dpSetSelected(pResult.specificContent.lastUpdatedBlockEndDate);
				    CPT_searchProductComponent.LastSearchDate = pResult.specificContent.lastUpdatedBlockEndDate;
				}
				            
				window.MW_setScenario = function(){
				    if(MW_FLASH.map) MW_FLASH.map.flashMap.setScenario(pResult.specificContent);
				    jQuery("#diagramContainer script").html('');
				    jQuery("#diagramContainer").html(jQuery("#diagramContainer").html());
				    //jQuery("#diagramContainer").html(jQuery("#diagramContainer").html());
				    jQuery('#travelDate').datePicker({clickInput:true}).bind(
																    'dateSelected',
																    function(e, selectedDate, $td)
																    {
																	    MW.Travel.changeDate(this.value);
																    }
															     )
	            };
	            
	            //Mise a jour du parcours sur la carte
	            setTimeout("MW_setScenario()",200);
			
			}
			jQuery("#diagramWaiter").hide();						
        };       
        
  
     }
      this.onDiagramFailed = function(){
			jQuery("#diagramWaiter").hide();
      }
     MW.Travel = new  MW.Travel_Class();   
     
     
     function onWebPlanningJSInfoSuccess (pResult)
     {
        document.getElementById('Planning_Data').innerHTML = pResult; 
        MW.WebPlanning.onClick("webPlanningContent");
     }