document.domain="tianqi.com";
$=function(id){return "string"==typeof id ? document.getElementById(id):id}
function loadJS(a,d){var b=document.body.appendChild(document.createElement("script"));d="utf-8"||d;b.language="javascript";b.charset=d;b.src=a}
function setHomePage(obj,homepage){if (document.all){document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(homepage);}else if (window.sidebar){if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}catch(e){alert("您的firefox安全限制限制您进行剪贴板操作，请在浏览器地址栏输入’about:config’并回车，然后将’signed.applets.codebase_principal_support’设置为’true’之后重试。");return;}};var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',homepage);}}
function SetCookie(c,e,a,f,d){var b=new Date();b.setDate(b.getDate()+365);a=b.toGMTString();f="/";d=".tianqi.com";document.cookie=c+"="+escape(e)+("; expires="+a)+("; path="+f)+("; domain="+d)+";"}
function getCookie(a){var b=a+"=";var c="";if(document.cookie.length>0){offset=document.cookie.lastIndexOf(b);if(offset!=-1){offset+=b.length;end=document.cookie.indexOf(";",offset);if(end==-1){end=document.cookie.length}c=unescape(document.cookie.substring(offset,end))}}return c};
function addFav(sURL, sTitle){var ua = navigator.userAgent.toLowerCase();if(ua.indexOf("msie 8")>-1){external.AddToFavoritesBar(sURL,sTitle,'实用工具');}else{try{window.external.addFavorite(sURL, sTitle);} catch(e){try{window.sidebar.addPanel(sTitle, sURL, "");} catch(e){alert("加入收藏失败，请使用Ctrl+D进行添加");}}}}
copyToClipboard=function(id){
	if(document.getElementById(id) != null)
		var txt = document.getElementById(id).value;
	else
		var txt = id;
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
		return true;
	}else if(navigator.userAgent.indexOf("Opera")!=-1){
		window.location=txt;
		return true;
	}else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}catch(e){
			alert("您的firefox安全限制限制您进行剪贴板操作，请在浏览器地址栏输入’about:config’并回车，然后将’signed.applets.codebase_principal_support’设置为’true’之后重试。");
			return;
		}
		var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if(!clip)return false;
		
		var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if(!trans)return false;
		
		trans.addDataFlavor('text/unicode');
		var str=new Object();
		var len=new Object();
		var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=txt;str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if(!clip)return false;
		
		clip.setData(trans,null,clipid.kGlobalClipboard);
		return true;		
	}
	return false;
}

