﻿/**
 * @name        Global Initialisation
 * @overview    An automated documentation publishing system for JavaScript.
 * @version        0.1
 * @revision    2007-06-01 00:00:00
 */
/**
 * @function    PageLoad_Init
 * @description    Toggles the class of elements either on or off
 */
 
var $DOM    = YAHOO.util.Dom
var $EVENT    = YAHOO.util.Event 



	
	var sendToLink  = $DOM.getElementsByClassName('sendToFriend'); //find send to link
	if (sendToLink)
    {
        for(var i = 0; i < sendToLink.length; i++)
        {
     		sendToLink = sendToLink[0];
        }
    }
	var printLink = document.createElement('div'); //create empty div
	$DOM.addClass(printLink, 'printLink'); //add class to div
	printLink.innerHTML = "<a href='javascript:open_new_window()'>Imprimer cette page</a>";
	
	var tabsVisible  = $DOM.getElementsByClassName('tabs'); //find send to link
	if (tabsVisible.length)
    {
		if (sendToLink){ // if research survey exists{
			insertAfter(printLink,sendToLink); // insert new link after the send to link
		}
    }
	
	

    var hitArea            = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue div.item' );
    var itemHeight = new Array();
     for ( var i = 0; i < hitArea.length; i++ )
        {
             var els = hitArea[i].offsetHeight;
             els = parseFloat(els);
             /*
             if (els > itemHeight)
             {
                 itemHeight[i] = els;
             }
             */
             itemHeight[i] = els;
        }
        
     
     var browser=navigator.appName;
     
     for ( var i = 0; i < hitArea.length; i++ )
        {
            $DOM.setStyle(hitArea[i], 'height', itemHeight[i] + 'px');
        }

    var newsItem            = $DOM.getElementsBySelector ( 'div#iSearchResults ul.library li' );
    
    if ( newsItem ) {
        
        var _hover = function (ev, obj)
        {
            if ($DOM.hasClass(this, 'barometer'))
            {
                $DOM.addClass(this, 'underline-barometer');
            }
            else if ($DOM.hasClass(this, 'syndicated'))
            {
                $DOM.addClass(this, 'underline-syndicated');
            }
            else{
                $DOM.addClass(this, 'underline');
            }
        }
        
        var _out = function (ev, obj)
        {
            $DOM.removeClass(this, 'underline');
            $DOM.removeClass(this, 'underline-barometer');
            $DOM.removeClass(this, 'underline-syndicated');
        }
        
        var _click = function (ev, obj)
        {
            //$DOM.removeClass(this, 'underline');
            var lnk        = this.getElementsByTagName('a')
            if(lnk.length){
                document.location    = lnk[0].href;    
            }
        }
        
            for ( var i = 0; i < newsItem.length; i++ )
                {
                    
                    /*@cc_on @*/
                    /*@if (@_jscript_version < 5.7)
                    $EVENT.addListener ( newsItem[i], "mouseover", _hover );
                    $EVENT.addListener ( newsItem[i], "mouseout", _out );
                    /*@end @*/
                    $EVENT.addListener ( newsItem[i], "click", _click );
                    
                }
        }
    
    var els            = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue ul.nav li a' );
    
    
    
    var defaultText  = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue div#iPointsDeVueDefault' );
  
    if ( els ) {
        var switcher = function ( ev, obj )
        {
            
            var els    = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue ul.nav li a' );
            for ( var i = 0; i < els.length; i++ )
            {
                var el    = els [ i ];
                //var ref    = el.hash.substr ( 1 );
                var div    = $DOM.get ( el.className );
                
                    if ( el == this ) {
                        $DOM.addClass ( el.parentNode, 'here' );
                        $DOM.removeClass ( div, 'jsHide' );
                        
                    } else {
                        $DOM.addClass ( div, 'jsHide' );
                        $DOM.addClass ( defaultText, 'jsHide' );
                        $DOM.removeClass ( el.parentNode, 'here' );
                    }
                
            }
            if ( ev ) {
                //$EVENT.stopEvent (ev);
            }
        }
        
        
      
        
        var found        = false;
        for ( var i = 0; i < els.length; i++ )
        {
            var el    = els [ i ];
            //var ref    = el.hash.substr ( 1 );
            var div    = $DOM.get ( el.className );
            $EVENT.addListener ( el, "focus", switcher );
            $EVENT.addListener ( el, "click", switcher );
            $EVENT.addListener ( el, "mouseover", switcher );
            if ( div )
            {
                if ( !found )
                {
                    //$DOM.addClass ( el.parentNode, 'here' );
                    found    = true;
                    $DOM.addClass ( div, 'jsHide' );
                } else {
                    $DOM.addClass ( div, 'jsHide' );
                }
            }
        }
    }
    
    
    
    
    $EVENT.addListener ( document, "mousemove", showDefault);
    
    function showDefault(ev,obj) {
        var panelSize = YAHOO.util.Region.getRegion('iPanelPointsDeVue');
        //get element height
        var h = $DOM.getStyle('iPanelPointsDeVue', 'height');
        

        h = parseFloat(h);
       
        //get element width
        var w = $DOM.getStyle('iPanelPointsDeVue', 'width');
        
        
        w = parseFloat(w);
        
        var areaTop = panelSize.top;
        //var areaBottom = panelSize.top+h;
        var areaBottom = panelSize.top+itemHeight+114;
        
       
        
        var areaLeft = panelSize.left;
        var areaRight = panelSize.left+w;
        
        
        
        var posx = 0;
        var posy = 0;
        if (!ev) var e = window.event;
        if (ev.pageX || ev.pageY)     {
            posx = ev.pageX;
            posy = ev.pageY;
        }
        else if (ev.clientX || ev.clientY)     {
            posx = ev.clientX + document.body.scrollLeft
                + document.documentElement.scrollLeft;
            posy = ev.clientY + document.body.scrollTop
                + document.documentElement.scrollTop;
        }
        
        
        if(posx < areaLeft || posx > areaRight || posy < areaTop || posy > areaBottom)
        {
            var els  = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue div.subcontainer div.item' );
            for ( var i = 0; i < els.length; i++ )
            {
                $DOM.addClass ( els[i], 'jsHide' );
            }
            
            var el    = $DOM.getElementsBySelector ( 'div#iPanelPointsDeVue ul.nav li')
            for ( var i = 0; i < el.length; i++ )
            {
                $DOM.removeClass ( el[i], 'here' );
            }
            $DOM.removeClass ( defaultText, 'jsHide' );
        }
    
        
    }    
