/* (c) 2008, 2009 Add This, LLC */
// share menu
if (!window._atw) {
    var m=document.compatMode;
    if (m) {
        var md = 1;
        if(m=='BackCompat') md = 2;
        else if (m=='CSS1Compat') md = 0; // standard compliant

        _ate.bro.mode = md;
        if (_ate.bro.msi) {
            _ate.bro.mod = md;

            if ((md == 2 || _ate.bro.ie6) && !window.addthis_do_ab) {
                var w = window, os = (w.onscroll ? w.onscroll : function () {});
                window.onscroll = function () {if (_atw) _atw.fpf(); os();};
            }
        } 
    }
	var _atw = {
        css : {},
        conf : {},
        /* is object empty? */
        ioe : function (o){
            for(var i in o){ if(o.hasOwnProperty(i)){return false;}}
            return true;
        },
        /* html utilities */
        h : {
            g : function (o) { if (typeof(o) == 'string') o = _atw.get(o); return o;},
            a : function (n) { return '<a name="'+n+'"></a>'; },
            dv : function (n,h,c,e) { return '<div '+(c===1?'class':'id')+'="'+n+'"' + (h === 0 ? ' style="display:none"' : '') + (e?e:'') + '>'; },
            sp : function (n,c,e) { return '<span '+(c===true?'class':'id')+'="'+n+'"'+(e?e:'')+'>'; },
            lb : function (l,n,v) { if (!n) n = ''; return '<label for="'+n+'">'+l+':'+(v?'  <span>('+v+')</span>':'')+'</label>'; }, 
            /* css */
            c : {
                _s : function (o, p, v) { o = _atw.h.g(o); if (o) o.style[p] = v;},
                h : function (o, v) { _atw.h.c._s(o,'display','none'); if (v) _atw.h.c._s(o,'visibility','hidden');},
                s : function (o, v) { _atw.h.c._s(o,'display','block'); if (v) _atw.h.c._s(o,'visibility','visible');},
                sw : function (o, w) {_atw.h.c._s(o,'width',w+'px');},
                sh : function (o, w) {_atw.h.c._s(o,'height',w+'px');},
                iv : function (o) {o = _atw.h.g(o); if (o) return o.style.display == 'block'; return false;}
            }
        },
        lfy : 0,
        /* fake position:fixed in quirks-mode IE */
        fpf : function () {
            if (_ate.bro.ie6 || (_ate.bro.msi && _ate.bro.mod == 2)) {
                var d = document, 
                    de = d.documentElement,
                    db = d.body,
                    w = _atw,
                    ies = (de && typeof de.scrollTop!='undefined'),
                    iep = (db && typeof db.scrollTop!='undefined');
                    y = (ies && iep) ? Math.max(de.scrollTop, db.scrollTop) : ies ? de.scrollTop : db.scrollTop;
                y+=10;
                if (y!=w.lfy) {
                    w.lfy = y;
                    w.get('at16p').style.top=y+'px';
                }
            }
        },
		rev: '$Rev: 63301 $',
        // is valid language
        ivl : function(m,o) {
            if (this.ivlc !== undefined) return this.ivlc;

            var v = 0;
            for (var q in o) {
                if (o[q][0][0] === m) {
                    v = 1; break;
                }
                if (v) break;
            }
            return (this.ivlc = !!v);
        },
		// m = language
		// i = index
		//		1 = Share Caption (Bookmark & Share)
		//		2 = More
		//		3 = Email Caption
		//		4 = Email
		//		5 = Favorites
		lang : function(m,i) {
                var nl =  (_ate.bro.msi ? navigator.userLanguage : navigator.language),
                    l = m || nl,
                    w = _atw,
                    v = 1,
                    z = w.conf.ui_localize || window.addthis_localize,
                    o = window.addthis_translations || []; /* defined in lang.js */

                if (l) {
                    if (l == m) {
                       if (!w.ivl(l,o)) l = nl;
                    } 
                    l = (l.split('-')).shift();
                }

				if (z) {
					switch (i) {
						case 1: z = z.share_caption; break;
						case 2: z = z.more; break;
						case 3: z = z.email_caption; break;
						case 4: z = z.email; break;
						case 5: z = z.favorites; break;
						case 6: z = z.email_instructions; break;
						case 7: z = z.email_to; break;
						case 8: z = z.email_from; break;
						case 9: z = z.email_message; break;
						case 10: z = z.email_privacy; break;
						case 11: z = z.email_send; break;
						case 12: z = z.email_valid; break;
						case 13: z = z.email_sent; break;
						case 14: z = z.rss_caption; break;
						case 15: z = z.rss_instructions; break;
						case 16: z = z.rss_remember; break;
						case 17: z = z.done; break;
						case 18: z = z.get_your_own; break;
						case 19: z = z.email_address; break;
						case 20: z = z.optional; break;
						case 21: z = z.max_characters; break;
						case 22: z = z.print; break;
                /* address book */ 
						case 23: z = z.whats_this; break;
						case 24: z = z.privacy; break;
						case 25: z = z.use_address_book; break;
						case 26: z = z.cancel; break;
						case 27: z = z.sign_in_contacts; break;
						case 28: z = z.username; break;
						case 29: z = z.password; break;
						case 30: z = z.remember_me; break;
						case 31: z = z.sign_in; break;
						case 32: z = z.select_address_book; break;
						case 33: z = z.error_auth; break;
						case 34: z = z.email_recipients; break;
						case 35: z = z.find_a_service; break;
						case 36: z = z.no_services; break;
						case 37: z = z.share_again; break;
						case 38: z = z.sign_out; break;
						case 39: z = z.getting_contacts; break;
					}
				}
				if (z) {
					return z;
				}
				for (var q in o) {
					for (var r in o[q][0]) {
						if (o[q][0][r] === l && o[q].length > i && o[q][i]) {
							return o[q][i];
						}
					}
				}
				return ['Bookmark &amp; Share','More...','Email a Friend','Email','Favorites','Multiple emails? Use commas.','To','From','Note','Privacy Policy: We never share your personal information.','Send','Please enter a valid email address.','Message sent!','Subscribe to Feed','Select from these web-based feed readers:','Please don\'t ask me again; send me directly to my favorite feed reader.','Done','Get your own button!','email address','optional','255 character limit','Print',"What's this?","Privacy","Use Address Book","Cancel","Sign in to use your contacts","Username","Password","Remember me","Sign in","Select address book",'Error signing in.','Please limit to 20 recipients.','Find a service','No matching services.','Share again.','Sign Out','Getting contacts'][i-1];
		},
		rss : {
            "aol":           "AOL",
            "bloglines":     "Bloglines",
            /*"feedreader":    "FeedReader", // dead as of 4/09 */
            "google":        "Google Reader",
            "mymsn":         "My MSN",
            "netvibes" :    "Netvibes",
            "newsgator-on":     "NewsGator", /*online */
            "newsisfree":    "Newsisfree",
            "pageflakes":    "Pageflakes",
            "technorati":    "Technorati",
            "winlive":       "Windows Live",
            "yahoo":         "Yahoo"
            //"rojo":          "Rojo",  <-- now blogs.com
            /*"feeddemon":     "FeedDemon",
            "netnewswire":   "NetNewWire",
            "pluck":         "Pluck",*/
            /*"newsgator":  "Newsgator desktop",*/
            /*"pluck-on" :      "Pluck Online",*/
            /*"feedlounge":    "Feedlounge",*/
            /*"newsburst":     "Newsburst",*/
            /*"msn" :         "MSN",*/
            /*"newsalloy":     "News Alloy",*/
            /*"sharpreader":   "SharpReader",
            "awasu":         "Awasu",
            "myearthlink":   "myEarthLink"*/
        },
		loc : {
            it : {
                    'segnalo' : 'Segnalo'
                 },
            es : {
                    'meneame' : 'Men&eacute;ame'
                 },
            ja : {
                    'hatena' : 'Hatena'
                 },
            nl : {
                    /*'hyves' : 'Hyves',*/
                    'nujij' : 'Nujij'
                 }
        },
		list : {
			'aim'         : 'AIM',
			'ask'         : 'Ask',
			'backflip'    : 'Backflip',
			'ballhype'    : 'BallHype',
			'bebo'        : 'Bebo',
			/*'blinklist'   : 'BlinkList',*/
			'blogger'     : 'Blogger',
			'blogmarks'   : 'Blogmarks',
			'buzz'        : 'Buzz',
			'delicious'   : 'Delicious',
			'digg'        : 'Digg',
			'diigo'       : 'Diigo',
			'email'       : '',
			'facebook'    : 'Facebook',
			'fark'        : 'Fark',
			'faves'       : 'Faves',
			'favorites'   : '',
			/*'feedmelinks' : 'FeedMeLinks', // dead as of 4/21/09 */
			'friendfeed'  : 'FriendFeed',
			/*'furl'        : 'Furl', // dead as of 3/2009 */
			'google'      : 'Google',
			'hatena'      : 'Hatena',
			'kaboodle'    : 'Kaboodle',
			'kirtsy'      : 'kIRTSY',
			'linkagogo'   : 'Link-a-Gogo',
			'linkedin'    : 'LinkedIn',
			'live'        : 'Live',
			/*'magnolia'    : 'Magnolia',*/
			'meneame'     : 'Men&eacute;me',
			'misterwong'  : 'Mister Wong',
			'mixx'        : 'Mixx',
			'multiply'    : 'Multiply',
			/*'myweb'       : 'MyWeb', // shut down 2/2009 */
			'myaol'       : 'myAOL',
			'myspace'     : 'MySpace',
			/*'netscape'    : 'Propeller',*/
			'netvibes'    : 'Netvibes',
			'netvouz'     : 'Netvouz',
			'newsvine'    : 'Newsvine',
			'nujij'       : 'Nujij',
			'plaxo'       : 'Plaxo',
			'propeller'   : 'Propeller',
			'print'       : '',
			'reddit'      : 'Reddit',
			/*'sharedstuff' : 'Shared Stuff',*/
            'segnalo' : 'Segnalo',
			'simpy'       : 'Simpy',
			/*'skrt'        : 'Sk*rt',*/
			'slashdot'    : 'Slashdot',
			'spurl'       : 'Spurl',
			'stumbleupon' : 'StumbleUpon',
			'stylehive'   : 'Stylehive',
			/*'tailrank'    : 'Tailrank', // dead 5/2009 */
			'technorati'  : 'Technorati',
			'thisnext'    : 'ThisNext',
			'twitter'     : 'Twitter',
			'tumblr'      : 'Tumblr',
			'typepad'     : 'TypePad',
			'wordpress'   : 'WordPress',
			'yahoobkm'    : 'Y! Bookmarks',
			'yardbarker'  : 'Yardbarker'
		},
        books : {
            'gmail'     : 'Gmail',
            /*'aol'       : 'AOL', <-- doesn't exist! */
            'hotmail'   : 'Hotmail',
            'yahoo'     : 'Yahoo!'
        },
        /* typedown object */
        tdo : {
            ga : function (id) {  // get all child nodes
                var r  = [];
                if (id) {
                    var e = _atw.get(id), c = e.childNodes;
                    if (c && e.hasChildNodes()) {
                        for (var i = 0; i<c.length;i++) {
                            var o = c.item(i);
                            if (o.tagName.toLowerCase() == 'a' && o.style.display != 'none') r.push(o);
                        }
                    }
                }
                return r;
            },
            sel : function (oid) {
                var c = _atw.tdo.ga(oid);
                for (var i = 0; i < c.length; i++) {
                    o = c[i]; // current element
                    if (o.className.indexOf('hover') > -1) {
                        o.onclick();
                        break;
                    }
                }
            },
            inc : function (oid, dir /*positive integer to move "down" the list, negative to move "up"*/) {
                var c = _atw.tdo.ga(oid), i = 1, p = 0, n = 0, o = 0, s = 0, h = 'hover', box =_atw.get(oid);
                if (c.length > 1) {
                    for ( i = 0; i < c.length; i++)
                    {
                        o = c[i]; // current element

                        if (i < c.length - 1) {
                            n = c[i+1];
                        } else {
                            n = c[0];
                        }

                        if (i > 0) p = c[i - 1];
                        else p = c[c.length - 1];

                        if (o.className.indexOf(h) > - 1)
                        {
                            // we're here
                            if (dir > 0 && n) {
                                n.className = h;
                                o.className = '';
                                break;
                            } else if (-dir > 0 && p) {
                                o.className = '';
                                p.className = h;
                                break;
                            } 
                        }
                    }

                    if (dir < 0 && p) n = p;

                    if (n == c[c.length-1]) {
                        box.scrollTop = Math.max(0, box.scrollHeight - (o.offsetHeight * 4));
                    } else if (n == c[0]) {
                        // back to top
                        box.scrollTop = 0; 
                    } else if (i < 3) {
                        box.scrollTop = 0; 
                    } else if (i > c.length - 3) { 
                        box.scrollTop = Math.max(0, box.scrollHeight - (o.offsetHeight * 4));
                    } else {
                        if (dir > 0) {
                            if (o.offsetTop + o.offsetHeight*2 > box.offsetHeight + box.scrollTop)
                                box.scrollTop = o.offsetTop;
                        } else {
                            if (o.offsetTop - o.offsetHeight < box.scrollTop) {
                                box.scrollTop = o.offsetTop - o.offsetHeight*3;
                            }
                        }
                    }
                }
                if (i == c.length) 
                {
                    // select first element
                    c[0].className = 'hover';
                    box.scrollTop = 0; 
                }
            }
        },
        cb : function (k) {
            if (k) { k.cancelBubble = true; if (k.preventDefault) k.preventDefault(); }
        },
        /* global keydown handler */
        hkd : function (k) {
            if (typeof(k) == _atu) {
                k = window.event; 
            } 
            var w = _atw;
            if (k.keyCode == 27) {
                w.clb();
                w.cb(k);
            }
        },
        /* typedown keydown handler */
        htkd : function (o, k) {
            if (typeof(k) == _atu) {
                k = window.event; 
            } 
            var w = _atw, t = 'at16eatdr', iv = w.h.c.iv(t)/* is typedown filter displayed ?*/;
            if (iv) {
                switch (k.keyCode)
                {
                    case 38: /*up arrow*/ 
                        w.tdo.inc(t, -1);
                        w.cb(k);
                        return false;
                    case 40: /*down arrow*/
                        w.tdo.inc(t, 1);
                        w.cb(k);
                        return false;
                    case 13: /*return*/
                        w.tdo.sel(t);
                        w.cb(k);
                        return false;
                }
            }
            return true;
        },
        filt : function (f, list, container, prefix, nomatch) {
            var s = 0,
                w = _atw,
                p = prefix || 'ati_',
                n = nomatch || 'at16nms',
                ff = f != '' ? f.replace(/\W+/g,"").replace(/ /g,'').toLowerCase() : '';
            w.h.c.h(n);
            if (container) w.h.c.s(container);
            for (var k in list) {
                var o = _atw.get(p+k.replace('@','_')),
                    c = w.h.c,
                    kl = k.toLowerCase(),
                    lkl = (list[k]).toLowerCase(),
                    d = 0;
                if (kl.indexOf(f)>-1 || kl.indexOf(ff)>-1 || lkl.indexOf(ff)>-1 || lkl.indexOf(f)>-1) { d = 1; s++; }
                if (d) c.s(o);
                else c.h(o);
            }
            if (s === 0) {
                w.h.c.s(n);
                if (container) w.h.c.h(container);
            }
            if (f.replace(/ /g,'') == '') {
                if (container) w.h.c.h(container);
            }
        },
		// pointer to hover div for deferred load
		div : null,
		// get document element by id
		get : function(id) { return document.getElementById(id); },
		// clear wait (timeout)
		xwa : function() { if (_atw.cwa !== null) clearTimeout(_atw.cwa); },
		// addthis_close settimeout pointer
		cwa : null,
		// clear hover wait (timeout)
		xhwa : function() { if (_atw.hwa !== null) clearTimeout(_atw.hwa); },
        // addthis hover settimeout pointer
        hwa : null,
		// options setup (boolean true when done)
		ost : false,
		// div id
		did : 'at15s',
		// ie6 hand cursor workaround
		ie6 : function() {
			return _ate.bro.ie6 ? ' style="cursor:hand;"' : "";
		},
        // reset form field to s if blank, or to blank if s
        rsf : function (o,s)
        {
            var ov = o.value;
            if (ov == s) {
                o.value = '';
                if (o.className.indexOf('at_ent') == -1) o.className += ' ' + 'at_ent';
            }
            else if (ov == '') {
                o.value = s;
                o.className=(o.className == 'at_ent')?'':o.className.replace(' at_ent','');
            }
        },
        // fake :hover for browsers that don't have it
        hov : function(o)
        {
            o.className = (o.className.indexOf("athov") > -1) ? o.className.replace(' athov', '') : o.className + ' athov';
        },
        // is panel open? 
        ipo : function () {
            var p = _atw.get('at16p');
            return p && p.style.width == '502px';
        },
        // open panel (yeah, you know me)
        opp : function (force) {
            var w = _atw,
                p = w.get('at16p'),
                pp = w.get('at16pp'),
                off = force;

            if (!addthis_do_ab) {
                if (!w.osta)  {
                    var e = w.get('at_email'),       
                        d = function (s) /* make sure any of our old hashes aren't lying around */
                        {
                            if (w.hash.indexOf('#at'+s) === 0) {
                                document.location.hash = w.hash = '#atabc';
                            }
                        };
                    d('pro');
                    d('opp');
                    d('cle');
                    d('clb');
                    d('abc');

                    e.url = _atr+'static/r07/ab'+(_ate.bro.mod!=2?'':'-quirks')+'01.html?&hc='+_euc(w.conf.ui_header_color)
                            +'&hb='+_euc(w.conf.ui_header_background)+'&br='+_euc(w.conf.ui_cobrand)+'&al='+w.conf.ui_language
                            +'&t='+_euc(w.get('at_to').value)+'&f='+_euc(w.get('at_from').value)+'&n='+_euc(w.get('at_msg').value)
                            +'&url='+_euc(addthis_url)+'&tit='+_euc(addthis_title)+'&wpl='+_euc(document.location.href)
                            +'&u='+_euc(_ate.uid)

                    // @todo this should be a sub-element of at_email
                    e.innerHTML = '<div id="at16abifc" class="atiemode'+_ate.bro.mod+'">'                                    /* v-- IE7 in NON-quirks mode needs some adjustment */
                                  +'<iframe id="at16abif"'+(_ate.bro.mod==0?' style="height:370px"':'')+' name="at16abif" src="'+e.url+'" '
                                  +'scrollbar="no" frameborder="0" scrolling="no"></iframe></div>';

                    if (w.ifpp) clearInterval(w.ifpp);
                    w.ifpp = setInterval(function() {w.ifp();}, 100);

                    w.osta = true;
                    off = force = false;
                } 
                if (force === undefined) {
                    var off = w.ipo();
                    w.get('at16abifc').style.width = off ? '300px' : ''; 
                }
                w.h.c.sw(p, off ? 300 : 502);
                w.get('at16pit').innerHTML = '&'+(off?'r':'l')+'aquo;';
            } else {
                off = (pp.style.display == 'block');
                if (!w.osta)
                {
                    w.ti = 1000;
                    var h = w.get('at15s'),
                        hp = h.parentNode,
                        un, pw,
                        preauth = 0;
                    hp.removeChild(h);
                    w.evar();
                    p.style.background = 0;
                    // for ab
                    var md = w.h.dv,
                        msp = w.h.sp,
                        mlb = w.h.lb,
                        al = w.conf.ui_language,
                        cs = '</span>',
                        ca = '</a>',
                        cd = '</div>',
                        min = function (i,e,v,z) { return '<input id="'+i+'" name="'+i+'" class="atinp" type="'+(i.indexOf('pass')>-1?'password':'text')+'" tabindex="'+(_atw.ti++)+'" '+(v?'value="'+v+'" ':'')+'size="'+(z?z:30)+'"'+e+'/>';},
                        cl = '<div style="clear:both;">' + cd,
                        efr = function (i,l,v,z) { return /*datr + */mlb(l,i) + min(i,'onfocus="_atw.rse(true);"',v,z);};

                    s = md('at_ab_error', 0, null, 'class="at_error"') + w.lang(al,33) + cd
                      + md('at16ppc') + md('at16pph') + w.lang(al, 32) + ':'
                      + '<select id="at16pphs" class="atinp" tabindex="'+(w.ti++)+'" style="display:none" onchange="_atw.swa(this.options[this.selectedIndex].value)">';

                    // checkmark:  &#10003;
                    for (var k in w.books) { s += '<option value="'+k+'">'+w.books[k]+'</option>'; if (!preauth) preauth = _ate.rck('at-auth-'+k);}
                    s += '</select>' + cd
                       + md('at16ppf', 0)
                       + '<div style="padding-bottom:6px;">'+w.lang(al,27)/*sign in to use your contacts*/+'.'+cd;

                    if (preauth) {
                        preauth = preauth.split('|');
                        un = preauth[0];
                        pw = preauth[1];
                    }
                    var lab = w.lang(al, 19);
                    lab = lab.charAt(0).toUpperCase() + lab.substr(1);
                    s += efr('at_ab_user', lab, un, 20) + cl
                       + efr('at_ab_pass', 'Password', pw, 20)
                       + md('at16abr') + '<input type="checkbox" tabindex="'+(w.ti++)+'" id="at_remember"'+(preauth?' checked':'')+'> ' + w.lang(al,30) + cd
                       + '<p id="atsb">'
                       + '<input id="at16abs" class="atbtn" tabindex="'+(w.ti++)+'" type="submit" value="'+w.lang(al,31)/*Sign In*/+'" onclick="return _atw.lda()"/>'
                       +  'or <a href="#" id="at16abc" onclick="_atw.rsp();return false" tabindex="'+(w.ti++)+'">'+w.lang(al,26)/*Cancel*/+ca
                       + '</p>'
                       + '<div id="at_signin_loading" class="at_loading" style="display:none;"><img src="/images/redloading.gif" width="16" height="16" alt="loading..."/> '+w.lang(al,39)/*Getting contacts*/+'...'+cd + cd;
                   
                    s += md('at16ppa', 0, 0, (_ate.bro.mod == 2 ? 'style="width:164px"' : '')) + cd
                       + '<a id="at16ppso" href="#" onclick="return _atw.daua(this);">'+w.lang(al,38)+ca
                       + md('at16ppb') + md('at16ep');
                    for (var k in w.books) {
                        s += '<a class="at_'+k+'" href="#" onclick="_atw.swa(\''+k+'\');">'+w.books[k]+ca;
                    }
                    s += cd + cd + cd;

                    pp.innerHTML = s;
                    // end ab

                    if (off) w.h.c.h(pp);
                    else w.h.c.s(pp);

                    w.h.c.sw(p, off ? 300 : 502);
                    w.osta = true;

                    // preload address books inside iframe if necessary
                    _atw.plda();
                }

                if (off !== false)  {
                    w.ifm('opp');
                } 
            }
            return false;
        },
        // reset ab panel
        rsp : function () {
            var w = _atw, hi = ['at16ppa', 'at16ppso', 'at16pphs', 'at16ppf'];
            for (var k in hi) w.h.c.h(hi[k]);
            w.h.c.s('at16ppb');
            w.rse(true);
        },
        // enable/disable ab tabbing
        abtd : function () {
            var w = _atw,
                off = !w.ipo(),
                sd = off ? w.h.c.h : w.h.c.s;
            sd('at16ppc');
            sd('at16abc');
            sd('at16abr');
            sd('at16abs');
            sd('at_ab_user');
            sd('at_ab_pass');
        },
        // deauthenticate ab
        daua : function ( solink ) {
            var w = _atw,
                c = w.data.contacts,
                s = solink.firstChild.nodeValue.split(' ').pop(),
                re = [], // elements to remove eventually
                td = w.get('at16eatdr');
            for (var k in w.books) {
                if (w.books[k] == s) {
                    if (_ate.rck('at-auth-sess-'+k)) _ate.kck('at-auth-sess-'+k);

                    if (td) {
                        var cl = td.getElementsByTagName('A'),
                            re = [];
                        for (var i = 0; i < cl.length; i++)
                        {
                            if (cl[i].className.indexOf(k) > -1) {
                                re.push(cl[i]); // mark element for deletion
                            }
                        }
                    }

                    w.data.contacts[k] = null;
                    if (w.data.auth[s]) w.abdata(c[s]);
                    w.data.auth[k] = null; 

                    w.rsp();
                    break;
                }
            }

            for (var k in c.origin) {
                if (c.origin[k] == s) {
                    delete c.origin[k];
                    delete c.all[c.origin[k]];
                }
            }
    
            for (i = 0; i < re.length; i++) td.removeChild(re[i]);

            if (td && td.getElementsByTagName('A').length == 0) {
                td.innerHTML = '';
                td.style.border = '';
            }
        },
        // show ab auth
        aua : function (b /*book id; e.g., 'gmail'*/) {
            var w = _atw,
                u = _atw.get('at_ab_user'),
                p = _atw.get('at_ab_pass'),
                s = w.get('at16pphs'),
                h = w.h.c.h;
            w.h.c.s(s)
            w.h.c.s('at16ppf');
            h('at16ppa');
            h('at16ppso');
            h('at16ppb');

            s.value = b;
            if (w.data.auth && w.data.auth[b]) {
                var a = w.data.auth[b]; 
                u.value = a.u;
                p.value = a.p;
            } else {
                var a = _ate.rck('at-auth-'+b);
                if (a) {
                    a = a.split('|');
                    u.value = a[0];
                    p.value = a[1];
                } else {
                    u.value = '';
                    p.value = '';
                }
            }
        },
        // switch address book (ui)
        swa : function (b /*book id; e.g., 'gmail'*/) {
            var w = _atw, c = w.data.contacts;
            if (c && c[b]) w.abdata(c[b]);
            else w.aua(b);
        },
        // preload addressbook
        plda : function () {
           for (var k in _atw.books) { 
               if (_ate.rck('at-auth-sess-'+k)) {
                   var preauth = _ate.rck('at-auth-'+k);
                   if (preauth) {
                       preauth = preauth.split('|');
                       var un = preauth[0],
                           pw = preauth[1];

                       _atw.lda(k, un, pw);
                   }
               }
           }
        },
        // load address book
        lda : function (fbk, u, p) {
            var w = _atw,
                c = w.data.contacts,
                s = w.get('at16pphs'),
                uf = w.get('at_ab_user'),
                pf = w.get('at_ab_pass'),
                u = u || uf.value,
                p = p || pf.value,
                v = fbk || s.options[s.selectedIndex].value; // service

            w.rse();

            if (!fbk) {
                if (u == '' || p == '') {
                    var e = ('at_ab_error'),    
                        al = w.conf.ui_language;
                    //e.style.display='block';
                    if (u == '') w.err(null, uf, e);
                    if (p == '') w.err(null, pp, e);
                    return false;
                }

                if (w.get('at_remember').checked) {
                    _ate.sck('at-auth-'+v, u+'|'+p);
                    _ate.sck('at-auth-sess-'+v,1,1);
                } else {
                    _ate.kck('at-auth-'+v);
                    _ate.kck('at-auth-sess'+v);
                }
            } 

            // @todo shorten this
            if (c && c[v]) w.abdata(c[v], !!fbk);
            else {
                w.h.c.s('at_signin_loading');
                var d = document,
                    o = d.ce('script');
                o.src = 'https://ws.addthis.com/share/v2/addrs?u='+_euc(u)+'&p='+_euc(p)+'&from='+_euc(v)+'&fmt=jsonp&callback=_atw.abdata'+(fbk?'bk':'');
                d.gn('head')[0].appendChild(o);
            }
        },
        // validate url
        vur : function(s) {
            return (/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/).test(s);
        },
        // validate email address
        vem : function (s) {
            return String(s).search(/^\s*\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b\s*$/i) != -1;
        },
        // add address to "to" field
        ato : function (o) {
            // o is an anchor tag
            var w = _atw,
                t = w.get('at_to'),
                a = o.firstChild.nodeValue,
                aa = a.split(' <'),
                ne = aa.length ? aa[1] : a,
                es = t.value.replace(/;/g,',').split(','),
                le = leo = es.pop(),
                lbp = le.indexOf('<');

            if (a.indexOf('<') !== -1) a = '"' + a.replace(/ </g, '" <');

            if (le) {
                if (lbp > -1) {
                    le = le.substr(lbp + 1, le.length - lbp).replace('>','');
                }
                if (w.vem(le)) {
                    es.push(leo.charAt(0) == ' ' ? leo.substr(1) : leo);
                }
            } 

            if (t.value.indexOf(ne) == -1) {
                es.push(a);
            }
            t.value = es.join(', ');
            w.h.c.h('at16eatdr');
            t.focus();
            return false;
        },
        // pointer to useful data
        data : {auth: {}, contacts: {all: {}, origin: {}}},
        // first element pointer, for determining where to refocus after an error
        fe : null,
        // errorer
        ert : function (m, o, en)  { // see note below (for IE timing bug)
            var w = _atw,
                a = w.get(en);
            a.innerHTML = m || w.lang(w.conf.ui_language,33);  
            w.h.c.s(a);
            if (o) o.style.borderColor = '#dd0000';
        },
        err : function (m, o, en) {
            var w = _atw, lb = _atc.ver >= 200;
            if (w.fe === null) {
                w.fe = o; o.focus(); 
                if (lb) {
                    o.style.outlineStyle = 'none';
                    o.style.outlineWidth = '0px';
                }
                else alert(m);
            }
            if (lb)
            {
                // needed because of IE focus timing bug
                // (el.focus() is not synchronous)
                _ate.sto ( function () { w.ert(m, o, en); }, 50);
            }
        },
        // return for fetching data in background
        abdatabk : function (r) {
            _atw.abdata(r, true);
        },
        abdata : function (r, f /* if this is forced, we don't want to do lots of ui stuff */) {
            var w = _atw,
                ac = w.get('at16ppa'), // address container, innerHTML gets updated
                so = w.get('at16ppso'), //sign out link, text node gets updated
                adab = window.addthis_do_ab && !f;
   
            w.h.c.h('at_signin_loading');
            if (r.status) {
                if (adab) {
                    w.err(null, w.get('at_ab_user'), 'at_ab_error');
                    w.err(null, w.get('at_ab_pass'), 'at_ab_error');
                }
            }
            else {
                if (adab) {
                    w.h.c.h('at16ppb');
                    w.h.c.h('at16ppf');
                }

                var c = r.data.contacts,
                    b = r.data.channel,
                    f = 1,
                    as = '',
                    s = '',
                    td = w.get('at16eatdr'),
                    u = w.get('at_ab_user'),
                    p = w.get('at_ab_pass');


                if (adab) {
                    if (!r.cache) _ate.cev('aba', b);
                    so.firstChild.nodeValue = w.lang(w.conf.ui_language, 38) +' '+ w.books[b];
                    w.h.c.s(so);
                    w.h.c.s(ac);

                    w.data.auth[b] = {u: u.value, p: p.value};
                }

                c.sort(function(a, b) { 
                          var a = ((a.fullName||a.pops[0].address||'')+'').toUpperCase(), b = ((b.fullName||b.pops[0].address||'')+'').toUpperCase(); 
                          return ( ( a == b ) ? 0 : ( ( a > b ) ? 1 : -1 ) );
                      });

                for (var i = 0 ; i < c.length; i++) {
                    var d = c[i].pops[0], n = d.displayName, a = d.address;
                    s += '<a href="#" onclick="return _atw.ato(this);">'+n+' &lt;'+a+'&gt;</a>';
                    w.data.contacts.all[a] = n;
                    w.data.contacts.origin[a] = b;
                }
                w.data.contacts[b] = r;
                w.data.contacts[b].cache = true;

                var cns = [];
                for (var a in w.data.contacts.all) { 
                    cns.push({id: a, name: w.data.contacts.all[a]});
                }
                cns.sort(function(a,b) { return a.name > b.name ? 1 : (a.name < b.name ? -1 : 0); });
                for (i = 0; i < cns.length; i++) {
                    var a = cns[i].id;
                    as += '<a id="_ataddr'+(a.replace('@','_'))+'" class="addthis_data_'+w.data.contacts.origin[a]+'" href="#" onclick="return _atw.ato(this);">'+w.data.contacts.all[a]+' &lt;'+a+'&gt;</a>';
                }

                td.innerHTML = as;
                if (as != '') td.style.border = "1px solid #ccc";
                if (adab) {
                    w.h.c.s('at16pphs');
                    w.get('at16pphs').value = b;
                    ac.innerHTML = s;
                }
            }
        },
        // menu clicks; incremented when a service is selected
        // (including more);
        // we know that email was selected directly from the hover 
        // menu if this is <2
        mck : 0,
        // close email form
        cef : function () {
            var w = _atw,
                d = w.mck < 2; /* direct email access */
            if (addthis_do_ab) {
                if (d) {
                    w.ifm('cef');
                } else {
                    w.ifm('cle');
                }
            } else {
                if (d) {
                    w.clb();
                } else {
                    _ate.as('more');
                }
            }
            return false;
        },
        // clear email form (after successful share)
        cle : function () {
            var w = _atw,
                n = w.get('at_msg'),
                t = w.get('at_to');
            if (n) n.value = '';
            if (t) t.value = '';
            w.h.c.h('at16pit');
        },
        // reset email form
        rse : function (abonly) {
            // @todo when names are finalized, compress these through disgusting string ops
            var w = _atw,
                f = 'at_from',
                t = 'at_to',
                u = 'at_ab_user',
                p = 'at_ab_pass',
                e = 'at_error',
                ea = 'at_ab_error',
                sc = 'at_success',
                ap = 'at_promo',
                em = 'at_email',
                h = w.h.c.h,
                s = w.h.c.s,
                z = function (o) { o = w.get(o); if (o) {o.style.borderColor = o.style.outlineWidth = o.style.outlineStyle = '';} };

            z(u); z(p); 
            h(ea); h(e); 
            h('at16eatdr');
            if (!abonly)  {
                z(f); z(t);
                h(sc); h(ap);
                s(em);
            }
        },
        // limit max length (of textarea, etc.)
        lml : function(o,l) {
            if (o.value.length>l)
                o.value = o.value.substring(0,l)
        },
		// hover div slide open function for ad treatments
		sli : function(tmot) {
			for (var i=0; i<_atw.sin.length; i++) {
				var sio = _atw.sin[i];
				if (sio.pos >= sio.end) {
					_atw.sin.splice(i,1);
				} else {
					sio.pos += sio.inc;
					this.h.c.sh(sio.obj, sio.pos);
					if (sio.tp) {
						sio.tp -= sio.inc;
						this.get(this.did).style.top = sio.tp+'px';
					}
				}
			}
			if (_atw.sin.length > 0) {
				_ate.sto('_atw.sli('+tmot+')',tmot);
			}
		},
		// add slide open event
		// obj = target object to size
		// end = target size
		// tmot = time between size increments
		// inc = size increments
		// wait = initial wait before animation
		// tp = top -- used when animating up
		sla : function(obj,end,tmot,inc,wait,tp) {
			_atw.sin.push({'obj':obj,'pos':0,'end':end,'inc':inc,'tp':tp});
			_ate.sto('_atw.sli('+tmot+')',wait);
		},
		// slide info array
		sin : [],
		// close pop-up
		clo : function() {
			var a = _atw,
				drop = a.get(_atw.did),
                v = _atc.ver,
				e = document.gn('embed');
			if (drop) {
				if (v < 200) a.h.c.h('at_email15');
				a.h.c.h(drop);
			}
			// show embed elements that have been hidden
			if (e && a.conf && a.conf.ui_hide_embed) { 
				for (i=0; i<e.length; i++)  {	
					if (e[i].addthis_hidden) e[i].style.visibility = 'visible';
				}
			}
			return false;
		},
        // send message to child iframe
        cfm : function (m) {
            var o = _atw.get('at16abif');
            if (o && o.src) o.src = _atw.get('at_email').url + '#' + m;
        },
        // send message via iframe url
        ifm : function (m) {
            var a = (addthis_wpl.split("#"))[0];
            window.parent.location.href = a + '#at' + m;
            return false;
        },
        hash : window.location.hash, // onload
        ifpp : null, // iframe poll pointer
        // poll iframe
        ifp : function (name) {
            var w = _atw,
                m = window.location.hash,       
                p = 0;
            if (m.length && m != w.hash)
            {
                switch (m)
                {
                    case '#atclb': w.clb(); p = 1; break;
                    case '#atopp': w.opp(); p = 1; break;
                    case '#atpro':               
                        w.opp(true); p = 1; w.cle(); w.pro(); break;
                    case '#atcle': w.opp(); p = 1; _ate.as('more'); break;
                    case '#atcef': /*w.opp();*/ p = 1; w.cef(); break;
                }
                if (!w.hash.length || w.hash == '') w.hash = '#atabc';
                if (p) window.location.hash = w.hash;
            }
        },
        // show promo
        pro : function () {
            var w = _atw, s = w.h.c.s;
            w.h.c.h('at_email');
            s('at_promo');
            s('at_success');
            w.ppr = true;
        },
        // close lightbox
        clb : function () {
            var w = window, a = _atw;
            a.mck = 0;
            if (w.addthis_popup_mode)
            {
                // if it's a popup, there's no real lightbox; close the window instead
                w.close();
            }
            else if (w.addthis_do_ab)
            {
                a.ifm('clb');
            }
            else
            {
                //if (_atw.ifpp) clearInterval(_atw.ifpp);
                var h = a.h.c.h;
                h('at_complete');
                h('at16lb');
                h('at_email');
                h('at_promo');
                h('at16p');
            }
            return false;
        },
		// clear field on focus
		cof : function(obj) {
			obj.style.color='#000000'; 
			if (obj.value==' email address') {
				obj.value='';
			}
		},
		// get service order from flash
		/*
		ord : function (arg) {
			try {
				var a = _ate;
				if (arg !== 1) {
					a.sto('_atw.ord(1)',100);
					return;
				}
				var o = this.get('atff');
				console.log("o="+o);
				if (o) {
					var arr = o.getpref('svc',['abc','def'],1);
					console.log('arr = '+arr);
				}
			} catch (e) { console.log(e); }
		},
		*/
		// show pop-up
		sho : function (atwhat) {
		  var a = _ate,
              w = _atw,
              v = _atc.ver,
              al = w.conf.ui_language,
		      _atflb = 'at16lb',
		      _athover = 'at_hover',
		      _atfeed = 'at_feed',
		      _atpriv = 'at-privacy',
		      _atshare = 'at_share',
		      _atpsf = 'at16psf',
              _atemail = 'at_email'+ (v >= 200 ? '' : 15),
              _atpit = w.get('at16pit'), /* need reference to update innerhtml */
		      _atfhover = w.get(_atw.did), 
		      _atpop = w.get('at16p'), /* need reference to update margin */
			  /*_atto = w.get('at_to'), <-- if we ever focus on To automatically */
			  _atcaption = w.get('at'+(v>=200?16:15)+'ptc'),
              n = 'none',
              doLb = false,
              h = w.h.c.h,
              s = w.h.c.s;
            /* re the hiding/showing functions above: */
            /* why do we set visibility too? IE7 simply has a rendering freakout if we set at16pit */
            /* to display:none (possibly because it's an inline element with a background image?) */

			h(_atshare);
			h(_atfeed);
			h(_atpsf, 1);
			h(_atemail, 1);
            h('at16abifc');
            h(_atpriv, 1);
			h('at_error');
			h(_athover);

			if (v >= 200) {
                h(_atfhover);
                h(_atpit, 1);
                h('at_promo');
                h('at_success');
            }

            if (atwhat=='feed') {
                h(_atshare);
                s(_atfeed);
                _atcaption.innerHTML = addthis_caption_feed;
                doLb = true;
			} else if (atwhat=='share' || atwhat=='') {
                _atfhover.style.display = '';
                h(_atpop);
                s(_athover);
                if (_atcaption) _atcaption.innerHTML = addthis_caption_share;
				atwhat='share';
			} else {
			/*} else {*/
                _atw.mck++;
                if (atwhat !== 'more') {
                    if (atwhat.indexOf('email') == -1) atwhat = 'email';
                    w.rse();
            
                    if (v >= 200) {
                        s('at16abifc');
                        w.plda();
                    
                        if (w.ppr) {
                            // must reset panel
                            w.ppr = false;
                            _atw.opp();
                            _atw.opp();
                        } 
                    }
                    s(_atemail, 1);
                    if (v >= 200) {
                        h(_atshare);
                        s(_atpit, 1);
                        s(_atpriv, 1);
                        var open = w.ipo();
                        if (_atpit) _atpit.innerHTML = '&'+(open ?'l':'r')+'aquo;';
                    } 
                    _atcaption.innerHTML = addthis_caption_email;
                    if (atwhat == 'emailab') _atw.opp();
                } else {
                    s(_atshare);
                    s(_atpsf, 1);
                    if (_atcaption) _atcaption.innerHTML = addthis_caption_share;
                }
                doLb = true;
			}
            if (doLb && v >= 200)
            {
                s(_atflb);
                // we care about the scrollable area when making the lightbox,
                // but need to subtract the scrollbar width
                // ws is the scrollable area, vs the viewport area, sbw the scrollbar width

                if (!addthis_do_ab) {
                    var ws = w.area(true), 
                        vs = w.area(),
                        sbw = w.sbw();  

                    w.h.c.sw(_atflb, (ws[0]-sbw)); // set width
                    w.h.c.sh(_atflb, (ws[1]-sbw)); // set height

                    _atpop.style.marginTop = Math.max(0, (vs[1]/2 - 445/2)) + 'px'; //'155px'; //(-255 + (w.spos())[1]) + 'px';
                } else {
                    _atpop.style.marginTop = 0;
                    _atpop.style.marginLeft = 0;
                    _atpop.style.top = 0;
                    _atpop.style.left = 0;
                }
                s(_atpop);
                if (!window.addthis_do_ab) w.fpf();
                if (atwhat=='more') {
                    w.h.c.sw(_atpop, 300);
                    w.h.c.sw('at16abifc', 300);
                    var f = w.get('at16filt');
                    if (f && f.style.display != 'none') f.focus();
                } 
                //if (atwhat == 'email') _atto.focus();
            }
			if (a.show-- > 0 && !_atc.abf) {
                var cc = w.conf.services_compact,           
                    ccl = cc.split(',').length;
				a.sev('40');
				a.cev('sho',atwhat);
                a.cev('lng',al||'en');
				a.cev('mnv',v);
                if (cc && cc !== addthis_options_default) {
                    if (ccl) a.cev('cmo',ccl);
                }
				a.img(_atc.ver+'sh','3');
			}
		},
		// trim and optionally url encode
		trim : function(s,e) {
			try {
				s = s.replace(/^[\s\u3000]+|[\s\u3000]+$/g, '');
				if (e) s = _euc(s);
				//return s.replace(/^\s+|\s+$/g,'');
			} catch (e) { }
			return s;
		},
		// generate url additional parameters
		uadd : function(svc,feed,share) {
			var t = this.trim, 
                w = _atw,
                u = t((share && share.url ? share.url : (w.share && w.share.url ? w.share.url :  addthis_url)),1),
                acs = w.conf.services_custom,
                hc = function (s) /* make sure any of our old hashes aren't lying around */
                        {
                            if (u && u != '') {
                                var i = u.indexOf('%23at'+s);
                                if (i > -1) u = u.substr(0, i);
                            }
                        };
                hc('pro');
                hc('opp');
                hc('cle');
                hc('clb');
                hc('abc');

            if (u.indexOf('addthis.com/static/r06/ab')>-1) {
                u = _duc(u);    
                u = u.split('&');
                for (var i = 0; i < u.length; i ++)
                {
                    var p = u[i].split('=');
                    if (p.length == 2) {
                        if (p[0] == 'url') {
                            u = t(p[1], 1);
                            break;
                        }
                    }
                } 
            }
       
            // find the custom service definition if there was more than one 
            if (acs instanceof Array) {
                for (var i = 0; i < acs.length; i++) {
                    if (acs[i].code == svc) {
                        acs = acs[i];
                        break;
                    }
                }
            }

            if (!w.share) w.share = {};
            var d = window,
                tmp = (w.share.templates && w.share.templates[svc] ? w.share.templates[svc] : ((share && share.templates && share.templates[svc]) ? share.templates[svc] : ''));

			return 'pub='+_ate.pub()
                   +'&source='+(w.conf.product||d.addthis_product||('men-'+_atc.ver))
                   +'&lng='+(d.addthis_language||'')
                   +'&s='+svc
                   +(feed?'&h1='+t((w.share.url || d.addthis_feed).replace('feed://',''),1)+'&t1=':'&url='+u+'&title=')
                   +t(w.share.title || d.addthis_title,1)
                   +(_atc.ver < 200 ? '&logo='+t(d.addthis_logo,1)+'&logobg='+d.addthis_logo_background+'&logocolor='+d.addthis_logo_color : '')
                   +'&ate='+_ate.sta()
                   +'&adt='+_atw.addt
                   +(w.share.description?'&desc='+w.share.description:'')
                   +(w.share.content?'&content='+t(w.share.content,1):'')
                   +(w.conf.data_track_linkback?'&sms_ss=1':'')
                   +((acs&&acs.url)?'&acn='+_euc(acs.name)+'&acc='+_euc(acs.code)+'&acu='+_euc(acs.url):'')
                   +(tmp?'&template='+t(tmp,1):'');
		},
        svcurl : function () {
            return '//'+_atd; 
        },
		// generate bookmark url with parameters
		genurl : function(svc,feed,share) {
			return _atw.svcurl() + (feed ? 'feed.php' : 'bookmark.php' ) + '?v='+(_atc.ver)+'&winname=addthis&'+_atw.uadd(svc,feed,share)+'&'+_ate.cst(4)+_ate.srd();
		},
		// calculate absolute position / offset from window root
		abpos : function(a) { 
			var e=document.documentElement,b=0,c=0,o=0,p=0,r=/fixed/;//,s='st='+e.scrollTop+' ie6='+_ate.bro.ie6+' : ';
			do { 
				//s += a.style.position + ' / ';
				o = r.test(a.style.position);
				p |= o;
				b += a.offsetTop || 0;
				c += a.offsetLeft || 0;
				if (o && a) {
					b += a.scrollTop;
					c += a.scrollLeft;
					//s += '[o '+e.scrollTop+','+e.scrollLeft+']';
				}
				a = a.offsetParent;
			} while(a); 
			if (!_ate.bro.ie6 && e.scrollTop && p) {
				b += e.scrollTop;
				c += e.scrollLeft;
				//s += '[de '+e.scrollTop+','+e.scrollLeft+']';
			}
			//alert(s+' p='+p);
			return [c,b];
		},
        // default url / title
        dut : function(iurl, ititle) {
            var d = document,
                lu = (iurl || '').toLowerCase(),
                lt = (ititle || '').toLowerCase();

            addthis_url = iurl;
            addthis_title = ititle; //.replace(/'/g, '\\\'');

            if (lu === '' || lu === '[url]' || lu === '<data:post.url/>') {
                addthis_url = location.href;
                var lks = d.getElementsByTagName('link');
                for (var i = 0; i < lks.length; i++ )
                {
                    var l = lks[i];
                    if (l.rel && l.rel == 'canonical' && l.href) addthis_url = l.href;
                }
            }
            if (lt === '' || lt === '[title]' || lt === '<data:post.title/>') addthis_title = d.title;
            return [addthis_url, addthis_title];
        },
        menu : function(elt, pane, iurl, ititle) { 
            var a = _ate, w = _atw, d = document, lu = (iurl || w.share.url || '').toLowerCase(), lt = (ititle || w.share.title || '').toLowerCase(), p = a.pub();
            if (pane == 'feed' && lu.length) {
                w.share.url = 'feed://' + lu;
            }

            // first time pop-up is shown, create menu
            if (!w.ost) {
                var wnd = window,
                    okd = wnd.onkeydown || function () {},
                    nkd = function (k) { _atw.hkd(k); okd(k); },
                    pro = w.conf.product || addthis_product;
                if (!_ate.bro.msi) {
                    wnd.onkeydown = nkd;
                }

                if (!_atc.ostm) {
                    // for pages that define conf after script, pick up late defines
                    if (!addthis_product || addthis_product.indexOf('f') !== 0) {
                        for (i in wnd.addthis_conf) {
                            _atc[i] = wnd.addthis_conf[i];
                        }
                    }
                    for (i in wnd.addthis_config) {
                        // XXX buggy now
                        w.conf[i] = wnd.addthis_config[i];
                    }
                    _atc.ostm = 1;
                }

                // ad show rate (0.0-0.x)
                w.addr = _atc.addr - Math.random();
                // ad type (int from 0-x)
                w.addt = _atc.addt >= 0 ? _atc.addt : Math.floor(3*Math.random());

                // load button swf helper code if it wasn't loaded already
                /*
                a.fcl = w.ord;
                a.lod(1);
                */

                // turn on ads for specific publishers
                //if (p == 'mjk') { w.addr = 1; }
                // exclude specified publishers from having ads show
                // myspace, weblogsinc, foxsports, ign, dmseo
                /*
                if (p !== _atu) {
                    var mn = _ate.mun(_duc(p)),
                        ma = ['6jb4','l33s','nlcv','edij','u9s7','ftho','u8l1','kcnv','ddjt','2oir','ja8b','2m6e','j7q8','eet4','u7rf','q093','q5go','6lee','rhqi','dnm7','8n9','7hs1','t1rr','73h4','5hk0','rii3','5vuh','fdv8','7n4p','ffru','96ad','slla','smrb'];
                    for (var i in ma) {
                        if (ma[i] === mn) {
                            w.addr = -1;
                            break;
                        }
                    }
                }

                // exclude non-http urls from displaying ads
                try { if (location.href.toString().indexOf('http') != 0) w.addr = -1; } catch (e) { }
                // exclude non-english-using users from seeing ads
                try { 
                    var al = (_ate.bro.msi ? navigator.userLanguage : navigator.language);
                    if (al && al.indexOf('en') == -1) w.addr = -1; 
                } catch (e) { }
                */

                w.addr = -1;
                w.ti = 1;

                // absolutely horrific space-saving functions
                var md = w.h.dv,
                    cs = '</span>',
                    ca = '</a>',
                    msp = w.h.sp,
                    mlb = w.h.lb,
                    min = function (i,e,v,z) { return '<input id="'+i+'" '+(addthis_do_ab?'class="abif" ':(_ate.bro.ffx && _ate.bro.mode == 2 ?'class="atfxmode2"':''))+'name="'+i+'" type="text" tabindex="'+(_atw.ti++)+'" '+(v?'value="'+v+'" ':'')+'size="'+(z?z:30)+'"'+e+'/>';},
                    al = w.conf.ui_language,
                    optional = w.lang(al,20),
                    eaddr = w.lang(al,19),
                    datr = md('', 1, 1),
                    cd = '</div>',
                    cl = '<div style="clear:both;">' + cd,
                    brc = '<br clear="all"/>',
                    /*rsf = function (t) { return '_atw.rsf(this,\''+t+'\')'; },*/
                    /*ofrs = function (t) { return 'onfocus="_atw.rse();'+rsf(t)+';" onblur="'+rsf(t)+'"'; },*/
                    ofrs = function (f) { return 'onfocus="_atw.rse();'+(f||'')+'"';}, 
                    efr = function (i,l,v,z,vv) { return /*datr + */mlb(l,i,v) + min(i,ofrs(),vv,z) /*+ brc*//* + cd*/; }, 
                    rss = window.addthis_feed || (w.share.url.indexOf('feed://') > -1) || w.hf, // true iff. addthis_feed was defined somewhere
                    hb = w.conf.ui_header_background,
                    hbs = (hb != '' ? ' style="background-color:'+hb+'"':""),
                    hc = w.conf.ui_header_color,
                    hcs = (hc!=''?' style="color:'+hc+'"':''),
                    cap = addthis_caption_share,
                    tb = ' target="_blank"',
                    exc = (w.conf.services_exclude || '').replace(/\s/g,'').replace(/\*/,''),
                    s = '<div id="at16lb"'+(_ate.bro.msi ? ' style="filter:alpha(opacity=0.001);"':'')+' onclick="return _atw.clb()">' + cd; // the lightbox, and the beginning of the huge html string

                // Define custom services (need to insert a style block)
                var o = (w.conf.services_compact || addthis_options_default).replace(/\s/g,'').replace(/\*/,''), 
                    osl = _atw.loc[w.conf.services_localize],
                    map = { aolfav: 'myaol', skrt: 'kirtsy', bluedot: 'faves', su:'stumbleupon', goog:'google' }, acs = w.conf.services_custom,
                    unp = addthis_options_rank.split(',');
                // add localized services to the hover if the hover was not customized
                if (osl && w.conf.services_compact == addthis_options_default) {
                    var i = 0;
                    for (var k in osl) {
                        // before increasing the size of the hover, peel off the least popular items
                        if (i < unp.length) {
                            o = o.replace(unp[i], k);
                        } else {
                            if (o.indexOf(k) == -1) o += ',' + k;
                        }
                        w.list[k] = osl[k];
                        i++;
                    }
                }
                // bring up visited services
                if (_ate.vst.length) {
                    for (var i = 0; i < Math.min(8, _ate.vst.length); i++) {
                        var svc = _ate.vst[i];
                        if (o.indexOf(svc) > -1) {
                            continue;
                        } else {
                            if (i < unp.length) {
                                o = o.replace(unp[i], svc)
                            } else {
                                o += ',' + svc;
                            }
                        }
                    }
                }
                o = o.split(',');
                // move more to the end
                for (var i = 0; i < o.length; i++) {
                    if (i < o.length - 1 && o[i] == 'more') {
                        var m = o.splice(i, 1);
                        o.push(m[0]);
                        break; 
                    }
                }

                if (acs) {
                    // custom service could be an object or array of objects; go overloading!
                    // we convert it into a 1-length array if it's the former
                    if (!(acs instanceof Array)) acs = [acs];
                    for (var i = 0; i < acs.length; i++) {
                        var service = acs[i];
                        if (service.name && service.icon && service.url && w.vur(service.url)) {
                            service.code = service.url = service.url.replace(/ /g,''); // in case of bad input
                            var qi = service.url.indexOf("?");
                            if (qi > -1) service.code = service.url.substr(0, qi);
                            if (service.code[service.code.length - 1] == '/') service.code = service.code.substr(0, service.code.length - 1);
                            service.code = service.code.split(".").slice(-2).join(".").toLowerCase();
                            if (service.code.indexOf("http") === 0) service.code = service.code.substr((service.code.indexOf('https') === 0 ? 8 : 7));
                            var cc = service.code.replace(/./g,"\\.");
                            w.list[service.code] = service.name;
                            w.css[service.code] = 'background:url('+service.icon+') no-repeat left'; 
                            if (i == 0) {
                                var sv = o.pop();
                                if (sv !== 'more') o.push(sv);
                                // the very first custom service gets to be in the hover menu
                                o.push(service.code);
                                if (sv === 'more') o.push(sv);
                            }
                        }
                    }
                }

                // the 'pop' container; i.e., the lightboxed content
                s += md('at16pcc')
                   + md('at16p', !rss && _atc.ver >= 200 ? 1 : 0)
                   + w.h.a('atabc') + w.h.a('atpro') + w.h.a('atclb') + w.h.a('atopp') + w.h.a('atcle') + w.h.a('atcef')
                   + md('at16pib')
                   + md('at16pi');
            
                // for ab
                s += (!addthis_do_ab && addthis_use_addressbook ? '<a id="at16pit" href="#" onclick="return _atw.opp()" style="display:none">&raquo;'+ca : ''); 

                s += md('at16pp', 0) + cd;

                s += md('at16pm', 1, 0, (_ate.bro.mod == 2 ? 'style="width:299px"' : (_ate.bro.mod==0?'style="width:300px"':'')));
                s += md('at16pt',1,0,hbs);
                if (cap == w.lang(al,1) && pane == 'feed') cap = w.lang(al, 14);
                s += '<h4><span id="at16ptc"'+hcs+'>'+cap+cs+'</h4><span id="at16_brand"'+hcs+'>'+w.conf.ui_cobrand+cs;
                s += '<a id="at16ptx" href="#" onclick="return _atw.clb()"'+hcs+'>X</a>'; 
                s += cd;
                //s += '<div id="at16pc">';
                s += md('at16pc',1,'at_default');     // addthis-pop-content 

                /* rss div, in case a feed is shared */
                var list = w.rss;

                s += md('at_feed', 0);  // hidden by default
                s += '<span style="display:block">'+w.lang(al,15)+cs /*Select from these web-based feed readers*/ + '<br/>';
                var i = 1;
                for (var sv in list)
                {
                    if (exc.indexOf(sv) > -1) continue;
                    s += '<div'+w.ie6()+ (i % 2 === 0 ?' class="at_litem"':'') + (' onclick="return addthis_sendto(\''+sv+'\');">') + '<a class="fbtn at_baa '+sv+'">'+list[sv]+'</a>' + cd;
                    i++;
                }
                s += cd;
                /* end rss */     
                
                s += md('at_share');

                s += md('at16psf');    // addthis-pop-services-filter
                s += min('at16filt', 'maxlength="50" onkeyup="_atw.filt(this.value,_atw.list)"','');
                //s += '<a id="at16psfx" href="#" onclick="this.value=\'\';return false;" title="X"></a>';
                s += cd;    // close -filter
                s += md('at16ps', 1, 0, (_ate.bro.mod == 2 ? 'style="height:292px"' : ''));
                s += md('at16nms', 0) + ((al == 'en' || al == '') ? w.lang(al,36) /*No matching services */ : '') + cd;

                list = w.list;
                //var i = 0, j = 0;
            
                var ll = w.conf.services_expanded || [],
                    pc = w.conf.product || addthis_product;
                // not alphabetized
                if (!w.conf.services_expanded) for (var sv in list) ll.push(sv);
                else ll = ll.split(',');
                ll.sort();

                for (i = 0; i < ll.length; i++) {
                    var sv = ll[i],
                        css = (w.css[sv] ? ' style="'+w.css[sv]+'"' : '');

                    // note: this will break if a service code ever contains another as a complete subset;
                    //       unlikely to occur, and this is more efficient
                    if (exc.indexOf(sv) > -1) continue;
                    if (sv !== 'more' && !(sv === 'email' && (a.pub() === '' && pc.indexOf('ffext') == -1 && pc.indexOf('fxe') == -1))) {
                        s += '<div'+w.ie6()+' id="ati_'+sv+'" class="at_item"' + css + ' onmouseover="_atw.hov(this)" onmouseout="_atw.hov(this)" '+(sv == 'favorites' && a.bro.opr ? ' rel="sidebar" href="'+lu+'"' : 'onclick="return addthis_sendto(\''+sv+'\');">') + msp('at15t at15t_'+sv, true, css) + list[sv] + cs + cd; 

                    }
                }
                s += cd;
                
                s += cl + cd;
                //if (rss) s += '<input type="checkbox" id="at_remember"/> ' + _atw.lang(al, 16);
                s += md("at_complete", 0);
                //s += md('at_s_msg') + w.lang(al,13)+cd;
                s += '<button onclick="_atw.clb()">'+w.lang(al,17)+'</button>';
                s += cd;
                s += md('at_success', 0) + w.lang(al, 13) + ' <a href="#" onclick="'+(addthis_do_ab?'_atw.ifm(\'cle\');_atw.rse();return false':'_atw.get(\'at16filt\').value=\'\';_atw.filt(\'\',_atw.list);return _ate.as(\'more\')')+'">'+_atw.lang(al,37)/*Share again*/+'</a>' + cd; 
                s += md('at_error', 0, null, 'class="at_error"') + cd;

                if (true) // || _atc.ver >= 200) // we think we can omit this safely
                {
                    if (a.bro.ffx && (!al || al.indexOf('en')>-1)) {
                        // @todo compress 
                        s += md('at_promo');
                        s += '<div class="at-promo-btm at-promo-content">';
                        s += '<h4>AddThis for Firefox<sup>NEW</sup></h4>';
                        s += '<span>Bookmark, email or share any page, anytime.' + cs;
                        s += '<div class="at-promo-btn"><a href="http://'+_atd+'landing/?to=ffext&utm_source=el&utm_medium=link&utm_content=ATTool_orig&utm_campaign=AT_tooldl" target="_blank">Install</a>';
                        s += cd + cd + cd;
                    } else {
                        s += md('at_promo', 0) + cd;
                    }
                    s += md('at_email', 0);

                    if (addthis_use_addressbook) s += '<div id="at_head" class="tmsg"><a id="at_use_addr" href="#" onclick="'+(addthis_do_ab?'_atw.ifm(\'opp\');_atw.abtd()':'_atw.opp()')+';return false">'+w.lang(al,25)/*Use Address Book*/+'</a>' + cd;    // @todo lang 6 goes away 
                    s += '<form onsubmit="addthis_send();return false;">';

                    s += mlb(w.lang(al,7), 'at_to', eaddr);                 
                    s += '<textarea id="at_to" '+(addthis_do_ab?'class="abif" ':(_ate.bro.ffx && _ate.bro.mode == 2 ?'class="atfxmode2"':''))+'cols="30" rows="4" '+(!_ate.bro.ffx?'style="resize:none"':'')+' onkey'+(a.bro.ffx?'press':'down')+'="_atw.htkd(this, event)" onkeyup="_atw.filt(this.value.replace(/;/g,\',\').replace(/ /g,\'\').split(\',\').pop(), _atw.data.contacts.all, \'at16eatdr\', \'_ataddr\')" tabindex="'+(w.ti++)+'" '+ofrs()+' >'+(addthis_do_ab?addthis_eto:'')+'</textarea>';

                    s += md('at16eatdr', 0, 0, addthis_do_ab?' class="abif"':'') + cd;

                    var cfrm = _ate.rck('at-from');
                    s += efr('at_from', w.lang(al, 8), eaddr, 0, (addthis_do_ab?addthis_efrom||cfrm:cfrm));

                    s += mlb(w.lang(al,9), 'at_msg', optional);                 
                    s += '<textarea id="at_msg" style="resize:none" '+(addthis_do_ab?'class="abif" ':(_ate.bro.ffx && _ate.bro.mode == 2 ?'class="atfxmode2"':''))+'cols="30" rows="4" tabindex="'+(w.ti++)+'" onkeyup="return _atw.lml(this,250);" '+ofrs()+'">'+(addthis_do_ab?addthis_enote:(_atc.enote==''?'':_atc.enote))+'</textarea>';  
                    s += '<div id="ateml"><small>'+w.lang(al,21)+'</small>'+cd;
                    var pp = w.lang(al,10);
                    var ppc = (pp.indexOf(':')),
                        pps = '';
                    if (ppc > 0) {
                        pps = pp.substr(ppc+1);
                        pp = pp.substr(0, ppc);
                    }

                    s += '<div id="addthis-pop-email-btns">';
                    s += '<input class="atbtn" type="submit" tabindex="'+(w.ti++)+'" value="'+w.lang(al,11)/*Sign in*/+'" onclick="return addthis_send();"/>';
                    s += '<input class="atbtn" type="reset" tabindex="'+(w.ti++)+'" value="'+w.lang(al,26)/*Cancel*/+'" onclick="return _atw.cef()" style="font-weight:normal;color:#666;" />';
                    s += cd;

                    s += '</form>';
                    s += cd;
                }
                
                s += cd;

                var ft0 = md('at16pf'),
                    f0 = ' class="at_baa"',
                    ft1 = ft0,
                    ft2 = ((al == '' || al == 'en') ? '<a id="at-whatsthis" href="http://'+_atd+'features?utm_source=hm&utm_medium=link&utm_content=WhatsThis_orig&utm_campaign=AT_features" target="_blank">'+w.lang(al,23)/*What's this?*/+'</a>' : '');
                    ft0 += ft2 + ((al == 'en' || al == '') ? '<a id="at-privacy" href="http://'+_atd+'privacy" target="_blank">'+w.lang(al,24)+'</a>' : '');
                var f1 = '<a'+f0+' id="at-logo" href="http://'+_atd+'?utm_source=mm&utm_medium=img&utm_content=ATLogo_orig&utm_campaign=AT_main" title="AddThis"'+tb+'>AddThis</a>' + cd;
                ft0 += f1;
                ft1 += ft2 + f1;
                s += (!addthis_do_ab ? ft0 : '') + cd + cd + cd + cd + cd;

                // header
                var ai = 'at15a',
                    af = '<iframe class="at15a" id="'+ai+'Z" src="" scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe>';
                    /*dc = '<div class="at15e_row"'*/
                    /*e1 = dc+'><label for="">',*/
                    /*e2 = '</label><input class="at15ti" type="text" size="20" maxlength="80" value=" email address" onfocus="_atw.cof(this)" ';*/

                    s += '<div id="'+w.did+'" onmouseover="_atw.xwa()" onmouseout="addthis_close()" style="z-index:1000000;position:absolute;display:none;visibility:hidden;top:0px;left:0px">';
                    s += md("at15s_head",1,0,hbs) + '<span id="at15ptc"'+hcs+'>'+addthis_caption_share+'</span><span id="at15s_brand"'+hcs+'>'+w.conf.ui_cobrand+'</span>' + cd;

                    //  top ad frame
                    if (w.addr >= 0) { s+= af.replace('Z','1'); }

                    if (_atc.ver < 200)
                    {
                        var dc = '<div class="at15e_row"',
                        e1 = dc+'><label for="">', /*cl = '<div style="clear:both;"></div>',*/
                        e2 = '</label><input class="at15ti" type="text" size="20" maxlength="80" value=" email address" onfocus="_atw.cof(this)" ';

                        // email pane
                        s += md('at_email15', 0);
                        s += e1+w.lang(al, 7)+':'+e2+' id="at_to" />'+cd;
                        s += e1+w.lang(al, 8)+':'+e2+' id="at_from" value="'+_ate.rck('at-from')+'"/>'+cd;
                        s += dc+' style="height:60px;"><label for="at_msg">'+w.lang(al, 9)+':</label><textarea id="at_msg" name="" cols="30" rows="3" style="width:150px;">'+_atc.enote+'</textarea>'+cd;
                        s += e1+'&nbsp;</label><input id="at_send" onclick="return addthis_send()" type="button" value="'+w.lang(al, 11)+'"/>'+cd;
                        s += cl+cd;
                    }

                    // hover pane 
                    // @todo combine with at_share; basically the same code here
                    s += md('at_hover', 0);
                    for (var i=0; i<o.length; i++) {
                        var sv = o[i], list = w.list, numServices = 0,
                            css = (w.css[sv] ? ' style="'+w.css[sv]+'"' : '');
                        if (sv in list) {
                            if (exc.indexOf(sv) > -1) continue;
                            if (sv !== 'email' || (a.pub() !== '' || (pc.indexOf('ffext') > -1 || pc.indexOf('fxe') > -1))) {
                                if (sv === 'more') {
                                    for (var i in list) numServices++;
                                }
                                s += '<div'+w.ie6()+' class="at_item at_col'+(i%2)+'"'+css+' onmouseover="_atw.hov(this)" onmouseout="_atw.hov(this)" onclick="return addthis_sendto(\''+sv+'\');"><span class="at15t at15t_'+sv+'"'+css+'>'+list[sv]+(sv==='more'&&al!='ja'&&al!='fr'&&al!='he'&&al!='it'?' ('+(numServices)+')':'')+cs+cd;
                            }
                        } 
                    }
                    s += cl+cd;
                    //  bottom ad frame
                    if (w.addr >= 0) { s+= af.replace('Z','2'); }

                    // footer
                    s += ft1.replace('mm','hm');

                // add div dropdown to document body
                w.div = d.ce('div');
                w.div.id = 'at20mc';
                w.div.innerHTML = s;

                // insert div into dom
                d.body.appendChild(w.div);
                w.div.style.zIndex = 1000000;
                w.div = null;
            } else {
                // showing a menu after it's been built; have to update some display items from conf
                // for now, language is a one-time global

                var b15 = w.get('at15s_brand'),
                    b16 = w.get('at16_brand'),  
                    bco = w.conf.ui_cobrand,
                    h15 = w.get('at15s_head'),
                    h16 = w.get('at16pt'),
                    h16s = w.get('at16ptc'),
                    h16x = w.get('at16ptx'),
                    h15s = w.get('at15ptc'),
                    uihc = w.conf.ui_header_color,
                    uihb = w.conf.ui_header_background;

                if (b15) b15.innerHTML = bco;
                if (b16) b16.innerHTML = bco;

                if (h15) h15.style.backgroundColor = uihb;
                if (h16) h16.style.backgroundColor = uihb;
                if (h16x) h16x.style.color = uihc;
                if (h16) h16.style.color = uihc;
                if (h16s) h16s.style.color = uihc;

                /*if (h15) h15.style.color = uihc; */
                if (b15) b15.style.color = uihc;
                if (h15s) h15s.style.color = uihc;
            }

            w.xwa(); 

            w.dut(iurl, ititle);

            var tdelta = 16, imgs = elt.getElementsByTagName('img'), spans = elt.getElementsByTagName('span');
            if (imgs && imgs[0]) {
                elt = imgs[0]; 
                tdelta = 0; 
            } else if (_atc.ver > 200 && elt.className && elt.className.indexOf('addthis_button')>-1 && spans && spans[0]) {
                elt = spans[0];
                tdelta = 0;
            } else if (a.bro.saf || a.bro.chr) {
                // no images. if only a text node exists, kill tdelta
                if (elt.childNodes && elt.childNodes.length == 1 && elt.childNodes[0].nodeType == 3) tdelta = 0;
            }

            w.sho(pane);

            // ignore in backwards compatibility mode
            if (_atc.ver < 200 || (pane != 'email' && pane != 'feed' && pane != 'more'))
            {
                //position and show the dropdown
                var totpos     = w.abpos(elt),
                    lpos       = totpos[0]+parseInt(w.conf.ui_offset_left),
                    tpos       = totpos[1]+tdelta+1+parseInt(w.conf.ui_offset_top),
                    windowsize = w.area(),
                    scrollpos  = w.spos(),
                    dropdown   = w.get(w.did) || {style: 0},
                    dropstyle  = dropdown.style,
                    dir        = 0,
                    hoverdir   = w.conf.ui_hover_direction || 0;

                if (dropstyle === 0) {
                    w.ost = true;
                    return false;
                }

                // needed here to obtian a valid width and height
                dropstyle.display = '';

                var dropwidth  = dropdown.clientWidth,
                    dropheight = dropdown.clientHeight;

                // check for pop-left insteadof pop-right of button
                if (lpos-scrollpos[0] + dropwidth + 20 > windowsize[0]) {
                    lpos = lpos - dropwidth + (elt.clientWidth || 50);
                    dir++;
                }
                // check for pop-over instead of under button
                if (hoverdir == 1 || ((tpos-scrollpos[1] + dropheight + elt.clientHeight + 20 > windowsize[1]) && hoverdir != -1)) {
                    tpos = tpos - dropheight - 20;
                    dir+=2;
                }
                if (a.show >= 0) {
                    a.cev('dir',dir);
                }
                
                // hide embed elements that intersect with dropdown coordinates
                if (w.conf.ui_hide_embed) {
                    var rpos = lpos + dropwidth, // dropdown right
                        bpos = tpos + dropheight, // dropdown bottom
                        e = d.gn('embed'),
                        etotpos = 0, elpos = 0, etpos = 0;
                    // iterate over embed objects
                    for (i=0; i < e.length;i++) {
                        etotpos = w.abpos(e[i]);
                        elpos = etotpos[0];
                        etpos = etotpos[1];
                        if (lpos < elpos + e[i].clientWidth && tpos < etpos + e[i].clientHeight) {
                            if (rpos > elpos && bpos > etpos) {
                                if (e[i].style.visibility != 'hidden') {
                                    e[i].addthis_hidden = true;
                                    e[i].style.visibility = 'hidden';
                                }
                            }
                        }
                    }
                }

                if (elt.className.indexOf('at300m') == -1) {
                    // calc final tpos
                    tpos += elt.clientHeight;
                }

    /* no ads, commented out
                // first time pop-up is shown, do ad setup and (possibly) swf/service order config
                if (!w.ost) {
                    // handle ad setup
                    if (w.addr >= 0) {
                        a.ab = w.addt;
                        // if ab === 2, setup for google ads
                        var nl = (a.ab === 3 ? 65 : 1);
                        /*
                         * number of text link lines
                         * 1,2,3 = snap links
                         * 65 = google single ad
                         * 95 = google test links
                         * 155 = amazon
                         * 205 = google rich media
                        // should end comment
                        var dn=dir&2, lines=nl, pxl=lines * 23, atf=w.get(ai+(dn?1:2));
                        // large ads are values > 3 in pixels, not lines
                        if (lines > 3) {
                            pxl = lines;
                        }
                        /*
                        if (lines > 250) {
                            dropdown.style.width = '310px';
                        } else if (lines > 50 && lines < 100) {
                            dropdown.style.width = '240px';
                        }
                        // should end comment
                        // if not cell 0, set frame url
                        if (a.ab) {
                            atf.src = w.svcurl()+'ads-next.php?r='+a.ran()+'&url='+_euc(addthis_url)+'&ate='+a.sta()+'&adt='+w.addt+'&pub='+a.pub()+'&lnz='+lines+'&key='+(_atc.skey || '');
                        }
                        //var r = dn ? pxl : pxl/16, t = dn ? tpos : false;
                        var r = pxl/16, t = dn ? tpos : false;
                        switch (a.ab) {
                            case 1: w.sla(atf,pxl,5,r,1,t); break;
                            case 2: w.sla(atf,pxl,5,r,1,t); break;
                            //case 3: w.sla(atf,pxl,5,pxl,0); break; // start fully open
                            //default: break; // do nothing
                        }
                        // when popping up, compensate for ad size when positing div
                        //if (dn) {
                        //	tpos -= pxl;
                        //}
                    } else {
                        a.ab = '~';
                    }
                }
     */

                // defer seting top/left until after ad calcs in case
                // it's pop-over and requires shifting up for aesthetics
                dropstyle.left = lpos + 'px';
                dropstyle.top = tpos + 'px';
                dropstyle.visibility = 'visible';
            } 

            // set 'setup done' flag true
            w.ost = true;
        },
		// determine browser window viewable area
        // cs : true iff. scrollwidth/height should be considered
		area : function(cs) {
			var w = window, d = document, de = d.documentElement, db = d.body, xs = 0, ys = 0, ww = 0, wh =0;
   
            if (cs) { 
                if (w.innerHeight && w.scrollMaxY) {  
                    xs = db.scrollWidth;
                    ys = w.innerHeight + w.scrollMaxY;
                } else if (db.scrollHeight > db.offsetHeight) { 
                    xs = db.scrollWidth;
                    ys = db.scrollHeight;
                } else { 
                    xs = db.offsetWidth;
                    ys = db.offsetHeight;
                }
            }
    
            if (self.innerHeight) { // Non-IE
                ww = self.innerWidth;
                wh = self.innerHeight;
            } else if (de && de.clientHeight) { // IE 6+ in 'standards compliant mode'
                ww = de.clientWidth;
                wh = de.clientHeight;
            } else if (db && ( db.clientWidth || db.clientHeight ) ) { // IE 4
                ww = db.clientWidth;
                wh = db.clientHeight;
            } else if (db) { // other IE
                ww = db.clientWidth;
                wh = db.clientHeight;
            }   
        
            return [(cs !== true || xs < ww ? ww : xs),(cs !== true || ys < wh ? wh : ys)];
            
		},
        // scrollbar width (needed so lightbox is width of page without scrollbars)
        // lame, expensive; @todo consider using table
        sbw : function () {
            try
            {
                var a = d.createElement('div'),
                    b = d.createElement('div'),
                    y = (d.getElementsByTagName('body'))[0];
                with (a.style)
                {
                    width='50px';
                    height='50px';
                    overflow='hidden';
                    position='absolute';
                    top='-200px';
                    left='-200px';
                }
                b.style = 'height:100px';
                y.appendChild(a);
                a.appendChild(b);
                var w1 = b.innerWidth; 
                a.style.overflow='scroll';
                var w2 = b.innerWidth;
                a.removeChild(b);
                y.removeChild(a);
                
                return w1 - w2;
            }
            catch (e)
            {
                return 20;
            }
        },
		spos : function() {
			var w = window, d = document, de = d.documentElement, db = d.body;
			if (typeof( w.pageYOffset ) == 'number' ) {
				//Netscape compliant
				return [w.pageXOffset, w.pageYOffset];
			} else if (db && ( db.scrollLeft || db.scrollTop ) ) {
				//DOM compliant
				return [db.scrollLeft, db.scrollTop];
			} else if (de && ( de.scrollLeft || de.scrollTop ) ) {
				//IE6 standards compliant mode
				return [de.scrollLeft, de.scrollTop];
			} else {
				return [0,0];
			}
		},
		// ensure that all variables are initialized correctly
		evar : function() {
			try {
                var w = _atw,
                    // set a var if undefined
                    x = function (v,n,i) {
                        if (!i) i = window;
                        if (!i[v]) i[v] = n;
                        return i[v];
                    }
				// initialize configuration vars if unset by publisher
				var a = 'addthis_', s = 'services_', l = a+"logo", h = a+"header", c = a+"caption_", o = a+"offset_", al = x(a+'language',(window.addthis_config || {}).ui_language || w.conf.ui_language || (_ate.bro.msi ? navigator.userLanguage : navigator.language)), uab = false;

                if (al === '' || al.indexOf('en') === 0) uab = true;
				x(a+'localize',0);
				x(a+'feed','');
				x(a+'wpl');
                w.hf = (addthis_feed.length > 0);
				x(c+'email', w.lang(al,3));
				x(a+'caption',w.lang(al,1));
				x(a+'use_addressbook',uab);
				x(a+'do_ab',false);
				x(a+'product','men-'+_atc.ver);
				w.list['more'] = w.lang(al,2);
				w.list['email'] = w.lang(al,4);
				w.list['favorites'] = w.lang(al,5);
				w.list['print'] = w.lang(al,22);
				x(a+'popup',false);      // internal
				x(a+'popup_mode',false); // internal    
				x(a+'url','');           
				x(a+'append_data',false); // deprecated
				x(a+'brand',''); 
				x(a+'title','');
				x(a+'content','');
				x(a+'options_default','email,favorites,print,delicious,digg,google,myspace,live,facebook,stumbleupon,twitter,more');
				x(a+'options_rank','stumbleupon,delicious,digg,live,google,myspace,facebook,twitter,print,favorites,email');
				x(a+'options',addthis_options_default);
				x(a+'exclude','');
				x(l,'');
				x(l+'_background','');
				x(l+'_color','');
				x(h+'_background','');
				x(h+'_color','');
				x(c+'share', addthis_caption);
				x(c+'feed', w.lang(al,14));
				x(o+'top', 0);
				x(o+'left', 0);
				x(a+"hide_embed", false);
				x(a+"share", {});
        
                var cc = w.conf && !w.ioe(w.conf) ? w.conf : window.addthis_config || {},
                    as = w.share || window.addthis_share || {};
                x('type', 'link', as);
                x('url', addthis_url, as);
                x('title', addthis_title, as);
                x('desc', '', as);
                x('thumbnail', '', as);
                x('author', '', as);

                x('username', window.addthis_pub, cc);
                x(s+'custom', [], cc);
                x(s+'compact', addthis_options, cc);
                x(s+'localize', addthis_language, cc);
                x(s+'expanded', '', cc);
                x(s+'exclude', addthis_exclude, cc);
                x('ui_click', false, cc);
                x('ui_hover_direction', 0, cc);
                x('ui_delay', window.addthis_hover_delay, cc);
                x('ui_language', addthis_language, cc);
                x('ui_hideEmbed', addthis_hide_embed, cc);
                x('ui_localize', addthis_localize, cc);
                x('ui_offset_top', addthis_offset_top, cc);
                x('ui_offset_left', addthis_offset_left, cc);
                x('ui_header_color', addthis_header_color, cc);
                x('ui_header_background', addthis_header_background, cc);
                x('ui_icons', true, cc);
                x('ui_cobrand', addthis_brand, cc);
                x('data_omniture_collector', '', cc);
                x('data_track_linkback', addthis_append_data, cc);
               
                w.conf = cc; 
                w.share = as; 
			} catch (e) {
                //console.log('evar',e);
			}
		}
	};

	// public function
	_ate.ao = function(elt, pane, iurl, ititle, iconf, ishare) {
        var w = _atw;
        // in the newer API, we can update our configuration before opening
        if (_atc.ver >= 250) {
            if (iconf) {
                w.conf = iconf;
            }
            if (ishare) {
                w.share = ishare;
            }
        }
        // if iconf/ishare were filled out, they'll be the basis of the new configuration
        // (not the global addthis_config/addthis_share) when we run evar()
        // this is relatively safe since we merge the globals with the local configuration 
        // before calling this method when used internally.
        w.evar();
        var rv = w.dut(iurl, ititle);
        if (iurl) w.share.url = rv[0];
        if (ititle) w.share.title = rv[1];
		var a = _ate, d = document, lu = (iurl || w.share.url || '').toLowerCase(), lt = (ititle || w.share.title || '').toLowerCase(), p = a.pub(), athd = w.conf.ui_delay;

        if (athd && pane == '') {
            // from http://portal.acm.org/citation.cfm?doid=634067.634255:
            //
            // In this research, we attempt to establish thresholds of detection for changes in a graphical 
            // user interface using adaptive tracking. For keyboard interactions, subjects did not notice delays 
            // of approximately 150 milliseconds. In contrast, for mouse interactions, subjects did not notice delays 
            // of up to 195 milliseconds. Given these findings, further research is clearly needed to firmly establish 
            // lower bounds on application responsiveness so that software and operating system engineers can more 
            // precisely tune the interactive real-time responsiveness of their systems

            athd = Math.min(500, Math.max(50, athd)); // min delay is 50ms, max is 500ms by policy
            w.xhwa();
            w.hwa = null;

            if (elt == 'hwe') {
                elt = w.hwe;
                w.hwe = null;
            } else {    
                w.hwe = elt;
                w.hwa = a.sto("_ate.ao('hwe','"+pane+"','"+iurl+"','"+(ititle?ititle.replace(/'/g,"\\'"):'')+"')",athd);
                return;
            }
        } 

        w.menu(elt, pane, iurl, ititle);

		return false;
	}

	// public function
	_ate.ac = function() {
		_atw.xhwa(); // cancel opening
		_atw.cwa = _ate.sto("_atw.clo()",_atc.cwait)
	}

	// public function (addthis_sendto internal)
	_ate.as = function(s, config, share) {
		var w = window, d = document, a = _atw, e = _ate, 
            share = share || addthis_share,
            config = config || a.conf || addthis_config,
            au = share.url, at = share.title, v = _atc.ver;

        if (!a.ost || !au) {
            // assume this was a naked invocation
            var rv = a.dut(au, at);
            au = rv[0];
            at = rv[1];
            //a.evar();
        }

		if (s !== 'more' && config.data_omniture_collector) {
            var i = d.ce("IFRAME"); 
            i.setAttribute("src", addthis_omniture_collector + "?sms_ss=" + s + "&sms_sa="+_euc(at) + "&sms_st=" + (s === 'email' ? 'Email' : 'Social Web'));
            w.h.c.sw(i,1);
            w.h.c.sh(i,1);
            d.body.appendChild(i); 
        }

		if (s === 'email') {
			a.sho(s);
			return false;
		}

		a.clo();
		if (s === 'favorites') {
            if (a.conf.data_track_linkback)
            {
                if (au.indexOf('?') == -1) au += '?';
                else au += '&';
                au += 'sms_ss=favorites';
            } 
			try {
				if (e.bro.saf || e.bro.chr) {
					alert('Press <'+(e.bro.win?'Control':'Command')+'>+D to bookmark in '+(e.bro.chr ? 'Chrome':'Safari'));
				} else if (e.bro.opr) {
					alert('Press <'+(e.bro.win?'Control':'Command')+'>+T to bookmark in Opera');
                } else if (document.all) {
					w.external.AddFavorite(au, at);
				} else {
					w.sidebar.addPanel(at, au, '');
				}
				(new Image()).src = a.genurl(s);
                if (v >= 200) a.clb(); // close the light box
				return false;
			} catch (e) {
				// alert(e);
			}
		} 

        // if nothing was selected, probably we're falling through from
        // a click on the button; since we have js access, we can show
        // the more menu if this is v200+
        if (w.addthis_popup !== true && v >= 200 && (!s || s === 'more')) {
            s = 'more';
            a.sho(s);
            return false;
        } 

		if (s === 'print') {
            w.print();

            if (v >= 200) a.clb(); // close the light box before printing
            (new Image()).src = a.genurl(s);
            return false;
        }

        var fd = ((au || w.addthis_feed || '').indexOf('feed') == 0) &&  _atw.rss[s] ? 1 : 0;
        if ((v < 200 || w.addthis_popup) && (!s || s === 'more')) w.open(a.genurl(s,fd,share), 'addthis', 'scrollbars=no,menubar=no,width='+(v>=200?'522,height=444':'625,height=495')+',resizable=no,toolbar=no,location=no,status=no');
		else w.open(a.genurl(s,fd,share), 'addthis');

		if (s) {
			e.cev('sct', e.scnt++);
		} else {
			e.cev('clk', e.clck++);
		}

        // we close the lightbox after opening the new window because ffx3 on windows
        // succeeds in closing the window when we're in popup mode (i.e., bookmark.php)
        // before the new window request gets pushed on to the stack
        if (v >= 200) a.clb();
	}

	// public function
	function addthis_send() {
        var   v = _atc.ver,
              w = _atw,
              fe = w.fe,
              lb = v >= 200,
              _atfrom  = w.get('at_from'),
              _atto    = w.get('at_to'),
              _success = w.get('at_' + (lb ? 'success' : 'send')),
              _promo = (lb ? w.get('at_promo') : _success),
              _atemail = w.get('at_email'+ (lb ? '' : '15')),
              _atmsg   = w.get('at_msg'),
              e = 'at_error',
              al = w.conf.ui_language,
              ve = w.vem,
              hadErr = 0;

        if (lb) {
            w.rse();
        }

        var es = _atto.value.replace(/;/g,',').split(',');
        if (es.length > 20) {
            w.err(w.lang(al,34), _atto, e);
            hadErr = 1;
        } else {
            for (var i = 0; i < es.length; i++)
            {
                var add = es[i],
                    afb = add.indexOf('<'),
                    afe = add.indexOf('>');
                if (afb > -1) add = add.substr(afb + 1);
                if (afe > - 1) add = add.substr(0, afe - afb - 1);
                if (!ve(add)) {
                    w.err(w.lang(al,12), _atto, e);
                    hadErr = 1;
                    break;
                } 
            }
        }
        if (!ve(_atfrom.value)) {
            w.err(w.lang(al,12), _atfrom, e);
            hadErr = 1;
        } 
        if (_atmsg.value.length > 250) {
            w.err(w.lang(al,17), _atmsg, e);
            hadErr = 1;
        }

        if (!hadErr) {
            var msg = _atmsg.value;
            if (msg == w.lang(al, 20)) msg = '';
            
            _ate.sck('at-from', _atfrom.value);
            var isrc = w.svcurl() +'tellfriend.php?&fromname=aaa&fromemail='+_euc(_atfrom.value)+'&tofriend='+_euc(_atto.value.replace(/;/g,','))+'&note='+_euc(msg)+'&'+w.uadd('e');
            // might work around AI problem
            /*if (document.createElement) {
                img = document.createElement('img');
                img.setAttribute('src', isrc);
                document.body.appendChild(img);
              } else {
            */
            (new Image()).src = isrc;

            if (lb)
            {
                w.ppr = true;
                if (addthis_do_ab) {
                    w.cle();
                    w.ifm('pro');
                    //w.get('at16pp').style.display = 'none';
                } else {
                    if (_promo) w.h.c.s(_promo);
                    w.h.c.s(_success);
                    w.h.c.h(_atemail);
                    w.cle();
                }
            }
            else
            {
                _success.value = w.lang(al, 13);
            }
            w.cwa = _ate.sto("_atw.clo()",1200);
        }
        return false;
	}

	// perform post-load functions (show menu, send to destination, create v120 buttons)
	while (_ate.plo.length > 0) {
		var v = _ate.plo.pop();
		if (v[0] === 'open') {
			addthis_open(v[1],v[2],v[3],v[4],v[5],v[6]);
		}
		// add v10 preload/clickout
		if (v[0] === 'cout') {
			function addthis_click(a,b) {
				if (window.addthis_clickout) {
					return addthis_sendto('');
				} else {
					return addthis_open(a,b||'',window.addthis_url||'',window.addthis_title||'');
				}
			}
		}
		if (v[0] === 'send') {
            var cf, sh;
            if (v.length > 2) {
                cf = v[2];
                sh = v[3];
            }
			addthis_sendto(v[1], cf, sh);
		}
		if (v[0] === 'span') {
			var s = _atw.get(v[1]);
			if (s) {
				_atw.evar();
				s.innerHTML = ('<a href="'+_atw.genurl('')+'" onmouseover="return addthis_open(this, \'share\', \''+v[2]+'\', \''+(v[3]||'').replace(/'/g, '\\\'')+'\')" onmouseout="addthis_close()" onclick="return addthis_to()" class="snap_noshots"><img src="'+_atr+'button1-bm.gif" width="125" height="16" style="border:none;padding:0px" alt="AddThis" /></a>');
			}
		}
	}
}