function copy(str){
	if(str){ 
		result = copyToClipboard(str);
		if(result){
			alert('复制成功！');
		}else if(result == false){
			alert('您的浏览器不支持剪贴板操作，请自行复制！');
		}
	}else{
		alert('内容为空！');
	}
}
function showrili(){
	$("light").style.display='block';
	//$("fade").style.display='block';
}
function closerili(){
	$("light").style.display='none';
	//$("fade").style.display='none';
}
var Calendar=(function(){var g=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42416,83315,21168,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46752,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448,84835];var p=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");	var q=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");var b=new Date();var min=b.getMinutes();if(min<10){min='0'+min;}var e=b.getFullYear();var i=b.getMonth();var m=b.getDate();function format(g,c){if(arguments.length>1){var i=format,f=/([.*+?^=!:${}()|[\]\/\\])/g,b=(i.left_delimiter||"{").replace(f,"\\$1"),d=(i.right_delimiter||"}").replace(f,"\\$1"),j=i._r1||(i._r1=new RegExp("#"+b+"([^"+b+d+"]+)"+d,"g")),h=i._r2||(i._r2=new RegExp("#"+b+"(\\d+)"+d,"g"));if(typeof(c)=="object"){return g.replace(j,function(l,k){var m=c[k];if(typeof m=="function"){m=m(k)}return typeof(m)=="undefined"?"":m})}else{if(typeof(c)!="undefined"){var a=Array.prototype.slice.call(arguments,1),e=a.length;return g.replace(h,function(k,l){l=parseInt(l,10);return(l>=e)?k:a[l]})}}}return g}function r(s){return(p[s%10]+q[s%12])}function h(u){var s,t=348;for(s=32768;s>8;s>>=1){t+=(g[u-1900]&s)?1:0}return(t+f(u))}function f(s){if(a(s)){return((g[s-1900]&65536)?30:29)}else{return(0)}}function a(s){return(g[s-1900]&15)}	function j(t,s){return(g[t-1900]&(65536>>s))?30:29}	function k(w){var u,t=0,s=0;var v=new Date(1900,0,31);var x=(w-v)/86400000;this.dayCyl=x+40;this.monCyl=14;for(u=1900;u<2050&&x>0;u++){s=h(u);x-=s;this.monCyl+=12}if(x<0){x+=s;u--;this.monCyl-=12}this.year=u;this.yearCyl=u-1864;t=a(u);this.isLeap=false;for(u=1;u<13&&x>0;u++){if(t>0&&u==(t+1)&&this.isLeap==false){--u;this.isLeap=true;s=f(this.year)}else{s=j(this.year,u)}if(this.isLeap==true&&u==(t+1)){this.isLeap=false}x-=s;if(this.isLeap==false){this.monCyl++}}if(x==0&&t>0&&u==t+1){if(this.isLeap){this.isLeap=false}else{this.isLeap=true;--u;--this.monCyl}}if(x<0){x+=s;--u;--this.monCyl}this.month=u;this.day=x+1}function l(t,x){var r="日一二三四五六";var v=["日","一","二","三","四","五","六","七","八","九","十"];var u=["初","十","廿","卅"];var w;if(t>10){w="十"+v[t-10]}else{w=v[t]}if(w=="一"){w="正"}w+="月";switch(x){case 10:w+="初十";break;case 20:w+="二十";break;case 30:w+="三十";break;default:w+=u[Math.floor(x/10)];w+=v[parseInt(x%10)]}w+=' 星期'+r.charAt(b.getDay());return(w)}function n(){var t=new k(new Date(e,i,m));var s=l(t.month,t.day);return(s)}function d(){var t='<a href="javascript:void(0);" onclick="showrili();" rel="nr" title="点击查看万年历">#{YY}年#{MM}月#{DD}日 <label id="t_hm">#{week}</label></a>';var s=format(t,{YY:e,MM:i+1,DD:m,week:b.getHours()+':'+min});return s}function c(){m=m+1;var s=i<9?("0"+(i+1)):i+1;var t=m+1<10?("0"+m):m;return(e+"-"+s+"-"+t)}function o(){var s='<a href="javascript:void(0);" onclick="showrili();" rel="nr" title="点击查看万年历">农历 '+n()+"</a>";return s}return{day:d,cnday:o,date:c}})();function t_hm_fun(){clearTimeout(t_hm_timer);	var d=new Date();var min=d.getMinutes();if(min<10){min='0'+min;}document.getElementById('t_hm').innerHTML=d.getHours()+':'+min;t_hm_timer = setTimeout("t_hm_fun()",3000);}var t_hm_timer = setTimeout("t_hm_fun()",3000);

var LightDrag = function ()
{
	var oWin = document.getElementById("light");
	var oH2 = oWin.getElementsByTagName("h2")[0];
	var bDrag = false;
	var disX = disY = 0;
	oH2.onmousedown = function (event)
	{
		var event = event || window.event;
		bDrag = true;
		disX = event.clientX - oWin.offsetLeft;
		disY = event.clientY - oWin.offsetTop;		
		this.setCapture && this.setCapture();		
		return false
	};
	document.onmousemove = function (event)
	{
		if (!bDrag) return;
		var event = event || window.event;
		var iL = event.clientX - disX;
		var iT = event.clientY - disY;
		var maxL = document.documentElement.clientWidth - oWin.offsetWidth;
		var maxT = document.documentElement.clientHeight - oWin.offsetHeight;		
		iL = iL < 0 ? 0 : iL;
		iL = iL > maxL ? maxL : iL; 		
		iT = iT < 0 ? 0 : iT;
		iT = iT > maxT ? maxT : iT;
		
		oWin.style.marginTop = oWin.style.marginLeft = 0;
		oWin.style.left = iL + "px";
		oWin.style.top = iT + "px";		
		return false
	};
	document.onmouseup = window.onblur = oH2.onlosecapture = function ()
	{
		bDrag = false;				
		oH2.releaseCapture && oH2.releaseCapture();
	};
}