var els            = $DOM.getElementsBySelector ( 'div.tabs ul.nav li a' );
    if ( els ) {
        var switcher = function ( ev, obj )
        {
            var els    = $DOM.getElementsBySelector ( 'div.tabs ul.nav li a' );
            for ( var i = 0; i < els.length; i++ )
            {
                var el    = els [ i ];
                var ref    = el.hash.substr ( 1 );
                var div    = $DOM.get ( ref );
        
                if ( el == this ) {
                    $DOM.addClass ( el.parentNode, 'here' );
                    $DOM.removeClass ( div, 'jsHide' );
                } else {
                    $DOM.addClass ( div, 'jsHide' );
                    $DOM.removeClass ( el.parentNode, 'here' );
                }
            }
            if ( ev ) {
                $EVENT.stopEvent (ev);
            }
        }
        
        // work out what should be the active tab
        var active = undefined;
        for ( var i = 0; i < els.length; i++)
        {
            // assume the active tab is the current one
            active = i;
            
            // if we're the analyses tab then don't bother checking for results
            if (els[i].hash == "#iAnalyses") break;
        }

        // add the listeners and setup default tab
        for ( var i = 0; i < els.length; i++ )
        {
            var el    = els [ i ];
            var ref    = el.hash.substr ( 1 );
            var div    = $DOM.get ( ref );
            $EVENT.addListener ( el, "focus", switcher );
            $EVENT.addListener ( el, "click", switcher );
            if ( div )
            {
                if ( active == i)
                {
                    $DOM.addClass ( el.parentNode, 'here' );
                } else {
                    $DOM.addClass ( div, 'jsHide' );
                }
            }
        }
    }    
 
