// Google search engine global params. Default is empty. All localized by market.

// search engine google API engine
var gcsId = '005212292509289221305:g4ognpyz5qu';
// name of the button search
var searchGoogleItemString = 'Buscar';
// link to the input type button
var linkToSearchPage = 'http://busqueda.disneylandparis.es/index.xhtml';
// text if google gives no result
var noResult = "\n\n\n<div id = 'noResultToDisplay'>";
noResult +="<p>No hay resultados que cumplan los criterios de b&uacute;squeda.</p><p>Recomendaciones:</p>\n";
noResult +="<ul><li>Aseg&uacute;rese de que todas las palabras est&eacute;n escritas correctamente.</li>\n";
noResult +="<li>Intente usar otras palabras.</li>\n";
noResult +="<li>Utilizar t&eacute;rminos m&aacute;s generales.</li>\n"
noResult +="<li>Trate de reducir el n&uacute;mero de palabras en su b&uacute;squeda.</li>\n"
noResult +="<li><a href='http://www.disneylandparis.es/mapa-del-sitio/index.xhtml'>Mira la mapa de la web.</a></li>\n"
noResult +="</ul></div>";
//langauge of the search engine (this param is called in google seacrh component of menu html)
var googleSearchLanguage = "es";
/* This Url is default one and is called by popupNova function as global param
Localized if necessary*/


var urlQualificator = "http://identification.disneylandparis.com/es/ope/1101DIQFNONOESNOSWE03";
var urlMyDisneyland = "https://my-disneyland.disneylandparis.es/login.xhtml";
var dontDisplayPopunder = new Array();
// Block J - Tab Management 
//Change Style
function findObj(n, d) { //v4.0
    var p,i,x;
    if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
    if(!x && document.getElementById) x=document.getElementById(n);
    return x;
}

function changestyle(couche, style) {
    if (!(layer = findObj(couche))) return;
    layer.style.display = style;  
}

function changecolor(couche, name) {
    if (!(layer = findObj(couche))) return;
    layer.className = name;
  
}

function switchLine (nbTab, position, tabName){
    //	var tempTabName;
    tempTabName = tabName+'8';	
    if (nbTab>4){
        if (!(layer1 = findObj('line1'))) return;
        if (!(layer2 = findObj('line2'))) return;
        if (position<=4){
            layer1.style.top = '31px';
            layer2.style.top = '-31px';
            if (nbTab!=8){
                changecolor(tempTabName,'tabButtonVide3');	  				  			
            } 
	  		 		
        }	
        if (position>4){
            layer1.style.top = '0px'; 
            layer2.style.top = '0px';	  	  			
            if (nbTab!=8){
                changecolor(tempTabName,'tabButtonVide2');	  				  			
            }	  		
        }  			
    }	
}

function generateBlockJ (nbTab, position, divName, tabName){	
    var tempDivName;
    var tempTabName;    
    var tempLine;
	
    if (position<=4){
        tempLine=8
        }else{
        tempLine=4
        } 	
	
    for (var i=1; i<=nbTab; i++){
        tempDivName = divName + i;
        tempTabName = tabName + i;
        if (i != position){
            changestyle(tempDivName,'none');
            if (i== tempLine){ 
                changecolor(tempTabName,'tabButtonOff2');				
            }else{
                changecolor(tempTabName,'tabButtonOff');
            } 			
        }else{
            changestyle(tempDivName,'block');
            if (i== tempLine){
                changecolor(tempTabName,'tabButtonOn2');				
            }else{
                changecolor(tempTabName,'tabButtonOn');
            } 	
			
            if(i!=1 && i!=5){
                tempTabName = tabName + (i-1);
                changecolor(tempTabName,'tabButtonOff3');				
            }
        }		
    }	
    switchLine (nbTab, position, tabName);	
}
// End Block J - Tab Management



var clear="http://www.disneylandparis.co.uk/Images/spacer.gif"; //path to clear.gif

document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>');


var ct=document.getElementById("ct");
ct.onreadystatechange=function(){
    if (msieVersion() == 6) { 
        pngfix();
    }
};

pngfix=function(){
    var els=document.getElementsByTagName('*'),ip=/\.png/i,al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length,uels=new Array(),c=0;
    while(i-->0){
        if(els[i].className.match(/unitPng/)){
            uels[c]=els[i];
            c++;
        }
    }
    if(uels.length==0)pfx(els);else pfx(uels);
    function pfx(els){
        i=els.length;
        while(i-->0){
            var el=els[i],es=el.style,elc=el.currentStyle,elb=elc.backgroundImage;
            if(el.src&&el.src.match(ip)&&!es.filter){
                es.height=el.height;
                es.width=el.width;
                es.filter=al+el.src+"',sizingMethod='crop')";
                el.src=clear;
            }else{
                if(elb.match(ip)){
                    var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;
                    es.filter=al+path[1]+"',sizingMethod='"+rep+"')";
                    es.height=el.clientHeight+'px';
                    es.backgroundImage='none';
                    if(j!=0){
                        if(elc.position!="absolute")es.position='static';
                        while(j-->0)if(!elkids[j].style.position)elkids[j].style.position="relative";
                    }
                }
            }
        }
    };
};




/***********************
       Forms utils 
***********************/

function optionYearPlus2(selectName, selectId, firstValue){		
    currentYear = new Date().getFullYear();
	
    document.write("<select name='"+selectName+"' id='"+selectId+"'>");
    document.write("<option>"+firstValue+"</option>");	
    document.write("<option value='2006'>"+currentYear+"</option>");
    document.write("<option value='2006'>"+(currentYear+1)+"</option>");
    document.write("<option value='2006'>"+(currentYear+2)+"</option>");	
    document.write("</select>");							
}	 

function optionLast90Year(selectName, selectId, firstValue){		
    currentYear = new Date().getFullYear();
    last90 = currentYear-90;
	
    document.write("<select name='"+selectName+"' id='"+selectId+"'>");
    document.write("<option>"+firstValue+"</option>");
    for (var i=currentYear; i>last90; i--) {
        document.write("<option value='"+i+"'>"+i+"</option>");
    }	
    document.write("</select>");	
}	

function optionDRPOpenYear(selectName, selectId, firstValue){		
    currentYear = new Date().getFullYear();
    DRPOpen = 1992;
    document.write("<select name='"+selectName+"' id='"+selectId+"'>");
    document.write("<option>"+firstValue+"</option>");	
    for (var i=currentYear; i>=DRPOpen; i--) {
        document.write("<option value='"+i+"'>"+i+"</option>");
    }	
    document.write("</select>");						
}	 


/***********************
       Browser detection 
***********************/

