﻿	(function(){
		var d = document,
			isStrict = d.compatMode == "CSS1Compat",dd = d.documentElement,db = d.body,m = Math.max,na = navigator.userAgent.toLowerCase(),
			ie = !!d.all,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)};	
			},
			creElm = function(o,t,pN){
				var el = d.createElement(t||'div');
				for(var p in o){
					p=='style'?el[p].cssText=o[p]:el[p]=o[p];
				}
				return (pN||db).insertBefore(el,(pN||db).firstChild);
			},
			div,
			div1 = creElm({id:'ckepop',style:"position:absolute;z-index:100000;display:none;top:50%;left:50%;"}),
			inputTimer,list,clist,as,texts={},script,timerover,timerout;
			
		var scripts = d.getElementsByTagName('script'),img = 'right.gif';
		for(var i=0,ci,btn;ci=scripts[i++];){
			if(/jiathis/gi.test(ci.src)&&ci.src.match(/btn=([^&]+)/)){
				img = ci.src.match(/btn=([^&]+)/)[1];
				break
			}
		};
		div = creElm({id:'ckepop',style:"right:0;position:"+(/msie 6/.test(na)?'absolute':'fixed')+";z-index:100000000;overflow:hidden;width:26px;top:150px;",innerHTML:"<table cellPadding=0 cellSpacing=0 ><tr><td><img id='jiathis_a'src=http://www.jiathis.com/code/images/"+img+" style='cursor:pointer;' onmouseover='$CKE.over()' onclick='$CKE.center(this)'/></td><td><div ></div></td></tr></table>"});	
		creElm({href:'http://www.jiathis.com/code/css/css1.css',rel:'stylesheet',type:'text/css'},'link');
		d.write('<script src="http://www.jiathis.com/code/ckepop.js" charset="utf-8"></script><script src="http://www.jiathis.com/code/ckecenterpop.js" charset="utf-8"></script>');
        $CKE = {
			pop : div.getElementsByTagName('div')[0],
			centerpop:div1,
			disappear : function(event){
				var evt = window.event||event,
					t = evt.srcElement||evt.target,
					contain = div1.contains?div1.contains(t):!!(div1.compareDocumentPosition(t) & 16),
				    contain1 = div.contains ? div.contains(t) : !!(div.compareDocumentPosition(t) & 16);
	            if (!contain &&!contain1) {
	                div1.style.display = 'none';
	            }
			},
			over : function(){
		     	if(div.offsetWidth>26) return;
	            clearInterval(timerout);
	            div.style.cssText +=";height:"+this.pop.offsetHeight+"px;width:26px;left:"+(getWH()-26)+"px"
	            var t = 10,tmp=0,step = this.pop.offsetWidth/55;
	            timerover = setInterval(function(){
	                if(t==0){
	                    clearInterval(timerover);
	                }else{
	                    var n = Math.round(step*t--);
	                    div.style.left = div.offsetLeft - n + 'px';
	                    div.style.width = div.offsetWidth + n + 'px'
	                }
	            },10)
			    
			},
			out : function(){
				if(div.offsetWidth>$CKE.pop.offsetWidth){
					clearInterval(timerover);
					
					div.style.cssText +=";height:"+$CKE.pop.offsetHeight+"px;width:"+($CKE.pop.offsetWidth+26)+"px;left:"+(getWH()-26-$CKE.pop.offsetWidth)+"px"
					var t = 10,tmp=0,step = (div.offsetWidth-26)/55;
					timerout = setInterval(function(){
						if(t==0){
							clearInterval(timerout);
							div.style.left = '';
						}else{
							var n = Math.round(step*t--);
							div.style.width = div.offsetWidth - n<26?26:div.offsetWidth - n + 'px'
							div.style.left = div.offsetLeft + n + 'px';		
						}
					},10) 
				}
			},
			center : function(a){
				if(a){
					db.style.position = 'static';
					var tl = getS();
					div1.style.display = "block";
					div1.style.margin = (-div1.offsetHeight/2+tl.t)+"px "+(-div1.offsetWidth/2+tl.l)+"px";
					list = d.getElementById('ckelist'),
					clist = list.cloneNode(true),
					as = clist.getElementsByTagName('input');
					for(var i=0,ci;ci = as[i++];){
						texts[ci.value] = ci.parentNode;			
					}
				}
			},
			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(){
				div1.style.display = 'none'
			}
		};
		if(ie){
			div.onmouseleave = $CKE.out
		}else{
			div.onmouseout = function(e){
				!(this===e.relatedTarget||(this.contains?this.contains(e.relatedTarget):this.compareDocumentPosition(e.relatedTarget)==20))&&$CKE.out.call(this);
			}
		}
		ie?d.attachEvent("onclick",$CKE.disappear):d.addEventListener("click",$CKE.disappear,false);
	})()
	function jiathis_sendto(m){
		window.open('http://www.jiathis.com/send/?webid='+m+'&url='+encodeURIComponent(location)+'&title='+encodeURIComponent(document.title),'')
		return false;
	}

 function jt_copyUrl(){
 var jtHerf=this.location.href;
 var jtTitle=document.title;
 if(window.clipboardData){
 var tempCurLink=jtTitle + "\n" + jtHerf;
 var ok=window.clipboardData.setData("Text",tempCurLink);
 if(ok) alert("复制成功,请粘贴到你的QQ/MSN上推荐给你的好友！");
 }else{alert("目前只支持IE，请复制地址栏URL,推荐给你的QQ/MSN好友！");}
 }
 
  function jt_addBookmark(title) {
                     var url=parent.location.href;
                     if (window.sidebar) { 
                            window.sidebar.addPanel(title, url,""); 
                     } else if( document.all ) {
                     window.external.AddFavorite( url, title);
                     } else if( window.opera && window.print ) {
                     return true;
                     }
       }