  
/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);

/* Cookie 1.2*/
jQuery.jCookie=function(i,b,l,j){if(!navigator.cookieEnabled){return false}var j=j||{};if(typeof(arguments[0])!=="string"&&arguments.length===1){j=arguments[0];i=j.name;b=j.value;l=j.expires}i=encodeURI(i);if(b&&(typeof(b)!=="number"&&typeof(b)!=="string"&&b!==null)){return false}var e=j.path?"; path="+j.path:"";var f=j.domain?"; domain="+j.domain:"";var d=j.secure?"; secure":"";var g="";if(b||(b===null&&arguments.length==2)){l=(l===null||(b===null&&arguments.length==2))?-1:l;if(typeof(l)==="number"&&l!="session"&&l!==undefined){var k=new Date();k.setTime(k.getTime()+(l*24*60*60*1000));g=["; expires=",k.toGMTString()].join("")}document.cookie=[i,"=",encodeURI(b),g,f,e,d].join("");return true}if(!b&&typeof(arguments[0])==="string"&&arguments.length==1&&document.cookie&&document.cookie.length){var a=document.cookie.split(";");var h=a.length;while(h--){var c=a[h].split("=");if(jQuery.trim(c[0])===i){return decodeURI(c[1])}}}return false};

/**
 * jQuery 1.2.6+ addthis plugin
  */
