<%

	Dim m_minyear
	Dim m_maxyear

	m_minyear		= 1950
	m_maxyear		= 2050

	Dim CalendarData(99,2)
	CalendarData(0,0)=&H2f
	CalendarData(0,1)=&H6c
	CalendarData(0,2)=&Ha0
	CalendarData(1,0)=&H24
	CalendarData(1,1)=&Hb5
	CalendarData(1,2)=&H50
	CalendarData(2,0)=&Hda
	CalendarData(2,1)=&H53
	CalendarData(2,2)=&H55
	CalendarData(3,0)=&H2c
	CalendarData(3,1)=&H4d
	CalendarData(3,2)=&Ha0
	CalendarData(4,0)=&H21
	CalendarData(4,1)=&Ha5
	CalendarData(4,2)=&Hb0
	CalendarData(5,0)=&H57
	CalendarData(5,1)=&H45
	CalendarData(5,2)=&H73
	CalendarData(6,0)=&Haa
	CalendarData(6,1)=&H52
	CalendarData(6,2)=&Hb0
	CalendarData(7,0)=&H1e
	CalendarData(7,1)=&Ha9
	CalendarData(7,2)=&Ha8
	CalendarData(8,0)=&H30
	CalendarData(8,1)=&He9
	CalendarData(8,2)=&H50
	CalendarData(9,0)=&H26
	CalendarData(9,1)=&H6a
	CalendarData(9,2)=&Ha0
	CalendarData(10,0)=&H9b
	CalendarData(10,1)=&Hae
	CalendarData(10,2)=&Ha6
	CalendarData(11,0)=&H2d
	CalendarData(11,1)=&Hab
	CalendarData(11,2)=&H50
	CalendarData(12,0)=&H23
	CalendarData(12,1)=&H4b
	CalendarData(12,2)=&H60
	CalendarData(13,0)=&H18
	CalendarData(13,1)=&Haa
	CalendarData(13,2)=&He4
	CalendarData(14,0)=&Hab
	CalendarData(14,1)=&Ha5
	CalendarData(14,2)=&H70
	CalendarData(15,0)=&H20
	CalendarData(15,1)=&H52
	CalendarData(15,2)=&H60
	CalendarData(16,0)=&H14
	CalendarData(16,1)=&Hf2
	CalendarData(16,2)=&H63
	CalendarData(17,0)=&H27
	CalendarData(17,1)=&Hd9
	CalendarData(17,2)=&H50
	CalendarData(18,0)=&H9d
	CalendarData(18,1)=&H5b
	CalendarData(18,2)=&H57
	CalendarData(19,0)=&H2f
	CalendarData(19,1)=&H56
	CalendarData(19,2)=&Ha0
	CalendarData(20,0)=&H24
	CalendarData(20,1)=&H96
	CalendarData(20,2)=&Hd0
	CalendarData(21,0)=&H1a
	CalendarData(21,1)=&H4d
	CalendarData(21,2)=&Hd5
	CalendarData(22,0)=&Had
	CalendarData(22,1)=&H4a
	CalendarData(22,2)=&Hd0
	CalendarData(23,0)=&H21
	CalendarData(23,1)=&Ha4
	CalendarData(23,2)=&Hd0
	CalendarData(24,0)=&H16
	CalendarData(24,1)=&Hd4
	CalendarData(24,2)=&Hd4
	CalendarData(25,0)=&H29
	CalendarData(25,1)=&Hd2
	CalendarData(25,2)=&H50
	CalendarData(26,0)=&H9e
	CalendarData(26,1)=&Hd5
	CalendarData(26,2)=&H58
	CalendarData(27,0)=&H30
	CalendarData(27,1)=&Hb5
	CalendarData(27,2)=&H40
	CalendarData(28,0)=&H25
	CalendarData(28,1)=&Hb6
	CalendarData(28,2)=&Ha0
	CalendarData(29,0)=&H5b
	CalendarData(29,1)=&H95
	CalendarData(29,2)=&Ha6
	CalendarData(30,0)=&Hae
	CalendarData(30,1)=&H95
	CalendarData(30,2)=&Hb0
	CalendarData(31,0)=&H23
	CalendarData(31,1)=&H49
	CalendarData(31,2)=&Hb0
	CalendarData(32,0)=&H18
	CalendarData(32,1)=&Ha9
	CalendarData(32,2)=&H74
	CalendarData(33,0)=&H2b
	CalendarData(33,1)=&Ha4
	CalendarData(33,2)=&Hb0
	CalendarData(34,0)=&Ha0
	CalendarData(34,1)=&Hb2
	CalendarData(34,2)=&H7a
	CalendarData(35,0)=&H32
	CalendarData(35,1)=&H6a
	CalendarData(35,2)=&H50
	CalendarData(36,0)=&H27
	CalendarData(36,1)=&H6d
	CalendarData(36,2)=&H40
	CalendarData(37,0)=&H1c
	CalendarData(37,1)=&Haf
	CalendarData(37,2)=&H46
	CalendarData(38,0)=&Haf
	CalendarData(38,1)=&Hab
	CalendarData(38,2)=&H60
	CalendarData(39,0)=&H24
	CalendarData(39,1)=&H95
	CalendarData(39,2)=&H70
	CalendarData(40,0)=&H1a
	CalendarData(40,1)=&H4a
	CalendarData(40,2)=&Hf5
	CalendarData(41,0)=&H2d
	CalendarData(41,1)=&H49
	CalendarData(41,2)=&H70
	CalendarData(42,0)=&Ha2
	CalendarData(42,1)=&H64
	CalendarData(42,2)=&Hb0
	CalendarData(43,0)=&H16
	CalendarData(43,1)=&H74
	CalendarData(43,2)=&Ha3
	CalendarData(44,0)=&H28
	CalendarData(44,1)=&Hea
	CalendarData(44,2)=&H50
	CalendarData(45,0)=&H1e
	CalendarData(45,1)=&H6b
	CalendarData(45,2)=&H58
	CalendarData(46,0)=&Hb1
	CalendarData(46,1)=&H5a
	CalendarData(46,2)=&Hc0
	CalendarData(47,0)=&H25
	CalendarData(47,1)=&Hab
	CalendarData(47,2)=&H60
	CalendarData(48,0)=&H1b
	CalendarData(48,1)=&H96
	CalendarData(48,2)=&Hd5
	CalendarData(49,0)=&H2e
	CalendarData(49,1)=&H92
	CalendarData(49,2)=&He0
	CalendarData(50,0)=&Ha3
	CalendarData(50,1)=&Hc9
	CalendarData(50,2)=&H60
	CalendarData(51,0)=&H17
	CalendarData(51,1)=&Hd9
	CalendarData(51,2)=&H54
	CalendarData(52,0)=&H2a
	CalendarData(52,1)=&Hd4
	CalendarData(52,2)=&Ha0
	CalendarData(53,0)=&H1f
	CalendarData(53,1)=&Hda
	CalendarData(53,2)=&H50
	CalendarData(54,0)=&H95
	CalendarData(54,1)=&H75
	CalendarData(54,2)=&H52
	CalendarData(55,0)=&H27
	CalendarData(55,1)=&H56
	CalendarData(55,2)=&Ha0
	CalendarData(56,0)=&H1c
	CalendarData(56,1)=&Hab
	CalendarData(56,2)=&Hb7
	CalendarData(57,0)=&H30
	CalendarData(57,1)=&H25
	CalendarData(57,2)=&Hd0
	CalendarData(58,0)=&Ha5
	CalendarData(58,1)=&H92
	CalendarData(58,2)=&Hd0
	CalendarData(59,0)=&H19
	CalendarData(59,1)=&Hca
	CalendarData(59,2)=&Hb5
	CalendarData(60,0)=&H2c
	CalendarData(60,1)=&Ha9
	CalendarData(60,2)=&H50
	CalendarData(61,0)=&H21
	CalendarData(61,1)=&Hb4
	CalendarData(61,2)=&Ha0
	CalendarData(62,0)=&H96
	CalendarData(62,1)=&Hba
	CalendarData(62,2)=&Ha4
	CalendarData(63,0)=&H28
	CalendarData(63,1)=&Had
	CalendarData(63,2)=&H50
	CalendarData(64,0)=&H1e
	CalendarData(64,1)=&H55
	CalendarData(64,2)=&Hd9
	CalendarData(65,0)=&H31
	CalendarData(65,1)=&H4b
	CalendarData(65,2)=&Ha0
	CalendarData(66,0)=&Ha6
	CalendarData(66,1)=&Ha5
	CalendarData(66,2)=&Hb0
	CalendarData(67,0)=&H5b
	CalendarData(67,1)=&H51
	CalendarData(67,2)=&H76
	CalendarData(68,0)=&H2e
	CalendarData(68,1)=&H52
	CalendarData(68,2)=&Hb0
	CalendarData(69,0)=&H23
	CalendarData(69,1)=&Ha9
	CalendarData(69,2)=&H30
	CalendarData(70,0)=&H98
	CalendarData(70,1)=&H79
	CalendarData(70,2)=&H54
	CalendarData(71,0)=&H2a
	CalendarData(71,1)=&H6a
	CalendarData(71,2)=&Ha0
	CalendarData(72,0)=&H1f
	CalendarData(72,1)=&Had
	CalendarData(72,2)=&H50
	CalendarData(73,0)=&H15
	CalendarData(73,1)=&H5b
	CalendarData(73,2)=&H52
	CalendarData(74,0)=&Ha8
	CalendarData(74,1)=&H4b
	CalendarData(74,2)=&H60
	CalendarData(75,0)=&H1c
	CalendarData(75,1)=&Ha6
	CalendarData(75,2)=&He6
	CalendarData(76,0)=&H2f
	CalendarData(76,1)=&Ha4
	CalendarData(76,2)=&He0
	CalendarData(77,0)=&H24
	CalendarData(77,1)=&Hd2
	CalendarData(77,2)=&H60
	CalendarData(78,0)=&H99
	CalendarData(78,1)=&Hea
	CalendarData(78,2)=&H65
	CalendarData(79,0)=&H2b
	CalendarData(79,1)=&Hd5
	CalendarData(79,2)=&H30
	CalendarData(80,0)=&H21
	CalendarData(80,1)=&H5a
	CalendarData(80,2)=&Ha0
	CalendarData(81,0)=&H16
	CalendarData(81,1)=&H76
	CalendarData(81,2)=&Ha3
	CalendarData(82,0)=&Ha9
	CalendarData(82,1)=&H96
	CalendarData(82,2)=&Hd0
	CalendarData(83,0)=&H1e
	CalendarData(83,1)=&H4a
	CalendarData(83,2)=&Hfb
	CalendarData(84,0)=&H31
	CalendarData(84,1)=&H4a
	CalendarData(84,2)=&Hd0
	CalendarData(85,0)=&H26
	CalendarData(85,1)=&Ha4
	CalendarData(85,2)=&Hd0
	CalendarData(86,0)=&Hdb
	CalendarData(86,1)=&Hd0
	CalendarData(86,2)=&Hb6
	CalendarData(87,0)=&H2d
	CalendarData(87,1)=&Hd2
	CalendarData(87,2)=&H50
	CalendarData(88,0)=&H22
	CalendarData(88,1)=&Hd5
	CalendarData(88,2)=&H20
	CalendarData(89,0)=&H17
	CalendarData(89,1)=&Hdd
	CalendarData(89,2)=&H45
	CalendarData(90,0)=&Haa
	CalendarData(90,1)=&Hb5
	CalendarData(90,2)=&Ha0
	CalendarData(91,0)=&H1f
	CalendarData(91,1)=&H56
	CalendarData(91,2)=&Hd0
	CalendarData(92,0)=&H15
	CalendarData(92,1)=&H55
	CalendarData(92,2)=&Hb2
	CalendarData(93,0)=&H28
	CalendarData(93,1)=&H49
	CalendarData(93,2)=&Hb0
	CalendarData(94,0)=&H9d
	CalendarData(94,1)=&Ha5
	CalendarData(94,2)=&H77
	CalendarData(95,0)=&H2f
	CalendarData(95,1)=&Ha4
	CalendarData(95,2)=&Hb0
	CalendarData(96,0)=&H24
	CalendarData(96,1)=&Haa
	CalendarData(96,2)=&H50
	CalendarData(97,0)=&H59
	CalendarData(97,1)=&Hb2
	CalendarData(97,2)=&H55
	CalendarData(98,0)=&Hac
	CalendarData(98,1)=&H6d
	CalendarData(98,2)=&H20
	CalendarData(99,0)=&H20
	CalendarData(99,1)=&Had
	CalendarData(99,2)=&Ha0