var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
        || this.searchVersion(navigator.appVersion)
        || "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i=0;i<data.length;i++)	{
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
    },
    dataBrowser: [
    {
        string: navigator.userAgent,
        subString: "OmniWeb",
        versionSearch: "OmniWeb/",
        identity: "OmniWeb"
    },
    {
        string: navigator.vendor,
        subString: "Apple",
        identity: "Safari"
    },
    {
        prop: window.opera,
        identity: "Opera"
    },
    {
        string: navigator.vendor,
        subString: "iCab",
        identity: "iCab"
    },
    {
        string: navigator.vendor,
        subString: "KDE",
        identity: "Konqueror"
    },
    {
        string: navigator.userAgent,
        subString: "Firefox",
        identity: "Firefox"
    },
    {
        string: navigator.vendor,
        subString: "Camino",
        identity: "Camino"
    },
    {		// for newer Netscapes (6+)
        string: navigator.userAgent,
        subString: "Netscape",
        identity: "Netscape"
    },
    {
        string: navigator.userAgent,
        subString: "MSIE",
        identity: "Explorer",
        versionSearch: "MSIE"
    },
    {
        string: navigator.userAgent,
        subString: "Gecko",
        identity: "Mozilla",
        versionSearch: "rv"
    },
    { 		// for older Netscapes (4-)
        string: navigator.userAgent,
        subString: "Mozilla",
        identity: "Netscape",
        versionSearch: "Mozilla"
    }
    ],
    dataOS : [
    {
        string: navigator.platform,
        subString: "Win",
        identity: "Windows"
    },
    {
        string: navigator.platform,
        subString: "Mac",
        identity: "Mac"
    },
    {
        string: navigator.platform,
        subString: "Linux",
        identity: "Linux"
    }
    ]

};
BrowserDetect.init();


/***********************
       Footer utils 
***********************/

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}


function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}




function openPrint(dns){
    printPage=window.open(document.location.href+'?print', 'print', 'width=540,height=600,scrollbars=yes');
}


function checkPrint(dns){
    if(document.location.href.indexOf('?print')!=-1){
        document.getElementById('print').href=dns+'print.css';
        window.print();
    }
}



function Set_Cookie( name, value, expires, path, domain, secure ) 
{
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );
    /*
    if the expires variable is set, make the correct 
    expires time, the current script below will set 
    it for x number of days, to make it for hours, 
    delete * 24, for minutes, delete * 60 * 24
    */
    if ( expires )
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}



function Set_Cookie2( name, value, expires, path, domain, secure ) 
{
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );
    /*
    if the expires variable is set, make the correct 
    expires time, the current script below will set 
    it for x number of days, to make it for hours, 
    delete * 24, for minutes, delete * 60 * 24
    */
    if ( expires )
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" + value  +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}




// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
    var start = document.cookie.indexOf( name + "=" );
    if (start!=1){
        start = document.cookie.indexOf(" "+ name + "=" );
    }

    var len = start + name.length + 1;
    if ( ( !start ) &&
        (name != document.cookie.substring( 0, name.length ) ) )
        {
        return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
	


// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
    if ( Get_Cookie( name ) ) document.cookie = name + "=" +
        ( ( path ) ? ";path=" + path : "") +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}	


function getURLVariable(strVarNameToSearch){ 
    if(location.search.substring(1)){ 
        // Get all the argument in the URL in a table 
        tbVar = location.search.substring(1).split('&'); 
        for(i=0 ; i<tbVar.length ; i++){ 
            // Look for equal character 
            intPosEgal = (tbVar[i].indexOf("=",0)); 
            // Get the name of the variable 
            strVarName = tbVar[i].substring(0,intPosEgal); 
            if(strVarNameToSearch == strVarName){ 
                // Return the variable value 
                return tbVar[i].substring(intPosEgal+1,tbVar[i].length); 
            } 
        } 
    } 
    // variable not found 
    return "" 
} 



function logout(redirect){

    Delete_Cookie('LOGIN', '/', '');
    Delete_Cookie('LOGIN', '/', '.disneylandparis.com.webrelaunch-prod.dlp.disney.com');
    Delete_Cookie('LOGIN', '/', '.disneylandparis.com');

    //   Set_Cookie( 'LOGOUT', 'yes', '', '/', '', ''); 
    window.document.location.href=redirect;
} 	


function Test_Login(){
    var bitLogged;
    Get_Cookie( 'LOGIN' )? bitLogged=true : bitLogged=false;
    if (document.location.href.indexOf("logout=true")!=-1){
        bitLogged=false;
        Delete_Cookie('LOGIN', '/', '');
    }
    return bitLogged;
}




/***********************
       Campaign utils 
***********************/


function trackParam(){

    // TDUID
    // récupère le Tradedoubler ID et le stocke dans un cookie sous le nom TDUID
    var tduid = getURLVariable('tduid'); 

    // AFFID
    // récupère l'Affilié ID et le stocke dans un cookie sous le nom AFFID
    var affid = getURLVariable('affId'); 
	
    // CAMID
    var camid = getURLVariable('camid'); 
	
    // MAUID	
    var mauid = getURLVariable('mauid'); 

    // recontruit le query string
    var wr1='';
    if (mauid!='' && camid!='') {
        wr1="camid="+camid+"&mauid="+mauid;
    }
    if (affid!='' && tduid!='') {
        if(wr1!=''){
            wr1=wr1+"&"
            }
        wr1=wr1+"affId="+affid+"&tduid="+tduid;
    }	
    return wr1;

}

function OmniAffiliate(){
    var param="";
    document.write("<span id='affiliateSpan'></span>"); 
    affiliate = document.getElementById("affiliateSpan");			
    if (trackParam()!=''){
        param='?'+trackParam();
    }
    if(affiliate!=null && param!=''){
        affiliate.innerHTML = "<iframe src='http://www.disneylandparis.com/affiliation.htm"+param+"' width='0' height='0' scrolling='none' frameborder='0' name='affiliation' align='center'>"; 			   
    }
}

/************************************************************************/
/************************************************************************/
/*************     IDENTIFICATION ANNUAL PASSPORT    ********************/
/*Annual Passport Management : this script enables a password section to
 fill in. If the required password is ok, the user can be connected to
            new offers. The script used ajax commons dev tools
/************************ EOS - spt. 2009 ********************************/
/************************************************************************/


//Définitions des variables globales :

// Chemin vers le XML des mots de passe
var pathXmlPass = "/FR/FR/Distant/system/XML/annual-passport/password.xml";
//Chemin vers les XML des messages d'erreur
var pathXmlErrorUrl = "/FR/FR/Distant/system/XML/annual-passport/errors.xml";
//Nom de l'élement HTML où sont affichés les messages d'erreur
var elementId = "message";
//Nom du cookie
var cookieNamePassword = "password";


// Méthode permettant de créer une instance asynchrone (AJAX) - private

function P_getRequester() {
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
        return xhr;
    }
    else if (window.ActiveXObject) {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
        return xhr;
    }
    if (!xhr) {
        alert("Your browser does not accept AJAX, use another browser (Internet Explorer, Firefox, GoogleChrome...)");
        return false;
    }
}

/* Méthode permettant de charger le fichier XML des mots de passe et de rencoyer la réponse (responseXML)
     Cette méthode appelle P_checkPassword qui renvoie le message d'erreur approprié - private  */

function P_loadPassData(index) {
    var requester = P_getRequester();
    requester.onreadystatechange = function() {
        if (4 == requester.readyState && 200 == requester.status) {
            var xml = requester.responseXML;
            switch(index){
                case 1 :
                    P_checkPassword(xml);
                    break;
                case 2 :
                    P_checkUrlPassword(xml);
                    break;
            }
        }
    };
    requester.open('GET', pathXmlPass, true);
    requester.send(null);
}