var PRELOADS = new Object;
function PageLoad_Init () {
    PageLoad_Init_Corners ( ) ;
    PageLoad_Init_FirstLast ( );
    PageLoad_Init_Links( );
    PageLoad_Init_unObtrusiveLink( );
    PageLoad_Init_ContactForm ( );
    PageLoad_Init_FilterEvents ( );
    PageLoad_Init_FilterVacancies( );
    PageLoad_Init_FilterMinute ( );
    PageLoad_Init_SearchField ( );
    PageLoad_Init_ShowHide ( );
    var rollover = function ( ev ) {
        var b = YAHOO.util.Dom.get ( PRELOADS['out'+this.id].target )
        if ( b ) {
            b.src    = PRELOADS['ovr'+this.id].src
        }
    }
    var rollout = function ( ev ) {
        var b = YAHOO.util.Dom.get ( PRELOADS['out'+this.id].target )
        if ( b ) {
            b.src    = PRELOADS['out'+this.id].src
        }
    }
    var addEvents = function ( elements, images, imgId ) {
        if ( elements ) {
            for ( var i = 0; i < elements.length; i++ ) {
                var element    = YAHOO.util.Dom.get ( elements[i] )
                if ( element ) {
                    var img        = YAHOO.util.Dom.get ( imgId )
                    var src        = null
                    if ( img ) {
                        src        = img.src
                    }
                    if ( element.id ) {
                        PRELOADS['ovr' + element.id]            = new Image
                        PRELOADS['ovr' + element.id].src        = images[i];
                        PRELOADS['out' + element.id]            = new Object
    
                        PRELOADS['out' + element.id].src        = src
                        PRELOADS['out' + element.id].target        = imgId;
                        YAHOO.util.Event.addListener ( element, "mouseover", rollover );
                        YAHOO.util.Event.addListener ( element, "mouseout" , rollout  );
                    }
                }
            }
        }
    }
    if ( YAHOO.util.Dom.get ( 'iPanelIndustryFocus' ) ) {
        addEvents ( ['iFMCG', 'iWorldpanel', 'iConsumer', 'iTechnology', 'iFinance', 'iMedia', 'iMediaIntelligence', 'iMediaResearch', 'iHealthcare', 'iAutomotive', 'iPolitical' ],
                    ['', '', '', '', '', '', '', '', '', '', '' ],
                    'iPanelIndustryFocusRollover'
                    )
    }
    if ( YAHOO.util.Dom.get ( 'iPanelOurExpertise' ) ) {
        addEvents ( [ 'iOurExpertiseSpeciaistExpertise', 'iOurExpertiseGlobalBrands', 'iOurExpertiseInsightServices' ],
                    [ '', '', '' ],
                    'iPanelOurExpertiseRollover'
                    )
    }
    var links    = YAHOO.util.Dom.getElementsBySelector ( 'div#iNavL2 ul li a.jsCollapse' )
    if ( links ) {
        var caller = function ( ev ) {
            var links    = YAHOO.util.Dom.getElementsBySelector ( 'div#iNavL2 ul li a.jsCollapse' )
            for ( var i = 0; i < links.length; i++ ) {
                var link    = links[i]
                var parent    = link.parentNode
                if ( link == this ) {
                    YAHOO.util.Dom.toggleClass ( parent, 'jsClosed' )
                } else {
                    YAHOO.util.Dom.addClass ( parent, 'jsClosed' )
                }
            }
            if ( ev ) {
                YAHOO.util.Event.stopEvent(ev);
            }
        }
        for ( var i = 0; i < links.length; i++ ) {
            var link    = links[i]
            var parent    = link.parentNode
            if ( !YAHOO.util.Dom.hasClass ( link, 'jsToggleOpen' ) ) {
            YAHOO.util.Dom.addClass ( parent, 'jsClosed' )
            }
            YAHOO.util.Event.addListener ( link, "click",  caller  );
        }
    }
};
/**
 * @function    PageLoad_Init_Links
 * @description    --
 */
function PageLoad_Init_Links ( ) {
    var tmp_anchors    = document.getElementsByTagName ('a');
    for (var i = 0; i < tmp_anchors.length; i++) {
        var tmp_anchor    = tmp_anchors [ i ];
		
		// new global behaviour - all external links and downloadable files to open in a new window
		if(getLinkType(tmp_anchor) != null){
			tmp_anchor.target    = '_blank';
		}
		// if rel="external" - open in a new window
        if (tmp_anchor.getAttribute ('href') && tmp_anchor.getAttribute ('rel') == 'external') {
            tmp_anchor.target    = '_blank';
        };
		// if rel="internal" - open in SAME window
        if (tmp_anchor.getAttribute ('href') && tmp_anchor.getAttribute ('rel') == 'internal') {
            tmp_anchor.target    = '';
        };
              
    };
	function getLinkType(node){
		// check external
		var d = String(document.location.hostname).toLowerCase().split(".");
		if(d.length>1) { d[0] = ""; d = d.join("."); }
		var a = String(node.hostname).toLowerCase();
		if(a==""||a=="void(0)") return null;
		if(a.indexOf(d)<0) return "External";
		// get file name portion only
		a = String(node.href).toLowerCase().split("?");
		a = a[0].split("/");
		a = a[a.length-1];
		// check for PDF
		if(a.indexOf(".pdf")>-1) return "PDF";
		// check for DOC
		if(a.indexOf(".doc")>-1) return "DOC";
		return null;
	}
};
function PageLoad_Init_unObtrusiveLink()
{
	var links = document.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++)
	{
		switch (true)
		{
			case /popup-sendtofriend/.test(links[i].className):
				links[i].onclick = function()
				{
					window.open(this.href, 'sendtofriend', 'location=0,toolbar=0,status=0,scrollbars=1,width=650,height=470');
					return (false);
				}
				break;
		}
	}
}

