/*@cc_on
   /*@if (@_jscript_version == 5.6)
   try { document.execCommand('BackgroundImageCache', false, true); } catch(err) {};
   /*@end
@*/

// Google stats
var _uacct = "UA-341691";
if(Array.prototype.push == null){ Array.prototype.push = function(){ for(var i = 0; i < arguments.length; i++){ this[this.length] = arguments[i]; }; return this.length; };};
if(String.prototype.trim == null){ String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); }; };
var fd = {};

fd.isDOMsavvy  = Boolean(document.getElementById && document.getElementsByTagName);
fd.browserLang = String(navigator.language ? navigator.language : navigator.userLanguage).toLowerCase().replace(/-[a-z]+$/, "") || "en";

fd.addEvent = function(obj, evType, fn, useCapture){
        if (obj.addEventListener){
                obj.addEventListener(evType, fn, useCapture);
                return true;
        } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
        };
        return false;
};
fd.removeEvent = function(obj, evType, fn, useCapture){
        try {
                if (obj.removeEventListener){
                        obj.removeEventListener(evType, fn, useCapture);
                        return true;
                } else if (obj.detachEvent){
                        var r = obj.detachEvent("on"+evType, fn);
                        return r;
                };
        } catch(err) {};
        return false;
};
fd.stopEvent = function(e) {
        e = e || document.parentWindow.event;
        if (e.stopPropagation) {
                e.stopPropagation();
                e.preventDefault();
        };
        /*@cc_on@*/
        /*@if(@_win32)
        e.cancelBubble = true;
        e.returnValue  = false;
        /*@end@*/
        return false;
};
fd.addClass = function addClass(e,c) {
        if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) { return; };
        e.className += ( e.className ? " " : "" ) + c;
};
fd.removeClass = function removeClass(e,c) {
        e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
};
fd.onDomReady = function() {
        fd.addClass(document.getElementsByTagName("body")[0], "js-enabled");
        for(var module in fd) {
                if(typeof fd[module].onDomReady == "function") fd[module].onDomReady();
        };
};
fd.onLoad = function(e) {
        if("urchinTracker" in window) { urchinTracker(); };
        for(var module in fd) {
                if(typeof fd[module].onLoad == "function") fd[module].onLoad();
        };
};
fd.onUnload = function(e) {
        for(var module in fd) {
                if(typeof fd[module].onUnload == "function") fd[module].onUnload();
        };
};
fd.onResize = function(e) {
        for(var module in fd) {
                if(typeof fd[module].onResize == "function") fd[module].onResize();
        };
};
fd.addCssFile = function(filename) {
        var fileref = document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", "/css/" + filename);
        if (typeof fileref!="undefined") { document.getElementsByTagName("head")[0].appendChild(fileref) };
};
fd.getInnerText = function(el) {
        if (typeof el == "string" || typeof el == "undefined") return el;
        if(el.innerText) return el.innerText;

        var txt = '', i;
        for (i = el.firstChild; i; i = i.nextSibling) {
                if (i.nodeType == 3) { txt += i.nodeValue; }
                else if (i.nodeType == 1) { txt += fd.getInnerText(i); };
        };
        return txt;
};
fd.joinNodeLists = function() {
        if(!arguments.length) { return []; };
        var nodeList = [];
        for (var i = 0; i < arguments.length; i++) {
                for (var j = 0, item; item = arguments[i][j]; j++) {
                        nodeList[nodeList.length] = item;
                };
        };
        return nodeList;
};
fd.faviconise = {
        imageCache: [],
        onLoad: function() {
                var aList = document.getElementsByTagName("a");
                var url, img, src, obj, par;
                for(var i = 0, a; a = aList[i]; i++) {
                        if(a.className.search("faviconise") == -1 || a.href.search("http:") == -1) { continue; };
                        
                        url = a.href.replace('http://','').match(/^[^\/]+/)[0];

                        src = "http://" + url + "/favicon.ico?a="+ new Date().getTime();
                        img = document.createElement('img');
                        img.onerror = fd.faviconise.noImage;
                        img.src = src;
                        img.className = "faviconised";
                        img.alt = "favicon for " + url;
                        
                        obj = {
                                url:src,
                                img:img
                        };

                        fd.faviconise.imageCache[fd.faviconise.imageCache.length] = obj;

                        a.parentNode.insertBefore(img, a.parentNode.firstChild);
                };
        },
        noImage: function(e) {
                for(var i = 0, obj; obj = fd.faviconise.imageCache[i]; i++) {
                        if(obj.url == this.src) {
                                obj.img.onerror = null;
                                obj.img.src = "http://www.frequency-decoder.com/media/nofavicon.jpg";
                                obj.img.alt = "No favicon replacement image";
                        };
                };
        },
        onUnload: function(e) {
                for(var i = 0, obj; obj = fd.faviconise.imageCache[i]; i++) {
                        obj.img.onerror = null;
                        obj.img = null;
                };
                fd.faviconise.imageCache = null;
        }
};
fd.imageRounder = {
        onLoad: function() {
                var images = document.getElementsByTagName("img");
                var w, h, m, img, wrap, corner, bar;
                var len = images.length;
                var div = document.createElement("div");
                var c   = ["tl","tr","bl","br"];
                var bs1 = ["lb", "rb"];
                var bs2 = ["tb", "bb"];
                var cnt = 0;
                
                while(len--) {
                        img = images[len];
                        if(img.className.search(/rounded/) == -1) { continue; };
                        
                        tmp = img.className.replace(/rounded/, "");
                        img.className = "";
                        w = img.width  || img.offsetWidth;
                        h = img.height || img.offsetHeight;

                        if(w < 20 || h < 20) {
                                img.className = tmp;
                                continue;
                        };

                        wrap = div.cloneNode(false);
                        wrap.className = "imageWrap " + tmp;
                        wrap.style.width = w + "px";
                        wrap.style.height = h + "px";
                        
                        for(var i = 0; i < 4; i++) {
                                corner = div.cloneNode(false);
                                corner.className = c[i];
                                wrap.appendChild(corner);
                                corner = null;
                        };

                        if(h>20) {
                                for(i = 0; i < 2; i++) {
                                        bar = div.cloneNode(false);
                                        bar.className = bs1[i];
                                        //bar.style.height = (h - 20) + "px";
                                        wrap.appendChild(bar);
                                        bar = null;
                                };
                        };

                        if(w>20) {
                                for(i = 0; i < 2; i++) {
                                        bar = div.cloneNode(false);
                                        bar.className = bs2[i];
                                        //bar.style.width = (w - 20) + "px";
                                        wrap.appendChild(bar);
                                        bar = null;
                                };
                        };

                        if(img.parentNode.tagName == "A") {
                                img = img.parentNode;
                                img.className = "";
                        };

                        m = 18 - ((h + 18) % 18);
                        if(m < 18) { m += 18; };
                        wrap.style.marginBottom = m + "px";
                        
                        wrap.appendChild(img.cloneNode(true));
                        img.parentNode.replaceChild(wrap, img);
                        wrap = img = null;
                        cnt++;
                };
                
                if(cnt) {
                        fd.addCssFile("imageRounder.css");
                };
        }
};
fd.scriptUpdate = {
        a:null,
        toggle:0,
        v:"",
        onLoad: function() {
                var h4s = document.getElementById("content").getElementsByTagName("h4");
                if(!h4s.length) { return; };
                
                for(var i = 0, h4; h4 = h4s[i]; i++) {
                        if(h4.firstChild.nodeValue.search(/v[0-9]+(\.[0-9]+)?/) != -1) {
                                fd.scriptUpdate.v = "Show Latest Change Only (" + h4.firstChild.nodeValue.match(/v[0-9]+(\.[0-9]+)?/)[0] + ")";
                                break;
                        };
                };
                
                if(!fd.scriptUpdate.v) { h4s = h4 = null; return; };

                var ul     = h4;
                var lastUL = h4;
                
                while(ul.nextSibling) {
                        ul = ul.nextSibling;
                        if(ul.tagName && ul.tagName == "UL") { break; };
                };
                
                if(!ul.tagName || ul.tagName != "UL") { return; };

                var cnt = 0;
                
                while(ul.nextSibling) {
                        ul = ul.nextSibling;
                        if(ul.tagName && (ul.tagName == "UL" || ul.tagName == "H4")) {
                                ul.className = ul.className + " scriptUpdate";
                                cnt++;
                        } else if(ul.tagName) { break; };
                };
                
                if(cnt) {
                        var p = document.createElement("p");
                        p.id = "showHideScriptUpdate";
                        fd.scriptUpdate.a = document.createElement("a");
                        fd.scriptUpdate.a.href = "#showHideScriptUpdate";
                        fd.scriptUpdate.a.onclick = fd.scriptUpdate.showHide;
                        p.appendChild(fd.scriptUpdate.a);
                        var h2 = document.createElement("h2");
                        h2.appendChild(document.createTextNode("ChangeLog"));
                        lastUL.parentNode.insertBefore(h2, lastUL);
                        lastUL.parentNode.insertBefore(p, lastUL);
                        p = h2 = null;
                        fd.scriptUpdate.showHide();
                };
        },
        showHide: function() {
                var elems = fd.joinNodeLists(document.getElementById("content").getElementsByTagName("h4"), document.getElementById("content").getElementsByTagName("ul"));
                for(var i = 0, elem; elem = elems[i]; i++) {
                        if(elem.className.search("scriptUpdate") == -1) { continue; };
                        elem.className = fd.scriptUpdate.toggle ? elem.className.replace("noShow", "") : elem.className + " noShow";
                };
                while(fd.scriptUpdate.a.firstChild) { fd.scriptUpdate.a.removeChild(fd.scriptUpdate.a.firstChild); };
                var txt = fd.scriptUpdate.toggle ? fd.scriptUpdate.v : "Show Entire ChangeLog";
                fd.scriptUpdate.a.appendChild(document.createTextNode(txt));
                fd.scriptUpdate.toggle = !fd.scriptUpdate.toggle;
                return false;
        },
        onUnLoad: function(e) {
                fd.scriptUpdate.a = null;
        }
};
fd.tablePaginater = {
        commentsPerPage:20,
        maxPages:9,
        comments:[],
        currentPage:1,
        lastPage:-1,
        numPages:0,
        jump:null,
        text: ["First Page","Previous Page (Page %p)","Next Page (Page %p)","Last Page (Page %t)","Page %p of %t"],

        onDomReady: function() {
                var hook = document.getElementById("user-comments");
                if(!hook) { return; };

                var divs = hook.getElementsByTagName("div");

                for(var i = 0, div; div = divs[i]; i++) {
                        if(!div.id || div.id == "" || div.id.search(/c([0-9]{6})/) == -1) { continue; };
                        fd.tablePaginater.comments.push(div);
                        /*@cc_on
                        @if(@_jscript_version <= 5.6)
                                if(div.getElementsByTagName('div')[0].getElementsByTagName('span').length < 2) { continue; };
                                div.onmouseover = function(e) { this.getElementsByTagName('div')[0].getElementsByTagName('span')[0].style.display = 'inline'; };
                                div.onmouseout  = function(e) { this.getElementsByTagName('div')[0].getElementsByTagName('span')[0].style.display = 'none'; };
                                div.getElementsByTagName('span')[0].style.display = 'none';
                        @end
                        @*/
                };

                if(fd.tablePaginater.comments.length > fd.tablePaginater.commentsPerPage) {
                        fd.addCssFile("pagination.css");
                        
                        var numPages = Math.ceil(fd.tablePaginater.comments.length / fd.tablePaginater.commentsPerPage);
                        if(numPages < 2) {
                                fd.tablePaginater.comments = [];
                                return;
                        };
                        if(fd.tablePaginater.maxPages > numPages) {
                                fd.tablePaginater.maxPages = null;
                        };
                        fd.tablePaginater.numPages = numPages;
                        fd.tablePaginater.currentPage = fd.tablePaginater.calculateCurrentPage();
                        fd.tablePaginater.showPage();
                        if(fd.tablePaginater.jump) {
                                setTimeout(function() { window.location.hash = fd.tablePaginater.jump; fd.tablePaginater.jump = null; }, 1000);
                        };
                } else {
                        fd.tablePaginater.comments = [];
                };
        },
        calculateCurrentPage: function() {
                if(window.location.href.search(/#c([0-9]{6})/) != -1) {
                        var comment = 'c' + window.location.href.match(/#c([0-9]{6})/)[1];
                        for(var i = 0, c; c = fd.tablePaginater.comments[i]; i++) {
                                if(c.id == comment) {
                                        fd.tablePaginater.jump = c.id;
                                        return Math.floor(i / 20) + 1;
                                };
                        };
                };
                return fd.tablePaginater.numPages;
        },
        createButton: function(details, ul, pseudo) {
                var li   = document.createElement("li");
                var but  = document.createElement(pseudo ? "div" : "a");
                var span = document.createElement("span");

                if(!pseudo) { but.href = "#"; };
                if(!pseudo) { but.title = details.title; };

                but.className = details.className;

                ul.appendChild(li);
                li.appendChild(but);
                but.appendChild(span);
                span.appendChild(document.createTextNode(details.text));

                if(!pseudo) { li.onclick = but.onclick = fd.tablePaginater.buttonClick; };
                if(!pseudo && details.id) { but.id = details.id; };

                li = but = span = null;
        },
        buildPagination: function() {
                function resolveText(txt, curr) {
                        curr = curr || fd.tablePaginater.currentPage;
                        return txt.replace("%p", curr).replace("%t", fd.tablePaginater.numPages);
                };

                if(fd.tablePaginater.maxPages) {
                        findex = Math.max(0, Math.floor(Number(fd.tablePaginater.currentPage - 1) - (Number(fd.tablePaginater.maxPages - 1) / 2)));
                        lindex = findex + Number(fd.tablePaginater.maxPages);
                        if(lindex > fd.tablePaginater.numPages) {
                                lindex = fd.tablePaginater.numPages;
                                findex = Math.max(0, fd.tablePaginater.numPages - Number(fd.tablePaginater.maxPages));
                        };
                } else {
                        findex = 0;
                        lindex = fd.tablePaginater.numPages;
                };

                // Remove old list if present
                if(document.getElementById("fdtablePaginaterWrapTop")) {
                        var wrapT = document.getElementById("fdtablePaginaterWrapTop");
                        var wrapB = document.getElementById("fdtablePaginaterWrapBottom");
                        wrapT.parentNode.removeChild(wrapT);
                        wrapB.parentNode.removeChild(wrapB);
                };

                var p = document.createElement("p");
                var s = (fd.tablePaginater.currentPage == -1 ? 0 : fd.tablePaginater.currentPage - 1) * fd.tablePaginater.commentsPerPage;
                var e = s + fd.tablePaginater.commentsPerPage > fd.tablePaginater.comments.length ? fd.tablePaginater.comments.length : s + fd.tablePaginater.commentsPerPage;
                
                p.appendChild(document.createTextNode("Showing comments " + (s+1) + " to " + e + " of " + fd.tablePaginater.comments.length));
                
                var wrapT = document.createElement("div");
                wrapT.className = "fdtablePaginaterWrap";
                wrapT.id = "fdtablePaginaterWrapTop";

                var wrapB = document.createElement("div");
                wrapB.className = "fdtablePaginaterWrap";
                wrapB.id = "fdtablePaginaterWrapBottom";

                // Create list scaffold
                var ulT = document.createElement("ul");
                ulT.id  = "tablePaginater";

                var ulB = document.createElement("ul");
                ulB.id  = "tablePaginaterClone";
                ulT.className = ulB.className = "fdtablePaginater";

                // Add to the wrapper DIVs
                wrapT.appendChild(p);
                wrapT.appendChild(ulT);
                wrapB.appendChild(p.cloneNode(true));
                wrapB.appendChild(ulB);

                // FIRST (only created if maxPages set)
                if(fd.tablePaginater.maxPages) {
                        fd.tablePaginater.createButton({title:fd.tablePaginater.text[0], className:"first-page", text:"\u00ab"}, ulT, !findex);
                        fd.tablePaginater.createButton({title:fd.tablePaginater.text[0], className:"first-page", text:"\u00ab"}, ulB, !findex);
                };

                // PREVIOUS (only created if there are more than two pages)
                if(fd.tablePaginater.numPages > 2) {
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[1], fd.tablePaginater.currentPage-1), className:"previous-page", text:"\u2039", id:"previousPageT"}, ulT, fd.tablePaginater.currentPage == 1);
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[1], fd.tablePaginater.currentPage-1), className:"previous-page", text:"\u2039", id:"previousPageB"}, ulB, fd.tablePaginater.currentPage == 1);
                };

                // NUMBERED
                for(var i = findex; i < lindex; i++) {
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[4], i+1), className:i != (fd.tablePaginater.currentPage-1) ? "page-"+(i+1) : "currentPage page-"+(i+1), text:(i+1), id:i == (fd.tablePaginater.currentPage-1) ? "currentPageT" : ""}, ulT);
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[4], i+1), className:i != (fd.tablePaginater.currentPage-1) ? "page-"+(i+1) : "currentPage page-"+(i+1), text:(i+1), id:i == (fd.tablePaginater.currentPage-1) ? "currentPageB" : ""}, ulB);
                };

                // NEXT (only created if there are more than two pages)
                if(fd.tablePaginater.numPages > 2) {
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[2], fd.tablePaginater.currentPage + 1), className:"next-page", text:"\u203a", id:"nextPageT"}, ulT, fd.tablePaginater.currentPage == fd.tablePaginater.numPages);
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[2], fd.tablePaginater.currentPage + 1), className:"next-page", text:"\u203a", id:"nextPageB"}, ulB, fd.tablePaginater.currentPage == fd.tablePaginater.numPages);
                };

                // LAST (only created if maxPages set)
                if(fd.tablePaginater.maxPages) {
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[3], fd.tablePaginater.numPages), className:"last-page", text:"\u00bb"}, ulT, lindex == fd.tablePaginater.numPages);
                        fd.tablePaginater.createButton({title:resolveText(fd.tablePaginater.text[3], fd.tablePaginater.numPages), className:"last-page", text:"\u00bb"}, ulB, lindex == fd.tablePaginater.numPages);
                };

                // DOM inject wrapper DIVs (FireFox Bug: this has to be done here if you use display:table)
                document.getElementById("user-comments").insertBefore(wrapT, document.getElementById("user-comments").firstChild);
                document.getElementById("user-comments").appendChild(wrapB);
        },
        showPage: function(pageNum) {
                var page = !pageNum ? fd.tablePaginater.currentPage - 1 : pageNum - 1;
                var lpage = fd.tablePaginater.lastPage;

                var c1 = lpage == -1 ? 0 : (lpage - 1) * fd.tablePaginater.commentsPerPage;
                var c2 = lpage == -1 ? fd.tablePaginater.comments.length : Math.min(fd.tablePaginater.comments.length, c1 + fd.tablePaginater.commentsPerPage);

                var d1 = fd.tablePaginater.commentsPerPage * page;
                var d2 = Math.min(fd.tablePaginater.comments.length, d1 + fd.tablePaginater.commentsPerPage);

                var arr = [[c1, c2], [d1, d2]];

                for(var e = 0; e < 2; e++) {
                        var cnt = 0;
                        for(var i = arr[e][0]; i < arr[e][1]; i++) {
                                fd.tablePaginater.comments[i].style.display = e ? "" : "none";
                        };
                };

                fd.tablePaginater.buildPagination();
        },
        buttonClick: function(e) {
                e = e || window.event;

                var a = this.tagName.toLowerCase() == "a" ? this : this.getElementsByTagName("a")[0];

                if(a.className.search("currentPage") != -1) return false;

                var ul = this;
                while(ul.tagName.toLowerCase() != "ul") ul = ul.parentNode;

                fd.tablePaginater.lastPage = fd.tablePaginater.currentPage;

                var showPrevNext = 0;

                if(a.className.search("previous-page") != -1) {
                        fd.tablePaginater.currentPage = fd.tablePaginater.currentPage > 1 ? fd.tablePaginater.currentPage - 1 : fd.tablePaginater.numPages;
                        showPrevNext = "previous";
                } else if(a.className.search("next-page") != -1) {
                        fd.tablePaginater.currentPage = fd.tablePaginater.currentPage < fd.tablePaginater.numPages ? fd.tablePaginater.currentPage + 1 : 1;
                        showPrevNext = "next";
                } else if(a.className.search("first-page") != -1) {
                        fd.tablePaginater.currentPage = 1;
                } else if(a.className.search("last-page") != -1) {
                        fd.tablePaginater.currentPage = fd.tablePaginater.numPages;
                } else {
                        fd.tablePaginater.currentPage = parseInt(a.className.match(/page-([0-9]+)/)[1]) || 1;
                };

                fd.tablePaginater.showPage();

                // Focus on the appropriate button (previous, next or the current page)
                // I'm hoping screen readers are savvy enough to indicate the focus event to the user
                var elem;
                
                if(showPrevNext) {
                        elem = document.getElementById((ul.id.search("tablePaginaterClone") != -1) ? showPrevNext+"PageB" : showPrevNext+"PageT");
                };

                if(!elem || (elem && elem.tagName && elem.tagName.toLowerCase() != "a")) {
                        elem = document.getElementById((ul.id.search("tablePaginaterClone") != -1) ? "currentPageB" : "currentPageT");
                };

                if(elem && elem.tagName.toLowerCase() == "a") { elem.focus(); };
                return fd.stopEvent(e);
        },
        onUnLoad: function(e) {
                fd.tablePaginater.comments = null;
        }
};