/* Méthode permettant de charger le fichier XML des messages d'erreur et de renvoyer la réponse (responseXML)
    Cette méthode appelle P_parserXml qui permet de surcharger la méthode P_loadErrorData - private  */

function P_loadErrorData(div,index) {
    var requester = P_getRequester();
    requester.onreadystatechange = function() {
        if (4 == requester.readyState && 200 == requester.status) {
            var xml = requester.responseXML;
            P_parserXml(xml,div,index);
        }
    };
    requester.open('GET', pathXmlErrorUrl, true);
    requester.send(null);
}

/* Méthode de redirection appelée dans toutes les pages sauf la page d'identification
   permettant de rediriger l'utilisateur vers l'url (méthode P_getUrlRedirection) du fichier XML.
   Cette méthode est appelée via sa méthode public P_redirect - private */


function P_loadUrlData(cookieNamePassword) {
    var requester = P_getRequester();
    requester.onreadystatechange = function() {

        if (4 == requester.readyState && 200 == requester.status) {
            var url = "";
            var xml = requester.responseXML;
            if (P_getCookie(cookieNamePassword)==null) {
                url = P_getUrlRedirection(xml);
                window.location = url;
            }
        }
    };
    requester.open('GET', pathXmlErrorUrl, true);
    requester.send(null);
}


function P_getUrlEnter(xml){
    var lien = xml.getElementsByTagName('txt');
    var lienTab = new Array();
    for(var i = 0;i<lien.length;i++){
        lienRead = lien[i].getElementsByTagName('urlOk')[0];
        lienTab[i] = lienRead.firstChild.data;

    }
    return 	lienTab[0];
}


function P_getUrlId() {
    var requester = P_getRequester();
    requester.onreadystatechange = function() {
        if (4 == requester.readyState && 200 == requester.status) {
            var xml = requester.responseXML;
            window.location = P_getUrlEnter(xml);
        }
    };
    requester.open('GET', pathXmlErrorUrl, true);
    requester.send(null);
}


function P_getUrlRedirection(xml){
    var urlTab = new Array();
    var url = xml.getElementsByTagName('txt');
    for(var i = 0;i<url.length;i++){
        urlRead = url[i].getElementsByTagName('urltxt')[0];
        urlTab[i] = urlRead.firstChild.data;
    }
    return 	urlTab[0];
}

// Méthode d'appel de méthode permettant de renvoyer les réponses via des méthodes spécifiques, en dessous - private

function P_parserXml(xml,div,index){
    var APform = document.getElementById("APform");
    var result="";
    switch (index){
        case 1 :
            result=P_getErrorUrl(xml);
            break;
        case 2 :
            result=P_getErrorMsg(xml);
            break;
        case 3 :
            result=P_getValidationMsg(xml);
            break;
        case 4 :
            result=P_getEmptyMsg(xml);
            break;
        case 5 :
            result=P_getErrorMsgUrl(xml);
            break;
    }
    if (result) {
        if (APform) {
            document.getElementById(div).innerHTML = result;
        }
    }
}

/* Ces six méthodes permettent d'extraire les listes de type chaine des fichier XML et de les renvoyer
   sous forme d'un tableau - private */

//Début


function P_getMdp(xml){
    var mdp = xml.getElementsByTagName('mdp');
    var mdpTab = new Array();
    for(var i = 0;i<mdp.length;i++){
        mdpRead = mdp[i].getElementsByTagName('mdptxt')[0];
        mdpTab[i] = mdpRead.firstChild.data;
    }
    return 	mdpTab;
}

function P_getErrorUrl(xml){
    var msg = xml.getElementsByTagName('txt');
    var msgTab = new Array();
    for(var i = 0;i<msg.length;i++){
        msgRead = msg[i].getElementsByTagName('errorUrl')[0];
        msgTab[i] = msgRead.firstChild.data;
    }
    return 	msgTab[0];
}

function P_getErrorMsgUrl(xml){
    var msg = xml.getElementsByTagName('txt');
    var msgTab = new Array();
    for(var i = 0;i<msg.length;i++){
        msgRead = msg[i].getElementsByTagName('errorUrlMdp')[0];
        msgTab[i] = msgRead.firstChild.data;
    }
    return 	msgTab[0];
}

function P_getErrorMsg(xml){
    var msg = xml.getElementsByTagName('txt');
    var msgTab = new Array();
    for(var i = 0;i<msg.length;i++){
        msgRead = msg[i].getElementsByTagName('errorMdp')[0];
        msgTab[i] = msgRead.firstChild.data;
    }
    return 	msgTab[0];
}

function P_getValidationMsg(xml){
    var msg = xml.getElementsByTagName('txt');
    var msgTab = new Array();
    for(var i = 0;i<msg.length;i++){
        msgRead = msg[i].getElementsByTagName('mdpOk')[0];
        msgTab[i] = msgRead.firstChild.data;
    }
    return 	msgTab[0];
}

function P_getEmptyMsg(xml){
    var msg = xml.getElementsByTagName('txt');
    var msgTab = new Array();
    for(var i = 0;i<msg.length;i++){
        msgRead = msg[i].getElementsByTagName('emptyMdp')[0];
        msgTab[i] = msgRead.firstChild.data;
    }
    return 	msgTab[0];
}

//Fin


// Méthode permettant de vérifier la valeur du mot de passe. Les messages renvoyés sont fonctions de la langue du site

function P_checkPassword(xml) {
    var password = document.getElementById('myPass').value;
    var msg = new Array();
    if (password) {
        msg = P_loadErrorData(elementId,2);
        var i;
        for(i=0; i<P_getMdp(xml).length;i++) {
            // le mot de passe est OK
            if (P_getMdp(xml)[i]==password) {
                msg = P_loadErrorData(elementId,3);
                P_setCookie(cookieNamePassword, password);
                P_getUrlId();
            }
        }
    }
    else {
        msg = P_loadErrorData(elementId,4);
    }
    return msg;
}

//Méthode permettant de modifier le type de l'input en password

function P_setFocusPassword() {

    var element = document.getElementById("test45");
    var elementList = element.getElementsByTagName("input");
    var child=elementList.item(0);
    element.removeChild(child);
    var input = document.createElement('input');
    input.setAttribute('id','myPass');
    input.setAttribute('type','password');
    input.setAttribute('size','17');
    input.setAttribute('value','');
    element.appendChild(input);
    if (document.all) {
        var span = document.createElement('span');
        span.innerHTML="&nbsp;";
        element.appendChild(span);
    }
    elementList[0].focus();

}



// Fonctions de cookies - private

function P_setCookie(name, value)	{
    var argv=P_setCookie.arguments;
    var argc=P_setCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=name+"="+escape(value)+((expires==null) ? "" : ("; expires="+expires.toGMTString()))+((path==null) ? "" : ("; path="+path))+
    ((domain==null) ? "" : ("; domain="+domain))+((secure==true) ? "; secure" : "");
}

function P_getCookieVal(offset) {
    var endstr=document.cookie.indexOf (";", offset);
    if (endstr==-1)
        endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function P_getCookie (cookieNamePassword) {
    var arg=cookieNamePassword+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen) {
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg)
            return P_getCookieVal (j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
    }
    return null;
}

