/* (c) 2008-2012 Add This, LLC */
//* vim: set expandtab tabstop=4 shiftwidth=4: */
/* -*- Mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*- */

/**
 * Root Revision (rrev): 109786
 * 
 * --- HOWTO ---
 *
 * creates or updates variables:
 *  _atd
 *  _atr
 *  _atc
 *  _euc
 *  addthis_*
 *
 * creates public fuctions:
 *
 *  addthis_open
 *  addthis_close
 *  addthis_sendto
 *
 * creates legacy public fuctions:
 *
 *  addthis_onmouseover
 *  addthis_onmouseout
 *  addthis_to
 *
 * --- TODO ---
 *
 * require pubid for email
 * limit email size to X bytes
 * can we iframe the menu? reduce code size; as of 1/30/10 stewart doesn't want to
 * templatable or via iframe work for bookmark/feed/other
 */

// BEGIN: _ate dupe guard
if (!((window._atc||{}).ver)) {
var _atd = 'www-test.addthis.com/',
    _atr = '//cache-test.addthis.com/cachefly/',
    _euc = encodeURIComponent,
    _duc = decodeURIComponent,
    _atc = {
        rsrcs : {},
        dr : 0,     // domready
        ver : 250,
        loc : 0,
        enote : '', // pre-filled email note
        cwait : 500, // menu close wait onmouseout in milliseconds
        bamp : 1, // -- clickback sample rate (-1=off, 1=on)
        camp : 1, // -- classification sample rate (-1=off, 1=on)
        csmp : 0.0001, // -- clipboard copy sample rate
        damp : 1, // domain-based psi sample rate (0.0-1.0)
        famp : 1, // -- file path referer sample rate (-1=off, 1=on)
        pamp : 0.20, // psi sample rate (-1=off, 1=on)
        tamp : 1, // -- test sample rate (-1=off, 1=on)
        lamp : 1, // -- lo.gif alternate sample rate
        vamp : 1, // -- view metadata sample rate (-1=off, 1=on)
        vrmp : 1, // --  verbose logging sample rate
        ltj  : 1, // -- load third-party javascript
        xamp : 1, // -- pixelator view sample rate (-1=off, 1=on)
        abf : !!window.addthis_do_ab // address book frame
        // xol : 1, // -- disable onload behavior
        // xcs : 1, // -- disable stylesheet loading
        // xic : 1, // -- disable iframe communication for old browsers (saf3/ffx2)
        // xtr : 1, // -- disable tracking
        // xck : 1, // -- disable document cookies
    };
}
/** BEGIN: AddThis Closure */
(function(){
_atc.rsrcs.countercss = _atr+'live/t07/counter00.css';
_atc.rsrcs.counterIE67css = _atr+'live/t07/counterIE6700.css';
_atc.rsrcs.counter = _atr+'live/t07/counter00.js';

_atc.rsrcs.qbarcss = _atr+'bannerQuirks.css';
_atc.rsrcs.barcss = _atr+'live/t07/banner01.css';
_atc.rsrcs.barjs = _atr+'live/t07/banner01.js';

_atc.rsrcs.overlayjs = _atr+'live/t07/overlay02.js';
_atc.rsrcs.widget32css = _atr+'live/t07/widgetbig40.css';
_atc.rsrcs.widgetcss = _atr+'live/t07/widget76.css';
_atc.rsrcs.widgetIE67css = _atr+'live/t07/widgetIE6700.css';
_atc.rsrcs.widgetpng = '//cache-test.addthis.com/cachefly/live/t07/widget40.png';

_atc.rsrcs.link = _atr+'live/t07/link.html';
_atc.rsrcs.pinit = _atr+'live/t07/pinit01.html';
_atc.rsrcs.linkedin = _atr+'live/t07/linkedin14.html';
_atc.rsrcs.tweet = _atr+'live/t07/tweet14.html';

_atc.rsrcs.menujs = 'live/t07/menu98.js';

_atc.rsrcs.sh = _atr+'live/t07/sh74.html';

if (!window.addthis || window.addthis.nodeType !== undefined) {
    function queueFor(call, ns, context){
        return function (){
            //alert('queueing for ' + call);
            window.addthis.plo.push({ call:call, args:arguments, ns:ns, ctx:context });
        };
    }

    function Queuer(name){
        var 
        self = this, 
        queue = this.queue = [];
        this.name = name;
        
        this.call = function(){
            queue.push(arguments);
        };
        this.call.queuer = this;
        
        this.flush = function(fn, context){
            for (var i=0; i<queue.length; i++)
                fn.apply(context || self, queue[i]);
            return fn;
        };
    }
        
    window.addthis = {
        ost       : 0,  // set to 1 after initialization
        cache     : {}, // for caching some DOM elements we use a lot
        plo       : [], // queued function calls pre-dom-readiness
        links     : [],
        ems       : [],
        _Queuer   : Queuer,
        _queueFor : queueFor,
        data      : {getShareCount: queueFor('getShareCount', 'data')},
        bar       : queueFor('bar'),
        button    : queueFor('button'),
        counter   : queueFor('counter'),
        count     : queueFor('counter'),
        toolbox   : queueFor('toolbox'),
        update    : queueFor('update'),
        init    : queueFor('init'),
        ad        : {
                event: queueFor('event','ad'),
                getPixels: queueFor('getPixels','ad')
        },
        util      : { getServiceName: queueFor('getServiceName')},
        ready     : queueFor('ready'),
        addEventListener    : queueFor('addEventListener', 'ed', 'ed'),
        removeEventListener : queueFor('removeEventListener', 'ed', 'ed'),
        user : {
            getID: queueFor('getID','user'),
            getGeolocation:queueFor('getGeolocation','user'),
            getPreferredServices:queueFor('getPreferredServices','user'),
            getServiceShareHistory:queueFor('getServiceShareHistory','user'),
            ready : queueFor('ready','user'),

            // bools
            isReturning : function (x) {
                // stub
            },
            isOptedOut : queueFor('isOptedOut','user'),
            isUserOf : queueFor('isUserOf','user'),
            hasInterest : queueFor('hasInterest','user'),
            isLocatedIn : queueFor('isLocatedIn','user'),

            // getters
            interests : queueFor('getInterests','user'),
            services : queueFor('getServices','user'),
            location : queueFor('getLocation','user')
        },
        session : {
            source : queueFor('getSource','session'),
            isSocial : queueFor('isSocial','sesesion'),
            isSearch : queueFor('isSearch','session') 
        }
    };

    var a = document.createElement('script'); a.type = 'text/javascript'; //a.async = true;
    a.src = '//cache-test.addthis.com/cachefly/live/t07/body00.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.appendChild(a); //(a, s);
}

/** END: AddThis Closure */
})();

