/* *** sageCrmFuction : version du 03/09/2010  *** */
var focoSwf;
var focusSwfLink;
var menuNoFlashConfigXmlFile;
var contentActualitesXmlFile;
var contentNouveautesProduitsXmlFile;
var contentTemoignagesXmlFile;
var contentLivresBlancsXmlFile;
var ourSitesHtmlFile;
var aboutHtmlFile;
var aboutSwfLink;

var selectedMenuIndex = null;
var selectedNeedIndex = null;

var radarContentXml = null;
var radarContentXml1 = null;
var radarContentXml2 = null;
var radarContentXml3 = null;
var radarContentXml4 = null;
var radarContentXml5 = null;

var onResizeAlreadyInitialized = false;

var initWithFlash = true;

function initializeOnResize()
{
    if ( ! onResizeAlreadyInitialized )
    {
        window.onresize = function()
        {
            updateTopMenuModule();
            updateOutfieldElements();
            updateFocusFlashZone();
            updateTopMenuContentZone();
        };
        onResizeAlreadyInitialized = true;
    }
}

/* *** screen saver functions  *** */
var flashNotInitialized = null;
var idleTime = 120000;
var timeOut = "";
var isIdle = 0;
var basicFocusHeight;

function init()
{
    Event.observe(document.body, "mousemove", resetIdle, true);
    setIdle();
}
function onIdleFunction()
{
    if ( isIdle == 0 )
    {
        var fadingDuration = 0.3;
        if ( $('topMenuContainerId') )
        {
            $('topMenuContainerId').fade({ duration: 0.6, from: 1, to: 0 });
        }
        if ( $('historicContainerId') )
        {
            $('historicContainerId').fade({ duration: fadingDuration, from: 1, to: 0 });
        }
        if ( $('newsContentContainerId') )
        {
            $('newsContentContainerId').fade({ duration: fadingDuration, from: 1, to: 0 });
        }
        if ( $('outfieldLeavesLeftId') )
        {
            $('outfieldLeavesLeftId').fade({ duration: fadingDuration, from: 1, to: 0 });
        }
        if ( $('outfieldLeavesRightId') )
        {
            $('outfieldLeavesRightId').fade({ duration: fadingDuration, from: 1, to: 0 });
        }
        if ( $('mainContainerId') )
        {
            $('mainContainerId').hide();
        }
        if ( $('footerPane') )
        {
            $('footerPane').hide();
        }
        if ( $('topMenuModuleId') )
        {
            $('topMenuModuleId').hide();
        }
        if ( $('flashFocusContainerId') )
        {
            basicFocusHeight = $('flashFocusContainerId').style.height;
            
            $('flashFocusContainerId').morph('height: ' + ( getCurrentWidthHeight()[1] - 10 ) + 'px;');
            $('flashFocusContainerId').style.zindex = "500";
            $('flashFocusContainerId').style.width = "100%";
        }
        
        /*
        $('flashFocusContainerId').style.position = "absolute";
        $('flashFocusContainerId').style.left = "0px";
        $('flashFocusContainerId').style.top = "0px";
        $('flashFocusContainerId').style.width = "100%";
        $('flashFocusContainerId').style.height = "98%";
        $('flashFocusContainerId').style.zindex = "500";
        */
        isIdle = 1;
    }
}
function resetIdle()
{
    window.clearTimeout( timeOut );
    setIdle();
    if ( isIdle > 0 )
    {   
        if ( $('topMenuContainerId') )
        {
            $('topMenuContainerId').show();
        }
        if ( $('historicContainerId') )
        {
            $('historicContainerId').show();
        }
        if ( $('newsContentContainerId') )
        {
            $('newsContentContainerId').show();
        }
        if ( $('outfieldLeavesLeftId') )
        {
            $('outfieldLeavesLeftId').show();
        }
        if ( $('outfieldLeavesRightId') )
        {
            $('outfieldLeavesRightId').show();
        }
        if ( $('mainContainerId') )
        {
            $('mainContainerId').show();
        }
        if ( $('footerPane') )
        {
            $('footerPane').show();
        }
        if ( $('topMenuModuleId') )
        {
            $('topMenuModuleId').show();
        }
        if ( $('flashFocusContainerId') )                
        {
            $('flashFocusContainerId').style.position = "relative";
            $('flashFocusContainerId').style.width = "100%";
            $('flashFocusContainerId').style.height = basicFocusHeight;
        }
                
        updateTopMenuModule();
        
        isIdle = 0;
    }
}
function setIdle()
{
    timeOut = window.setTimeout( "onIdleFunction()", idleTime );
}


    
function initDynamicResourcesPathsForDnn()
{
    focoSwf = $('focoSwf').href;
    focusSwfLink = $('focusSwf').href;
    menuNoFlashConfigXmlFile = $('noFlashConfigXml').href;
    contentActualitesXmlFile = $('contentActualitesXml').href;
    contentNouveautesProduitsXmlFile = $('contentNouveautesProduitsXml').href;
    contentTemoignagesXmlFile = $('contentTemoignagesXml').href;
    contentLivresBlancsXmlFile = $('contentLivresBlancsXml').href;
    ourSitesHtmlFile = $('ourSitesHtml').href;
    aboutHtmlFile = $('aboutHtml').href;
    aboutSwfLink = $('aboutSwf').href;
}