// Méthode permettant d'extraire les paramètres de l'url sous forme d'un tableau - private

function P_extractUrlParams(){
    var t = location.search.substring(1).split('&');
    var urlParams = [];
    for (var i=0; i<t.length; i++){
        var x = t[ i ].split('=');
        urlParams[x[0]]=x[1];
    }
    return urlParams;
}

//Méthode qui permet de récupérer le paramètre spécifique password passé dans l'url - private

function P_getUrlPassword() {
    var password = P_extractUrlParams()[cookieNamePassword];
    if (password !=null && password != "") {
        return password;
    } else {
        return null;
    }
}

/* Méthode de vérification du mot de passe envoyé dans l'url : si le mot de passe de l'url
   se trouve dans le fichier XML, l'utilisateur est automatiquement identifié; on place le cookie et
   on n'affiche pas le formulaire d'identification, sinon on affiche un message invitant l'utilisateur à s'identifier - private*/

function P_checkUrlPassword(xml) {
    var urlPassword = P_getUrlPassword();
    var msg = P_loadErrorData(elementId,5);
    var validate = false;
    for (var i = 0;i<P_getMdp(xml).length; i++) {
        if (P_getMdp(xml)[i]==urlPassword) {
            P_setCookie(cookieNamePassword, urlPassword);
            P_loadErrorData(elementId,3);
            P_loadUrlData(cookieNamePassword);
            validate = true;
        }
    }
    if (!validate) {
        return msg;
    }
}

/* Appel de la méthode qui vérifie les paramètres passés par l'url pour une identification automatique - public */

function P_checkUrlParam() {
    if (P_getUrlPassword() != null) {
        return  P_loadPassData(2);
    }else {
        return false;
    }
}

/* Cette méthode permet de renommer P_loadErrorData pour plus de clarté dans le code - public */

function P_submitPass() {
    return P_loadPassData(1);
}


function P_displayLink() {
    if (P_getCookie(cookieNamePassword)!=null) {
        var element = document.getElementById("test45");
        var elementList = element.getElementsByTagName("input");
        var child=elementList.item(0);       
        element.removeChild(child);
        document.getElementById("submitPass").style.display="none";
        document.getElementById("txtLink").style.marginLeft="30px";
        document.getElementById("txtLink").style.display="block";

        
    }
}

/* Cette méthode permet de renommer P_loadUrlData pour plus de clarté dans le code - public */

function P_redirect() {
    return P_loadUrlData(cookieNamePassword);
}

/* Méthode permettant d'ajouter un écouteur dans le code javascript, quelque soit le navigateur.
     Cette méthode permet d'éviter d'inclure du code javascript dans le code HTML. Private */

function P_addListener(element, baseName, handler) {
    if (element.addEventListener) { //Firefox Safari
        element.addEventListener(baseName, handler, false);
    }
    else if (element.attachEvent) { //IE
        element.attachEvent('on'+baseName, handler);
    }
}

/* Méthode permettant l'accès au bouton qui soumet le mot de passe. Cette méthode appelle l'écouteur
    dans son contexte.  Public */

function P_displayMessage(id) {
    var element = document.getElementById(id);
    P_addListener(element, 'click', P_submitPass);
}

function P_changeInputType(id) {
    var element = document.getElementById(id);
    P_addListener(element, 'click', P_setFocusPassword);
}


/***********************************************************************************/
/**************************            SITE MAP RULES        ********************************/
/***********************************************************************************/
/******        The method enables to affect a specific style (with columns) to the site Map***********/
/*********************            Code BY EOS ON MAY 2010                     *****************/
/***********************************************************************************/

function setSiteMapColContainer (arg1,arg2,arg3,arg4) {    
    // args is an array of all arguments of the method : each argument is an integer
    // which defines in order the number of titles of level 1 (in bold)
    // diplayed in each column
    var args = setSiteMapColContainer.arguments;
    var oldHTML = new Array();
    var ulFooterColText = new Array();
    var footerLeftSpacer = "\n\t<div id='footerLeftSpacer'></div>\n";
    var newHTML = "";
    var HTML = "";
    var colContainer = document.getElementById('colContainer');
    var footerColText = document.getElementById('footerColText');
    ulFooterColText = footerColText.getElementsByTagName('ul');    
    var j = 0;
    var incrJ = 0;
    for (var i = 0; i<ulFooterColText.length; i++) {
        oldHTML[i] = ulFooterColText[i].innerHTML;
    }
    // We create "nbreDiv.lenght" columns for the siteMap.
    // This algo allows to create dynamically 4 (==nbreDiv) columns to present the siteMap
    for (var i = 0; i < args.length; i++) {
        incrJ+= args[i]; 
        newHTML = "\n\t<div id='footerColTextDyn'>\n";
        for (j; j< incrJ; j++) {
            if (oldHTML[j] != undefined) {
                newHTML += "\n<ul>"+oldHTML[j]+"</ul>\n";
            }
        }       
        newHTML += "\n\t</div>\n";
        HTML +=newHTML;        
    }
    // We remove all HTML code in colContainer
    footerColText.parentNode.removeChild(footerColText);
    // We add the new HTML code with footerColTextDyn div
    colContainer.innerHTML=footerLeftSpacer+HTML;    
}

function deleteEndSep () {
    if (document.getElementById('menuFooter')) {
        var  menuFooter = document.getElementById('menuFooter');      
        var spanMenuFooter = menuFooter.getElementsByTagName('span');        
        var nbrSspanMenuFooter = spanMenuFooter.length;       
        spanMenuFooter[nbrSspanMenuFooter-1].style.backgroundImage = "none";
    }
    if ( document.getElementById('choices')) {
        var  choices = document.getElementById('choices');
        var spanChoices = choices.getElementsByTagName('span');
        var nbrSpanChoices = spanChoices.length;
        spanChoices[nbrSpanChoices-1].style.backgroundImage = "none";
    }
}

//Display the free footer text at the right place

function displayFreeFooterText () {
    if (document.getElementById("hiddenFreeTextFooter") && document.getElementById("freeTextFooter")) {
        document.getElementById("freeTextFooter").innerHTML=document.getElementById("hiddenFreeTextFooter").innerHTML;
    }
}

/***********************************************************************************/
/**********************               POP UP UNDER        **************************/
/***********************************************************************************/
/******These methods enable to affect a popup to the current window which***********/
/**************************redirect the guest to a survey***************************/
/***********************************************************************************/
var divId = "";
var isPopunderIncluded = true;
var displayPopunder = true;


