(function() {
'DEVELOPED BY ANGE TUTEUR';
'NO DISTRIBUTION WITHOUT CONSENT OF THE AUTHOR';
'ORIGIN : http://fmdesign.forumotion.com/t444-night-mode#3675';
if (/msie/i.test(window.navigator.userAgent)) return; // browser exclusion
if (!window.fa_night_mode && typeof document.getElementsByTagName('HEAD')[0].style.pointerEvents === 'string') {
window.fa_night_mode = {
targets : ['page-footer', 'pun-foot', 'ipbwrapper'], // target node that the dimmer will be attached to
// executed when the dimmer is changed
dimLight : function() {
var val = +fa_night_mode.dimmer.value;
fa_night_mode.shade.style.backgroundColor = 'rgba(0, 0, 0, ' + val / 100 + ')';
fa_night_mode.counter.innerHTML = ( val / 90 * 100 ).toFixed() + '%';
my_setcookie('fa_night_level', val);
}
};
// startup variables
var dimmer = document.createElement('INPUT'),
container = document.createElement('DIV'),
counter = document.createElement('SPAN'),
cookie = my_getcookie('fa_night_level'); // cookies <3
// cache nodes to the global object
fa_night_mode.dimmer = dimmer;
fa_night_mode.counter = counter;
// stuff to do when the document is ready
$(function() {
// find one ( AND ONLY ONE ) of the targets to attach the dimmer
for (var i = 0, j = fa_night_mode.targets.length, footer; i < j; i++) {
footer = document.getElementById(fa_night_mode.targets[i]);
if (footer) {
footer.appendChild(container);
break;
}
}
if (!footer) {
document.body.appendChild(container); // fallback if footer cannot be found
}
});
}
}());