/* *** main utils functions *** */
function getXMLDocument( transport)
{
  var strDocument = transport.responseText;
  var xmlDocument = transport.responseXML;
  try
  {
        if( ! xmlDocument || xmlDocument.childNodes.length == 0 )
        {
            xmlDocument = ( new DOMParser() ).parseFromString( strDocument, "application/xml" );
        }
  }
  catch( e )
  {
    return null;
  }
  return xmlDocument;
}

/* *** Utils *** */
function preloadImages() 
{
     var i = 0;
     imageObj = new Image();
     images = new Array();
     images[0]="../images/focus-no-flash-needs-background-hover-first.png";
     images[1]="../images/focus-no-flash-needs-background-hover-second.png";
     images[2]="../images/focus-no-flash-needs-background-hover-third.png";
     for( i = 0; i <= 2; i++ ) 
     {
          imageObj.src=images[i];
     }
} 

/* *** Outfield element initialization *** */
function initOutfieldElement()
{
    outfieldZone = new OutfieldZone();    
}

function updateOutfieldElements()
{
    if ( document.body.clientWidth < 1250 )
    {
        $('outfieldLeavesLeftId').style.visibility = 'hidden';
        $('outfieldLeavesRightId').style.visibility = 'hidden';
    }
    else
    {
        $('outfieldLeavesLeftId').style.visibility = 'visible';
        $('outfieldLeavesRightId').style.visibility = 'visible';
    }
}

var OutfieldZone = Class.create(
{
    initialize : function()
    {
        updateOutfieldElements();
        initializeOnResize();
    }
});

/* *** Top menu module element initialization *** */
function initTopMenuModule()
{


    if ( $$('.focusNoFlashContent')[0] )
    {
        $$('.focusNoFlashContent')[0].style.visibility = 'hidden';
    }

    //Modal Window  
    var modal = new Control.Modal($('modalWindowOurSitesId'),
    {
        overlayOpacity: 0.90,
        className: 'modal',
        fade: true,
        fadeDuration: 0.75,
        afterOpen: function()
        {
            callOurSites = new CallOurSites( this );
        } 
    });
    modal.href = ourSitesHtmlFile;
    
    //Modal About Window  
    var modalAbout = new Control.Modal($('modalWindowAboutId'),
    {
        overlayOpacity: 0.90,
        className: 'modal',
        fade: true,
        fadeDuration: 0.75,
        afterOpen: function()
        {
            callAbout = new CallAbout( this );
        } 
    });
    modalAbout.href = aboutHtmlFile;

    if ( $('topMenuModuleId') && $('topMenuRightId') )
    {
        topMenuModuleZone = new TopMenuModuleZone();
    }
    
    // top menu width zone update
    updateTopMenuContentZone();
    
    if ( $$('.topInputSearch') )
    {
        $$('.topInputSearch').invoke('observe', 'focus', onSearchFormFocus);
    }
}

function onSearchFormFocus()
{
    if ( $('topInputSearchId').value == 'RECHERCHEZ DANS SAGE CRM')
    {
        $('topInputSearchId').value = '';
    }
}