Function ConvertToNongLi(m_gongli)
	Dim days
	Dim years
	Dim alldays
	Dim result
	
	days	= DaysFromNewYear(m_gongli)	
	alldays = GetDaysFromStart(Year(m_gongli))	
	years   = Year(m_gongli)	
	if days <= alldays Then		
		years = years - 1
		days  = days + GetGongYearDays(years)	
	end if
	days = days - GetDaysFromStart(years)
	result = CalNongDate(years,days)	
	ConvertToNongLi = result
end function


function CalNongDate(years,days)

	Dim resultday,resultyear,resultmonth
	dim caldays,IsRunyue,i
	caldays = 0
	
	resultyear = years
	IsRunyue = false

	for i=1 to 12
		caldays = caldays + GetNotRunNongMonthDays(years,i)	
		if caldays>=days then	
			caldays = caldays - GetNotRunNongMonthDays(years,i)
			resultmonth = i
			resultday = days - caldays
			IsRunyue = false
			exit for
		else
			if GetNongRunYue(years) = i then   
				caldays = caldays + GetNongRunYueDays(years)
				if caldays>=days then
					caldays = caldays - GetNongRunYueDays(years)
					resultmonth = i
					resultday = days - caldays
					IsRunyue = true
					exit for
				end if
			end if
		end if
	next
	CalNongDate=resultyear & "-" & resultmonth & "-" & resultday

