﻿-function() {
	var d = document, isStrict = d.compatMode == "CSS1Compat", dd = d.documentElement, db = d.body, m = Math.max, ie = !!d.all, ua = navigator.userAgent
			.toLowerCase(), head = d.getElementsByTagName('head')[0], getWH = function() {
		return {
			h : (isStrict ? dd : db).clientHeight,
			w : (isStrict ? dd : db).clientWidth
		}
	}, getS = function() {
		return {
			t : m(dd.scrollTop, db.scrollTop),
			l : m(dd.scrollLeft, db.scrollLeft)
		}
	}, getP = function(o) {
		var l, t;
		if (o.getBoundingClientRect) {
			var p = getS();
			var el = o.getBoundingClientRect();
			l = p.l + el.left;
			t = p.t + el.top;
		} else {
			l = o.offsetLeft;
			t = o.offsetTop;
			while (o = o.offsetParent) {
				l += o.offsetLeft;
				t += o.offsetTop;
			}
		}
		return {
			x : l,
			y : t
		};
	}, creElm = function(o, t, a) {
		var b = d.createElement(t || 'div');
		for ( var p in o) {
			p == 'style' ? b[p].cssText = o[p] : b[p] = o[p]
		}
		return (a || db).insertBefore(b, (a || db).firstChild)
	}, div = creElm( {
		style : "position:absolute;z-index:1000000000;display:none;overflow:auto;"
	}), div1 = creElm( {
		style : "position:fixed;z-index:1000000000;display:none;top:50%;left:50%;overflow:auto;"
	}), iframe = creElm(
			{
				style : 'position:' + (/firefox/.test(ua) ? 'fixed'
						: 'absolute') + ';display:none;filter:alpha(opacity=0);opacity:0',
				frameBorder : 0
			}, 'iframe'), timer, inputTimer, list, clist, h, texts = {}, clickpopjs;
	creElm( {
		href : 'http://shareto.googlecode.com/svn/trunk/css/css1.css',
		rel : 'stylesheet',
		type : 'text/css'
	}, 'link');
	sharetoBtnContain = {
		pop : div,
		centerpop : div1,
		disappear : function(b) {
			var c = window.event || b, t = c.srcElement || c.target, contain = div1.contains ? div1
					.contains(t)
					: !!(div1.compareDocumentPosition(t) & 16), contain1 = div.contains ? div
					.contains(t)
					: !!(div.compareDocumentPosition(t) & 16);
			if (!contain && !contain1
					&& t.className.indexOf('shareto_button_compact') == -1
					&& t.parentNode.className != 'shareto_button') {
				iframe.style.display = div1.style.display = 'none';
			}
		},
		over : function(e) {
			var c = window.event || e, target = c.srcElement || c.target, T = this, timerCont, fn = function() {
				timerCont = setInterval(function() {
					if (div.innerHTML) {
						var p = getP(target), wh = getWH(), tl = getS();
						with (div.style) {
							display = "block";
							var a = T.style.display;
							T.style.display = 'block';
							top = p.y + target.offsetHeight + 'px';
							left = p.x + 'px';
							T.style.display = a;
						}
						;
						with (iframe.style) {
							top = div.offsetTop + 'px';
							left = div.offsetLeft + 'px';
							width = div.offsetWidth + 'px';
							height = div.offsetHeight + 'px';
							margin = "";
							display = 'block'
						}
						;
						clearInterval(timerCont)
					}
				}, 50)
			};
			if (!clickpopjs) {
				clickpopjs = creElm( {
					src : 'http://share-to-anywhere.googlecode.com/svn/trunk/www/shareto_button_menu.js',
					charset : 'utf-8'
				}, 'script', head);
				clickpopjs.onloaded = 0;
				clickpopjs.onload = function() {
					clickpopjs.onloaded = 1;
					fn()
				};
				clickpopjs.onreadystatechange = function() {
					/complete|loaded/.test(clickpopjs.readyState)
							&& !clickpopjs.onloaded && fn()
				}
			} else {
				fn()
			}
			return false
		},
		out : function() {
			timer = setTimeout(function() {
				div.style.display = 'none';
				div1.style.display != 'block'
						&& (iframe.style.display = 'none')
			}, 100)
		},
		move : function() {
			clearTimeout(timer)
		},
		center : function() {
			if (!this.script) {
				this.script = creElm( {
					src : 'http://share-to-anywhere.googlecode.com/svn/trunk/www/shareto_button_window.js',
					charset : 'utf-8'
				}, 'script', head);
				db.style.position = 'static'
			} else {
				var a = getS();
				div1.style.display = "block";
				div1.style.margin = (-div1.offsetHeight / 2 + a.t) + "px " + (-div1.offsetWidth / 2 + a.l) + "px";
				list = d.getElementById('ckelist'), clist = list
						.cloneNode(true), h = clist
						.getElementsByTagName('input');
				for ( var i = 0, ci; ci = h[i++];) {
					texts[ci.value] = ci.parentNode
				};
				with (iframe.style) {
					left = top = '50%';
					width = div1.offsetWidth + 'px';
					height = div1.offsetHeight + 'px';
					margin = div1.style.margin;
					display = 'block'
				}
			}
			;
			return false;
		},
		choose : function(o) {
			clearTimeout(inputTimer);
			inputTimer = setTimeout(function() {
				var s = o.value.replace(/^\s+|\s+$/, ''), frag = d
						.createDocumentFragment();
				for ( var p in texts) {
					eval("var f = /" + (s || '.') + "/ig.test(p)");
					f && frag.appendChild(texts[p].cloneNode(true))
				}
				list.innerHTML = '';
				list.appendChild(frag)
			}, 100)
		},
		centerClose : function() {
			iframe.style.display = div1.style.display = 'none'
		}
	};
	var h = d.getElementsByTagName('a');
	for ( var i = 0, ci, tmp; ci = h[i++];) {
		if (/\bshareto_button\b/.test(ci.className)) {
			ci.onmouseout = sharetoBtnContain.out;
			ci.onmousemove = sharetoBtnContain.move;
			ci.onclick = sharetoBtnContain.center;
			ci.onmouseover = sharetoBtnContain.over;
			ci.hideFocus = true;
			continue
		}
		;
		if (/\bshareto_button_compact\b/.test(ci.className)) {
			ci.className = 'shareto_button_compact st_button stico stico_shareto';
			ci.onmouseout = sharetoBtnContain.out;
			ci.onmousemove = sharetoBtnContain.move;
			ci.onclick = sharetoBtnContain.center;
			ci.onmouseover = sharetoBtnContain.over;
			ci.hideFocus = true;
			continue
		}
		;
		if (ci.className
				&& (tmp = ci.className.match(/^shareto_button_(\w+)$/))
				&& tmp[1]) {
			ci.innerHTML = '<span class="stico st_button stico_' + tmp[1] + '"></span>';
			ci.onclick = function(a) {
				return function() {
					share_to(a)
				}
			}(tmp[1]);
			ci.href = 'javascript:void(0);';
			if (tmp[1]=="tsina")
			{
				ci.title ='分享到新浪微博'
			}
			else if (tmp[1]=="kaixin001")
			{
				ci.title ='分享到开心网'
			}
			else if (tmp[1]=="qzone")
			{
				ci.title ='分享到QQ空间'
			}
		
		}
	}
	;
	div.onmouseover = function() {
		clearTimeout(timer)
	};
	div.onmouseout = function() {
		sharetoBtnContain.out()
	};
	ie ? d.attachEvent("onclick", sharetoBtnContain.disappear) : d.addEventListener("click",
			sharetoBtnContain.disappear, false);
	document.write('<script src="http://shareto.googlecode.com/svn/trunk/js/analytics.js"></script>');
}();
function share_to(m) {
	 if (m == "tsina") {
		void ((function(s, d, e) {
			try {
			} catch (e) {
			}
			var f = 'http://v.t.sina.com.cn/share/share.php?', u = d.location.href, p = [
					'url=', e(u), '&title=', e(d.title), '&appkey=330242870' ]
					.join('');
			function a() {
				if (!window
						.open(
								[ f, p ].join(''),
								'mb',
								[
										'toolbar=0,status=0,resizable=1,width=620,height=450,left=',
										(s.width - 620) / 2, ',top=',
										(s.height - 450) / 2 ].join('')))
					u.href = [ f, p ].join('');
			}
			;
			if (/Firefox/.test(navigator.userAgent)) {
				setTimeout(a, 0)
			} else {
				a()
			}
		})(screen, document, encodeURIComponent));
	}   else if (m == "kaixin001") {
		var kw = window
				.open(
						'',
						'kaixin001',
						'toolbar=no,titlebar=no,status=no,menubar=no,scrollbars=no,location:no,directories:no,width=570,height=350,left='
								+ (screen.width - 570)
								/ 2
								+ ',top='
								+ (screen.height - 420) / 2);
		var tempForm = kw.document.createElement('form');
		function openPostWindow(url, data, name) {
			var tempForm = document.createElement('form');
			tempForm.id = 'tempForm1';
			tempForm.method = 'post';
			tempForm.action = url;
			tempForm.target = 'kaixin001';
			var hideInput = document.createElement('input');
			hideInput.type = 'hidden';
			hideInput.name = 'rcontent';
			hideInput.value = data;
			tempForm.appendChild(hideInput);
			document.body.appendChild(tempForm);
			tempForm.submit();
			document.body.removeChild(tempForm);
		}
		function add2Kaixin001() {
			var u = document.location.href;
			var t = document.title;
			var c = '' + (document.getSelection ? document.getSelection()
					: document.selection.createRange().text);
			var iframec = '';
			var url = 'http://www.kaixin001.com/repaste/bshare.php?rtitle='
					+ encodeURIComponent(t) + '&rurl=' + encodeURIComponent(u)
					+ '&from=maxthon';
			var data = encodeURIComponent(c);
			openPostWindow(url, c, '_blank')
		}
		add2Kaixin001();
	}  else if (m == "qzone") {// 未开放分享
		window.open(
				"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="
						+ encodeURIComponent(document.location), 'qzone',
				'toolbar=0,status=0,width=900,height=760,left='
						+ (screen.width - 900) / 2 + ',top='
						+ (screen.height - 760) / 2);
	} 
	return false;
}
// function googleTranslateElementInit() {
// new google.translate.TranslateElement({}, 'google_translate_element');
// }
function st_addBookmark(title){
    var url = parent.location.href;
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if(document.all) { // IE Favorite
        window.external.AddFavorite( url, title);
    } else if(window.opera) { // Opera 7+
        return false; // do nothing
    } else { 
         alert('请按 Ctrl + D 为chrome浏览器添加书签!');
    }
}