function popupNova(genericTest,currentTest){

    var testPagePopunder = "";
    var divImageBackground = "";
    var myStyle = "";
    var noThankYou = "";
    var html= "";
   
    if (genericTest == "myDisneyland") {
        if (currentTest == "joinNow") {
            myStyle =  "width : 180px; height: 30px;  border: 0px; float: left;";
            testPagePopunder = '\n<a href='+urlMyDisneyland+'  alt="Disneyland Paris" title="Disneyland Paris" style="'+myStyle+'"></a>\n';
            divImageBackground = '\n<div id="pop_upRedirect">\n';
            noThankYou = "width : 60px; height: 15px;  border: 0px; float: left;";
            divId= "pop_upRedirect";
        }else if (currentTest == "joinAtEnd"){
            myStyle =  "width : 265px; height: 30px;  border: 0px; float: left;";
            testPagePopunder = '\n<a href="#" onclick= popCenter("'+urlMyDisneyland+'");setCapNova(); alt="Disneyland Paris" title="Disneyland Paris" style="'+myStyle+'"></a>\n';
            divImageBackground = '\n<div id="pop_upUnder">\n';
            noThankYou = "width : 80px; height: 15px;  border: 0px; float: left;";
            divId= "pop_upUnder";
        }
        if (document.getElementById('divPopUnder')) {
           
            //html +="<div id='bodyMask'></div>";
            html += "\n";
            // iframe is constructed in the code for ie6
            html += '<iframe id="iframe" width="330px" height="330px" style="position:absolute;top:30%;left:30%;visibility:hidden;z-index:987;"></iframe>\n';
            html += divImageBackground;
            html += '<div id="closeWindowCross">\n';
            html += '<a href="#" onclick="fermerPopupNova();" alt="Close Window" title="Disneyland Paris" style="border: 0px; float: right; width: 19px; height: 19px;"></a>\n';
            html += '</div>\n';
            html += '<div id="LienCliquezIci">\n';
            html += testPagePopunder;
            html += '</div>\n';
            html += '<div id="closeWindowArea">\n';
            html += '<a href="#" onclick="fermerPopupNova();" alt="Close Window" title="Disneyland Paris" style ="'+noThankYou+'"></a>\n';
            html += '</div>\n';
            html += '</div>\n';
            document.getElementById('divPopUnder').innerHTML = html;
            document.getElementById('maskBody').style.display = "block";
        }
        
    } else if (genericTest == "qualificator") {
        if (currentTest == "joinNow") {
            myStyle =  "width : 110px; height: 30px;  border: 0px; float: left;";
            testPagePopunder = '\n<a href='+urlQualificator+'  alt="Disneyland Paris" title="Disneyland Paris" style="'+myStyle+'"></a>\n';
            divImageBackground = '\n<div id="qualificatorBuzz">\n';            
            divId= "qualificatorBuzz";
        }else if (currentTest == "joinAtEnd"){
            myStyle =  "width : 118px; height: 20px;  border: 0px; float: left;";
            testPagePopunder = '\n<a href="#" onclick= popCenter("'+urlQualificator+'");setCapNova(); alt="Disneyland Paris" title="Disneyland Paris" style="'+myStyle+'"></a>\n';
            divImageBackground = '\n<div id="qualificatorSully">\n';            
            divId= "qualificatorSully";
        }
        if (document.getElementById('divPopUnder')) {
            html += "\n";
            // iframe is constructed in the code for ie6
            html += '<iframe id="iframe" width="330px" height="330px" style="position:absolute;top:30%;left:30%;visibility:hidden;z-index:987;"></iframe>\n';
            html += divImageBackground;
            html += '<div id="closeWindowQualif">\n';
            html += '<a href="#" onclick="fermerPopupNova();" alt="Close Window" title="Disneyland Paris" style="border: 0px; float: right; width: 12px; height: 12px;"></a>\n';
            html += '</div>\n';
            html += '<div id="LienCliquezIci">\n';
            html += testPagePopunder;
            html += '</div>\n';           
            html += '</div>\n';
            document.getElementById('divPopUnder').innerHTML = html;
            document.getElementById('maskBody').style.display = "block";
        }
    }    
}


function fermerPopupNova() {
    document.getElementById(divId).style.display="none";
    // Iframe is for ie6
    document.getElementById("iframe").style.display="none";
    if (document.getElementById('maskBody')) {
        document.getElementById("maskBody").style.display="none";
    }
   

}

// This method constructs a popup whishes displayed behind the main window
function popCenter(page) {
    if (document.getElementById('maskBody')) {
        document.getElementById("maskBody").style.display="none";
    }
    var options = "'status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes'";
    var width = "1000";
    var height = "740";
    var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
    window.open(page,"","top="+top+",scrollbars=yes"+",left="+left+",width="+width+",height="+height+","+options);
    
    if ((window.parent && navigator.userAgent.indexOf('Chrome/') > 0)
        || navigator.userAgent.indexOf('Opera/') > 0) {
        window.parent.blur();
    } else {
        window.focus();
    }



}



// Public function called in Home Page. It gives rules to display or not the popunder (random function)

function Aleatoire(repetition) {
    var x = -1;
    while (x < 0) {
        x = Math.ceil(Math.random() * repetition);
    }
    return x;
}

function getCookiePopUp(NameOfCookie){
    if (document.cookie.length > 0) {
        begin = document.cookie.indexOf(NameOfCookie+"=");
        if (begin != -1) {
            begin += NameOfCookie.length+1;
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
        }
    }
    return null;
}

function setCookiePopUp(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    var path = "/";    
    var splitMyDomain = new Array();
    var splitMyDomainLenght = 0;
    var myDomainToCheck = window.location.host;
    splitMyDomain = myDomainToCheck.split('.')
    splitMyDomainLenght = splitMyDomain.length;
    var tld = splitMyDomain[splitMyDomainLenght-1];
    var domain = ".";
    var end = 0;
    (tld == "uk") ?  end = 4 : end = 3;
    for (var i =0; i<end; i++) {
        if (splitMyDomain[splitMyDomainLenght-i]) {
            domain +=splitMyDomain[splitMyDomainLenght-end+i]+".";
        }
    }
    domain = domain.substring(0,domain.length-1);
    document.cookie = NameOfCookie + "=" + escape(value) +"; path="+path+
    "; domain="+domain+ ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}




function DoTheCookieStuff(name,capping,genericTest,currentTest) {
    if (isPopUpDisplayed()) {
        times_visited=eval(getCookiePopUp(name))+1;
        setCookiePopUp(name,times_visited,1);
        if (times_visited<=capping)    {
            popupNova(genericTest,currentTest);
        }
    }
}

function setCapNova() {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (15 * 24 * 3600 * 1000));
    document.cookie = "apb176dpg" +  "=" + escape(3) + "; expires=" + ExpireDate.toGMTString();
    document.getElementById(divId).style.display="none";
    document.getElementById("iframe").style.display="none";
}


// dontDisplayPopunder is golbal param defined in popunderUrlGlobalVar

function isPopUpDisplayed()  {
    var hote = window.location.host;
    var url = window.location.href;
    var noPopunderHost = hote.indexOf("my-disneyland");
    var displayPopPup = true;
    if (dontDisplayPopunder && dontDisplayPopunder.length > 0) {
        for (var i=0; i<dontDisplayPopunder.length; i++) {
            if (url.indexOf(dontDisplayPopunder[i]) > 0) {
                displayPopPup = false;
            }
        }
    }
    if (noPopunderHost >= 0) {
        displayPopPup = false;
    }
    return  displayPopPup;
}