function updateTopMenuContentZone()
{
    if ( $('topMenuContainerId') )
    {
        currentWidth = getCurrentWidthHeight()[0];
        if ( $('mainContainerId') )
        {
            if ( currentWidth <= $('mainContainerId').offsetWidth )
            {
                $('topMenuContainerId').style.width = $('mainContainerId').offsetWidth + "px";
            }
            else
            {
                $('topMenuContainerId').style.width = 100 + "%";
            }
        }
        else if ( currentWidth <= 972 )
        {
            $('topMenuContainerId').style.width = 972 + "px";
        }
        else
        {
            $('topMenuContainerId').style.width = 100 + "%";
        }
    }

    if ( $('historicContainerId') )
    {
        currentWidth = getCurrentWidthHeight()[0];
        if ( $('mainContainerId') )
        {
            if ( currentWidth <= $('mainContainerId').offsetWidth )
            {
                $('historicContainerId').style.width = $('mainContainerId').offsetWidth + "px";
            }
            else
            {
                $('historicContainerId').style.width = 100 + "%";
            }
        }
        else if ( currentWidth <= 972 )
        {
            $('historicContainerId').style.width = 972 + "px";
        }
        else
        {
            $('historicContainerId').style.width = 100 + "%";
        }       
    }
}

var CallOurSites = Class.create(
{
    modalWindow: null,
	initialize : function( modalWindow )
	{
        this.modalWindow = modalWindow;        
        $('modalWindowCustCloseButtonId').observe( 'click', this.doActionCloseModalWindowOurSites.bindAsEventListener( this ) );
	},
	doActionCloseModalWindowOurSites : function( event )
	{
        event.stop();
        this.modalWindow.close();
	}
});

var CallAbout = Class.create(
{
    modalWindow: null,
	initialize : function( modalWindow )
	{
        this.modalWindow = modalWindow;        
        $('modalWindowCustCloseButtonId').observe( 'click', this.doActionCloseModalWindowAbout.bindAsEventListener( this ) );
	},
	doActionCloseModalWindowAbout : function( event )
	{
        event.stop();
        this.modalWindow.close();
	}
});

function updateTopMenuModule()
{
    if ( $('topMenuModuleId') )
    {
        currentWidth = getCurrentWidthHeight()[0];
        if ( currentWidth > 972 )
        {
            $('topMenuModuleId').style.left = ( ( currentWidth / 2 ) + 260 ) + "px";
        }
        else if ( !$('mainContainerId') )
        {
            $('topMenuModuleId').style.left = 740 + "px";
        }
        $('topMenuModuleId').style.top = ( $('topMenuRightId').offsetTop + 28 ) + "px";
        //$('topMenuModuleId').style.left = ( $('topMenuRightId').offsetLeft + $('topMenuRightId').offsetWidth - $('topMenuModuleId').offsetWidth )+ "px";
    }
}

var TopMenuModuleZone = Class.create(
{
    initialize : function()
    {
        updateTopMenuModule();
        initializeOnResize();
    }
});


/* *** No flash menu initialization *** */
function initNoFlashMenu()
{


    if ( $$('.focusNoFlashContent')[0] && !swfobject.hasFlashPlayerVersion("9.0.0") )
    {
        $$('.focusNoFlashContent')[0].style.visibility = 'visible';
    }


    if ( initWithFlash )
    {
        // focus flash initialization
        if ( $('flashFocusObjectId') )
        {
            var flashvars = {};
            if ( selectedMenuIndex != null )
            {
                flashvars = {
                    selectedMenuIndex: selectedMenuIndex,
                    configUrl: menuNoFlashConfigXmlFile
                };
            }
            else if ( selectedNeedIndex != null )
            {
                flashvars = {
                    selectedNeedIndex: selectedNeedIndex,
                    configUrl: menuNoFlashConfigXmlFile
                };        
            }
            else
            {
                flashvars = {
                    configUrl: menuNoFlashConfigXmlFile
                };        	
            }
            var params = {
                allowFullScreen: "always",
                allowScriptAccess: "always",
                quality: "high",
                wmode: "transparent"
            };
            var attributes = {};
            swfobject.embedSWF(focusSwfLink, "flashFocusObjectId", "100%", "100%", "9.0.0","expressInstall.swf", flashvars, params, attributes);
        }
    }

    // no flash menu asynchronous content loading from xml config
    ajaxNoFlashMenuZone = new AjaxNoFlashMenuZone( menuNoFlashConfigXmlFile );
  
    // no flash needs asynchronous content loading from xml config
    ajaxNoFlashNeedsZone = new AjaxNoFlashNeedsZone( menuNoFlashConfigXmlFile );


    if ( initWithFlash )
    { 
        // screen saver initilization
        if ( swfobject.hasFlashPlayerVersion("9.0.0") )
        {
            Event.observe(window, "load", init, false); 
        }
    }

    // width flash zone update
    updateFocusFlashZone();
}

