/* Wikispaces http://wikispaces.com/ Copyright 2005 Tangient LLC */ function display(id, ieattr, mozattr) { var b = document.getElementById(id); if (!b) return false; if (b.style.display == "none" || b.style.display == "") { if (navigator.userAgent.toLowerCase().indexOf('msie') + 1) { b.style.display = ieattr; } else { b.style.display = mozattr; } } else { b.style.display = "none"; } } function opts() { o1 = document.getElementById('os1'); display('submenu1', 'inline', 'inline'); display('pagemenu_bottom', 'block', 'block'); if (o1.innerHTML.indexOf('details')) { o1.innerHTML = "details >>"; } else { o1.innerHTML = ""; } return false; } function pop(url, w, h) { id = Math.floor(Math.random() * 10000); eval("pop_" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + w + ',height=' + h);"); } function dtoh(d) { var s = "0123456789ABCDEF"; var l = d % 16; var h = (d - l)/16; return "" + s.charAt(h) + s.charAt(l); } function htod(h) { return parseInt(h,16); } function fade(id, i) { if (!i) { i = 0; } if (typeof id == 'string') e = document.getElementById(id); else e = id; var c = 171 + (i * 7); if (c <= 255) { e.style.background = "#FFFF" + dtoh(c); setTimeout(function () {fade(id, ++i);}, 200); } } function settext (id, s) { if (o = document.getElementById(id)) o.innerHTML = s; } function focus(elementId) { var element = document.getElementById(elementId); element.focus(); } function dynamicLoadJavascript(src) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = src; document.getElementsByTagName('head')[0].appendChild(script); } function dynamicLoadCss(src) { var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = src; document.getElementsByTagName('head')[0].appendChild(link); } function Map() { this.map = new Object(); // Map API this.add = function(k,o){ this.map[k] = o; } this.remove = function( k ){ delete this.map[k]; } this.get = function( k ){ return k==null ? null : this.map[k]; } this.first = function( ){ return this.get( this.nextKey( ) ); } this.next = function( k ){ return this.get( this.nextKey(k) ); } this.nextKey = function( k ){ for (i in this.map) { if (!k) return i; if (k==i) k=null; /*tricky*/ } return null; } } var NEXT_CMD_ID = 0; function Mutex( cmdObject, methodName ) { // define static variable and method if (!Mutex.Wait) Mutex.Wait = new Map(); Mutex.SLICE = function( cmdID, startID ) { Mutex.Wait.get(cmdID).attempt( Mutex.Wait.get(startID) ); } // define instance method this.attempt = function( start ) { for (var j=start; j; j=Mutex.Wait.next(j.c.id)) { if (j.enter || (j.number && (j.number < this.number || (j.number == this.number && j.c.id < this.c.id) ) ) ) return setTimeout("Mutex.SLICE("+this.c.id+","+j.c.id+")",10); } this.c[ this.methodID ](); //run with exclusive access this.number = 0; //release exclusive access Mutex.Wait.remove( this.c.id ); } // constructor logic this.c = cmdObject; this.methodID = methodName; Mutex.Wait.add( this.c.id, this ); //enter and number are "false" this.enter = true; this.number = (new Date()).getTime(); this.enter = false; this.attempt( Mutex.Wait.first() ); }