function displayPopUpUnder(displayNb,random,testRef,genericTest) {
    if (Aleatoire(random ) == 1){
        var cakeName = "";
        (genericTest == "myDisneyland") ?  cakeName = "apb176dpg" : cakeName = "000XFR529";
        DoTheCookieStuff(cakeName,displayNb,genericTest,testRef);

    }
}
/***********************************************************************************/
/**********************               END POP UP UNDER        **************************/
/***********************************************************************************/

/***********************************************************************************/
/**********************               GOOGLE SEARCH 03-2010        **************************/
/***********************************************************************************/


function displayGoogleSearchField() {
    if (isGoogleSearchDisplayed()) {
        var menuContainer = document.getElementById("menuContainer");
        var ul = menuContainer.getElementsByTagName("ul");
        var html = "<form onsubmit='return submitQueryGsc()' action='' class='gsc-submit-form'>"
        +"<input name='q'  id='query-input' onfocus='inputFocusGcs();' class='gsc-search-field'"
        +"onblur='inputBlurGcs();' autocomplete='off'></input>"
        +"<button type='submit'  class='gsc-search-button'><div class='gsc-search-button-div'>"+searchGoogleItemString+"</div></button>"
        +"</form>";
        ul[ul.length-1].innerHTML = html;
        if ($$('table.gcsc-branding')) {
            $$('table.gcsc-branding').each(function(elmt, i) { 
                elmt.hide();
            });                    
        }
    }
}


function inputFocusGcs() {
    document.getElementById('query-input').style['background'] = '';
}

function inputBlurGcs() {
    var queryInput = document.getElementById('query-input');
    if (!queryInput.value) {
        queryInput.style['background'] = '';
    } else {
        if ($$('table.gcsc-branding')) {
            $$('table.gcsc-branding').each(function(elmt, i) { 
                elmt.hide();
            });                    
        }

    }
}

function initGsc() {
    google.search.CustomSearchControl.attachAutoCompletion(
        gcsId,
        document.getElementById('query-input'),
        'two-page-form');
    inputBlurGcs();
}

function submitQueryGsc() {
    window.location = linkToSearchPage+'?q='
    + encodeURIComponent(
        document.getElementById('query-input').value);
    return false;
}

function isGoogleSearchDisplayed()  {
    var subDomain = window.location.href;
    var myDisneyland = subDomain.indexOf("my-disneyland");
    var brochure = subDomain.indexOf("brochure");
    var brochure_de = subDomain.indexOf("broschuere");
    var brochure_se = subDomain.indexOf("begar-en-e-broschyr");
    var brochure_it = subDomain.indexOf("catalogo");
    var brochure_es = subDomain.indexOf("folleto");
    var brochure_dk = subDomain.indexOf("brochurebestilling");
    var displayGoogle = true;
    if (myDisneyland != -1 || brochure != -1 || brochure_de != -1 || brochure_se != -1 || brochure_it != -1 || brochure_es != -1 || brochure_dk != -1) {
        displayGoogle = false;
    }
    return  displayGoogle;
}


/**********************               SPECIAL OFFERS        **************************/
/******These methods enable to display one or two offers in the bottom frame***********/
/***********************************************************************************/


function displayOneOrTwoOffers(){

    var imgBgOffer2 = document.getElementById("imageBgBottomMiddle");
    var imgBgOffer3 = document.getElementById("imageBgBottomRight");    
    
    var offer2 = imgBgOffer2.style.backgroundImage;
    var offer3 = imgBgOffer3.style.backgroundImage;

    var returnOffer2 = offer2.indexOf("Background2");
    var returnOffer3 = offer3.indexOf("Background3"); 

    var caseTwoOffers = false;
    var caseOneOffer = false;
    
    if (returnOffer3 != -1) {
        caseTwoOffers = true;
        if (returnOffer2 != -1) {
            caseOneOffer = true;
        }
    }

    /* In that case, there is only one offer proposed to the guest */

    if (caseOneOffer) {

        /* NEW DOM CONSTRUCTION */

        /* delete the offers 2 and 3 frames, we keep only the first frame wihch contents the first offer*/
        imgBgOffer3.parentNode.removeChild(imgBgOffer3);
        imgBgOffer2.parentNode.removeChild(imgBgOffer2);

        /*  reverse order of div to make css construction easier */

        var node = document.getElementById('imageBgBottomLeft');
        var newNode = document.getElementById("imageBgLeft");
        node.insertBefore(newNode,node.firstChild);

        /* adding new parent div in the DOM code to surround  the div children
         * The new div id is 'dynamicStyleDom' */

        var divs = node.getElementsByTagName("div");
        var getCssId = new Array();
        var getHtml = new Array();

        for (var i = 1; i<divs.length; i++) {
            getCssId[i]=divs.item(i).id;
            getHtml[i]=divs.item(i).innerHTML;            
        }
        var div = document.createElement("div");
        div.id = "dynamicStyleDom";
        newNode.parentNode.insertBefore(div,newNode.nextSibling);
       

        for (var j = 1; j<getCssId.length; j++) {         
            document.getElementById(getCssId[j]).parentNode.removeChild(document.getElementById(getCssId[j]));
            divHtml = document.createElement("div");          
            divHtml.id= getCssId[j];
            divHtml.innerHTML= getHtml[j];           
            document.getElementById("dynamicStyleDom").appendChild(divHtml);          
        }      

        /* Now we set new attribute id name to the div children of the parent node.
         *  The  CSS properties are defined in the CSS code with the right properties name */

        var dynDiv = document.getElementById("QuickBookingBgBottom").getElementsByTagName("div");
        dynDiv.item(0).setAttribute("id", "dynamicStyleDomContent");
        dynDiv.item(1).setAttribute("id", "dynamicStyleDomImage");
        dynDiv.item(3).setAttribute("id", "dynamicStyleDomTitle");
        dynDiv.item(5).setAttribute("id", "dynamicStyleDomButton");
        dynDiv.item(6).firstChild.setAttribute("id", "dynamicStyleDomButtonText");   
    }
    /* In that case, there are two offers proposed to the guest */
    
    else if (caseTwoOffers) {

        imgBgOffer3.parentNode.removeChild(imgBgOffer3);

        var imageBgBottomLeft = document.getElementById("imageBgBottomLeft").style;
        var imageBgBottomMiddle = document.getElementById("imageBgBottomMiddle");
        var textBgBottomLeftRight = document.getElementById("textBgBottomLeftRight").style;
        var textBgBottomMiddle = document.getElementById("textBgBottomMiddle").style;
        var button = document.getElementById("buttonBackGroundQuickBook").style;
        var buttonTxt = document.getElementById("buttonBackGroundQuickBookText").firstChild.style;
       

        var imageArray = imageBgBottomMiddle.getElementsByTagName("div");
        imageArray.item(3).setAttribute("id", "dynamicStyleDomButtonTwoOffers");
        imageArray.item(4).setAttribute("id", "dynamicStyleDomTextTwoOffers");

        var DynButton = document.getElementById("dynamicStyleDomButtonTwoOffers").style;
        var DynButtonTxt = document.getElementById("dynamicStyleDomTextTwoOffers").firstChild.style;

        imageBgBottomLeft.width="319px";
        imageBgBottomMiddle.style.width="318px";
        textBgBottomLeftRight.marginLeft="52px";        
        textBgBottomMiddle.marginLeft="60px";
        textBgBottomMiddle.width="219px";
      
        buttonTxt.marginLeft="85px";
        button.marginLeft="80px";
        DynButtonTxt.marginLeft="85px";
        DynButton.marginLeft="80px";

        if (msieVersion()==6) {
            textBgBottomLeftRight.marginLeft="30px";
            textBgBottomMiddle.marginLeft="30px";
            buttonTxt.marginLeft="80px";
            button.marginLeft="40px";
            DynButtonTxt.marginLeft="80px";
            DynButton.marginLeft="40px";

        } 
    }
}