$.fn.addthis = function (a) {
	a = a || {};
	return this.each(function () {
		$$addthis.initBtn(this)
	})
};
var $$addthis = {
	gourl: "http://addthis.org.cn/go/?act=share",
	timeDelayout: 420,
	favsN: 37,
	favs: {
			"facebook": {
				id: 73,
				name: "Facebook"
			},
			"twitter": {
				id: 74,
				name: "Twitter"
			},
			"google": {
				id: 1,
				name: "谷歌书签"
			},
			"reddit": {
				id: 75,
				name: "Reddit"
			},
			"myspace": {
				id: 76,
				name: "Myspace"
			},
			"delicious": {
				id: 71,
				name: "Delicious"
			},
			"digg": {
				id: 72,
				name: "Digg"
			},
                        "diglog": {
				id: 16,
				name: "Diglog"
			},
                        "fav": {
				id: 0,
				name: "本地收藏"
			},
			"gmail": {
				id: 31,
				name: "Gmail"
			},
			"xiaonei": {
				id: 22,
				name: "人人网"
			},
			"kaixin": {
				id: 23,
				name: "开心网"
			},
			"sinav": {
				id: 28,
				name: "新浪微博"
			},
			"sohubai": {
				id: 24,
				name: "搜狐&middot;白"
			},
			"digu": {
				id: 35,
				name: "嘀咕"
			},
			"zuosa": {
				id: 29,
				name: "做啥"
			},
			"douban": {
				id: 21,
				name: "豆瓣/九点"
			},
			"renjian": {
				id: 38,
				name: "人间"
			},
			"jianghu": {
				id: 36,
				name: "淘江湖"
			},
			"yahoo": {
				id: 3,
				name: "雅虎收藏"
			},
			"youdao": {
				id: 41,
				name: "有道"
			},
			"tongxue": {
				id: 32,
				name: "同学微博"
			},
			"s51": {
				id: 37,
				name: "51社区"
			},
			"hotmail": {
				id: 40,
				name: "Hotmail"
			},
			"vivi": {
				id: 5,
				name: "新浪ViVi"
			},
			"live": {
				id: 11,
				name: "微软Live"
			},
			"googlereader": {
				id: 30,
				name: "Buzz"
			},
			"xianguo": {
				id: 27,
				name: "鲜果"
			},
			"hexun": {
				id: 12,
				name: "和讯网摘"
			},
			"misterwong": {
				id: 14,
				name: "Mister-Wong"
			},
			"wake": {
				id: 10,
				name: "挖客"
			},
			"leshou": {
				id: 19,
				name: "乐收"
			},
			"follow5": {
				id: 33,
				name: "5享网"
			},
			"poco": {
				id: 20,
				name: "POCO"
			},
			"f115": {
				id: 25,
				name: "115收藏"
			}

	},
	e: encodeURIComponent,
	gotourl: function (a) {
		open($$addthis.gourl + a, 'addthis', 'width=750,height=500,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');
		return false
	},
	windowOffset: function () {
		var a = {
			width: 0,
			height: 0,
			left: 0,
			top: 0,
			right: 0,
			bottom: 0
		};
		if (window.innerWidth && window.innerWidth.constructor == Number) {
			a.width = window.innerWidth;
			a.height = window.innerHeight;
			a.left = window.pageXOffset;
			a.top = window.pageYOffset
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			a.width = document.documentElement.clientWidth;
			a.height = document.documentElement.clientHeight;
			a.left = document.documentElement.scrollLeft;
			a.top = document.documentElement.scrollTop
		} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
			a.width = document.body.clientWidth;
			a.height = document.body.clientHeight;
			a.left = document.body.scrollLeft;
			a.top = document.body.scrollTop
		}
		a.right = a.left + a.width;
		a.bottom = a.top + a.height;
		return a
	},
	showposition: function (a, b, c, d) {
		if (!$.boxModel) {
			b.css("width", (b.get(0).clientWidth + parseInt(b.css("padding-left")) + parseInt(b.css("padding-right")) + (parseInt(b.css("border-left-width")) ? parseInt(b.css("border-left-width")) : 0) + (parseInt(b.css("border-right-width")) ? parseInt(b.css("border-right-width")) : 0)) + "px")
		}
		a.css("width", b.get(0).offsetWidth + "px");
		c.css("width", b.get(0).offsetWidth + "px");
		a.css("height", b.get(0).offsetHeight + "px");
		c.css("height", b.get(0).offsetHeight + "px");
		var e = d.offset();
		var f = $$addthis.windowOffset();
		var g = a.offset();
		var h = 0,
		top = 0;
		if (f.right - e.left <= a.width()) {
			h = e.left + d.width() - a.width()
		} else {
			h = e.left
		}
		if (f.bottom - e.top - (d.find("*").height() || 16) <= a.height()) {
			top = e.top - a.height()
		} else {
			top = e.top + d.height()
		}
		a.css("left", h + "px");
		a.css("top", top + "px");
		a.css("visibility", "visible");
		e = f = g = h = top = null
	},
	showThisItem: function (a) {
		$(".addthis_box").hide();
		$(a).show()
	},
	initBtn: function (m) {
		m.mouse_over = function (f, e) {
			if (m.locked) {
				$$addthis.showThisItem(m.addbox);
				clearTimeout(m.timeOut);
				return false
			}
			m.locked = true;
			var g = $(m).attr("i") ? "|" + $(m).attr("i") + "|": "";
			m.u = $(m).attr("u") ? $(m).attr("u") : document.location.href;
			m.t = $(m).attr("t") ? $(m).attr("t") : document.title;
			m.e = $(m).attr("e") ? $(m).attr("e") : "mouseover";
			m.argStr = "&u=" + $$addthis.e(m.u);
			m.argStr += "&t=" + $$addthis.e(m.t);
			var h = $(m).attr("d") ? $(m).attr("d") : (window.getSelection ? window.getSelection().toString() : document.getSelection ? document.getSelection() : document.selection.createRange().text);
			m.argStr += "&d=" + $$addthis.e(h);
			m.argStr += "&tag=" + $$addthis.e($(m).attr("tag") ? $(m).attr("tag") : "");
			m.addthis = m;
			$(".addthis_box").hide();
			var i = $('<div class="addthis_box"></div>').get();
			$("body").append(i);
			m.addbox = i;
			var j = "";
			j += '<iframe class="bgfrm" frameborder="0" tabindex="-1" src="javascript:;"></iframe>';
			j += '<div class="addshow"><div class="addh"><div class="addt">請手動更改域>勿留下任何上网痕迹!</b></div></div><div class="addbody"><div class="addlist">';
			var k = 0;
			for (var l in $$addthis.favs) {
				if ((!g && k < $$addthis.favsN) || (g && g.indexOf("|" + $$addthis.favs[l].id + "|") >= 0)) {
					j += '<div class="li"><a class="add_' + $$addthis.favs[l].id + '" item="' + $$addthis.favs[l].id + '" href="#">' + $$addthis.favs[l].name + '</a></div>';
					k++
				}
			}

			j += '</div><div style="clear:both;line-height:0"></div></div>';
			j += '</div>';
			$(i).html(j);
			if ($(m).attr("abordercolor")) $(i).css({
				"border-color": $(m).attr("abordercolor")
			});
			if ($(m).attr("aheadbgcolor")) {
				$(i).find(".addh").css({
					"background-color": $(m).attr("aheadbgcolor")
				});
				$(i).find(".addbottom").css({
					"background-color": $(m).attr("aheadbgcolor")
				})
			}
			$$addthis.showposition($(i), $(i).find(".addshow"), $(i).find(".bgfrm"), $(m));
			$(i).find(".addlist .li").mouseover(function (a) {
				if ($$addthis.isMouseLeaveOrEnter(a || event, this)) $(this).addClass("on")
			}).mouseout(function (a) {
				if ($$addthis.isMouseLeaveOrEnter(a || event, this)) $(this).removeClass("on")
			}).children("a").click(m.listclick);

			$(m).mouseout(function (a) {
				if ($$addthis.isMouseLeaveOrEnter(a || event, m)) {
					m.timeOut = setTimeout(m.boxmouseout, $$addthis.timeDelayout)
				}
			});
			$(m.addbox).mouseover(function (a) {
				if ($$addthis.isMouseLeaveOrEnter(a || event, m.addbox)) {
					if (m.e == "click") {
						clearTimeout(m.timeOut)
					} else if (m.e == "mouseover") {
						m.boxmouseover(a);
						clearTimeout(m.timeOut)
					}
				}
			});
			$(m.addbox).mouseout(function (a) {
				if ($$addthis.isMouseLeaveOrEnter(a || event, m.addbox)) {
					m.timeOut = setTimeout(m.boxmouseout, $$addthis.timeDelayout)
				}
			});
			g = btn_t = btn_u = h = i = j = null
		};
		m.listclick = function (a) {
			if ($(this).attr("item")) {
				if (Number($(this).attr("item")) == 0) {
					$$addthis.localFav(m.t, m.u)
				} else {
					$$addthis.gotourl('&id=' + $.attr(this, "item") + m.argStr)
				}
				$(m.addbox).hide();
				return false
			}
		};
		m.boxmouseover = function (a) {
			$$addthis.showposition($(m.addbox), $(m.addbox).find(".addshow"), $(m.addbox).find(".bgfrm"), $(m));
			$(m.addbox).show()
		};
		m.boxmouseout = function (a) {
			$(m.addbox).fadeOut()
		};
		if ($(m).attr("e") == "click") {
			$(m).click(function (a) {
				m.mouse_over(m, a);
				return false
			})
		} else {
			$(m).click(function (a) {
				return false
			}).mouseover(function (a) {
				m.mouse_over(m, a)
			})
		}
	},
	localFav: function (t, u) {
		try {
			window.external.AddFavorite(u, t)
		} catch(e) {
			try {
				window.sidebar.addPanel(t, u, "")
			} catch(e) {
				alert("使用快捷键 Ctrl+D 或 Cmd+D 来收藏此页！")
			}
		}
	},
	isMouseLeaveOrEnter: function (e, a) {
		if (e.type != 'mouseout' && e.type != 'mouseover') return false;
		var b = e.relatedTarget ? e.relatedTarget: e.type == 'mouseout' ? e.toElement: e.fromElement;
		while (b && b != a) b = b.parentNode;
		return (b != a)
	}
};