function RESTrequest(url) {
        this.url = url;
        this.id = "RESTrequest-" + RESTrequest.RESTrequestId++;
        this.noCache = '&noCacheIE=' + (new Date()).getTime();
        this.scriptObj = document.createElement("script");
        this.scriptObj.setAttribute("type", "text/javascript");
        this.scriptObj.setAttribute("charset", "utf-8");
        this.scriptObj.setAttribute("src", this.url);
        this.scriptObj.setAttribute("id", this.id);
        document.getElementsByTagName("head").item(0).appendChild(this.scriptObj);
};
RESTrequest.prototype.removeScript = function() {
        document.getElementsByTagName("head").item(0).removeChild(this.scriptObj);
};
RESTrequest.RESTrequestId = 0;

fd.flickry = {
        url:"http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=ba866f4619559410d8b2c98f71afb85f&user_id=84708626%40N00&per_page=9&page=1&format=json&jsoncallback=fd.flickry.callback&random=" + Math.floor(Math.random()*1000),
        RESTrequest:null,
        timer:null,
        callback: function(JSONdata) {
                // Clear the error timeout
                clearTimeout(fd.flickry.timer);

                fd.flickry.RESTrequest.removeScript();
                fd.flickry.RESTrequest = null;

                if(!JSONdata.stat || JSONdata.stat != "ok") { return; };

                // Grab the scaffold & remove the loading-flickr class
                var scf = document.getElementById("flickr-stream-wrapper");
                if(!scf) { return; };
                scf.className = "";

                var img = document.createElement("img");
                var div = document.createElement("div");
                var a   = document.createElement("a");
                var spn = document.createElement("span");

                var url = "http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg";
                var cnt = 1;
                var imgN, divN, aN;

                div.className = "flickr_badge_image";

                for(var i = 0,photo;photo = JSONdata.photos.photo[i];i++) {
                        imgN = img.cloneNode(false);
                        divN = div.cloneNode(true);
                        aN   = a.cloneNode(false);

                        imgN.alt = "Flickr image";
                        
                        imgN.style.visibility = "hidden";
                        imgN.onload = fd.flickry.startImgFade;
                        
                        imgN.src        = url.replace("{farm-id}",photo.farm).replace("{server-id}",photo.server).replace("{id}",photo.id).replace("{secret}",photo.secret).replace("[mstb]","s");
                        divN.id         = "flickr_badge_image" + cnt++;
                        aN.href         = "http://www.flickr.com/photos/frequency-decoder/" + photo.id + "/";
                        aN.title        = photo.title;

                        scf.appendChild(divN);
                        divN.appendChild(aN);
                        aN.appendChild(imgN);
                        aN.appendChild(spn.cloneNode(false));
                };

                divN = imgN = img = div = a = spn = scf = null;
        },
        startImgFade:function() {
                fd.fadeIn.init(this);
        },
        responseTimeOut: function() {
                var scf = document.getElementById("flickr-stream-wrapper");
                if(scf.getElementsByTagName("img").length)  { return; };
                scf.parentNode.removeChild(scf);
                scf = fd.flickry.timer = null;
        },
        onLoad: function() {
                var sb  = document.getElementById("sidebar");
                if(!sb || document.getElementsByTagName("body")[0].id == "full-oddity") { return; };

                var div = document.createElement("div");
                div.id = "flickr-stream-wrapper";
                div.className = "loading-flickr";

                sb.insertBefore(div, sb.firstChild);

                fd.flickry.RESTrequest = new RESTrequest(fd.flickry.url);
                fd.flickry.timer = setTimeout(fd.flickry.responseTimeOut, 20000);
        }
};
fd.fadeIn = {
        ids:0,
        objBag: {},
        timer:null,
        init:function(obj) {
                if(!obj.id) { obj.id = "fi_" + fd.fadeIn.ids++; };
                if(!(obj.id in fd.fadeIn.objBag)) { fd.fadeIn.objBag[obj.id] = { "obj":obj, "op":0 }; };
                fd.fadeIn.setOpacity(obj, 0);
                obj.style.visibility = 'visible';
                if(fd.fadeIn.timer == null) { fd.fadeIn.fadeIn(); };
        },
        setOpacity: function(obj, opacity) {
                opacity = (opacity == 100)?99.999:opacity;
                // IE/Win
                obj.style.filter = "alpha(opacity:"+opacity+")";
                // Safari<1.2, Konqueror
                obj.style.KHTMLOpacity = opacity/100;
                // Older Mozilla and Firefox
                obj.style.MozOpacity = opacity/100;
                // Safari 1.2, newer Firefox and Mozilla, CSS3
                obj.style.opacity = opacity/100;
        },
        fadeIn:function() {
                var recall = false;
                for(elem in fd.fadeIn.objBag) {
                        if(fd.fadeIn.objBag[elem].op <= 100) {
                                fd.fadeIn.setOpacity(fd.fadeIn.objBag[elem].obj, fd.fadeIn.objBag[elem].op);
                                fd.fadeIn.objBag[elem].op += 10;
                                recall = true;
                        };
                };
                if(recall) { fd.fadeIn.timer = window.setTimeout("fd.fadeIn.fadeIn()", 50); }
                else { fd.fadeIn.timer = null; };
        },
        onUnLoad:function(e) {
                for(elem in fd.fadeIn.objBag) {
                        fd.fadeIn.objBag[elem].obj = null;
                };
                fd.fadeIn.objBag = null;
        }
};
fd.doDaySuffix = {
        onLoad: function() {
                var spans = document.getElementsByTagName('span');
                for(var z = 0, span; span = spans[z]; z++) {
                        if(!span.className || span.className != "pub-date") { continue; };
                        var txt = span.innerHTML.match(/^([0-9]+)/);
                        if(!txt.length) continue;
                        txt = txt[0];
                        span.innerHTML = span.innerHTML.replace(txt, txt + fd.doDaySuffix.daySuffix(txt));
                };
        },
        daySuffix: function(d) {
                return d.substr(-(Math.min(d.length, 2))) > 3 && d.substr(-(Math.min(d.length, 2))) < 21 ? "th" : ["st", "nd", "rd", "th"][Math.min(d%10, 4)-1];
        }
};
fd.livePreview = {
        helpOn:false,
        onLoad: function() {
                if(!document.getElementById("message")) { return; };

                // Are cookies enabled
                var cookieEnabled = fd.cookie.cookieEnabled();

                var hook = document.getElementById("submit-bar");
                var cbox = document.getElementById("forget");

                // Create buttons
                if(cookieEnabled) {
                        var draftButton = document.createElement('input');
                        draftButton.setAttribute('type','submit');
                        draftButton.setAttribute('id','draftbutton');
                        draftButton.setAttribute('name','draftbutton');
                        draftButton.onclick = fd.livePreview.saveDraft;
                        draftButton.className = "button";
                        draftButton.value = "Save draft";

                        var deleteButton = document.createElement('input');
                        deleteButton.setAttribute('type','submit');
                        deleteButton.setAttribute('id','deletebutton');
                        deleteButton.setAttribute('name','deletebutton');
                        deleteButton.onclick = fd.livePreview.deleteDraftWrapper;
                        deleteButton.className = "button";
                        deleteButton.value = "Clear draft";

                        var saveButton = hook.getElementsByTagName('input')[0];
                        if(saveButton.value.toLowerCase() == "save") { saveButton.onclick = fd.livePreview.deleteDraft; };
                };

                var quoteButton = document.createElement('input');
                quoteButton.setAttribute('type','submit');
                quoteButton.setAttribute('id','quotebutton');
                quoteButton.setAttribute('name','quotebutton');
                quoteButton.onmousedown = fd.livePreview.quoteText;
                quoteButton.onclick = fd.stopEvent;
                quoteButton.className = "button";
                quoteButton.value = "Quote";
                quoteButton.title = "Add any selected text as a quotation";

                // Create the comment preview scaffold
                var div = document.createElement('div');

                // Add the new buttons to the form
                if(cookieEnabled) {
                        cbox.parentNode.insertBefore(draftButton, cbox);
                        cbox.parentNode.insertBefore(document.createTextNode(' '), cbox);
                        cbox.parentNode.insertBefore(deleteButton, cbox);
                        cbox.parentNode.insertBefore(document.createTextNode(' '), cbox);
                };

                cbox.parentNode.insertBefore(quoteButton, cbox);
                cbox.parentNode.insertBefore(document.createTextNode(' '), cbox);

                if(cookieEnabled) {
                        fd.livePreview.loadDraft();
                };
                
                fd.livePreview.createButtonInfo();
        },
        quoteText: function(e) {
                var txt = '';
                if(window.getSelection){
                        txt = window.getSelection();
                } else if(document.getSelection){
                        txt = document.getSelection();
                } else if(document.selection){
                        txt = document.selection.createRange().text;
                } else {
                        return fd.stopEvent(e);
                };

                if(!txt || String(txt).length == 0) {
                        return fd.stopEvent(e);
                };

                txt = String(txt).replace("\r\n", "").replace("\n", "");

                document.getElementById('message').value = document.getElementById('message').value + "\n\nbq. " + txt + "\n";

                return fd.stopEvent(e);
        },
        nameCookie: function() {
                var loc = window.location + ' ';
                loc = loc.replace('#cpreview','','i');
                loc = loc.replace('http://www.frequency-decoder.com/','','i');
                loc = loc.replace('/','_','ig');
                loc = loc.replace(' ','','ig');
                if(loc.charAt(loc.length) == "_") loc = loc.substr(0,loc.length-1);
                return loc;
        },
        saveDraft: function() {
                loc = fd.livePreview.nameCookie();
                var val = document.getElementById('message').value;
                if(val == "") return false;
                var setCookie = true;
                if(escape(val).length > 2000) {
                        setCookie = confirm("Your message contains more characters than can be safely saved in a cookie; therefore, some of the message may be lost when saved as a draft.\n\n Do you wish to save the draft anyway?");
                };
                if(setCookie) {
                        fd.cookie.createCookie(loc, escape(val), 14);
                        if(escape(val).length < 2001) alert('A draft of your message has been saved for 14 days');
                        var deleteButton = document.getElementById('deletebutton');
                        deleteButton.className = "button";
                };
                return false;
        },
        deleteDraftWrapper: function() {
                fd.livePreview.deleteDraft();
                return false;
        },
        deleteDraft: function() {
                loc = fd.livePreview.nameCookie();
                fd.cookie.createCookie(loc, "", -1);
                var deleteButton = document.getElementById('deletebutton');
                deleteButton.className = "button opaque";
        },
        loadDraft: function() {
                loc = fd.livePreview.nameCookie();
                var draft = fd.cookie.readCookie(loc);
                var deleteButton = document.getElementById('deletebutton');
                if(draft != null) {
                        document.getElementById('message').value = unescape(draft);
                        deleteButton.className = "button";
                } else {
                        deleteButton.className = "button opaque";
                };
        },
        createButtonInfo: function() {
                var hook = document.getElementById("submit-bar");
                
                var div = document.createElement('div');
                div.id = "button-help";

                var p = document.createElement('p');
                p.className = "comments-closed";
                p.style.marginTop = "18px";
                
                var a = document.createElement('a');
                a.href="#button-help";
                a.className = "no-scroll comment-leadin no-marge";

                a.id="button-help-link";
                a.appendChild(document.createTextNode("What are these fandangled buttons?"));

                p.appendChild(a);
                hook.appendChild(p);

                a.onclick = function(e) {
                        if(fd.livePreview.helpOn) {
                                document.getElementById("button-help").style.display = "none";
                                this.innerHTML = "What are these fandangled buttons?";
                        } else {
                                document.getElementById("button-help").style.display = "block";
                                this.innerHTML = "Hide the button explanation please\u2026";
                        };
                        fd.livePreview.helpOn = !fd.livePreview.helpOn;
                        return false;
                };

                var inner = document.createElement('div');
                inner.innerHTML = (fd.cookie.cookieEnabled()) ? "<p class=\"comment-leadin no-marge\">The <strong>Save Draft</strong> button will save a draft of your comment for 14 days (as a cookie). Once saved, the comment box will be automatically populated with the saved draft every time you revisit this page. Naturally, the <strong>Clear draft</strong> button clears any draft previously saved for the current page.</p><p class=\"comment-leadin\">The <strong>Quote</strong> button enables you to highlight on-screen text and, once the button is clicked, add this text to your comment as a Textile formatted <code>blockquote</code>.</p>" : "<p class=\"comment-leadin no-marge\">The <strong>Quote</strong> button enables you to highlight on-screen text and, once the button is clicked, add this text to your comment as a Textile formatted <code>blockquote</code>.</p>";
                div.appendChild(inner);

                hook.parentNode.parentNode.appendChild(div);
                div.style.display = "none";
        }
};
fd.cookie = {
        enabled:null,
        cookieEnabled: function() {
                if(fd.cookie.enabled != null) return fd.cookie.enabled;
                var cookieEnabled = (navigator.cookieEnabled) ? true : false;
                if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
                        document.cookie="testcookie";
                        cookieEnabled=(document.cookie=="testcookie")? true : false;
                        document.cookie="";
                };
                fd.cookie.enabled = cookieEnabled;
                return cookieEnabled;
        },
        createCookie:function(name,value,days) {
                if (days) {
                        var date = new Date();
                        date.setTime(date.getTime()+(days*24*60*60*1000));
                        var expires = "; expires="+date.toGMTString();
                } else { expires = ""; };
                document.cookie = name+"="+value+expires+"; path=/";
        },
        readCookie:function(name) {
                var nameEQ = name + "=";
                var ca = document.cookie.split(';');
                for(var i=0;i < ca.length;i++) {
                        var c = ca[i];
                        while(c.charAt(0)==' ') { c = c.substring(1,c.length); };
                        if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); };
                };
                return null;
        }
};
fd.gravatar = {
        testImg:null,
        testImgLoaded:false,

        onDomReady: function() {
                // Quick check for noscript elements
                if(document.getElementsByTagName("noscript").length == 0) return;

                // Create a test gravatar (to check if gravatar.com is available)
                fd.gravatar.testImg = document.createElement("img");
                fd.gravatar.testImg.onload = fd.gravatar.testImgWasLoaded;
                fd.gravatar.testImg.src = "http://www.gravatar.com/avatar.php?gravatar_id=90773223bc930c4319071d2bb9222086&size=40&default=http%3A%2F%2Fwww.frequency-decoder.com%2Fmedia%2Fgravatar.jpg&amp;random="+ (new Date().getTime());
        },
        testImgWasLoaded: function() {
                fd.gravatar.testImgLoaded = true;
        },
        onLoad: function() {
                if(!fd.gravatar.testImgLoaded) return;

                var noscripts = document.getElementsByTagName("noscript");

                var src;
                var img          = document.createElement("img");
                img.className    = "gr hidden-gr";
                img.style.width  = "30px";
                img.style.height = "30px";
                img.alt          = "";

                for(var i = 0, noscript; noscript = noscripts[i]; i++) {
                        if(noscript.innerHTML.search(/(src=")([^"]+)/) != -1) {
                                src = noscript.innerHTML.match(/(src=")([^"]+)/)[2].replace(/&amp;amp;/g, "&amp;");

                                newImg = img.cloneNode(true);

                                newImg.onload = function() {
                                        this.className = "gr loaded-gr";
                                };

                                newImg.src = src;

                                noscript.parentNode.insertBefore(newImg, noscript);
                                newImg = null;
                        };
                };
        },
        onUnLoad:function(e) {
                fd.gravatar.testImg = null;
        }
};
fd.tagMullet = {
        sortedTags:[],

        onLoad: function() {
        
                var wrap = document.getElementById('tagMullet');
                if(!wrap) return;

                var reg         = /tagSize([0-9]{1,3})/;
                var tagObj      = {};
                var links       = wrap.getElementsByTagName('a');
                var arr         = [];
                var size;
                
                for(var i = 0, lnk; lnk = links[i]; i++) {
                        size = lnk.className.match(reg);
                        if(!size || !size.length) continue;

                        size = parseInt(size[1]) || 0;

                        lnk.className = "";
                        lnk.style.fontSize = "20px";
                        lnk.title = "Tag frequency: " + size;

                        if(!(size in tagObj)) {
                                tagObj[size] = [];
                                arr.push(parseInt(size));
                        };
                        
                        tagObj[size].push(lnk);
                };

                i = 1;
                while (i<arr.length) {
                        var j,v = arr[i];
                        for (j=i-1; j>=0; j--) {
                                if (arr[j] <= v) { break; };
                                arr[j+1] = arr[j];
                        };
                        arr[j+1] = v;
                        i++;
                };
                
                for(var z = 0; z < arr.length; z++) {
                        fd.tagMullet.sortedTags.push(tagObj[arr[z]]);
                };
                
                if(fd.tagMullet.sortedTags.length && ("fdSliderController" in window)) {
                        var frm         = document.createElement("form");
                        frm.method      = "post";
                        frm.action      = window.location;
                        frm.id          = "tagCloudForm";
                        
                        var p           = document.createElement("p");
                        
                        var inp         = document.createElement("input");
                        inp.type        = "hidden";
                        inp.id          = inp.name = "tagCloudInput";
                        
                        p.appendChild(inp);
                        frm.appendChild(p);
                        
                        wrap.parentNode.insertBefore(frm, wrap.nextSibling);

                        fd.tagMullet.max = fd.tagMullet.sortedTags.length;

                        fdSliderController.addSlider(inp, [0,fd.tagMullet.max], "fd.tagMullet.updateTagCloud", "", true, true, false);
                        fdSliderController.sliders["tagCloudInput"]._callback = fd.tagMullet.updateTagCloud;
                        
                        var div = document.createElement("div");
                        div.id = "sliderInfo";
                        
                        div.innerHTML = "<h3>About the Slider <span class=\"amp\">&amp;</span> Tag-Cloud</h3><p>Move the slider handle from left to right in order to emphasise tags with a higher frequency. Whenever the slider handle is positioned full-left, all tags are highlighted.</p>";
                        
                        inp.parentNode.appendChild(div);
                };
        },
        updateTagCloud: function() {
                // Grab the current value from the hidden input
                var val = document.getElementById("tagCloudInput").value;
                for(var i = 0, tags; tags = fd.tagMullet.sortedTags[i]; i++) {
                        var opc = val == 0 ? 100 : Math.ceil(100 - (Math.abs((i+1) - val) * (100 / fd.tagMullet.max)));
                        if(opc < 10) { opc = 10; };
                        
                        for(var j = 0, tag; tag = tags[j]; j++) {
                                fd.fadeIn.setOpacity(tag, opc);
                        };
                };
        }
};
fd.switchFontToLucidaGrande = {
        onLoad: function() {
                if(navigator.userAgent.toLowerCase().indexOf("mac") != -1 || (document.childNodes && !document.all && !navigator.taintEnabled)) {
                        /*

                           Switch font to Lucida Grande if on a MAC *or* if using WEBKIT.
                        
                           Of course, "Lucida Grande" is available on Windows now that it's bundled with Safari but
                           it only looks good when rendered by Safari (i.e. WebKit) on Windows - without cleartype activated
                           it just looks like shit when rendered by any other browser; and cleartype is almost never
                           turned on.

                        */
                        if (!document.styleSheets) { return; };
                        try {
                                var rules = (document.styleSheets[0].cssRules || document.styleSheets[0].rules);
                                if(rules && rules.length) { rules[0].style.fontFamily = "Lucida Grande, Verdana, Sans-Serif"; };
                        } catch(e) {};
                };
        }
};
fd.pageLinks = {
        onLoad:function() {
                var c = document.getElementById("content");
                if(!c || document.getElementsByTagName("body")[0].id.search(/article/) == -1) { return; };

                var lnks  = c.getElementsByTagName("a");
                var aBag  = {};
                var li    = document.createElement("li");
                var found = false;
                var clone, span, liClone, p, inComment;

                for(var i = 0, lnk; lnk = lnks[i]; i++) {
                        if(lnk.href.search(/frequency-decoder|^\/|#/) != -1) { continue; };
                        p = lnk;
                        inComment = false;

                        while(p.parentNode) {
                                p = p.parentNode;
                                if(p.id=="comment-block-wrapper" || p.id == "footer") {
                                        inComment = true;
                                        break;
                                };
                        };

                        if(inComment) { continue; };

                        clone = document.createElement("a");
                        clone.title = clone.href = lnk.href;
                        clone.rel = "nofollow";
                        clone.appendChild(document.createTextNode(fd.trimString(fd.getInnerText(lnk), 32)));

                        span = document.createElement("span");
                        span.appendChild(document.createTextNode(fd.trimString(String(clone.href), 37)));

                        clone.appendChild(document.createElement("br"));
                        clone.appendChild(span);

                        liClone = li.cloneNode(true);
                        liClone.appendChild(clone);

                        aBag[lnk.href] = liClone;

                        found = true;

                        clone = liClone = span = null;
                };

                if(found) {
                        var h3 = document.createElement("h3");
                        h3.appendChild(document.createTextNode("External Article Links"));

                        var ul = document.createElement("ul");
                        ul.className = "posts article-links";

                        for(obj in aBag) {
                                ul.appendChild(aBag[obj]);
                        };

                        var sidebar = document.getElementById("sidebar");
                        sidebar.appendChild(h3);
                        sidebar.appendChild(ul);

                        h3 = ul = aBag = null;
                };
        }
};
  /**
    * Begins quickly and decelerates towards end.  (quartic)
    * @method easeOutStrong
    * @param {Number} t Time value used to compute current value
    * @param {Number} b Starting value
    * @param {Number} c Delta between start and end values
    * @param {Number} d Total length of animation
    * @return {Number} The computed value for the current animation frame
    */
fd.tween = function() {
        this.curr = 0;
        this.setTo(0);
        this.callback = null;
};

fd.tween.prototype.setTo = function(f) {
        this.minValue   = this.curr;
        this.maxValue   = f;
        this.totalSteps = 30;
        this.actualStep = 0;
};

fd.tween.prototype.getNextValue = function() {
        this.curr = (this.actualStep++ == this.totalSteps) ? this.maxValue : this.easeInOut(this.minValue, this.maxValue, this.totalSteps, this.actualStep, 0.6);
        return this.curr;
};

fd.tween.prototype.easeInOut = function(minValue,maxValue,totalSteps,actualStep,powr) {
        //Generic Animation Step Value Generator By www.hesido.com
        var delta = maxValue - minValue;
        var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta);
        return Math.ceil(stepp)
};

fd.liveSearch = {
        defaultText: "Search: type, then enter",
        originalText: "Search: type, then enter",
        timer: null,
        inp: null,
        frm:null,
        oXMLHttpRequest: null,
        scaf1:null,
        scaf2:null,
        resize:new fd.tween(),
        fade:new fd.tween(),
        txt:"",
        
        onLoad: function() {
                var frm = document.getElementById("livesearch_form");
                if(!frm) { return; };

                fd.addCssFile("search.css");
                
                fd.liveSearch.frm = frm;
                fd.liveSearch.inp = document.getElementById("livesearch_text");
                fd.liveSearch.inp.setAttribute("autocomplete", "off");
                fd.liveSearch.inp.value = !fd.liveSearch.inp.value.trim() || fd.liveSearch.inp.value == fd.liveSearch.originalText ? fd.liveSearch.defaultText : fd.liveSearch.inp.value;
                fd.liveSearch.inp.onfocus = fd.liveSearch.onFocus;
                fd.liveSearch.inp.onblur  = fd.liveSearch.onBlur;
                fd.liveSearch.frm.onsubmit = fd.liveSearch.startSearch;
                frm = null;
        },
        onFocus: function() {
                if(this.value == fd.liveSearch.defaultText) { this.value = ""; };
                try { this.select(); } catch(err) {};
        },
        onBlur: function() {
                if(this.value == "") { this.value = fd.liveSearch.defaultText; };
        },
        animateFade: function() {
                fd.fadeIn.setOpacity(fd.liveSearch.scaf2, Math.round(fd.liveSearch.fade.getNextValue()));

                if(fd.liveSearch.fade.curr == fd.liveSearch.fade.maxValue) {
                        fd.liveSearch.fadeTimer = null;
                        fd.fadeIn.setOpacity(fd.liveSearch.scaf2, fd.liveSearch.fade.maxValue);
                        if(fd.liveSearch.fade.callback != null) {
                                fd.liveSearch.fade.callback();
                        };
                        fd.liveSearch.fade.callback = null;
                } else {
                        fd.liveSearch.fadeTimer = setTimeout(fd.liveSearch.animateFade, 50);
                };
        },
        animateResize: function() {
                fd.liveSearch.scaf1.style.height = Math.round(fd.liveSearch.resize.getNextValue()) + "px";

                if(fd.liveSearch.resize.curr == fd.liveSearch.resize.maxValue) {
                        fd.liveSearch.resizeTimer = null;
                        fd.liveSearch.scaf1.style.height = Math.ceil(fd.liveSearch.resize.maxValue) + "px";
                        if(fd.liveSearch.resize.callback != null) fd.liveSearch.resize.callback();
                        fd.liveSearch.resize.callback = null;
                } else {
                        fd.liveSearch.resizeTimer = setTimeout(fd.liveSearch.animateResize, 50);
                };
        },
        startSearch: function() {
                if(fd.liveSearch.inp.value == "" && fd.liveSearch.resize.curr != 0) {
                        fd.liveSearch.inp.style.display = "none";
                        fd.liveSearch.fade.setTo(0);
                        fd.liveSearch.fade.callback = function() {
                                fd.liveSearch.resize.setTo(0);
                                fd.liveSearch.txt = "";
                                fd.liveSearch.resize.callback = function() {
                                        fd.liveSearch.inp.value = fd.liveSearch.defaultText;
                                        fd.liveSearch.inp.style.display = "";
                                        fd.liveSearch.inp.blur();
                                };
                                fd.liveSearch.animateResize();
                        };
                        fd.liveSearch.animateFade();
                        return false;
                };
                
                if(fd.liveSearch.inp.value == "" || fd.liveSearch.inp.value.length < 4 || fd.liveSearch.inp.value == fd.liveSearch.txt) { return false; };
                fd.liveSearch.txt = fd.liveSearch.inp.value;
                fd.liveSearch.inp.style.display = "none";
                if(document.getElementById('search-results')) {
                        fd.liveSearch.fade.setTo(0);
                        fd.liveSearch.fade.callback = fd.liveSearch.search;
                        fd.liveSearch.animateFade();
                        return false;
                };
                fd.liveSearch.search();
                return false;
        },
        search:function() {
                fd.liveSearch.oXMLHttpRequest = new XMLHttpRequest;
                fd.liveSearch.oXMLHttpRequest.open("POST", window.location, true);
                fd.liveSearch.oXMLHttpRequest.onreadystatechange = fd.liveSearch.rsc;
                fd.liveSearch.oXMLHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                fd.liveSearch.oXMLHttpRequest.send("q=" + encodeURI(fd.liveSearch.inp.value));
        },
        removeResults:function(e) {
                if(document.getElementById('search-results')) {
                        fd.liveSearch.txt = "";
                        fd.liveSearch.fade.setTo(0);
                        fd.liveSearch.resize.setTo(0);
                        fd.liveSearch.fade.callback = fd.liveSearch.animateResize;
                        fd.liveSearch.animateFade();
                };
                return false;
        },
        rsc:function() {
                if(fd.liveSearch.oXMLHttpRequest.readyState == XMLHttpRequest.DONE) {
                        fd.liveSearch.resizeTimer = fd.liveSearch.fadeTimer = null;

                        var callback = fd.liveSearch.oXMLHttpRequest.responseText;
                        
                        var div  = document.createElement("div");
                        var body = document.body;

                        if(!document.getElementById('search-results')) {
                                fd.liveSearch.scaf1 = div.cloneNode(false);
                                fd.liveSearch.scaf1.id = "search-results";

                                fd.liveSearch.scaf2 = div.cloneNode(false);
                                fd.liveSearch.scaf2.className = "h-doc";
                                fd.fadeIn.setOpacity(fd.liveSearch.scaf2, 0);
                                
                                fd.liveSearch.scaf1.appendChild(fd.liveSearch.scaf2);
                        }
                        
                        fd.liveSearch.scaf2.innerHTML = callback;

                        var clone = fd.liveSearch.scaf1.cloneNode(true);
                        clone.id = "search-results-clone";
                        clone.style.height = "auto";
                        
                        if(!document.getElementById('search-results')) {
                                fd.liveSearch.scaf1.style.display = "none";
                                fd.liveSearch.scaf1.style.height = "0px";
                                fd.liveSearch.scaf1.style.display = "";
                                body.insertBefore(fd.liveSearch.scaf1, body.firstChild);
                        };
                        
                        body.insertBefore(clone, body.firstChild);
                        
                        fd.liveSearch.resize.setTo(clone.offsetHeight);
                        fd.liveSearch.fade.setTo(100);
                        fd.liveSearch.resize.callback = function() { fd.liveSearch.inp.style.display = ""; fd.liveSearch.animateFade(); };
                        fd.liveSearch.animateResize();
                        
                        body.removeChild(clone);
                        clone = body = div = null;
                };
        }
};

fd.trimString = function(str, maxLen) {
        str = str.trim();
        if(str.length <= maxLen) return str;
        if(arguments.length == 3) {
                return str.substr(0, maxLen)+ "\u2026";
        } else {
                var len = Math.round((maxLen - 3) / 2);
                return str.substr(0, len) + " \u2026 " + str.substr(str.length-len, str.length);
        };
};

window.onload = fd.onLoad;
window.onunload = function() { fd.onUnload(); };
window.onresize = function() { fd.onResize(); };