function updateFocusFlashZone()
{
    if ( $('flashFocusContainerId') )
    {
        currentWidth = getCurrentWidthHeight()[0];
        if ( $('mainContainerId') )
        {
            if ( currentWidth <= $('mainContainerId').offsetWidth )
            {
                $('flashFocusContainerId').style.width = $('mainContainerId').offsetWidth + "px";
            }
            else
            {
                $('flashFocusContainerId').style.width = 100 + "%";
            }
        }
        else if ( currentWidth <= 972 )
        {
            $('flashFocusContainerId').style.width = 972 + "px";
        }
        else
        {
            $('flashFocusContainerId').style.width = 100 + "%";
        }
    }
}

function initRadarFlashZone()
{
    // radar flash initialization
    if ( $('radar01Swf') )
    {
        // radar flash initialization
        if ( $('radarNoFlashId') )
        {
            if ( radarContentXml != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId', radarContentXml );
            }
        }
        // radar flash 1 initialization
        if ( $('radarNoFlashId1') )
        {
            if ( radarContentXml1 != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId1', radarContentXml1 );
            }
        }
        // radar flash 2 initialization
        if ( $('radarNoFlashId2') )
        {
            if ( radarContentXml2 != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId2', radarContentXml2 );
            }
        }
        // radar flash 3 initialization
        if ( $('radarNoFlashId3') )
        {
            if ( radarContentXml3 != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId3', radarContentXml3 );
            }
        }
        // radar flash 4 initialization
        if ( $('radarNoFlashId4') )
        {
            if ( radarContentXml4 != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId4', radarContentXml4 );
            }
        }
        // radar flash 5 initialization
        if ( $('radarNoFlashId5') )
        {
            if ( radarContentXml5 != null )
            {
                initParticularRadarFlashZone( 'radarNoFlashId5', radarContentXml5 );
            }
        }
    }
}

function initParticularRadarFlashZone( currentRadarNoFlashZoneId, currentRadarContentXml )
{
    var flashvars = {
        dataURL: currentRadarContentXml
    };
    var params = {
        allowFullScreen: "always",
        quality: "high",
        wmode: "transparent"
    };
    var attributes = {};
    swfobject.embedSWF($('radar01Swf').href, currentRadarNoFlashZoneId, "100%", "100%", "9.0.0","expressInstall.swf", flashvars, params, attributes);                
}

/* *** News bloc initialization *** */
function initNewsBloc()
{

    // asynchronous loading with scroll management for the "Actualités" part
    ajaxScrollContentZone = new AjaxScrollContentZone( contentActualitesXmlFile, $('moveBloc1Left'), $('moveBloc1Right'), 'Z' );
    
    // asynchronous loading with scroll management for the "Nouveautés produits" part
    ajaxScrollContentZone = new AjaxScrollContentZone( contentNouveautesProduitsXmlFile, $('moveBloc2Left'), $('moveBloc2Right'), 'Y' );

    // asynchronous loading with scroll management for the "Témoignages" part
    ajaxScrollContentZone = new AjaxScrollContentZone( contentTemoignagesXmlFile, $('moveBloc3Left'), $('moveBloc3Right'), 'X' );

    // asynchronous loading with scroll management for the "Guides et Livres Blancs" part
    ajaxScrollContentZone = new AjaxScrollContentZone( contentLivresBlancsXmlFile, $('moveBloc4Left'), $('moveBloc4Right'), 'A' );
    /*
    // news#1 zone scroll initialization
    scrollNewsAZone = new ScrollContentZone( $('moveBlocLeftNewsA'), $('moveBlocRightNewsA'), 'toolbarNewsA', 'scrollerNewsA', 'e1NewsA-pane' );
    */

    // Sifr replacement
    if ( $('underIE6') == null && typeof sIFR == "function" )
    {
        sIFR.replaceElement(named({sSelector:"h2.newBlocTitleTypo", sFlashSrc:focoSwf, sColor:"#007F64", sCase:"upper", sWmode:"transparent", sFlashVars:"textalign=center"}));
    }
}

