// Message en fonction du browser function detectIE() { if ($.browser["msie"]) { $('head').append(''); } } // --- code popup --- function openWide() { $(this).clone(false).appendTo($("#_code")); $('#_code a').css({"margin-right":"3em"}); $("#_code").show(); } function returnToNormal() { $("#_code").html(""); $("#_code").hide(); } function initCode() { $(".code").click(openWide); $(".code").css({cursor: "pointer"}); $('body').append('
'); $('#_code').css( { 'font-size':$('.corps:first').css('font-size'), 'text-align': "justify", position: "fixed", left:0, top:0, width: "100%", height: "100%", "background-color": "rgba(0, 0, 0, 0.8)", 'z-index':2000, 'padding':'3px'} ); $('#_code').hide(); $('#_code').click(returnToNormal); } // --- end of code popup section --- // -- multilanguage handling -- // show a message to user function message(msg) { $('#blackpage').css({cursor: 'auto'}); $('#blackpage').show().html(msg); } // from cookie first if not, from Navigator function getUserLanguage() { var language = $.cookie('language'); if (! language) { if ( (navigator) && (navigator.language) && (navigator.language.substring(0,2) == 'fr' ) ) { language='fr'; } else { language='en'; } } return language; } // return the path of the equivalent page in another language function pathToLanguage(lang) { return window.location.pathname.replace(/(.*\/Scratch\/)(..)(\/.*$)/,'$1'+lang+'$3'); } // return the link to the equivalent page in another language function linkToLang(lang, msg) { return ''+msg+''; } // return a link that will hide the message function hideClickMessage(msg) { return ''; } // put the selected language in the cookie function setLanguage(lang) { $.cookie('language',lang, { path: '/Scratch'}); } // select the good language and hide the message function hideMessage() { setLanguage(getPageLanguage()); $('#blackpage').fadeOut(); } // get the language of the current page function getPageLanguage() { var lang=window.location.pathname.replace(/.*\/Scratch\/(..).*$/,'$1'); if ( lang == window.location.pathname ) { return ""; } else { return lang; } } // alert the user if its navigator configuration tell // me it should prefer another language function alertLanguage() { var language=getUserLanguage(); var language_of_current_page=getPageLanguage(); if ( language_of_current_page == "" ) { return true; } if (language != language_of_current_page) { if ( language == 'fr' ) { message(linkToLang('fr','Aller sur la Version Française ?') + hideClickMessage('No thanks, I prefer read english.')); } else if (language == 'en') { message(linkToLang('en','Go to English Version?')+ hideClickMessage('Non merci, je préfère le français.')); } else { // don't know which language the user prefer message(linkToLang('en','Go to English Version?')+'