/**
 * @function    PageLoad_Init_FirstLast
 * @description    Adds 'first' and 'last' classes to various elements
 */
function PageLoad_Init_FirstLast ( ) {
    $D                    = YAHOO.util.Dom;
    // add classes to columns
    var tmp_rows        = $D.getElementsByClassName ( 'row', 'div' );
    for ( var i = 0; i < tmp_rows.length; i++ ) {
        var tmp_row        = tmp_rows [ i ];
        var tmp_cols    = $D.getElementsByClassName ( 'col', 'div', tmp_row );
        if ( tmp_cols.length ) {
            $D.addClass ( tmp_cols [ 0 ], 'first' );
            $D.addClass ( tmp_cols [ tmp_cols.length - 1 ], 'last' );
        };
    };
    // add classes to lists
    var tmp_lists        = document.getElementsByTagName ( 'ul' );
    for ( var i = 0; i < tmp_lists.length; i++ ) {
        var tmp_list    = tmp_lists [ i ].getElementsByTagName ( 'li' );
        if ( tmp_list.length ) {
            $D.addClass ( tmp_list [ 0 ], 'first' );
            $D.addClass ( tmp_list [ tmp_list.length - 1 ], 'last' );
        }
    };
    var tmp_lists        = document.getElementsByTagName ( 'ol' );
    for ( var i = 0; i < tmp_lists.length; i++ ) {
        var tmp_list    = tmp_lists [ i ].getElementsByTagName ( 'li' );
        if ( tmp_list.length ) {
            $D.addClass ( tmp_list [ 0 ], 'first' );
            $D.addClass ( tmp_list [ tmp_list.length - 1 ], 'last' );
        }
    };
};
/**
 * @function    PageLoad_Init_Corners
 * @description    Add rounded corners to all elements that require them
 */
function PageLoad_Init_Corners ( ) {
    if ( ThinkCo.component.Corners ) {
        var $C        = ThinkCo.component.Corners;
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div.module h3' ), '', '', 2, 'span' );
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div.module h2' ), '', '', 2, 'span' );
        //$C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div#iTNSLive h2' ), '', '', 2, 'span' );
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'blockquote' ), '', '', 3, 'span' );
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div.links' ), '', '', 2, 'span' );
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div#iNavL2 ul li a' ), '', '', 2, 'span' );
        $C.internal ( YAHOO.util.Dom.getElementsBySelector ( 'div#iNavL2 ul li span.here' ), '', '', 2, 'span' );
        $C.externalWrap ( YAHOO.util.Dom.getElementsBySelector ( 'div.module div.subcontainer' ), '', '', 2, 'div');
    };
};
/**
 *
 */