/**********************        END       SPECIAL OFFERS        **************************/
/******These methods enable to display one or two offers in the bottom frame***********/
/***********************************************************************************/


/**********************              POPUP IFRAME                 **************************/
/******These methods enable to display one or two offers in the bottom frame***********/
/***********************************************************************************/

function displayRedirectDiv(iframes) {
    if (iframes) {
        $('iframePoupupBackground').style.display = 'block';
        $('containerIframe').style.display = 'block';
        $('frameId').src = iframes;
    }
}
            
function iframeClose() {
    $('iframePoupupBackground').style.display = "none";
    $('containerIframe').style.display = 'none';
}

function retrieveIframe() {   
    if ($('iframePoupupBackground')) {
        Event.observe($('iframePoupupBackground'), 'click', function() {
            $('iframePoupupBackground').style.display = "none";
            $('containerIframe').style.display = 'none';
        })
    }
}


/**********************         END POPUP IFRAME           *************************/




/**********************           CHANGE WEBSITE SELECT        **************************/
/******These methods enable to display a select menu in the footer for changing website********/
/***********************************************************************************/



function changeHttpValue(httpValue) {
    var i = httpValue.selectedIndex;
    if(i > 0)     {                  
        window.open(httpValue.options[i].value,'External','');
    }
}            
function changeSite() {               
    Event.observe($('changeSite'),'change',function(){
        changeHttpValue(this);
    });               
}
/*************************************************************
*METHODS ENABLE TO APPLY RULES OF PRESENTATION TO THE HEADER** 
****************AND THE MENU ABOVE****************************
************Code by EOS -- JANUARY 2010 --********************
**************************************************************/

/* The both methods below enables to apply rules of presentation to the header.
If the my disneyland si not linked, the method moveLayerWithoutLink is called , else the
method moveLayerWithLink is called by the public method moveDownLayer */

// Private

function moveLayerWithLink() {
    var menuHeader = document.getElementById("menuHeader");
    var roundFrame = document.getElementById("menuRoundFrame");
    var menuInsideHeader = document.getElementById("menuInsideHeader");
    var menuHeaderLink = document.getElementById("menuHeaderLink").offsetWidth;
    var frameWidth = roundFrame.offsetWidth;
    var menuHeaderWidth = menuHeader.offsetWidth;    
    var widthMenuInsideHeader = menuHeaderWidth- (menuHeaderLink+ frameWidth+ 30);
    var menuInsideHeaderUl = new Array()
    menuInsideHeaderUl = menuInsideHeader.getElementsByTagName("ul");
    menuInsideHeader.style.width=widthMenuInsideHeader+"px";
    var menuHeaderHeight = menuInsideHeader.offsetHeight;    
    if (menuHeaderHeight > 31) {
        for (var i=0; i<menuInsideHeaderUl.length; i++) {
            menuInsideHeaderUl[i].style.height="22px";
        }
        menuInsideHeader.style.width=(widthMenuInsideHeader-20)+"px";
        menuInsideHeader.style.marginTop="20px";
        menuInsideHeader.style.marginLeft="30px";
    }
    menuHeader.style.visibility="visible";
}
// Private

function moveLayerWithoutLink() {
    var menuHeader = document.getElementById("menuHeader");
    var menuInsideHeader = document.getElementById("menuInsideHeader");
    menuInsideHeader.style.width="600px";
    menuInsideHeader.style.height="10px";
    var menuInsideHeaderli = new Array();
    menuInsideHeaderli = menuInsideHeader.getElementsByTagName("li");
    for (var i = 0; i<menuInsideHeaderli.length; i++) {
        menuInsideHeaderli[i].style.cssFloat="left";
        menuInsideHeaderli[i].style.width="auto";
    }
    menuHeader.style.visibility="visible";
}

// Public

function moveDownLayer() {
    if (document.getElementById("menuRoundFrame") != null) {
        moveLayerWithLink();
    } else {
        moveLayerWithoutLink();
    }
}

// This method enables to make distinction between Internet Explorer Versions - Private

function msieVersion() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf ( "MSIE " );
    if ( msie > 0 ) {
        return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
    }
    else {
        return 0;
    }
}

// This method applies specific presentation rules to the rollover menu
// If the text of the menu is longer than the box, the menu is affected by
// a sepific styleSheet which allows to display the menu on two lines
// - Public


function displayTwoLines() {
    var menu = document.getElementById("menuContainer");
    var menuUl = menu.getElementsByTagName("ul");
    var menuUlFirstLevel = new Array();
    var i = 0;
    var j = 0;
    var z = 0;
    var navigateur = navigator.appName;
    
    var ie = "Microsoft Internet Explorer";
    var menuLi = menu.getElementsByTagName("li");
    var menuStyle = new Array();
    var menuLength = new Array();
    var stringData = new Array();
    var arrayString = new Array();
    var nbreEspace = new Array();
    var stringDataLi = new Array();
    var lineHeihtToLine = new Array();

    // Test IE & OPERA
    if (msieVersion() > 6 || navigateur=="Opera" || navigator.platform=="MacPPC") {
        document.getElementById("blueLine").style.marginTop="-1px";
        document.getElementById("imageRightMenu").style.marginTop="-16px";
    }
    //alert("menuLi.length "+menuLi.length);
    for (i =0; i<menuUl.length; i+=2) {
        menuUlFirstLevel[j++]=menuUl[i];
    }
    
    for (i=0; i<menuLi.length; i++) {
        stringDataLi[i] = menuLi[i].firstChild.firstChild.data;
    }
    
    for (i = 0; i<menuUlFirstLevel.length; i++) {
         
        if (navigateur == ie && msieVersion()<9) {          
            stringDataLi.splice(stringDataLi.indexOf(menuUlFirstLevel[i].firstChild.firstChild.firstChild.data),1);
        }
        else {
            stringDataLi.splice(stringDataLi.indexOf(menuUlFirstLevel[i].childNodes[1].firstChild.firstChild.textContent),1);
        }

    }

    for (i = 0; i<stringDataLi.length; i++) {
        if (stringDataLi[i].length>29) {
            lineHeihtToLine[z++]=stringDataLi[i];
        }
    }

    for (i=0; i<menuLi.length; i++) {
        for (var y=0; y<lineHeihtToLine.length; y++) {
            if (lineHeihtToLine[y]==menuLi[i].firstChild.firstChild.data) {
                menuLi[i].firstChild.style.lineHeight="18px";
                menuLi[i].firstChild.style.height="35px";
            }
        }
    }

    for (y=0; y<menuUlFirstLevel.length;y++) {

        if (navigateur == ie ) {
            menuStyle[y] = (msieVersion() < 9) ? menuUlFirstLevel[y].firstChild.firstChild.style : menuUlFirstLevel[y].childNodes[1].firstChild.style;
            stringData = (msieVersion() < 9) ? trim(menuUlFirstLevel[y].firstChild.firstChild.firstChild.data) : trim(menuUlFirstLevel[y].childNodes[1].firstChild.firstChild.data);
            
            menuLength[y] = (stringData.length)*6;
            arrayString = stringData.split(" ");
            nbreEspace = arrayString.length-1;
            if ((menuLength[y]>102 && menuLength[y]<109) || (menuLength[y]>105 && menuLength[y]<187 && nbreEspace>3)) {
                 menuStyle[y].letterSpacing="0.05em";
            }
            if( menuLength[y]>102) {
                menuStyle[y].lineHeight="14px";
                if (msieVersion() == 6 ) {
                    menuStyle[y].backgroundPosition="0em -0.118em";
                    menuStyle[y].marginTop="4px";
                } else {
                    menuStyle[y].backgroundPosition="-0.45em -0.3em";
                    if (msieVersion() == 9) {
                        menuStyle[y].marginTop="2px";
                    }
                }
            }
        }else {
            menuStyle[y] = menuUlFirstLevel[y].childNodes[1].firstChild.style;
            stringData = trim(menuUlFirstLevel[y].childNodes[1].firstChild.firstChild.textContent);
            menuLength[y] = (stringData.length)*6;
            arrayString = stringData.split(" ");
            nbreEspace = arrayString.length-1;
            var goTo = false;
            if (nbreEspace>2 && menuLength[y]==96) {
                menuStyle[y].lineHeight="14px";
                goTo = true;
            }
            else if (menuLength[y]>=108 && goTo == false) {
                menuStyle[y].lineHeight="14px";
                if (menuLength[y]<=112) {
                    menuStyle[y].letterSpacing="1pt";
                }
            }
        }
    }
}