end function

function RunYueIsLarge(years)

	RunYueIsLarge = CalendarData(years-m_minyear,0) AND &H40

end function

function GetGongYearDays(years)

	if YearIsRunNian(years) then
		GetGongYearDays = 366
	else
		GetGongYearDays = 365
	end if
end function

function GetNongRunYueDays(years)
	if GetNongRunYue(years) =0 then
		GetNongRunYueDays = 0
		exit function
	end if
	if RunYueIsLarge(years) then
		GetNongRunYueDays = 30
	else
		GetNongRunYueDays = 29
	end if
end function

function GetGongMonthDays(years,months)

	GetGongMonthDays = 30
	if months = 2 then
		if YearIsRunNian(years) Then
			GetGongMonthDays = 29
		else
			GetGongMonthDays = 28
		end if
	else
		if GongMonthIsLarge(months) Then
			GetGongMonthDays = 31
		else
			GetGongMonthDays = 30
		end if
	end if

end function

function GetNotRunNongMonthDays(years,months)

	if NongMonthIsLarge(years,months) Then
		GetNotRunNongMonthDays = 30
	else
		GetNotRunNongMonthDays = 29
	end if

end function



function DaysFromNewYear(m_day)

	Dim days,i
	days = 0
	for i=1 to Month(m_day) - 1
		days = days + GetGongMonthDays(year(m_day),i)
	next
	days = days + Day(m_day)
	DaysFromNewYear = days

