/*
ShareThis Loader Version 1.23
11/04/2008 ShareThis.com 
*/

if (!SHARETHIS) {
	function SHARETHIS_merge(){
		var mix = {};
		for (var i = 0, l = arguments.length; i < l; i++){
			var object = arguments[i];
			if (typeof(object) != 'object') continue;
			for (var key in object){
				var op = object[key], mp = mix[key];
				mix[key] = (mp && typeof(op) == 'object' && typeof(mp) == 'object') ? SHARETHIS_merge(mp, op) : SHARETHIS_unlink(op);
			}
		}
		return mix;
	}

	function SHARETHIS_unlink(object){
		var SHARETHIS_unlinked;	
		switch (typeof(object)){
			case 'object':
				SHARETHIS_unlinked = {};
				for (var p in object) SHARETHIS_unlinked[p] = SHARETHIS_unlink(object[p]);
			break;
			case 'hash':
				SHARETHIS_unlinked = SHARETHIS_unlink(object.getClean());
			break;
			case 'array':
				SHARETHIS_unlinked = [];
				for (var i = 0, l = object.length; i < l; i++) SHARETHIS_unlinked[i] = SHARETHIS_unlink(object[i]);
			break;
			default: return object;
		}
		return SHARETHIS_unlinked;
	}


	function Sharelet(options){
		this.node=null;
		this.button=null;
		
		this.properties={
			type:       '',
			title:      document.title,
			summary:    '',
			content:    '',
			url:        document.URL,
			icon:       '',
			category:   '',
			updated:    document.lastModified,
			published:  '',
			author:     ''
		}
		this.options= {
			button: true,
			buttonText: 'ShareThis'
		}
		this.initialize=function(options){
			this.options = SHARETHIS_merge(this.options, options);
		}
		this.initialize(options);
		this.bind= function(node){
			if (this.node !== null && this.node !== node) {
				try {this.node.removeChild(this.button)} catch(err){
				}
			}
			if (this.options.button == true) {
				try{node.appendChild(this.button)} catch(err){
				}
			}
			this.node = node;
		}
	}

	function ShareThisWidget(){
	    
		this.visible= 0;
	    this.wrapper= null;
	    this.iframe=null;
	    this.close=null;
	    this.sharelet=null;
	    this.left=0;
	    this.top=0;
	    this.hiddenEmbeds=false;
	    this.loaderHTML= '<html><head><style>body{background:#eee url(http://w.sharethis.com/widget/1.15/load.gif) center center no-repeat;color:#bbb;font:bold 18px Arial,Helvetica,sans-serif;padding:50px 20px;text-align:center;}</style></head><body>Getting ready to share!</body></html>';
	 //   this.options = options;
        var d = document.createElement('div');
        d.className = 'stwrapper';
        d.style.visibility = 'hidden';
        this.wrapper = d;

	    this.hide=function(opts){
	        SHARETHIS.widget.visible = 0;
	        SHARETHIS.widget.wrapper.style.visibility = 'hidden';
	        if (Boolean(SHARETHIS.widget.hiddenEmbeds) == true || (opts && Boolean(opts.embeds) != true)) {
	            SHARETHIS.widget.hiddenEmbeds = false;
	            SHARETHIS.widget.showEmbeds();
	        }
	        return false;
	    }
       
        try {
            var f = document.createElement('<iframe name="stframe" allowTransparency="true" style="body{background:transparent;}"></iframe>');
        } catch(err) {
            var f = document.createElement('iframe');
            f.allowTransparency="true";
            f.setAttribute("allowTransparency", "true");
        }
        f.id = 'stframe';
        f.className = 'stframe';
        f.name = 'stframe';
        f.frameBorder = '0';
        f.scrolling = 'no';
        f.width = '354px';
        f.height = '437px';
        d.appendChild(f);
        this.iframe = f;

        var a = document.createElement('a');
        a.href = 'javascript:void(0);';
        a.title = 'close';
        a.className = 'stclose';
        a.onclick = this.hide;
        a.style.color = '#fff';
        var t = document.createTextNode('X');
        a.appendChild(t);
        d.appendChild(a);
        this.close = a;

		this.show=function(opts){
	        SHARETHIS.widget.visible = 1;
	        SHARETHIS.widget.wrapper.style.left = this.left+'px';
	        SHARETHIS.widget.wrapper.style.top = this.top+'px';
	        if (SHARETHIS.widget.wrapper.parentNode == null
	            || typeof(SHARETHIS.widget.wrapper.parentNode.tagName) == 'undefined'){
	            document.body.appendChild(SHARETHIS.widget.wrapper);
	        }
	        SHARETHIS.widget.wrapper.style.visibility = 'visible';
	        if (opts && Boolean(opts.embeds) != true) {
	            SHARETHIS.widget.hiddenEmbeds = true;
	            SHARETHIS.widget.hideEmbeds();
	        }
	        return false;
	    }

	    this.hideEmbeds=function() {
	        var embeds = document.getElementsByTagName('embed');
	        for (var i=0; i< embeds.length; i++) {
	            embeds[i].style.visibility = "hidden";
	        }
	    }
	    this.showEmbeds=function() {
	        var embeds = document.getElementsByTagName('embed');
	        for (var i=0; i< embeds.length; i++) {
	            embeds[i].style.visibility = "visible";
	        }
	    }
	    this.loading=function(){
	        var w = parent.frames['stframe'];
	        try {
	        w.window.document.open();
	        w.window.document.clear();
	        w.window.document.write(this.loaderHTML);
	        w.window.document.close();
	        } catch(err) {}
	    }
	}

/*
	 *    ShareThis
	 *
	 *    This global object implements the ShareThis API and binding sharelets and the widget
	 *    together.
	 */
	function ShareThis(options){
		
	    this.version=    '1.23';
	    this.ready=      false;
	    this.readyList=  [];
	    this.toolbar=    false;
	    this.counter=    0;
	    this.widget=     null;
	    this.sharelets=  [];
	    this.page=       {};
	   	this.query=      {};
		this.lastUrl=     'blank';
		this.logFlag=		true;
	    this.meta={
	        publisher : '',
	        hostname  : location.host,
	        location  : location.pathname
	    }
	    this.load=function(t, opts) {
	        var e = document.createElement(t);
	        for (var i in opts) {
	            e.setAttribute(i, opts[i]);
	        }
	        try {
	            document.getElementsByTagName('head')[0].appendChild(e);
	        } catch (err) {
	            document.body.appendChild(e);
	        }
	    }
		this.onReady= function() {
	        SHARETHIS.ready = true;
	        for (var i = 0; i < SHARETHIS.readyList.length; ++i)
	            SHARETHIS.readyList[i].apply(document, [SHARETHIS]);
	    }
		this.luminescence=function(color) {
	        var rgb = {};
	        if (color.length == 7) {
	  	    rgb = [parseInt('0x' + color.substring(1, 3)) / 255,
	  	           parseInt('0x' + color.substring(3, 5)) / 255,
	  		   parseInt('0x' + color.substring(5, 7)) / 255];
	        } else if (color.length == 4) {
	  	    rgb =  [parseInt('0x' + color.substring(1, 2)) / 15,
	  		    parseInt('0x' + color.substring(2, 3)) / 15,
	  		    parseInt('0x' + color.substring(3, 4)) / 15];
	        }
	        var r = rgb[0], g = rgb[1], b = rgb[2];
	        var min = Math.min(r, Math.min(g, b));
	        var max = Math.max(r, Math.max(g, b));
	        return (min + max) / 2;
	    }
	    this.initialize=function(options){
	        var options = options || {};
	        this.options = options;
	        if (options.publisher) {
	            this.meta.publisher = options.publisher;
	        }
			this.page=new Sharelet(SHARETHIS_merge(options,{button:false}));
			this.widget=new ShareThisWidget;
	        if (options.headerbg) {
	            var l = this.luminescence(options.headerbg);
	            this.widget.close.style.color = l > 0.5 ? '#000' : '#fff';
	        }
	        var css = 'http://w.sharethis.com/widget/' + this.version + '/sharethis.css';
	        this.load('link', {
	            href : (this.options.css ? this.options.css : css),
	            rel  : 'stylesheet',
	            type : 'text/css'
	        });
	        if (typeof(window.addEventListener) != 'undefined') {
	            window.addEventListener("load", this.onReady, false);
	        } else if (typeof(document.addEventListener) != 'undefined') {
	            document.addEventListener("load", this.onReady, false);
	        } else if (typeof window.attachEvent != 'undefined') {
	            window.attachEvent("onload", this.onReady);
	        }
	    }
		this.initialize(options);
	    this.selection=function(){
	        if (window.getSelection) {
	            this.page.properties.selection = window.getSelection();
	        } else if (document.getSelection) {
	            this.page.properties.selection = document.getSelection();
	        } else if (document.selection && document.selection.createRange) {
	            this.page.properties.selection = document.selection.createRange().text;
	        }
	    }

	    this.defer=function(f) {
	        if (this.ready) {
	            f.apply(document, [SHARETHIS]);
	        } else {
	            this.readyList.push( function() { return f.apply(this, [SHARETHIS]) } );
	            //this.readyList.push(f);
	        }
	    }
	    this.pageSize=function() {
	        var pScroll = [0,0];
	        if (typeof(window.pageYOffset) == 'number') {
	            //Netscape compliant
	            pScroll = [window.pageXOffset, window.pageYOffset];
	        } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
	            //DOM compliant
	            pScroll = [document.body.scrollLeft, document.body.scrollTop];
	        } else if (document.documentElement
	          && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
	            //IE6 standards compliant mode
	            pScroll = [document.documentElement.scrollLeft,
	                       document.documentElement.scrollTop];
	        }
	        return pScroll;
	    }
	    this.addEntry=function(properties, options){
	        var options = options || {};
		try{properties.url=properties.url.toString();}
		catch(err){
			//noop
		}
	        if (typeof(options.button) == "undefined") {
	            options.button = true;
	        }
	        if (typeof(options.bind) == "undefined") {
	            options.bind = true;
	        }
			var s=new Sharelet(SHARETHIS_merge(this.options, options));
	        s.properties = SHARETHIS_merge(s.properties, properties);
	        s.idx = this.sharelets.push(s) - 1;
	        s.sharethis = this;
	        s.widget = this.widget;
		
			if(s.properties.url!==this.lastUrl){
				this.lastUrl=s.properties.url;
			}
			else{
				this.logFlag=false;
			}

	        s.popup = function(e){
	             if (s.options.onclick) {
	                  var res = s.options.onclick.apply(document, [s]);
	                  if (res == false) {
	                      return false;
	                  }
	             }
	             SHARETHIS.selection();
				var query_str=[];

				for (var j in SHARETHIS.meta) {
					var tmp="meta_"+j+"="+encodeURIComponent(encodeURIComponent(SHARETHIS.meta[j]));
					if(SHARETHIS.meta[j]!==""){
						query_str.push(tmp);
					}
				}
				for (var j in SHARETHIS.page.properties) {
					var tmp="page_"+j+"="+encodeURIComponent(encodeURIComponent(SHARETHIS.page.properties[j]));
					if( (j==="url" || j==="title" || j==="summary") ){
						if(SHARETHIS.page.properties[j]!==""){
							query_str.push(tmp);
						}
					}
				}
				var olist=[s];
				for (var i=0; i < olist.length; i++) {
					obj = olist[i];
					for (var j in obj.properties) {
						var tmp=j+"[]="+encodeURIComponent(encodeURIComponent(obj.properties[j]));
						if(obj.properties[j]!==""){
							query_str.push(tmp);
						}
					}
					for (var j in obj.options) {
						var tmp="opts_"+j+"="+encodeURIComponent(encodeURIComponent(obj.options[j]));
						if(obj.options[j]!==""){
							query_str.push(tmp);
						}
					}
				}
				for (var j in SHARETHIS.query) {
					var tmp="query_"+j+"="+encodeURIComponent(encodeURIComponent(SHARETHIS.query[j]));
					/*if(j==="tabs" || j==="services" || j==="ireg" || j==="reg" || j==){
						query_str.push(tmp)//lightbox only uses: tabs, services, ireg, reg but sending everything
					}*/
					query_str.push(tmp)//lightbox only uses: tabs, services, ireg, reg but sending everything
				}
				var qry_str=query_str.join('&');
			//	qry_str=qry_str.replace(/%3B/,'');
			//	console.log(qry_str);
				var p = window.open("http://sharethis.com/share/lightbox.php?"+qry_str, "stframe","status=1,toolbar=0,width=354,height=437");
	             s.widget.popup = p;
	             return false;
	        }
	        s.attachButton = function(a){
	            a.onclick = (Boolean(s.options.popup) == true ? s.popup : s.onClick);
	        }
	        s.onClick = function(e){
	            if (s.options.onclick) {
	                 var res = s.options.onclick.apply(document, [s]);
	                 if (res == false) {
	                     return false;
	                 }
	            }
	            findPos = function(obj) {
	                var obj = obj || {};
	                if (obj.parentNode && obj.parentNode.className.indexOf('stbutton') != -1) {
	                    obj = obj.parentNode;
	                }
	                var pScroll = SHARETHIS.pageSize();
	                var pos = pScroll;
	                var widgetWidth = 354;
	                if (obj.offsetParent) {
	                    odims = {offsetLeft:obj.offsetLeft, scrollWidth:obj.scrollWidth};
	                    pos = [obj.offsetLeft+obj.scrollWidth,obj.offsetTop+obj.scrollHeight];
	                    while (obj = obj.offsetParent) {
	                        pos[0] += obj.offsetLeft;
	                        pos[1] += obj.offsetTop;
	                    }
	                    if (s.options.offsetLeft) {
	                        pos[0] += parseInt(s.options.offsetLeft);
	                    }
	                    if (s.options.offsetTop) {
	                        pos[1] += parseInt(s.options.offsetTop);
	                    }
	                    if (!s.options.offsetLeft && !s.options.offsetTop) {
	                        pos[0] -= odims.scrollWidth;
	                        if (pos[0] + widgetWidth > document.body.scrollWidth) {
	                            pos[0] -= widgetWidth - odims.scrollWidth;
	                        }
	                    }
	                }
	                return pos;
	            }
	            if (!e) var e = window.event;
	            var el = e.target || e.srcElement;
	            var coords = findPos(el);
	            s.widget.left = coords[0];
	            s.widget.top = coords[1];
            
	            if (s.widget.visible) {
	                if (s == s.widget.sharelet) {
	                    s.widget.hide(s.options);
	                } else {
	                    s.widget.loading();
	                    s.share();
	                }
	            } else {
	                if (s == s.widget.sharelet) {
	                    s.widget.show(s.options);
	                } else {
	                    s.widget.show(s.options);
	                    s.widget.loading();
	                    s.share();
	                }
	            }
	            return false;
	        }
	        s.share = function(){
	            return s.sharethis.share(s);
	        }
	        if (typeof(s.options.button) == "undefined" || Boolean(s.options.button) != false) {
	            var a = document.createElement("a");
	            a.className = 'stbutton stico_' + (s.options.style ? s.options.style : (SHARETHIS.options.style ? SHARETHIS.options.style : 'default'));
	            a.title = "ShareThis via email, AIM, social bookmarking and networking sites, etc.";
	            a.href = "#";
	            a.onclick = (Boolean(s.options.popup) == true ? s.popup : s.onClick);
	            var t = document.createElement("span");
	            t.className = 'stbuttontext';
	            t.appendChild(document.createTextNode(s.options.buttonText));
	            a.appendChild(t);
	            s.button = a;
	            if (typeof(s.options.bind) == "undefined" || Boolean(s.options.bind) != false) {
	                var id = 'sharethis_' + s.idx;
	                document.write('<span id="' + id + '"></span>');
	                var x = document.getElementById(id);
	                if (x) {
	                    x.appendChild(a);
	                }
	            }
	        }
	        if(this.logFlag){this.defer(function(){SHARETHIS.log('view', s)});}
	        return s;
	    }
	    this.share=function(sharelet){
	        this.selection();
	        this.widget.sharelet = sharelet;
	        this.widget.show(sharelet.options);
	        var f = SHARETHIS.form([sharelet]);
	        document.body.appendChild(f);
	        f.submit();
	    }
	    this.form=function(olist) {
			field = function(k, v, brackets) {
	            var f   = document.createElement("input");
	            f.type  = "hidden";
	            f.name  = (brackets == true ? k + "[]" : k);
	            f.value = v;
	            return f;
	        }
	        normalize = function(s){
	            if (s == null) {
	                return '';
	            }
	            return encodeURIComponent(s);
	        }

	        var f    = document.createElement("form");
	        //f.className  = "stform";
	        f.method = "post";
	        f.action = "http://sharethis.com/share/lightbox.php";
	        f.target = "stframe";
	        for (var j in this.meta) {
	            f.appendChild(field("meta_" + j, normalize(this.meta[j])));
	        }
	        for (var j in this.page.properties) {
	            f.appendChild(field("page_" + j, normalize(this.page.properties[j])));
	        }
	        for (var j in this.query) {
	            f.appendChild(field("query_" + j, normalize(this.query[j])));
	        }
	        for (var i=0; i < olist.length; i++) {
	            obj = olist[i];
	            for (var j in obj.properties) {
	                f.appendChild(field(j, normalize(obj.properties[j]), true));
	            }
	            for (var j in obj.options) {
	                f.appendChild(field("opts_"+j, normalize(obj.options[j]), false));
	            }
	        }
	        return f;
	    }
	    this.log=function(event, obj) {
	        var url = "http://r.sharethis.com/log?event=" + event
	            + "&publisher=" + encodeURIComponent(SHARETHIS.meta.publisher)
	            + "&hostname=" + encodeURIComponent(SHARETHIS.meta.hostname)
	            + "&location=" + encodeURIComponent(SHARETHIS.meta.location)
	            + "&url=" + encodeURIComponent(obj.properties.url)
	            + "&ts" + (new Date()).getTime() + "." + SHARETHIS.counter++;

	        var logger = new Image(1,1);
	        logger.src = url;
	        logger.onload = function(){return;}
	    }
	}

	var _query = [];
	_query.tabs = 'web,email';
_query.charset = 'utf-8';
_query.services = 'digg,facebook,delicious,stumbleupon,google_bmarks,yahoo_bmarks,newsvine,windows_live,yahoo_myweb';
_query.style = 'default';
_query.publisher = 'cdeba687-f6eb-49e4-9ffb-c08bba66d5d5';
_query.headerbg = '#772322';
_query.linkfg = '#990016';
	var SHARETHIS=new ShareThis(_query);
	SHARETHIS.log('pview', SHARETHIS.page);
	SHARETHIS.query = _query;
	var st = SHARETHIS;

} // end if !SHARETHIS

// Don't run if called from HEAD, or if toolbar has been run
var _slist = document.getElementsByTagName('script');
var _s = _slist[_slist.length - 1];
if (_s && _s.parentNode.tagName != "HEAD" && typeof(_sttoolbar) == "undefined") {
    var obj = SHARETHIS.addEntry(null,SHARETHIS_merge(_query,{bind:false}));
    var id = 'sharethis_' + obj.idx;
    document.write('<span id="' + id + '"></span>');
    var x = document.getElementById(id);
    obj.bind(x);
}