// Fix indexOf in IE
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
        for (var i = (start || 0), j = this.length; i < j; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}


function trim (myString) {
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}


/* This method enables to display the login/logout system depending
of the identification mode of the guest - Public */

function displayLoginLogout(){
    var menuInsideHeaderRight = document.getElementById("menuInsideHeaderRight");
    var navBarLi = menuInsideHeaderRight.getElementsByTagName("li");
    if (Get_Cookie( 'LOGIN' )) {
        navBarLi[2].style.display="block";
        navBarLi[1].style.display="none";
    }
    else {
        navBarLi[1].style.display="block";
        navBarLi[2].style.display="none";
    }
}

// This method enables to highlight rollover menu depending where the guest is
// connected - Public

function highLightLink(menuHeaderSelected) {
    var backgroundUrlQa="url(http://qa-visiter-fr.emea.wdpr.disney.com/UK/EN/Neutral/Images/107x28-backBlueMenu.jpg)";
    var backgroundUrlProd="url(http://www.disneylandparis.co.uk/UK/EN/Neutral/Images/107x28-backBlueMenu.jpg)";
    var menu = document.getElementById("menuContainer");
    var menuUl = new Array();
    menuUl = menu.getElementsByTagName("ul");
    var menuUlFirstLevel = new Array();
    var j = 0;
    var i =0;
    var ApplyToMenu = "";
    var navigateur = navigator.appName; 
    if(menuHeaderSelected == '8'){
        var MenuImageRightSrc = document.MenuImageRight.src;
        MenuImageRightSrc = MenuImageRightSrc.replace(".jpg", "Select.jpg");
        document.MenuImageRight.src = MenuImageRightSrc;
    }
    else{               
        for (i =0; i<menuUl.length; i+=2) {
            menuUlFirstLevel[j++]=menuUl[i];
        }
        ApplyToMenu =  menuUlFirstLevel[menuHeaderSelected].firstChild.firstChild || menuUlFirstLevel[menuHeaderSelected].childNodes[1].firstChild;
        with(ApplyToMenu.style) {
            background = backgroundUrlProd;
            backgroundRepeat="no-repeat";
            backgroundPosition="center";
            color="#fff";
            }
        
        if (navigateur == "Microsoft Internet Explorer" ) {      
            with(ApplyToMenu.style) {               
                if (msieVersion() > 6) {
                    width="107px";
                    marginLeft="-1px";
                    marginTop="0px";
                    //marginTop="-1px";
                    menu.style.height = "30px";
                   
                }
                }
            if (ApplyToMenu.style.lineHeight == "14px"){
                ApplyToMenu.style.marginTop="2px";
                if (msieVersion() > 6) {
                    ApplyToMenu.style.marginTop="1px";
                } else {
                    ApplyToMenu.style.marginTop="2px";
                }
            }
        }
        else {            
            with(ApplyToMenu.style) {                
                width="106px";
                marginLeft="0px";               
                if (ApplyToMenu.style.lineHeight == "14px"){
                    marginTop="1px";
                }
                }
            if (navigateur == "Opera") {
                ApplyToMenu.style.backgroundPosition="50% -0.03em";
            }
        }
    }
}

/*************************************************************
*METHODS ENABLE TO APPLY RULES OF PRESENTATION TO THE HEADER** 
****************AND THE MENU ABOVE****************************
***************ROLLOVER ON MYDISNEYLAND**********************
************Code by EOS -- JUNE 2010 --********************
**************************************************************/
function getMenuRoundFrameWidth() {
    var Middle = document.getElementById("menuRoundFrameMiddle").offsetWidth;
    var Left = document.getElementById("menuRoundFrameLeft").offsetWidth;
    var Right = document.getElementById("menuRoundFrameRight").offsetWidth;
    var width = Middle+Left+Right;
    return width;
}

function diplayOffers() {
    var menuRoundFrame = document.getElementById('menuRoundFrame');
    P_addListener(menuRoundFrame, 'mouseover', offersBlock);
}

function hideOffers (){
    var menuRoundFrame = document.getElementById('menuRoundFrame');
    P_addListener(menuRoundFrame, 'mouseout', offersNone);
}

function offersBlock () {
    var imageSize = 400;
    var rolloverOffers = document.getElementById('rolloverOffers');
    var displayLine = document.getElementById('displayLine');
    if (getMenuRoundFrameWidth()<imageSize) {
        rolloverOffers.style.width = imageSize+"px";
        rolloverOffers.style.marginLeft = (getMenuRoundFrameWidth()-imageSize)+"px";
        if (msieVersion() == 6) {
            rolloverOffers.style.marginLeft = "-"+imageSize+"px";
        }
    } else {
        rolloverOffers.style.width = getMenuRoundFrameWidth()+"px";
        displayLine.style.marginLeft = (getMenuRoundFrameWidth()-imageSize)+"px";
        if (msieVersion() == 6) {
            displayLine.style.marginLeft = ((getMenuRoundFrameWidth()-imageSize)/2)+"px";
            rolloverOffers.style.marginLeft = "-"+getMenuRoundFrameWidth()+"px";
        }
    }
    rolloverOffers.style.display='block';
}

function offersNone (){
    var rolloverOffers = document.getElementById('rolloverOffers');
    rolloverOffers.style.display='none';
}

/****************END ROLLOVER****************************/

