/*-
 * Copyright (c) 2008 Fredrik Lindberg - http://www.shapeshifter.se
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

var shares = eval('{shares:[{"name":"delicious","image":"delicious_24x24.png","title":"Bookmark at Del.icio.us","url":"http://del.icio.us/post?v=2&url=%url%&title=%title%"},{"name":"digg","image":"Digg_24x24.png","title":"Digg This!","url":"http://digg.com/submit?url=%url%&title=%title%"},{"name":"stumbleupon","image":"Stumbleupon_24x24.png","title":"Stumble upon","url":"http://www.stumbleupon.com/submit?url=%url%&title=%title%"},{"name":"google","image":"Google_24x24.png","title":"Google Bookmarks","url":"http://www.stumbleupon.com/submit?url=%url%&title=%title%"},{"name":"twitter","image":"Twitter_24x24.png","title":"Twitter","url":"http://twitter.com/home?status=%title%: %url%"},{"name":"reddit","image":"Reddit_24x24.png","title":"Reddit","url":"http://reddit.com/submit?url=%url%&title=%title%"},{"name":"diigo","image":"Diigo_24x24.png","title":"Diigo","url":"http://www.diigo.com/post?url=%url%&title=%title%"},{"name":"facebook","image":"FaceBook_24x24.png","title":"Share on Facebook","url":"http://www.facebook.com/sharer.php?u=%url%&t=%title%"},{"name":"blogmarks","image":"BlogMarks_24x24.png","title":"BlogMarks","url":"http://blogmarks.net/my/new.php?mini=1&simple=1&url=%url%&title=%title%"},{"name":"blinklist","image":"Blinklist_24x24.png","title":"Blinklist","url":"http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=%url%&Title=%title%"},{"name":"magnolia","image":"Magnolia_24x24.png","title":"ma.gnolia","url":"http://ma.gnolia.com/bookmarklet/add?url=%url%&title=%title%"},{"name":"technorati","image":"Technorati_24x24.png","title":"Technorati","url":"http://technorati.com/faves?add=%url%"}]}');

var _share_icon_path = '';
var _share_show = ['delicious', 'digg', 'stumbleupon', 'twitter', 'technorati', 'google', 'facebook', 'reddit', 'diigo', 'blogmarks', 'blinklist', 'magnolia'];

if (share_icon_path) { _share_icon_path = share_icon_path; }
if (share_show) { _share_show = share_show; }

var share_docurl = location.href;
if (typeof share_domain != "undefined") {
	var tmp = share_docurl.indexOf("/", 7);
	if (tmp > 0) {
		share_docurl = 'http://' + share_domain + share_docurl.substring(tmp);
	}
	else {
		share_docurl = share_domain;
	}
}

for (j = 0; j < _share_show.length; j++) {
	for (i = 0; i < shares.length; i++) {
		if (shares[i].name == _share_show[j]) {
			var url = shares[i].url;
			var img = shares[i].image;
			url = url.replace("%url%", encodeURI(share_docurl));
			url = url.replace("%title%", escape(document.title));

			document.write('<a target="_blank" rel="nofollow" href="' + url + '" title="'+ shares[i].title +'"><img src="' + _share_icon_path + img + '" border="0"></a>');
		}
	}
}