end function

function Cal2N(n)
	Dim i
	Cal2N = 1
	for i=0 to n - 1
		Cal2N = Cal2N * 2
	next
end function

function YearIsRunNian(years)

	YearIsRunNian = CalendarData(years-m_minyear,0) AND &H80

end function

function GetDaysFromStart(years)

	GetDaysFromStart = (CalendarData(years-m_minyear,0) AND &H3f)

end function

function NongMonthIsLarge(years,months)

	Dim ch
	NongMonthIsLarge = false
	if(months<9) then
		if(CalendarData(years-m_minyear,1) AND Cal2N(8 - months)) then
			NongMonthIsLarge = true
		end if
	else
		ch=Cal2N(12 - months)
		ch=MoveBit(ch)
		if(CalendarData(years-m_minyear,2) AND ch) then NongMonthIsLarge = true
	end if
 
end function

function GetNongRunYue(years)

	GetNongRunYue = (CalendarData(years-m_minyear,2) AND &H0f)

end function

function GongMonthIsLarge(months)

	GongMonthIsLarge = false
	if months < 8 then
		if (months mod 2) <> 0 then
			GongMonthIsLarge = true
		end if
	else
		if ((months mod 2) = 0) then
			GongMonthIsLarge = true
		end if
	end if

end function

%>
<SCRIPT LANGUAGE="JSCript" RUNAT=Server>
function MoveBit(num)
{
	return num<<=4;
}
</SCRIPT>

<%

