//---字符串轉換函數或公用字符串函數---//
function jieya(s){//解压缩
var o="0000000000",o2=o+o,o3=o2+o2+o2;
s=s.replace(/J/g,'00');
s=s.replace(/I/g,'000');
s=s.replace(/H/g,'0000');
s=s.replace(/G/g,'00000');
s=s.replace(/t/g,'02');
s=s.replace(/Q/g,'0202');
s=s.replace(/R/g,'02020202');
s=s.replace(/s/g,'002');
s=s.replace(/T/g,'002002');
s=s.replace(/r/g,'0002');
s=s.replace(/q/g,'00002');
s=s.replace(/p/g,'000002');
s=s.replace(/o/g,'0000002');
s=s.replace(/n/g,'00000002');
s=s.replace(/m/g,'000000002');
s=s.replace(/l/g,'0000000002');
s=s.replace(/k/g,'01');
s=s.replace(/j/g,'0101');
s=s.replace(/L/g,'01010101');
s=s.replace(/i/g,'001');
s=s.replace(/h/g,'001001');
s=s.replace(/g/g,'0001');
s=s.replace(/u/g,'00010001');
s=s.replace(/f/g,'00001');
s=s.replace(/e/g,'000001');
s=s.replace(/d/g,'0000001');
s=s.replace(/c/g,'00000001');
s=s.replace(/b/g,'000000001');
s=s.replace(/a/g,'0000000001');
s=s.replace(/N/g,o3+o3+o3+o3+o3+o3+o3+o3);
s=s.replace(/M/g,o3+o3+o3+o3+o3+o3+o3);
s=s.replace(/z/g,o3+o3+o3+o3+o3+o3);
s=s.replace(/w/g,o3+o3+o3+o3+o3);
s=s.replace(/y/g,o3+o3+o3+o3);
s=s.replace(/x/g,o3+o3+o3);
s=s.replace(/V/g,o3+o3);
s=s.replace(/A/g,o3);
s=s.replace(/B/g,o2+o2+o);
s=s.replace(/C/g,o2+o2);
s=s.replace(/D/g,o2+o);
s=s.replace(/E/g,o2);
s=s.replace(/F/g,o);
return s;
}
function jieyaNum(s){//解压缩2
s=s.replace(/k/g,'00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c00c0c');
s=s.replace(/H/g,'00c00c0c00c00c00c0c');
s=s.replace(/G/g,'00c00c00c0c');
s=s.replace(/t/g,'00c00c0c');
s=s.replace(/f/g,'00c');
return s;
}
function dToStr(dv){//將單位天的純小數轉換成如5:08:02的時間格式
var h=floor(dv*24);
var min=floor((dv*24-h)*60);
var sec=floor(((dv*24-h)*60-min)*60);
if(min<10)
min='0'+min;
if(sec<10)
sec='0'+sec;
return h+':'+min+':'+sec;
}
function rad2str2(d){//將弧度轉為字串,精確到分,例: -23°59'
var s="+";
var w1="°",w2="'",w3='"';
if(d<0) d=-d,s='-';
d*=180/Math.PI;
var a=Math.floor(d);
var b=Math.floor((d-a)*60+0.5);
if(b>=60) b-=60, a++;
a=""+a, b="0"+b;
s+=a.substr(a.length-3,3)+w1;
s+=b.substr(b.length-2,2)+w2;
return s;
}
function revJD2(jd){ //儒略日小數部分換成如5:08的時間格式
var f=tail(jd-0.1665)//取jd小數部分F
var dv=f;
var ymd=dToStr(dv);
return ymd;
}
function yearStr(v){//年份
if(v<=0){
return '前'+(-v+1)+'年';
}
else{
return v+'年';
}
}
function dayStr(v){//星期
return '日一二三四五六'.charAt(round(rem((v+1),7)));
}
function szodStr(v){//星座
return '摩羯寶瓶雙魚白羊金牛雙子巨蟹獅子處女天秤天蠍射手'.substring(2*v,2*v+2)+'座';
}
function sjsx(v,a){
var sjsx=new Array('孟','仲','季');if(a==1)sjsx=new Array('a','b','c');
return sjsx[round(rem(v,3))];}
function lunMStr(v,b){///農暦月數月序,b代表農暦頒行暦種---1代表:[武周]行周暦...
var str=new Array('正','二','三','四','五','六','七','八','九','十','十一','十二');//各暦種公用月序
if(b==1)str=new Array('一','二','三','四','五','六','七','八','九','十','正','臘');//(1)[武周]行周暦-月序
if(b==6)str=new Array('寓','卯','辰','巳','五','六','七','八','九','十','子','丑');//(6)[唐肅宗]行周暦-月序
var v0=abs(v);
var vstr=str[(v0-1)%12];var nun='閏';if(b==2)nun='後';
if(ya<-1187&&v==-12||v0==13)
vstr='十三';
if(v0==0)
vstr='XX';
if(ya>=-1187&&v<0)
vstr=nun+vstr;
return vstr;
}
function lunDStr(v){//農曆中文日數
var str='十一二三四五六七八九初十廿三';
var vstr=str.charAt(floor(v/10)+10)+str.charAt(v%10);
if(v==10)vstr='初十';if(v==20)vstr='二十';
return vstr;
}
function dsz(v){//數
var vstr=v;if(v<10)vstr='0'+v;
return vstr;
}
function sStr(v){//節氣
return '小寒大寒立春雨水驚蟄春分清明穀雨立夏小滿芒種夏至小暑大暑立秋處暑白露秋分寒露霜降立冬小雪大雪冬至'.substring(2*v-2,2*v);
}
function ifgStr(v){//公曆類型
if(v==-1){
alert('公曆曆法去掉了1582年10月5日至10月14日,因這十天在歷史上不存在!');
return('不存在');
}
else
return (v)?'格里曆':'儒略曆';
}
function gzStr(v){//60干支、甲子为1式
return '甲乙丙丁戊己庚辛壬癸'.charAt(v%10)+'子丑寅卯辰巳午未申酉戌亥'.charAt(v%12);
}
function nzb(v){//年紫白八卦位
return '中巽震坤坎離艮兌乾'.charAt(v%9);
}
function sxbg(v){//日紫白八卦
return '乾坎艮艮震巽巽離坤坤兌乾'.charAt(v%12);
}
function wtsz(v){//烏兔時
return '卯未申辰申'.charAt(v%5);
}
//其它通用字符
var nlm = new Array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
var Ganh=new Array("己","庚","辛","壬","癸","甲","乙","丙","丁","戊");//五合
var Gan5=new Array("戊","己","庚","辛","壬","癸","甲","乙","丙","丁");//相克
var sfw=new Array("南","東","北","西","南","東","北","西","南","東","北","西");
var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
var Zhi3=new Array("午","未","申","酉","戌","亥","子","丑","寅","卯","辰","巳");//相沖
var Zih6=new Array("丑","子","亥","戌","酉","申","未","午","巳","辰","卯","寅");//六合
var Zhai=new Array("未","午","巳","辰","卯","寅","丑","子","亥","戌","酉","申");//相害
var Zxin=new Array("卯","未","巳","子","辰","申","午","戌","寅","酉","丑","亥");//相刑
var Zpo=new Array('酉','辰','亥','午','丑','申','卯','戌','巳','子','未','寅');//破
var AnimalIdx=["鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬"];
var AnimalIdx2=["馬","羊","猴","雞","狗","豬","鼠","牛","虎","兔","龍","蛇"];
var dayglk = new Array('辛已丁命財官印','庚戊丙命財官印','癸辛已命財官印','壬庚戊命財官印','乙癸辛命財官印','甲壬庚命財官印','丁乙癸命財官印','丙甲壬命財官印','已丁乙命財官印','戊丙甲命財官印');
var daglk2 = new Array('命互祿在寅貴丑未','命互祿在卯貴子申','命互祿在巳貴亥酉','命互祿在午貴亥酉','命互祿在巳貴丑未','命互祿在午貴子申','命互祿在申貴丑未','命互祿在酉貴午寅','命互祿在亥貴卯巳','命互祿在子貴卯巳');
var Sukuyou = new Array('東方','東方','東方','東方','東方','東方','東方','北方','北方','北方','北方','北方','北方','北方','西方','西方','西方','西方','西方','西方','西方','南方','南方','南方','南方','南方','南方','南方');
var Sukuyou2 = new Array('角木蛟--吉','亢金龍--凶','氐土貉--凶','房日兔--吉','心月狐--凶','尾火虎--吉','箕水豹--吉','斗木獬--吉','牛金牛--凶','女土蝠--凶','虛日鼠--凶','危月燕--凶','室火豬--吉','壁水貐--吉','奎木狼--凶','婁金狗--吉','胃土雉--吉','昴日雞--凶','畢月烏--吉','觜火猴--凶','參水猿--凶','井木犴--吉','鬼金羊--凶','柳土獐--凶','星日馬--凶','張月鹿--吉','翼火蛇--凶','軫水蚓--吉');
var Sukuyou4 = new Array('角','亢','氐','房','心','尾','箕','斗','牛','女','虛','危','室','壁','奎','婁','胃','昴','畢','觜','參','井','鬼','柳','星','張','翼','軫');
var jxName = new Array('九紫','八白','七赤','六白','五黃','四緑','三碧','二黒','一白');
var jxName2= new Array('-右弼-天乙星(火)-吉神','-左輔-太陰星(土)-吉神','-破軍-鹹池星(金)-凶神','-武曲-青龍星(金)-吉神','-廉貞-天符星(土)-凶神','-文昌-招搖星(木)-安神','-祿存-軒轅星(木)-安神','-巨門-攝提星(土)-凶神','-貪狼-太乙星(水)-吉神');
var Rokuyou = new Array("<font color=#804000>先勝</font>","<font color=#804000>友引</font>","<font color=#804000>先負</font>","<FONT color=#0000A0>佛滅</font>","<FONT color=#FF8C1A>大安</font>","<font color=#804000>赤口</font>");
var tsName=new Array('姓毛名辛','姓文名政','姓洪名范','姓虞名程','姓金名赤','姓陳名泰','姓沈名興','姓耿名章','姓趙名達','姓郭名燦','姓王名清','姓李名素','姓劉名旺','姓康名忠','姓誓名廣','姓伍名保','姓郭名嘉','姓汪名文','姓曾名光','姓伍名仲','姓重名德','姓鄭名祖','姓路名明','姓魏名明','姓方名公','姓蔣名端','姓向名般','姓封名齊','姓郢名班','姓潘名蓋','姓鄔名恒','姓范名寧','姓彭名泰','姓徐名舜','姓張名詞','姓楊名賢','姓管名仲','姓康名傑','姓薑名開','姓謝名壽','姓虞名起','姓湯名信','姓賀名諤','姓皮名時','姓李名成','姓吳名逐','姓文名折','姓戮名丙','姓俞名忠','姓程名寅','姓化名秋','姓葉名堅','姓印名德','姓林名薄','姓張名朝','姓方名清','姓辛名亞','姓易名彥','姓姚名黎','姓傅名稅');
var jzjy=new Array('中','下','上');var jxm=new Array('右弼','貪狼','巨門','祿存','文昌','廉貞','武曲','破軍','左輔');
var jzbg=new Array('離火','坎水','坤土','震木','巽木','中','乾金','兌金','艮土');
var jzbg2=new Array('乾金','坤水','巽火','離木','兌金','配卦前10年同4後10年同6','艮水','坎火','震木');
var jzss=new Array('丙午丁九紫火管山<br>壬子癸一白水管水','壬子癸一白水管山<br>丙午丁九紫火管水','未坤申二黑土管山<br>丑艮寅八白土管水','甲卯乙三碧木管山<br>庚酉辛七赤金管水','辰巽巳四綠木管山<br>戌乾亥六白金管山','未坤申二黑土管山<br>丑艮寅八白土管水','戌乾亥六白金管山<br>辰巽巳四綠木管水','庚酉辛七赤金管山<br>甲卯乙三碧木金管水','丑艮寅八白土管山<br>未坤申二黑土管水');
var Gan3jsd=new Array("甲子","丙子","戊子","庚子","壬子","甲子","丙子","戊子","庚子","壬子");
var Gan2=new Array('甲不開倉','乙不栽植','丙不修竈','丁不剃頭','戊不受田','己不破券','庚不經絡','辛不合醬','壬不泱水','癸不詞訟');
var dehu=new Array('辛丑','辛巳','丙午','甲戌甲午','癸酉癸未','甲辰己未','壬戌','己亥','丁巳','辛丑','戊子','乙未','丁丑','癸未','甲辰丙午','丁亥己未','戊辰戊戌','己未','壬寅','甲申','壬辰','丙子','甲子','丁亥丁巳','己卯','丁未','丙申','辛未','壬申','甲午','丁酉庚子','丙子丙申','乙丑','丁酉','癸亥','辛未','乙未','壬子','甲辰','丙辰丁巳','庚辰','丙子','丁巳丁未','己未','庚戌','庚申','辛丑','辛亥','乙亥','丁亥甲寅','癸巳癸未','戊子丙子','甲辰甲申','庚子','辛未','丙戌','辛巳辛酉','庚辰','辛酉辛丑','丙寅');
var Gan3jd=new Array(0,12,24,36,48,0,12,24,36,48);
var Gan4a=new Array("<td width=30><font color=#FF8C1A>金匱</font></td>","<td width=30><font color=#FF8C1A>天德</font></td>","<td width=30><font color=#0000A0>白虎</font></td>","<td width=30><font color=#FF8C1A>玉堂</font></td>","<td width=30><font color=#0000A0>天牢</font></td>","<td width=30><font color=#0000A0>玄武</font></td>","<td width=30><font color=#FF8C1A>司命</font></td>","<td width=30><font color=#0000A0>勾陳</font></td>","<td width=30><font color=#FF8C1A>青龍</font></td>","<td width=30><font color=#FF8C1A>明堂</font></td>","<td width=30><font color=#0000A0>天刑</font></td>","<td width=30><font color=#0000A0>朱雀</font></td>");
var ciytust = new Array('赤眼','招瘟','疾病','錢財','狐狸','牢獄','風火','瘡毒','田蠶','富貴','招客','進口');
var Zhi2=new Array('子不問卜','丑不冠帶','寅不祭祀','卯不穿井','辰不哭泣','巳不遠行','午不苫蓋','未不服藥','申不安床','酉不會客','戌不吃犬','亥不嫁娶');
var Zhi2a=new Array('申辰丑命三六合','巳酉子命三六合','戌午亥命三六合','亥未戌命三六合','申子酉命三六合','酉丑申命三六合','寅戌未命三六合','亥卯午命三六合','子辰巳命三六合','巳丑辰命三六合','寅午卯命三六合','卯未寅命三六合');
var taisen=new Array('占門碓','碓磨廁','廚灶爐','倉庫門','房床栖','占門床','占碓磨','廁灶廚','倉庫爐','房床門','門碓栖','碓磨床','廚灶碓','倉庫廁','房床爐','占大門','碓磨栖','廚灶床','倉庫碓','房床廁','占門爐','門碓磨','廚灶栖','倉庫床','房床碓','占門廁','碓磨爐','廚灶門','倉庫栖','占房床','占門碓','碓磨廁','廚灶爐','門倉庫','房床栖','占門床','占碓磨','廁灶廚','倉庫爐','房床門','門碓栖','碓磨床','廚灶碓','倉庫廁','房床爐','占大門','碓磨栖','廚灶床','倉庫碓','房床廁','占門爐','門碓磨','廚灶栖','倉庫床','房床碓','占門廁','碓磨爐','廚灶門','倉庫栖','占房床');
var taisen2=new Array('外東南','外東南','外正南','外正南','外正南','外正南','外正南','外西南','外西南','外西南','外西南','外西南','外西南','外正西','外正西','外正西','外正西','外正西','外西北','外西北','外西北','外西北','外西北','外西北','外正北','外正北','外正北','外正北','外正北','房內北','房內北','房內北','房內北','房內北','房內中','房內中','房內南','房內南','房內南','房內西','房內東','房內東','房內東','房內東','房內中','外東北','外東北','外東北','外東北','外東北','外東北','外正東','外正東','外正東','外正東','外正東','外東南','外東南','外東南','外東南');
var jcName = new Array('建','除','滿','平','定','執','破','危','成','收','開','閉');
var zrxName = new Array('金匮<font color=#FF8C1A>(黃道日)</font>','天德<font color=#FF8C1A>(黃道日)</font>','白虎<FONT color=#0000A0>(黑道日)</font>','玉堂<font color=#FF8C1A>(黃道日)</font>','天牢<FONT color=#0000A0>(黑道日)</font>','玄武<FONT color=#0000A0>(黑道日)</font>','司命<font color=#FF8C1A>(黃道日)</font>','勾陳<FONT color=#0000A0>(黑道日)</font>','青龍<font color=#FF8C1A>(黃道日)</font>','明堂<font color=#FF8C1A>(黃道日)</font>','天刑<FONT color=#0000A0>(黑道日)</font>','朱雀<FONT color=#0000A0>(黑道日)</font>');
var mEn=new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
var dayStrcn=new Array("一","二","三","四","五","<font color=#008000>六</font>","<font color=#FF0000>日</font>");
var dayEn=new Array("MON","TUE","WED","THR","FRI","<font color=#5FB30B>SAT</font>","<font color=#FF6A6A>SUN</font>");