//Create a global object to hook things onto so that they don't interfere with local variables var SiteBase = { SharedFunctions: { "DOMReady": function() { //Set up the menu this.SetupMenu(); //This function is called on every page when the DOM is ready //Style buttons with jQuery $('input[type=submit],input[type=button],input[type=reset],button').not(".nostyle").removeClass('ui-button-default').button(); //Toggle the JS powerbar $('#body div.powerbar').toggle(); //Set up the language switch $('#master_ddllangjs').change(function() { SiteBase.SharedFunctions.ChangeLanguage($('#master_ddllangjs').val()); }); //Set up the fonts this.FontControl.Initialize(); } //End DOMReady ,"SetupMenu":function() { //Hide the menu items var $menuItems = $('#menu div.submenu'); $menuItems.not('.openeditem').hide(); //Set icon properly $menuItems.filter('.openeditem').prev('a.menuitem[data-expandable=true]').find('div.menuicon').data('open', 2).css('backgroundPosition', '-96px 0'); //Add expandable menu item code $('#menu a.menuitem[data-expandable=true]').click(function(e) { // Animate Icon var $icon = $(this).find('div.menuicon'); var dopen = $icon.data('open'); if ((dopen == undefined || dopen == '' || dopen === 1) && dopen !== 0) { //Open $icon.data('open', 0) var pos = 0; var intid; intid = setInterval(function() { if (pos > -96) { pos -= 16; $icon.css('backgroundPosition', pos + 'px 0') } else { $icon.data('open', 2); clearInterval(intid); } }, 50); $menuitem = $(this).next(); if ($menuitem.is('.submenu')) { $menuitem.slideDown(); } } else if ((dopen === 2) && dopen !== 0) { //Close $icon.data('open', 0) var pos = -96; var intid; intid = setInterval(function() { if (pos < 0) { pos += 16; $icon.css('backgroundPosition', pos + 'px 0') } else { $icon.data('open', 1); clearInterval(intid); } }, 50); $menuitem = $(this).next(); if ($menuitem.is('.submenu')) { $menuitem.slideUp(); } } e.preventDefault(); }) .mousedown(function() { return false; }); //return false on Mousedown prevents from highlighting the text } //End SetupMenu ,"FontControl": { "Initialize": function() { //Figure out the font size and attach click events to the font size links var fontsize = parseInt($('#body').css('font-size').replace('px','')); var $content = $('#body'); if (isNaN(fontsize)) { fontsize = 13; } $('#fontlarger').click(function(e) { if (fontsize < 21) { fontsize += 2; SiteBase.SharedFunctions.FontControl.SetCookie(fontsize); $content.css('font-size', fontsize + 'px'); } e.preventDefault(); }) .mousedown(function() { return false; }); //return false on Mousedown prevents from highlighting the text $('#fontsmaller').click(function(e) { if (fontsize > 13) { fontsize -= 2; SiteBase.SharedFunctions.FontControl.SetCookie(fontsize); $content.css('font-size', fontsize + 'px'); } e.preventDefault(); }) .mousedown(function() { return false; }); //return false on Mousedown prevents from highlighting the text SiteBase.SharedFunctions.FontControl.CheckFont(); }, //End Initialize "CheckFont": function() { if (document.cookie.length > 0) { //Check that cookies exists c_start = document.cookie.indexOf("FontSize="); //Check for the font size cookie if (c_start != -1) { //Make sure it's there c_start += 9; //Add the length of "FontSize=" to the start c_end = document.cookie.indexOf(";",c_start); //Find the end of the cookie value if (c_end == -1) { c_end = document.cookie.length; } //Check if it's the end of the cookie string var size = unescape(document.cookie.substring(c_start,c_end)); //Get the size if (size && !isNaN(size)) { //Check the size $('#body').css('font-size', size + 'px'); //Set the size of the central content. } } } }, "SetCookie": function(fontsize) { /*This function sets the FontSize cookie*/ var exdate = new Date(); exdate.setTime(exdate.getTime() + (10 * 365 * 24 * 60 * 60 * 1000)); document.cookie="FontSize=" + escape(fontsize) + "; expires=" + exdate.toGMTString() + "; path=/"; } }, //End FontControl "ChangeLanguage":function(langid) { if (confirm('This will refresh the page and any unsaved changes will be lost. Are you sure that you want to continue?\n\nCeci va rafraichir la page et toutes information modifiées et non sauvegardées seront perdus. Etes-vous sur de vouloir continuer?')) { var exdate = new Date(); exdate.setTime(exdate.getTime() + (10 * 365 * 24 * 60 * 60 * 1000)); document.cookie = "lang=" + escape(langid) + "; expires=" + exdate.toGMTString() + "; path=/"; var path = window.location.href; if (path.indexOf('?') > -1) { if (path.indexOf('lang=') > -1) { path = path.replace(/lang=[0-9]/gi, 'lang=' + encodeURIComponent(langid)); } else { path = path + '&lang=' + encodeURIComponent(langid); } } else { path = path + '?lang=' + encodeURIComponent(langid); } window.location = path; } else { $('#master_ddllang > option').each(function(i, elem) { if (elem.value == langid) { $(this).parent().selectedIndex = i; } }); } }, //End ChangeLanguage "ShowMsgBox":function(msg, title, modal, callback, buttons, style) { title = title || ''; modal = modal || false; callback = callback || function() { $(this).remove(); }; buttons = buttons || null; style = style || ""; return $("
").attr('style',style).dialog({ "title":title, "height":"auto", "resizable":false, "draggable":false, "modal":modal, "close":callback, "show":"fold", "buttons":buttons }).html(msg); } } //End SharedFunctions }; //End SiteBase $(function() { SiteBase.SharedFunctions.DOMReady(); $("a.helplink").mouseover(function(e){ HelpPopUp($(this).get(0),$(this).data("tag"),$(this).data("title"),$(this).data("desc"),e); }); });