Function Constellation(Birth)

	Dim NewBirth
	If Year(NewBirth) <1951 or Year(NewBirth) > 2049 Then Exit Function
	NewBirth = ConvertToNongLi(Birth)
	dim BirthDay,BirthMonth
	BirthDay=day(NewBirth)
	BirthMonth=month(NewBirth)
	Responpse.Write "NewBirth:" & NewBirth
	Constellation = "<img width=15 height=15 align=absmiddle src=../images/" & GBL_DefineImage & "cnstl/z"
	Select Case BirthMonth
	case 1
		if BirthDay>=21 then
			Constellation = Constellation & "11.gif alt=水瓶座" & Birth & ">"
		else
			Constellation = Constellation & "10.gif alt=魔羯座" & Birth & ">"
		end if
	case 2
		if BirthDay>=20 then
			Constellation = Constellation & "12.gif alt=双鱼座" & Birth & ">"
		else
			Constellation = Constellation & "11.gif alt=水瓶座" & Birth & ">"
		end if
	case 3
		if BirthDay>=21 then
			Constellation = Constellation & "1.gif alt=白羊座" & Birth & ">"
		else
			Constellation = Constellation & "12.gif alt=双鱼座" & Birth & ">"
		end if
	case 4
		if BirthDay>=21 then
			Constellation = Constellation & "2.gif alt=金牛座" & Birth & ">"
		else
			Constellation = Constellation & "1.gif alt=白羊座" & Birth & ">"
		end if
	case 5
		if BirthDay>=22 then
			Constellation = Constellation & "3.gif alt=双子座" & Birth & ">"
		else
			Constellation = Constellation & "2.gif alt=金牛座" & Birth & ">"
		end if
	case 6
		if BirthDay>=22 then
			Constellation = Constellation & "4.gif alt=巨蟹座" & Birth & ">"
		else
			Constellation = Constellation & "3.gif alt=双子座" & Birth & ">"
		end if
	case 7
		if BirthDay>=23 then
			Constellation = Constellation & "5.gif alt=狮子座" & Birth & ">"
		else
			Constellation = Constellation & "4.gif alt=巨蟹座" & Birth & ">"
		end if
	case 8
		if BirthDay>=24 then
			Constellation = Constellation & "6.gif alt=处女座" & Birth & ">"
		else
			Constellation = Constellation & "5.gif alt=狮子座" & Birth & ">"
		end if
	case 9
		if BirthDay>=24 then
			Constellation = Constellation & "7.gif alt=天秤座" & Birth & ">"
		else
			Constellation = Constellation & "6.gif alt=处女座" & Birth & ">"
		end if
	case 10
		if BirthDay>=24 then
			Constellation = Constellation & "8.gif alt=天蝎座" & Birth & ">"
		else
			Constellation = Constellation & "7.gif alt=天秤座" & Birth & ">"
		end if
	case 11
		if BirthDay>=23 then
			Constellation = Constellation & "9.gif alt=射手座" & Birth & ">"
		else
			Constellation = Constellation & "8.gif alt=天蝎座" & Birth & ">"
		end if
	case 12
		if BirthDay>=22 then
			Constellation = Constellation & "10.gif alt=魔羯座" & Birth & ">"
		else
			Constellation = Constellation & "9.gif alt=射手座" & Birth & ">"
		end if
	case else
		Constellation=""
	end select
	
	Constellation = Constellation & " " & DisplayBirthAnimal(year(NewBirth))

End Function

Function DisplayBirthAnimal(BirthYear)

	Dim Temp,tmp
	Temp = BirthYear mod 12
	tmp = "<img width=15 height=15 align=absmiddle src=../images/" & GBL_DefineImage & "snxa/sx"
	Select Case Temp
		Case 0: tmp=tmp & "2s.gif alt=申猴>"
		Case 1: tmp=tmp & "10s.gif alt=酉鸡>"
		Case 2: tmp=tmp & "11s.gif alt=戌狗>"
		Case 3: tmp=tmp & "12s.gif alt=亥猪>"
		Case 4: tmp=tmp & "1s.gif alt=子鼠>"
		Case 5: tmp=tmp & "2s.gif alt=丑牛>"
		Case 6: tmp=tmp & "2s.gif alt=寅虎>"
		Case 7: tmp=tmp & "2s.gif alt=卯兔>"
		Case 8: tmp=tmp & "2s.gif alt=辰龙>"
		Case 9: tmp=tmp & "2s.gif alt=巳蛇>"
		Case 10: tmp=tmp & "2s.gif alt=午马>"
		Case 11: tmp=tmp & "2s.gif alt=未羊>"
		Case else: tmp = ""
	End Select

	DisplayBirthAnimal = tmp

End Function

Function GetNongLiTimeValue(DateString)

	Dim Temp,TempStr
	If isNumeric(Replace(DateString,"-","")) = False Then
		GetNongLiTimeValue = 0
		Exit Function
	End If
	Temp = Split(DateString,"-")
	If Ubound(Temp) <> 2 Then
		GetNongLiTimeValue = 0
		Exit Function
	End If
	TempStr = Temp(0)

	If Len(Temp(1)) < 2 Then Temp(1) = "0" & Temp(1)
	TempStr = TempStr & Temp(1)

	If Len(Temp(2)) < 2 Then Temp(2) = "0" & Temp(2)
	TempStr = TempStr & Temp(2)

	GetNongLiTimeValue = cCur(TempStr & "000000")

End Function%>