/* *** Scroll (by horizontal slide) content zone with AJAX content loading *** */
var AjaxScrollContentZone = Class.create(
{
    scrollZoneSuffix : null,
    currentScrollContentZone : null,
    initialize : function( xmlSource, moveLeftLink, moveRightLink, scrollZoneSuffix )
    {
        // variables initialization
        this.scrollZoneSuffix = scrollZoneSuffix;
        
        // get content from request
        new Ajax.Request
        (
            xmlSource,
            {
                method: 'get',
                onComplete: this.onComplete.bind( this )
            }
        );

        // scroll zone initialization
        currentScrollContentZone = new ScrollContentZone( moveLeftLink, moveRightLink, 'toolbar' + this.scrollZoneSuffix, 'scroller' + this.scrollZoneSuffix, 'e1' + this.scrollZoneSuffix + '-pane' );
    },
    onComplete : function( transport )
    {
        var toolbarContent = '';
        var scrollScrollerContent = '';				
        
        var xmlDocument = getXMLDocument( transport );
        var xmlNodesContent = xmlDocument.getElementsByTagName('content');
        for ( var i=0; i < xmlNodesContent.length; i++ )
        {
            var contentId = xmlNodesContent[i].getElementsByTagName('id')[0].firstChild.nodeValue;
            var contentTitle = xmlNodesContent[i].getElementsByTagName('title')[0].firstChild.nodeValue;
            var contentDescription = xmlNodesContent[i].getElementsByTagName('description')[0].firstChild.nodeValue;

            var simpleToolbarContent = '<li id="e' + (i+1) + this.scrollZoneSuffix + '-tab">';
            simpleToolbarContent += '#';
            simpleToolbarContent += '</li>';
            toolbarContent += simpleToolbarContent;
            
            var simpleContent = '<div class="scrollSection" id="e' + (i+1) + this.scrollZoneSuffix + '-pane">';
            if (contentTitle)
            {
                simpleContent += '<h2>';
                simpleContent += contentTitle;
                simpleContent += '</h2>';
                simpleContent += '<br />';
            }
            simpleContent += contentDescription;
            simpleContent += '</div>';
            scrollScrollerContent+= simpleContent;
        }
        $('toolbar' + this.scrollZoneSuffix).update( toolbarContent );
        $('scrollContent' + this.scrollZoneSuffix).update( scrollScrollerContent );		
    }
});

/* *** no flash menu zone with AJAX content loading *** */
var AjaxNoFlashMenuZone = Class.create(
{
    initialize : function( xmlSource )
    {
        // get content from request
        new Ajax.Request
        (
            xmlSource,
            {
                method: 'get',
                onComplete: this.onComplete.bind( this )
            }
        );
    },
    onComplete : function( transport )
    {
        var noFlashMenuContent = '<div class="innerFocusNoFlashMenu">';
        noFlashMenuContent += '<div class="start"></div>';
        noFlashMenuContent += '<div class="innerFocusNoFlashMenuButtons">';
        
        var xmlDocument = getXMLDocument( transport );
        var xmlNodesMenu = xmlDocument.getElementsByTagName('menu');
        
        for ( var i=0; i < xmlNodesMenu.length; i++ )
        {
            var xmlNodesItem = xmlNodesMenu[i].getElementsByTagName('item');
            for ( var i=0; i < xmlNodesItem.length; i++ )
            {
                var menuItem = xmlNodesItem[i];
                var itemTitle = menuItem.getAttribute('title');
                var itemHref = menuItem.getAttribute('href');
                
                var simpleItemContent = '<a href="' + itemHref + '">';
                if ( i == 0 )
                {
                    simpleItemContent += '<div class="button first">';
                }
                else if ( i == ( xmlNodesItem.length - 1 ) )
                {
                    simpleItemContent += '<div class="button last">';
                }
                else
                {
                    simpleItemContent += '<div class="button">';
                }
                simpleItemContent += itemTitle;
                simpleItemContent += '</div>'
                simpleItemContent += '</a>';
                noFlashMenuContent += simpleItemContent;
            }
        }
        noFlashMenuContent += '</div>'
        noFlashMenuContent += '<div class="end"></div>';
        noFlashMenuContent += '</div>'
        $('noFlashMenuContent').update( noFlashMenuContent );
    }
});