/* 	gaTracker 1.0.1: jQuery Google Analytics Integration 
	A quicker, automated way to embed Google Analytics.
	(c)2007 Jason Huck/Core Five Creative
	
	* BETA Support for new Analytics API (ga.js) by Jamie Thompson - http://jamazon.co.uk
	* Requires jQuery 1.2.x or higher (for cross-domain $.getScript)
	* TODO: more testing, delay after $.getScript for Safari
	
	Usage:
	Only a tracking code is required:
	$.gaTracker('UA-XXXXX-XX');

	...but other options can be specified:
	$.gaTracker(
		'UA-XXXXX-XX',
		{
			external:	'/external/',
			mailto:		'/mailto/',
			download:	'/downloads/',
			extensions:	[
				'pdf','doc','xls','csv','jpg','gif', 'mp3',
				'swf','txt','ppt','zip','gz','dmg','xml'		
			]
		}
	);

*/


(function($){
	$.gaTracker = function(code, opts){
		opts = jQuery.extend({
			external:	'/external/',
			mailto:		'/mailtos/',
			download:	'/downloads/',
			extensions: [
					'pdf','doc','xls','csv','jpg','gif', 'mp3',
					'swf','txt','ppt','zip','gz','dmg','xml', 'js'		
			]	
		}, opts);
		
		// Returns the given URL prefixed if it is:
		//		a) a link to an external site
		//		b) a mailto link
		//		c) a downloadable file
		// ...otherwise returns an empty string.
		function decorateLink(u){
			var trackingURL = '';
			
			if(u.indexOf('://') == -1 && u.indexOf('mailto:') != 0){
				// no protocol or mailto - internal link - check extension
				var ext = u.split('.')[u.split('.').length - 1];			
				var exts = opts.extensions;
				
				for(i = 0; i < exts.length; i++){
					if(ext == exts[i]){
						trackingURL = opts.download + u;
						break;
					}
				}				
			} else {
				if(u.indexOf('mailto:') == 0){
					// mailto link - decorate
					trackingURL = opts.mailto + u.substring(7);					
				} else {
					// complete URL - check domain
					var regex = /([^:\/]+)*(?::\/\/)*([^:\/]+)(:[0-9]+)*\/?/i;
					var linkparts = regex.exec(u);
					var urlparts = regex.exec(location.href);					
					if(linkparts[2] != urlparts[2]) trackingURL = opts.external + u;
				}
			}
			
			return trackingURL;			
		}
		
		// add tracking code to the current page
		function addTracking(){
			$.pageTracker = _gat._getTracker(code);
			$.pageTracker._initData();
			$.pageTracker._trackPageview();
		
			// examine every link in the page
			$('a').each(function(){
				var u = $(this).attr('href');
				
				if(typeof(u) != 'undefined'){
					var newLink = decorateLink(u);

					// if it needs to be tracked manually,
					// bind a click event to call GA with
					// the decorated/prefixed link
					if(newLink.length){
						$(this).click(function(){
							$.pageTracker._trackPageview(newLink);
						});
					}
				}				
			});
		}
		
		// include the external GA script in try/catch to play nice
		function initGA(){
			try{
				// determine whether to include the normal or SSL version
				var gaURL = (location.href.indexOf('https') == 0 ? 'https://ssl' : 'http://www');
				gaURL += '.google-analytics.com/ga.js';
		
				// include the script
				$.getScript(gaURL, function(){
					addTracking();
				});
			} catch(err) {
				// log any failure
				console.log('Failed to load Google Analytics:' + err);
			}
		}
		
		initGA();
	}
})(jQuery);
