// IOTBS2.1 :: Invasion of the Body Switchers - Look Who's Switching Too // >>> Core functions for all versions // *********************************************** // This copyright statement must remain in place for both personal and commercial use // GNU General Public License -- http://www.gnu.org/copyleft/gpl.html // *********************************************** // Original concept by Andy Clarke -- http://www.stuffandnonsense.co.uk/ // DOM scripting by brothercake -- http://www.brothercake.com/ // Create element and attributes based on a method by beetle -- http://www.peterbailey.net/ // Modifications made to allow images using CSS by Scott Martin on behalf of Solihull Council //************************************************ var switcher; function switchManager(canvas, path){ switcher = this; this.canvas = canvas == 'body' && typeof document.body != 'undefined' ? document.body : document.getElementsByTagName(canvas)[0]; this.initial = this.canvas.className; if(this.initial == ''){this.initial = 'itobs'; }this.path = (typeof path != 'undefined' && path != '' ? path : null); this.itoken = /(\:\[[0-9]+\])/; if(this.path != null){this.tokenrefs = ['', -1]; this.linkeles = document.getElementsByTagName('link'); }this.master = null; this.string = ''; this.idstring = ''; this.isop = typeof window.opera != 'undefined'; this.isie = typeof window.attachEvent != 'undefined' && !this.isop; this.iskde = navigator.vendor == 'KDE'; this.cookie = this.read(); if(this.cookie != null){this.string = this.cookie; if(this.path == null){this.canvas.className = this.initial + this.string; }for(var i=0; i 1){if(this.path != null && this.itoken.test(this.cookie[i][1])){this.tokenrefs = [this.cookie[i][0],parseInt(this.cookie[i][1].split(':[')[1], 10)]; }this.cookie[i][1] = this.cookie[i][1].replace(this.itoken, ''); tmp += ' ' + this.cookie[i][1] + ' '; this.idcookie[i] = this.cookie[i]; }}this.cookie = tmp; }return this.cookie;}; switchManager.prototype.save = function(ident, chosen, ind, obj){this.ident = ident; this.idstring = this.idstring.replace(this.ident + '=', ''); var len = obj.classes.length; for(var i=0; i < len; i++){this.string = this.string.replace(' ' + obj.classes[i] + ' ',''); var reg = new RegExp('(' + obj.classes[i] + ')' + '(\:\[[0-9]+\])?' + '&', ''); this.idstring = this.idstring.replace(reg,''); }if(chosen != 'default'){this.string += ' ' + chosen + ' '; this.idstring += this.ident + '=' + chosen; if(this.master == obj){this.idstring += ':[' + ind + ']';}this.idstring += '&';}if(this.path != null){if(this.master != obj){var linkele = document.getElementById(this.ident + '-stylesheet'); //alert('linkele1 '+linkele); if(linkele != null){var sheetpath = this.path + /*this.ident*/ 'screen-switcher' + '-' + chosen + '.css'; //alert('this.ident '+ this.ident+' chosen '+chosen+' sheetpath '+sheetpath); if(this.isop){setTimeout(function() { linkele.href = sheetpath; }, 10); }if(this.isie){var request = new ActiveXObject('Microsoft.XMLHTTP'); request.onreadystatechange = function(){if(request.readyState == 4 && /(200|304)/.test(request.status.toString())){linkele.href = ''; linkele.href = sheetpath; }}; request.open('GET', sheetpath, true); request.send(null); }linkele.href = sheetpath; }}else{len = this.alternates.length; for(i=0; i 0 && this.linkeles[i - 1] == this.alternates[0]){inscope = true;} if(inscope) {if(this.linkeles[i].getAttribute('title') != null && this.linkeles[i].getAttribute('rel') != null && /(alternat)(iv)?(e stylesheet)/i.test(this.linkeles[i].rel)){this.alternates[this.alternates.length] = this.linkeles[i]; }else{inscope = false;break; }}}var isenabled = 0; var watcher = window.setInterval(function(){var len = switcher.alternates.length; for(var i=0; i