function PageLoad_Init_SearchField ( ) {
    var tmp_search    = YAHOO.util.Dom.get ( 'q' );
    if ( tmp_search ) {
        tmp_search.value    = 'recherche TNS'
        var tmp_focus = function ( ) {
            var tmp_val    = this.value.trim();
            if ( tmp_val == 'recherche TNS' ) {
                this.value    = ''
            };
        };
        var tmp_blur = function ( ) {
            var tmp_val    = this.value.trim();
            if ( tmp_val == '' || tmp_val == 'recherche TNS' ) {
                this.value    = 'recherche TNS'
            };
        };
        YAHOO.util.Event.addListener ( tmp_search, "focus", tmp_focus );
        YAHOO.util.Event.addListener ( tmp_search, "blur",  tmp_blur  );
    };
}
function PageLoad_Init_ContactForm ( ) {
    var tmp_searchBy    = YAHOO.util.Dom.get ( 'ContactForm_lstType' )
    if ( tmp_searchBy ) {
        var tmp_selectSector = YAHOO.util.Dom.get ( 'ContactForm_lstType_0' )
        var callerBySector = function ( ev ) {
            YAHOO.util.Dom.removeClass ( 'iFindExpertSectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertServices', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertSolutions', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertTools', 'jsHide' );            
        }
        YAHOO.util.Event.addListener ( tmp_selectSector, "click",  callerBySector  );
        
        var tmp_selectService = YAHOO.util.Dom.get ( 'ContactForm_lstType_1' )
        var callerByService = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'iFindExpertSectors', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'iFindExpertServices', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertSolutions', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertTools', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectService, "click",  callerByService  );
        
        var tmp_selectSolution = YAHOO.util.Dom.get ( 'ContactForm_lstType_2' )
        var callerBySolution = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'iFindExpertSectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertServices', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'iFindExpertSolutions', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertTools', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectSolution, "click",  callerBySolution  );
        
        var tmp_selectTool = YAHOO.util.Dom.get ( 'ContactForm_lstType_3' )
        var callerByTool = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'iFindExpertSectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertServices', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'iFindExpertSolutions', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'iFindExpertTools', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectTool, "click",  callerByTool  );
    }
}
function PageLoad_Init_FilterEvents ( ) {
    var tmp_searchBy    = YAHOO.util.Dom.get ( 'FilterEvents_lstType' )
    if ( tmp_searchBy ) {
        var tmp_selectSector = YAHOO.util.Dom.get ( 'FilterEvents_lstType_0' )
        var callerBySector = function ( ev ) {
            YAHOO.util.Dom.removeClass ( 'FilterEvents_iFindEventSectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventPartnerships', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventYears', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectSector, "click",  callerBySector  );
        
        var tmp_selectPartnership = YAHOO.util.Dom.get ( 'FilterEvents_lstType_1' )
        var callerByPartnership = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventSectors', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'FilterEvents_iFindEventPartnerships', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventYears', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectPartnership, "click",  callerByPartnership  );
        
        var tmp_selectYear = YAHOO.util.Dom.get ( 'FilterEvents_lstType_2' )
        var callerByYear = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventSectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'FilterEvents_iFindEventPartnerships', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'FilterEvents_iFindEventYears', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectYear, "click",  callerByYear  );      
    }
}
function PageLoad_Init_FilterVacancies ( ) {
    var tmp_searchBy    = YAHOO.util.Dom.get ( 'FilterVacancies_lstType' )
    if ( tmp_searchBy ) {
        var tmp_selectSector = YAHOO.util.Dom.get ( 'FilterVacancies_lstType_0' )
        var callerBySector = function ( ev ) {
            YAHOO.util.Dom.removeClass ( 'FilterVacancies_iFindVacancySectors', 'jsHide' );
            YAHOO.util.Dom.addClass ( 'FilterVacancies_iFindVacancyRoles', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectSector, "click",  callerBySector  );
        
        var tmp_selectRole = YAHOO.util.Dom.get ( 'FilterVacancies_lstType_1' )
        var callerByRole = function ( ev ) {
            YAHOO.util.Dom.addClass ( 'FilterVacancies_iFindVacancySectors', 'jsHide' );
            YAHOO.util.Dom.removeClass ( 'FilterVacancies_iFindVacancyRoles', 'jsHide' );
        }
        YAHOO.util.Event.addListener ( tmp_selectRole, "click",  callerByRole  );
    }
}
function PageLoad_Init_FilterMinute() {
    var tmp_searchBy = YAHOO.util.Dom.get('FilterMinutes_lstType')
    if (tmp_searchBy) {
        var tmp_selectTheme = YAHOO.util.Dom.get('FilterMinutes_lstType_0')
        var callerByTheme = function(ev) {
            YAHOO.util.Dom.removeClass('FilterMinutes_iFindMinuteThemes', 'jsHide');
            YAHOO.util.Dom.addClass('FilterMinutes_iFindMinuteYears', 'jsHide');
        }
        YAHOO.util.Event.addListener(tmp_selectTheme, "click", callerByTheme);

        var tmp_selectYear = YAHOO.util.Dom.get('FilterMinutes_lstType_1')
        var callerByYear = function(ev) {
            YAHOO.util.Dom.addClass('FilterMinutes_iFindMinuteThemes', 'jsHide');
            YAHOO.util.Dom.removeClass('FilterMinutes_iFindMinuteYears', 'jsHide');
        }
        YAHOO.util.Event.addListener(tmp_selectYear, "click", callerByYear);
    }
}
function PageLoad_Init_ShowHide()
{
    var toggleDivs = $DOM.getElementsByClassName ('show-hide');
    var contactSel = document.getElementById('ContactForm_ddlMethod');
    if (toggleDivs)
    {
        for(var i = 0; i < toggleDivs.length; i++)
        {
            if (
               contactSel.value != 'Phone'
               )
            {
                toggleDivs[i].style.display = 'none';
            }
        }
        if  (
            contactSel
            )
        {
            contactSel.onchange  = function()
            {
                if (
                   this.value == 'Phone'
                   )
                {
                    toggleDivs[0].style.display = 'block';
                } 
                else
                {
                    toggleDivs[0].style.display = 'none';            
                }
            }  
        }
    } 
}

// open new window to print report
function open_new_window() 
	{
	new_window = open("","displayWindow","width=600,scrollbars=yes,height=600,left=10,top=10");
	
	new_window.document.open();
	
	var reportTitle = document.getElementsByTagName ('h1');
	var reportHeading;
	var reportContent;
	for(var i = 0; i < reportTitle.length; i++){
		reportHeading = reportTitle[0].innerHTML;
	}
	if (document.getElementById("iFicheTechnique")!= null){
		reportContent = "<h2>Fiche technique</h2>"+(document.getElementById("iFicheTechnique").innerHTML);
	}
	if (document.getElementById("iAnalyses")!= null){
		reportContent += "<h2>Analyse</h2>"+(document.getElementById("iAnalyses").innerHTML);
	}
	if (document.getElementById("iResultats")!= null){
		reportContent += "<h2>Résultats</h2>"+(document.getElementById("iResultats").innerHTML);
	}
	
	new_window.document.write("<html><head><title>"+reportHeading+" - print version</title></head><style type=\"text/css\">@media print {.printLink{display:none;}}body{font-size:11pt;line-height:1.4em;font-family:times;}h1{font-size:18pt;border-bottom:1px solid #ccc;padding-bottom:0.4em;}h2{font-size:14pt;border-bottom:1px solid #ddd;padding-bottom:0.4em;}h3{font-size:12pt;}table{border-collapse:collapse;}table tr td{padding:3px;border:1px solid #ccc;}</style>");
	new_window.document.write("<body bgcolor=\"#FFFFFF\"><img alt='TNS Sofres' src='/_assets/sofreslogo.gif'/><br />");
	new_window.document.write("<a class='printLink' href=\"javascript:window.print()\">Imprimer</a><h1>"+reportHeading+"</h1>");
	new_window.document.write("<div class=\"content\">"+reportContent+"</div>");
	new_window.document.write("</body></html>");
	new_window.document.close(); 
	}

// add the event call
YAHOO.util.Event.onDOMReady ( PageLoad_Init );
// Homepage Accordion (requires js\thirdparty\mootools.js)
function Init_HmPgAccordion(){
    try{
        var accordion = new Accordion('dt a', 'dd', {
            opacity: false,
            show: 0,
            fixedHeight: 165, // same value in css for dl#iOurExpertiseMenu dd.open
            onActive: function(toggler, element){
                $(toggler.parentNode).addClass('open');
            },
            onBackground: function(toggler, element){
                $(toggler.parentNode).removeClass('open');
            }
        }, $('iOurExpertiseMenu'));
        var lnk = $ES('dt a', 'iOurExpertiseMenu');
        for (var i=0; i<lnk.length; i++) lnk[i].addEvent("click", function(event){ event = new Event(event); event.stop(); } );
    }catch(e){ }
}

//create function, it expects 2 values.
function insertAfter(newElement,targetElement) {
	//target is what you want it to go after. Look for this elements parent.
	var parent = targetElement.parentNode;
	
	//if the parents lastchild is the targetElement...
	if(parent.lastchild == targetElement) {
		//add the newElement after the target element.
		parent.appendChild(newElement);
		} else {
		// else the target has siblings, insert the new element between the target and it's next sibling.
		parent.insertBefore(newElement, targetElement.nextSibling);
		}
}

Init_HmPgAccordion();
