// @Nom:          miseEnPage.js //
// @Année:        2011          //
// @Auteur:       Benjamin JEHL //
// @Copyright:    db-clic.com   //

/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/* HISTORIQUE --------------------------------------------------------------- */
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
loader = "loading";
NavigLevel = "ext";
NavigVertical = null;
NavigHorizontal = null;
NavigClick = 0;
BoutonClick = 0;
chooseContentBox = "start";



/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/* INTERFACE CLIENT --------------------------------------------------------- */
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
function rootPage(){
        // Dimension interface Client
        screenHEIGHT = document.body.clientHeight;
        screenWIDTH = document.body.clientWidth;
        // Dimension Interface & Conteneur
        redimWidth = screenWIDTH-80;
        if(redimWidth<=898){redimWidth=898;}
        if(redimWidth>=1238){redimWidth=1238;}
        redimHeight = screenHEIGHT-80;
        if(redimHeight<505){redimHeight=505;}if(redimHeight>558){redimHeight=558;}
        ContentBoxHEIGHT = redimHeight+80;
        ContentBoxWIDTH = redimWidth+80;
        TopContent = (screenHEIGHT-ContentBoxHEIGHT)/2;
        LeftContent = (screenWIDTH-ContentBoxWIDTH)/2;
        if(TopContent<=0){TopContent=0;}
        if(LeftContent<=0){LeftContent=0;}
        alinHomeTOP = ((redimHeight+20)-578)/2;
        alinHomeLEFT = ((redimWidth+20)-1258)/2;
        if(alinHomeTOP>=0){alinHomeTOP=0;}
        if(alinHomeLEFT>=0){alinHomeLEFT=0;}
        HomeTOP = (screenHEIGHT-(redimHeight+20))/2;
        HomeLEFT = (screenWIDTH-(redimWidth+20))/2;
        if(HomeTOP<=0){HomeTOP=0;}
        if(HomeLEFT<=0){HomeLEFT=0;}
        HauteurConteneur = redimHeight+20;
        LargeurConteneur = redimWidth+20;
        // Redim interface
        w3c_X = (redimWidth-145)/2;
        document.getElementById('w3c').style.left = w3c_X+"px";
        document.getElementById('xhtml').style.left = w3c_X+51+"px";
        document.getElementById('css').style.left = w3c_X+112+"px";
       
        // Dimension INTERIEUR / EXTEIEUR
        // Interieur
        if(NavigLevel=="int"){LargeurContenu=7765;HauteurContenu=578;}
        // Exterieur
        if(NavigLevel=="ext"){LargeurContenu=1258;HauteurContenu=578;}



        /* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ EXTERIEUR / INTERIEUR ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
        // Alignements
        if(NavigVertical == null){document.getElementById('Interieur').style.top = alinHomeTOP+"px";document.getElementById('Exterieur').style.top = alinHomeTOP+"px"}
        if(NavigHorizontal == null){document.getElementById('Interieur').style.left = 0+"px";document.getElementById('Exterieur').style.left = alinHomeLEFT+"px";}
        
        if(NavigLevel == "ext"){cible="Exterieur";}
        if(NavigLevel == "int"){cible="Interieur";}
        // Extremum
                // On recupere les positions de la cible
                target_id = document.getElementById(cible);
                // Positions
                targettop = target_id.style.top;
                target_top = parseFloat(targettop);
                targetleft = target_id.style.left;
                target_left = parseFloat(targetleft);
                
                
                target_maxTop = HauteurConteneur-HauteurContenu;
                target_maxLeft = LargeurConteneur-LargeurContenu;
                // On determine les extremums
                if (target_top>=0){target_top=0;}
                if (target_top<=target_maxTop){target_top=target_maxTop;}
                if (target_left>=0){target_left=0;}
                if (target_left<=target_maxLeft){target_left=target_maxLeft;}
                // On reaffecte les positions à la cible
                target_id.style.top = target_top+"px";
                target_id.style.left = target_left+"px";

        /* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ INTERFACE ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
        // Content BOX
        if (chooseContentBox=="start"){
                contentBoxWidth = 608;
                contentBoxHeight = redimHeight-120;
        }
        
        if (chooseContentBox=="defaut"){
                contentBoxWidth = 608;
                contentBoxHeight = redimHeight-80;
                
                document.getElementById('laCarte_Content').style.display = "block";
                document.getElementById('laCarte_Content').style.height = contentBoxHeight-128+"px";
                
                document.getElementById('scrollbox2').style.display="block";
                document.getElementById('scrollbox2').style.height = contentBoxHeight-128+"px";
                document.getElementById('laCarte_bg').style.top = 0+"px";
                document.getElementById('scrollbar2').style.marginTop = 0+"px";
                document.getElementById('scrollbar2').style.height = (document.getElementById('laCarte_Content').offsetHeight*document.getElementById('scrollbox2').offsetHeight)/document.getElementById('laCarte_bg').offsetHeight+"px";
               
        }
        if (chooseContentBox=="photos"){
                contentBoxWidth = 494;
                contentBoxHeight = redimHeight-80;
                document.getElementById('photos_box').style.display = "block";
                document.getElementById('photos_box').style.width = contentBoxWidth-78+"px";
                document.getElementById('photos_box').style.height = contentBoxHeight-156+"px";
                
                document.getElementById('photos_bg').style.width = contentBoxWidth-78+"px";
                document.getElementById('photos_bg').style.top = 0+"px";
                
                setScrollbarA = parseInt(document.getElementById('photos_box').style.height);
                setScrollbarB = parseInt(document.getElementById('photos_bg').style.height); 
                                                      
                if(setScrollbarA<setScrollbarB){
                        document.getElementById('scrollbox3').style.display="block";
                }else{
                        document.getElementById('scrollbox3').style.display="none";
                }
                
                document.getElementById('scrollbox3').style.height = setScrollbarA+"px";
                
                document.getElementById('scrollbar3').style.top = 0+"px";
                document.getElementById('scrollbar3').style.height = (document.getElementById('photos_box').offsetHeight*document.getElementById('scrollbox3').offsetHeight)/document.getElementById('photos_bg').offsetHeight+"px";
                          
                          
                                                        
                document.getElementById('photos_Content').style.display = "block";
                document.getElementById('photos_Content').style.width =contentBoxWidth-50+"px";
                document.getElementById('photos_Content').style.height = contentBoxHeight-50+"px";
                document.getElementById('bullePhotos4').style.height = contentBoxHeight-156+"px";
                document.getElementById('bullePhotos4').style.width = contentBoxWidth-55+"px";
                document.getElementById('bullePhotos5').style.height = contentBoxHeight-156+"px";
                document.getElementById('bullePhotos5').style.left = contentBoxWidth-55+"px";
                document.getElementById('bullePhotos6').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos7').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos7').style.width = contentBoxWidth-78+"px";
                document.getElementById('bullePhotos8').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos8').style.left = contentBoxWidth-64+"px";
                
        }
        if (chooseContentBox=="agenda"){
                contentBoxWidth = 608;
                contentBoxHeight = redimHeight-80;
                document.getElementById('agenda_box').style.display = "block";
                document.getElementById('agenda_box').style.width = contentBoxWidth-78+"px";
                document.getElementById('agenda_box').style.height = contentBoxHeight-156+"px";
                
                document.getElementById('agenda_bg').style.width = contentBoxWidth-78+"px";
                document.getElementById('agenda_bg').style.top = 0+"px";
                
                setScrollbarA = parseInt(document.getElementById('agenda_box').style.height);
                setScrollbarB = parseInt(document.getElementById('agenda_bg').style.height); 
                                                      
                if(setScrollbarA<setScrollbarB){
                        document.getElementById('scrollbox1').style.display="block";
                }else{
                        document.getElementById('scrollbox1').style.display="none";
                }
                
                document.getElementById('scrollbox1').style.height = setScrollbarA+"px";
                
                document.getElementById('scrollbar1').style.top = 0+"px";
                document.getElementById('scrollbar1').style.height = (document.getElementById('agenda_box').offsetHeight*document.getElementById('scrollbox1').offsetHeight)/document.getElementById('agenda_bg').offsetHeight+"px";
 
                
                
                
                                        
                document.getElementById('bullePhotos2').style.width = contentBoxWidth-78+"px";
                document.getElementById('bullePhotos3').style.left = contentBoxWidth-64+"px";
                document.getElementById('bullePhotos4').style.height = contentBoxHeight-156+"px";
                document.getElementById('bullePhotos4').style.width = contentBoxWidth-55+"px";
                document.getElementById('bullePhotos5').style.height = contentBoxHeight-156+"px";
                document.getElementById('bullePhotos5').style.left = contentBoxWidth-55+"px";
                document.getElementById('bullePhotos6').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos7').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos7').style.width = contentBoxWidth-78+"px";
                document.getElementById('bullePhotos8').style.top = contentBoxHeight-142+"px";
                document.getElementById('bullePhotos8').style.left = contentBoxWidth-64+"px";
        }
        
        if (chooseContentBox=="contact"){contentBoxWidth = 342;contentBoxHeight = redimHeight-80;}
        if (chooseContentBox=="admin"){contentBoxWidth = 270;contentBoxHeight = redimHeight-120;if(contentBoxHeight>=233){contentBoxHeight=233;}}
        if (chooseContentBox=="mentions"){
                contentBoxWidth = 608;contentBoxHeight = redimHeight-80;
                if(contentBoxHeight>=424){
                        contentBoxHeight=424;                        
                }
                
        }
        if (chooseContentBox=="googleMap"){contentBoxWidth = 462;contentBoxHeight = redimHeight-120;if(contentBoxHeight>=325){contentBoxHeight=325;}}

        contentBoxMarginLeft = (redimWidth-contentBoxWidth)/2+10;
        contentBoxMarginTop = (redimHeight-contentBoxHeight)/2+10;
        //ContentBoxWindow
        document.getElementById('contentBoxWindow').style.width = contentBoxWidth+"px";
        document.getElementById('contentBoxWindow').style.height = contentBoxHeight+"px";
        document.getElementById('contentBoxWindow').style.marginTop = contentBoxMarginTop+"px";
        document.getElementById('contentBoxWindow').style.marginLeft = contentBoxMarginLeft+"px";
        //Fx
        if (navigator.appName=='Microsoft Internet Explorer'){
            document.getElementById('FxWindow').style.width = contentBoxWidth-10+"px";
            document.getElementById('FxWindow').style.height = contentBoxHeight-10+"px";
        }else{
            document.getElementById('FxWindow').style.width = contentBoxWidth+2+"px";
            document.getElementById('FxWindow').style.height = contentBoxHeight+2+"px";
            document.getElementById('MoZmidlle').style.height = contentBoxHeight-21+"px";
            document.getElementById('MoZbottom').style.width = contentBoxWidth-21+"px";
        }
        document.getElementById('FxWindow').style.marginTop = contentBoxMarginTop+6+"px";
        document.getElementById('FxWindow').style.marginLeft = contentBoxMarginLeft+6+"px";
              

        //--> Modules
                //ContactBox
                adjustContactBox = contentBoxHeight-158;
                document.getElementById('bulleContact').style.height = adjustContactBox+24+"px";
                document.getElementById('bulleContactMiddle').style.height = adjustContactBox+"px";
                document.getElementById('mailBox').style.height = adjustContactBox-144+"px";
                //AdminBox
                document.getElementById('admin_Content').style.height = contentBoxHeight-50+"px"; 
                
                //MentionsBox
                adjustMentionsBox = contentBoxHeight-158;
                document.getElementById('bulleMentions').style.height = adjustMentionsBox+26+"px";
                document.getElementById('bulleMentionsMiddle').style.height = adjustMentionsBox+2+"px";
                // MapBox
                adjustMapBox = contentBoxHeight-158;
                document.getElementById('contact_Content').style.height = contentBoxHeight-50+"px"; 
                document.getElementById('bulleMap').style.height = adjustMapBox+24+"px";
                document.getElementById('bulleMapMiddle').style.height = adjustMapBox+"px";
                
                
                
        //color
        document.getElementById('contentBoxColor').style.width = contentBoxWidth+"px";
        document.getElementById('contentBoxColor').style.height = contentBoxHeight+"px";
        document.getElementById('cMiddleLeft').style.height = contentBoxHeight-16+"px";
        document.getElementById('cMiddle').style.height = contentBoxHeight-2+"px";
        document.getElementById('cMiddle').style.width = contentBoxWidth-16+"px";
        document.getElementById('cMiddleRight').style.height = contentBoxHeight-16+"px";
        //border
        document.getElementById('bTop').style.width = contentBoxWidth-16+"px";
        document.getElementById('bMiddleLeft').style.height = contentBoxHeight-16+"px";
        document.getElementById('bMiddleRight').style.height = contentBoxHeight-16+"px";
        document.getElementById('bBottom').style.width = contentBoxWidth-16+"px";
        // Redimensionnements
        document.getElementById('SceneBox').style.width = ContentBoxWIDTH+"px";
        document.getElementById('SceneBox').style.height = ContentBoxHEIGHT+"px";
        document.getElementById('headerBox').style.width = redimWidth+70+"px";
        document.getElementById('top').style.width = redimWidth+"px";
        document.getElementById('ContentWindow').style.width = LargeurConteneur+"px";
        document.getElementById('Left').style.height = redimHeight+"px";
        document.getElementById('ContentWindow').style.height = HauteurConteneur+"px";
        document.getElementById('Right').style.height = redimHeight+"px";
        document.getElementById('bottom').style.width = redimWidth+"px";
        // Alignements
        document.getElementById('SceneBox').style.top = TopContent+"px";
        document.getElementById('SceneBox').style.left = LeftContent+"px";
        document.getElementById('topRight').style.left = redimWidth+40+"px";
        document.getElementById('ContentRight').style.left = LargeurConteneur+30+"px";
        document.getElementById('bottomRight').style.left = redimWidth+40+"px";
        document.getElementById('footerBox').style.top = redimHeight+50+"px";
        document.getElementById('caution').style.width = redimWidth+"px";
        /* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ DBUGG I.E ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
        if (navigator.appName=='Microsoft Internet Explorer'){
                document.getElementById('contact_Content_title').style.paddingTop = 3+"px";
                document.getElementById('admin_Content_title').style.paddingTop = 3+"px";
                document.getElementById('mentions_Content_title').style.paddingTop = 3+"px";
                document.getElementById('gmaps_Content_title').style.paddingTop = 3+"px";
                document.getElementById('newsLabel').style.top = -4+"px";
        }
        /* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ HYPER-NAV ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
        // Affichage des fleches de navigations
        if(LargeurConteneur<LargeurContenu){
            opacity('nav_left',100);opacity('nav_right',100);
            document.getElementById('nav_left').style.top = (redimHeight/2)+"px";
            document.getElementById('nav_right').style.top = (redimHeight/2)+"px";
        }else{
                document.getElementById('nav_left').style.display = "none";
                document.getElementById('nav_right').style.display = "none";
        }
        if(loader=="loading"){document.getElementById('loader').style.display = "none";loader="loaded";}
        
}
