// from http://www.kryogenix.org // by Scott Andrew - http://scottandrew.com // add an eventlistener to browsers that can do it somehow. function addEvent(obj, evType, fn) { if (obj.addEventListener) { obj.addEventListener(evType, fn, false); return true; } else if (obj.attachEvent) { var r = obj.attachEvent('on'+evType, fn); return r; } else { return false; } } function floatImages() { // adapted from http://www.dithered.com/javascript/browser_detect/ //**************************************************************// // sniff user agent var userAgent = navigator.userAgent.toLowerCase(); // if Mozilla 1.4 then quit if ((userAgent.indexOf('gecko') != -1) && (userAgent.indexOf('gecko/') + 14 == userAgent.length) && (parseFloat(userAgent.substring(userAgent.indexOf('rv:') + 3)) == '1.4')) return; // if Opera then quit if (document.all && window.Event) return; //**************************************************************// // check this browser can cope with what we want to do if (!document.getElementById) return; var blogDiv = document.getElementById('blog'); if (!blogDiv) return; if (!blogDiv.offsetWidth) return; blogDiv.className = (blogDiv.offsetWidth >= 500) ? "float-images" : "block-images"; } // Blockquote citations // Simon Willison's work: // http://simon.incutio.com/archive/2002/12/20/#blockquoteCitations // Also Dunstan Orchard's work: // http://1976design.com/blog/archive/2003/11/10/updates/ function blockquoteCite() { if (!document.createElementNS) { document.createElementNS = function(ns, elt) { return document.createElement(elt); } } quotes = document.getElementsByTagName('blockquote'); for (i = 0; i < quotes.length; i++) { var cite = quotes[i].getAttribute('cite'); // value of cite attribute should only contain URI, not any other if ((cite) && (cite != '')) { newlink = document.createElementNS('http://www.w3.org/1999/xhtml', 'a'); newlink.setAttribute('href', cite); newlink.className = 'cite-link'; newlink.appendChild(document.createTextNode(cite)); newdiv = document.createElementNS('http://www.w3.org/1999/xhtml', 'cite'); newdiv.className = 'blockquote-cite'; newdiv.appendChild(document.createTextNode('Source: ')); newdiv.appendChild(newlink); quotes[i].appendChild(newdiv); quotes[i].removeAttribute('cite'); } } } // Ins and Del tags citations function insdelCite() { if (!document.createElementNS) { document.createElementNS = function(ns, elt) { return document.createElement(elt); } } var insdel = new Array(2); insdel[0] = document.getElementsByTagName('ins'); insdel[1] = document.getElementsByTagName('del'); for (var i=0; i= 0) { this.isIE = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = 'Netscape6/'; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; } // treat any other 'Gecko' browser as NS 6.1. s = 'Gecko'; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = 6.1; return; } } // 2003-11-19 sidesh0w // set delay vars to emulate normal hover delay var delay; var interval = 0.60; // this function runs on window load // it runs through all the links on the page as starts listening for actions function makeNiceTitles() { if (!document.createElement || !document.getElementsByTagName) return; if (!document.createElementNS) { document.createElementNS = function(ns, elt) { return document.createElement(elt); } } // do regular links if (!document.links) { document.links = document.getElementsByTagName('a'); } for (var ti=0; ti STD_WIDTH) { w = h_pixels; } else if ((STD_WIDTH>t_pixels) && (t_pixels>h_pixels)) { w = t_pixels; } else if ((STD_WIDTH>t_pixels) && (h_pixels>t_pixels)) { w = h_pixels; } else { w = STD_WIDTH; } d.style.width = w + 'px'; mpos = findPosition(lnk); mx = mpos[0]; my = mpos[1]; d.style.left = (mx+15) + 'px'; d.style.top = (my+35) + 'px'; if (window.innerWidth && ((mx+w) > window.innerWidth)) { d.style.left = (window.innerWidth - w - 25) + 'px'; } if (document.body.scrollWidth && ((mx+w) > document.body.scrollWidth)) { d.style.left = (document.body.scrollWidth - w - 25) + 'px'; } document.getElementsByTagName('body')[0].appendChild(d); CURRENT_NICE_TITLE = d; } function hideNiceTitle(e) { // 2003-11-19 sidesh0w // clearTimeout if (delay) clearTimeout(delay); if (!document.getElementsByTagName) return; if (CURRENT_NICE_TITLE) { document.getElementsByTagName('body')[0].removeChild(CURRENT_NICE_TITLE); CURRENT_NICE_TITLE = null; } } addEvent(window, "load", floatImages); addEvent(window, "resize", floatImages); addEvent(window, "load", blockquoteCite); addEvent(window, "load", insdelCite); addEvent(window, "load", noAltTooltip); addEvent(window, "load", makeNiceTitles); // I'm very poor in JavaScript. Please correct me if I'm wrong.