/* *** no flash needs zone with AJAX content loading *** */
var AjaxNoFlashNeedsZone = Class.create(
{
    initialize : function( xmlSource )
    {
        // get content from request
        new Ajax.Request
        (
            xmlSource,
            {
                method: 'get',
                onComplete: this.onComplete.bind( this )
            }
        );
    },
    onComplete : function( transport )
    {

        var noFlashNeedsContent = '';    

        if ( $('underIE6') )
        {
            $('noFlashNeedsContentId').className = 'noFlashNeedsContentIe6';
        }
        
        var xmlDocument = getXMLDocument( transport );
        var xmlNodesArbre = xmlDocument.getElementsByTagName('arbre');
        
        for ( var j=0; j < xmlNodesArbre.length; j++ )
        {
            // vous avez un projet
            var xmlNodesVousavezunprojet = xmlNodesArbre[j].getElementsByTagName('vousavezunprojet');
            for ( var i=0; i < xmlNodesVousavezunprojet.length; i++ )
            {
                var elementVousavezunprojet = xmlNodesVousavezunprojet[i];
                var vousavezunprojetHref = elementVousavezunprojet.getAttribute('href');
                vousavezunprojetHref = vousavezunprojetHref.replace( /\'/g, "\\'" );
                if ( $('underIE6') )
                {
                    noFlashNeedsContent += '<div class="firstNeedZone" onclick="location.href = \'';
                    noFlashNeedsContent += vousavezunprojetHref;
                    noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6 noFlashNeedsHoverFirstIe6\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6\'"></div>';
                }
                else
                {
                    noFlashNeedsContent += '<div class="firstNeedZone" onclick="location.href = \'';
                    noFlashNeedsContent += vousavezunprojetHref;
                    noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent noFlashNeedsHoverFirst\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent\'"></div>';
                }

                // faites vous rappeler
                var xmlNodesFaitesvousrappeler = xmlNodesArbre[j].getElementsByTagName('faitesvousrappeler');
                for ( var i=0; i < xmlNodesFaitesvousrappeler.length; i++ )
                {
                    var elementFaitesvousrappeler = xmlNodesFaitesvousrappeler[i];
                    var faitesvousrappelerHref = elementFaitesvousrappeler.getAttribute('href');
                    faitesvousrappelerHref = faitesvousrappelerHref.replace( /\'/g, "\\'" );
                    
                    if ( $('underIE6') )
                    {
                        noFlashNeedsContent += '<div class="secondNeedZone" onclick="location.href = \'';
                        noFlashNeedsContent += faitesvousrappelerHref;
                        noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6 noFlashNeedsHoverSecondIe6\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6\'"></div>';
                    }
                    else
                    {
                        noFlashNeedsContent += '<div class="secondNeedZone" onclick="location.href = \'';
                        noFlashNeedsContent += faitesvousrappelerHref;
                        noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent noFlashNeedsHoverSecond\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent\'"></div>';
                    }
                }
                
                // contactez nous
                var xmlNodesContacteznous = xmlNodesArbre[j].getElementsByTagName('contacteznous');
                for ( var i=0; i < xmlNodesContacteznous.length; i++ )
                {
                    var elementContacteznous = xmlNodesContacteznous[i];
                    var contacteznousHref = elementContacteznous.getAttribute('href');
                    contacteznousHref = contacteznousHref.replace( /\'/g, "\\'" );
                    if ( $('underIE6') )
                    {
                        noFlashNeedsContent += '<div class="thirdNeedZone" onclick="location.href = \'';
                        noFlashNeedsContent += contacteznousHref;
                        noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6 noFlashNeedsHoverThirdIe6\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContentIe6\'"></div>';
                    }
                    else
                    {
                        noFlashNeedsContent += '<div class="thirdNeedZone" onclick="location.href = \'';
                        noFlashNeedsContent += contacteznousHref;
                        noFlashNeedsContent += '\'" onmouseover="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent noFlashNeedsHoverThird\'" onmouseout="$(\'noFlashNeedsContentId\').className = \'noFlashNeedsContent\'"></div>';
                    }
                }
            }
        }

        $('noFlashNeedsContentId').update( noFlashNeedsContent );
    }
});

/* *** common content initialization *** */
function initContentCommonZone()
{
        // Sifr replacement
    if ( $('underIE6') == null && typeof sIFR == "function" )
    {
        sIFR.replaceElement(named({sSelector:"h2.contentTitleTypo", sFlashSrc:focoSwf, sColor:"#007f64", sWmode:"transparent", sFlashVars:"textalign=left"}));
    }
}

/* *** about zone *** */
function initAboutZone()
{
    // about flash initialization
    if ( $('modalWindowCustCloseButtonId') )
    {
        var flashvars = {
            configUrl: menuNoFlashConfigXmlFile
        };        	
        var params = {
            allowFullScreen: "always",
            quality: "high",
            wmode: "opaque",
            bgcolor: "#DAE5B9"
        };
        var attributes = {};
        swfobject.embedSWF(aboutSwfLink, "flashAboutObjectId", "100%", "100%", "9.0.0","expressInstall.swf", flashvars, params, attributes);
    }
}

function initModalWindowCustZone()
{
    if ( $('modalWindowCustCloseButtonId') && $('modalWindowCustContainerId') )
    {
        $('modalWindowCustContainerId').observe( 'mouseover',
            function()
            {
                $('modalWindowCustCloseButtonId').addClassName('modalWindowCustCloseButtonShow');
            }        
        ); 
        $('modalWindowCustContainerId').observe( 'mouseout',
            function()
            {
                $('modalWindowCustCloseButtonId').removeClassName('modalWindowCustCloseButtonShow');
            }        
        ); 
    }
}

/* *** our sites content selector *** */
function initOurSitesZone()
{
    ourSitesContentSelector = new ModalWindowViewerContentSelector( 'ourSitesThirdRowId', 'ourSitesDetailId-', 'ourSitesThumbnailId-', '1' );
}

var ModalWindowViewerContentSelector = Class.create(
{
    ourSitesThirdRowId: 'ourSitesThirdRowId',
    detailSelectorPrefix: 'ourSitesDetailId-',
	thumbnailSelectorPrefix: 'ourSitesThumbnailId-',
    currentSelectedId: '1',
	initialize : function( ourSitesThirdRowId, detailSelectorPrefix, thumbnailSelectorPrefix, currentSelectedId )
	{
		// variables initialization
		this.detailSelectorPrefix = detailSelectorPrefix;
		this.thumbnailSelectorPrefix = thumbnailSelectorPrefix;
        this.ourSitesThirdRowId = ourSitesThirdRowId;
						
		// browse all the thumbnails to enable mapping on link list
		if ( $(this.ourSitesThirdRowId).hasChildNodes() )
		{
			var ourSitesThirdRowChildNodes = $(this.ourSitesThirdRowId).childNodes;
			for ( var i = 0; i < ourSitesThirdRowChildNodes.length; i++ ) 
			{
				var childNode = $(this.ourSitesThirdRowId).childNodes[i];
				if ( childNode.tagName == 'DIV' )
				{
					$(childNode.id).observe( 'mouseover', this.doActionHoverRefreshDetail.bindAsEventListener( this, childNode.id.split("-")[1] ) );
				}
			}			
		}
	
	},
	doActionHoverRefreshDetail : function(event, detailId)
	{
        event.stop();
        $(this.detailSelectorPrefix + this.currentSelectedId).hide();
        $(this.thumbnailSelectorPrefix + this.currentSelectedId).removeClassName('ourSitesSmallThumbnailSelected');
        $(this.detailSelectorPrefix + detailId).show();
        $(this.thumbnailSelectorPrefix + detailId).addClassName('ourSitesSmallThumbnailSelected');
        this.currentSelectedId = detailId;
	}
});

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getCurrentWidthHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}

/* *** Vertical content scrolling *** */
function initVerticalScrollingContent( scrollZoneSuffix )
{
    // récupération des index de la toolbar de référence
    if ( $('toolbar'+scrollZoneSuffix) )
    {
        // browse all the tab links to enable mapping on link list
        if ( $('toolbar'+scrollZoneSuffix).hasChildNodes() )
        {
            var toobalChildNodes = $('toolbar'+scrollZoneSuffix).childNodes;
            var indexCount = 0;
            for ( var i = 0; i < toobalChildNodes.length; i++ )
            {
                var childNode = $('toolbar'+scrollZoneSuffix).childNodes[i];
                if ( childNode.tagName == 'LI' && childNode.className != 'noContent' )
                {
                    indexCount = indexCount + 1;
                    var scrollBarControl = new Control.ScrollBar( 'scrollbar_content-' + indexCount + scrollZoneSuffix, 'scrollbar_track-' + indexCount + scrollZoneSuffix );

                }
            }			
        }
    }
}

/* *** Generic modal window *** */
function initNewModalWindow( modalWindowContentId, modalWindowHtmlContentId )
{

    // Modal Window  
    var modal = new Control.Modal( $( modalWindowContentId ),
    {
        overlayOpacity: 0.90,
        className: 'modal',
        fade: true,
        fadeDuration: 0.75,
        afterOpen: function()
        {
            callModalWindow = new CallModalWindow( this );
        } 
    });
    modal.href = $(modalWindowHtmlContentId).href;
}

var CallModalWindow = Class.create(
{
    modalWindow: null,
	initialize : function( modalWindow )
	{
        this.modalWindow = modalWindow;
        $('modalWindowCustCloseButtonId').observe( 'click', this.doActionCloseModalWindowOurSites.bindAsEventListener( this ) );
	},
	doActionCloseModalWindowOurSites : function( event )
	{
        event.stop();
        this.modalWindow.close();
	}
});

function initModalWindowViewerZone()
{
    modalWindowViewerGenericContentSelector = new ModalWindowViewerGenericContentSelector( 'modalWindowViewerThirdRowId', 'modalWindowViewerDetailId-', 'modalWindowViewerThumbnailId-', '1' );
}

var ModalWindowViewerGenericContentSelector = Class.create(
{
    ourSitesThirdRowId: 'modalWindowViewerThirdRowId',
    detailSelectorPrefix: 'modalWindowViewerDetailId-',
	thumbnailSelectorPrefix: 'modalWindowViewerThumbnailId-',
    currentSelectedId: '1',
	initialize : function( ourSitesThirdRowId, detailSelectorPrefix, thumbnailSelectorPrefix, currentSelectedId )
	{
		// variables initialization
		this.detailSelectorPrefix = detailSelectorPrefix;
		this.thumbnailSelectorPrefix = thumbnailSelectorPrefix;
        this.ourSitesThirdRowId = ourSitesThirdRowId;
						
		// browse all the thumbnails to enable mapping on link list
		if ( $(this.ourSitesThirdRowId).hasChildNodes() )
		{
			var ourSitesThirdRowChildNodes = $(this.ourSitesThirdRowId).childNodes;
			for ( var i = 0; i < ourSitesThirdRowChildNodes.length; i++ ) 
			{
				var childNode = $(this.ourSitesThirdRowId).childNodes[i];
                //window.alert('childNode = ' + childNode);
				if ( childNode.tagName == 'DIV' )
				{
                    var ourSitesThirdRowChildNodes2 = childNode.childNodes;
                    //window.alert('ourSitesThirdRowChildNodes2 = ' + ourSitesThirdRowChildNodes2);
                    for ( var j = 0; j < ourSitesThirdRowChildNodes2.length; j++ ) 
                    {
                        var childNode2 = ourSitesThirdRowChildNodes2[j];
                        if ( childNode2.tagName == 'DIV' )
                        {
                            //window.alert('childNode2 = ' + childNode2);
                            $(childNode2.id).observe( 'mouseover', this.doActionHoverRefreshDetail.bindAsEventListener( this, childNode2.id.split("-")[1] ) );
                        }
                    }
				}
            }
		}
	
	},
	doActionHoverRefreshDetail : function(event, detailId)
	{
        event.stop();
        $(this.detailSelectorPrefix + this.currentSelectedId).hide();
        $(this.thumbnailSelectorPrefix + this.currentSelectedId).removeClassName('modalWindowViewerSmallThumbnailSelected');
        $(this.detailSelectorPrefix + detailId).show();
        $(this.thumbnailSelectorPrefix + detailId).addClassName('modalWindowViewerSmallThumbnailSelected');
        this.currentSelectedId = detailId;
	}
});

var MWViewerScrollable = Class.create(
{
    container: null,
    element: null,
	initialize : function( container, topArrow, bottomArrow )
	{
        this.container = container;
        $(topArrow).observe( 'click', this.doActionMoveToTop.bindAsEventListener( this ) );
        $(bottomArrow).observe( 'click', this.doActionMoveToBottom.bindAsEventListener( this ) );
	},
	doActionMoveToTop : function( event )
	{
        event.stop();
        Effect.Scroll( this.container, { duration:'0.2', offset:20} );
        //new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
	},
	doActionMoveToBottom : function( event )
	{
        event.stop();
        Effect.Scroll( this.container, { duration:'0.2', offset:-20} );
        //new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
	}
});

function moveTo( container, element )
{
    Position.prepare();
    container_y = Position.cumulativeOffset($(container))[1]
    element_y = Position.cumulativeOffset($(element))[1]
    new Effect.Scroll(container, {x:0, y:(element_y-container_y)});
    return false;
}