function signs(by, bm, bd, sx) {
var start = 1901, 
birthyear 	= by;
month		= bm;
date		= bd;

var dzsvalue, dcsvalue, dzstitle, dcstitle, sx_txt, dcselement;

var msgalert = '' + by + ' ' + bm + ' ' + bd; 
// alert(msgalert);

var sign=new Array();
sign = ch_calendar(by,bm,bd);

// document.write(bd + '/' + bm + '/' + by + ': ' + sign[0] + ' - ' + sign[1] + ' - ' + sign[2] + ' ')

if (sx == 0) { sx_txt = "Nata il "; }
if (sx == 1) { sx_txt = "Nato il "; }

if (month == 1 && date >=20 || month == 2 && date <=18) {dzsvalue = "zw_aquarius"; dzstitle = "sotto il segno dell'Acquario, ";}
if (month == 2 && date >=19 || month == 3 && date <=20) {dzsvalue = "zw_pisces"; dzstitle = "sotto il segno dei Pesci, ";}
if (month == 3 && date >=21 || month == 4 && date <=19) {dzsvalue = "zw_aries"; dzstitle = "sotto il segno dell'Ariete, ";}
if (month == 4 && date >=20 || month == 5 && date <=20) {dzsvalue = "zw_taurus"; dzstitle = "sotto il segno del Toro, ";}
if (month == 5 && date >=21 || month == 6 && date <=21) {dzsvalue = "zw_gemini"; dzstitle = "sotto il segno dei Gemelli, ";}
if (month == 6 && date >=22 || month == 7 && date <=22) {dzsvalue = "zw_cancer"; dzstitle = "sotto il segno del Cancro, ";}
if (month == 7 && date >=23 || month == 8 && date <=22) {dzsvalue = "zw_leo"; dzstitle = "sotto il segno del Leone, ";}
if (month == 8 && date >=23 || month == 9 && date <=22) {dzsvalue = "zw_virgo"; dzstitle = "sotto il segno della Vergine, ";}
if (month == 9 && date >=23 || month == 10 && date <=22) {dzsvalue = "zw_libra"; dzstitle = "sotto il segno della Bilancia, ";}
if (month == 10 && date >=23 || month == 11 && date <=21) {dzsvalue = "zw_scorpio"; dzstitle = "sotto il segno dello Scorpione, ";}
if (month == 11 && date >=22 || month == 12 && date <=21) {dzsvalue = "zw_sagittarius"; dzstitle = "sotto il segno del Sagittario, ";}
if (month == 12 && date >=22 || month == 1 && date <=19) {dzsvalue = "zw_capricorn"; dzstitle = "sotto il segno del Capricorno, ";}

var bDate = new Date();

bDate.setDate(bd); bDate.setMonth(bm); bDate.setFullYear(by);

if ( sign[0] == 'rat' ) { 
		dcsvalue = "zc_rat"; dcstitle = "nell'anno del Topo "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'ox' ) { 
		dcsvalue = "zc_ox"; dcstitle = "nell'anno del Bue "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'tiger' ) { 
		dcsvalue = "zc_tiger"; dcstitle = "nell'anno della Tigre "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'rabbit' ) { 
		dcsvalue = "zc_rabbit"; dcstitle = "nell'anno del Coniglio "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'dragon' ) { 
		dcsvalue = "zc_dragon"; dcstitle = "nell'anno del Drago "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'snake' ) { 
		dcsvalue = "zc_snake"; dcstitle = "nell'anno del Serpente "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'horse' ) { 
		dcsvalue = "zc_horse"; dcstitle = "nell'anno del Cavallo "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'sheep' ) { 
		dcsvalue = "zc_ram"; dcstitle = "nell'anno dell'Ariete "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'monkey') { 
		dcsvalue = "zc_monkey"; dcstitle = "nell'anno della Scimmia "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'rooster' ) { 
		dcsvalue = "zc_rooster"; dcstitle = "nell'anno del Gallo "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'dog' ) { 
		dcsvalue = "zc_dog"; dcstitle = "nell'anno del Cane "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

if ( 	sign[0] == 'pig' ) { 
		dcsvalue = "zc_pig"; dcstitle = "nell'anno del Maiale "; 
		dcstitle += "di " + sign[1] + " " + sign[2]; 
	}

var titolo = '' + sx_txt + bd + "/" + bm + "/" + by + ": " + dzstitle + dcstitle;
// var signs_c = '<img src="http://www.motoko.it/images/morpheus/zodiac/' + dcsvalue + '.gif" title="' + titolo + '">'
// var signs_w = '<img src="http://www.motoko.it/images/morpheus/zodiac/' + dzsvalue + '.gif" title="' + titolo + '">'

var signs_c = '<img src="/img/masayume/zodiacnew/' + dcsvalue + '.gif" title="' + titolo + '" style="float: left; padding-right: 10px;"> ';
var signs_w = '<img src="/img/masayume/zodiacnew/' + dzsvalue + '.gif" title="' + titolo + '" style="float: left; margin-bottom: 5px;"> ';

document.write(signs_w + ' ' + signs_c);

} // end function signs

function ch_calendar(y,m,d) {
	
	/*
	NOTA: 1) definire l'anno iniziale [calendar_start], nel caso attuale il 1408 è un anno di earth rat (iniziano entrambi i cicli)
	occorre definire un anno di inizio del ciclo di 60 anni oppure occorre modificare di conseguenza gli array [elementi,segni] 
	NOTA: 2) se l'anno è pari è Yang, se è dispari è Yin
	*/	

	var calendar_start = 1408;
	var calendar_max = 2019;
	
	// controllo che l'anno sia nel range definito
	// var elementi=new Array('earth','earth','metal','metal','water','water','wood','wood','fire','fire');
	var elementi=new Array('Terra','Terra','Metallo','Metallo','Acqua','Acqua','Legno','Legno','Fuoco','Fuoco');
	var segni=new Array('rat','ox','tiger','rabbit','dragon','snake','horse','sheep','monkey','rooster','dog','pig');
	
	var calendar=new Array("05-02-1408", "24-01-1409", "12-02-1410", "01-02-1411", "22-01-1412", "09-02-1413", "30-01-1414", "18-02-1415", "07-02-1416", "26-01-1417", "14-02-1418", "03-02-1419", "23-01-1420", "10-02-1421", "31-01-1422", "21-01-1423", "09-02-1424", "28-01-1425", "16-02-1426", "05-02-1427", "25-01-1428", "12-02-1429", "01-02-1430", "22-01-1431", "10-02-1432", "29-01-1433", "17-02-1434", "06-02-1435", "26-01-1436", "13-02-1437", "03-02-1438", "23-01-1439", "11-02-1440", "31-01-1441", "20-01-1442", "08-02-1443", "28-01-1444", "15-02-1445", "04-02-1446", "25-01-1447", "13-02-1448", "01-02-1449", "22-01-1450", "10-02-1451", "30-01-1452", "17-02-1453", "06-02-1454", "26-01-1455", "14-02-1456", "03-02-1457", "23-01-1458", "11-02-1459", "01-02-1460", 
	"20-01-1461", "07-02-1462", "28-01-1463", "15-02-1464", "04-02-1465", "25-01-1466", "13-02-1467", "02-02-1468", "21-01-1469", "09-02-1470", "19-01-1471", "17-02-1472", "05-02-1473", "26-01-1474", "14-02-1475", "04-02-1476", "23-01-1477", "11-02-1478", "31-01-1479", "19-02-1480", "07-02-1481", "27-01-1482", "15-02-1483", "05-02-1484", "25-01-1485", "13-02-1486", "02-02-1487", "22-01-1488", "09-02-1489", "29-01-1490", "17-02-1491", "06-02-1492", "26-01-1493", "14-02-1494", "03-02-1495", "24-01-1496", "10-02-1497", "30-01-1498", "18-02-1499", "08-02-1500", "28-01-1501", "16-02-1502", "06-02-1503", "26-01-1504", "13-02-1505", "02-02-1506", "22-01-1507", "10-02-1508", "30-01-1509", "18-02-1510", "07-02-1511", "28-01-1512", "15-02-1513", "04-02-1514", "24-01-1515", 
	"12-02-1516", "31-01-1517", "21-01-1518", "09-02-1519", "29-01-1520", "16-02-1521", "06-02-1522", "26-01-1523", "13-02-1524", "01-02-1525", "22-01-1526", "10-02-1527", "31-01-1528", "18-02-1529", "07-02-1530", "27-01-1531", "15-02-1532", "03-02-1533", "23-01-1534", "11-02-1535", "01-02-1536", "21-01-1537", "09-02-1538", "29-01-1539", "17-02-1540", "05-02-1541", "25-01-1542", "13-02-1543", "02-02-1544", "22-01-1545", "10-02-1546", "31-01-1547", "19-02-1548", "07-02-1549", "27-01-1550", "14-02-1551", "04-02-1552", "23-01-1553", "11-02-1554", "01-02-1555", "21-01-1556", "08-02-1557", "29-01-1558", "16-02-1559", "05-02-1560", "25-01-1561", "13-02-1562", "02-02-1563", "23-01-1564", "10-02-1565", "30-01-1566", "18-02-1567", "07-02-1568", "26-01-1569", "14-02-1570", 
	"03-02-1571", "24-01-1572", "11-02-1573", "01-02-1574", "21-01-1575", "09-02-1576", "28-01-1577", "16-02-1578", "05-02-1579", "25-01-1580", "13-02-1581", "02-02-1582", "23-01-1583", "11-02-1584", "30-01-1585", "17-02-1586", "06-02-1587", "27-01-1588", "14-02-1589", "04-02-1590", "24-01-1591", "12-02-1592", "31-01-1593", "20-01-1594", "08-02-1595", "28-01-1596", "15-02-1597", "05-02-1598", "25-01-1599", "14-02-1600", "02-02-1601", "22-01-1602", "10-02-1603", "30-01-1604", "17-02-1605", "06-02-1606", "27-01-1607", "15-02-1608", "03-02-1609", "24-01-1610", "12-02-1611", "01-02-1612", "20-01-1613", "08-02-1614", "28-01-1615", "16-02-1616", "05-02-1617", "25-01-1618", "13-02-1619", "03-02-1620", "21-01-1621", "09-02-1622", "30-01-1623", "18-02-1624", "06-02-1625", 
	"27-01-1626", "15-02-1627", "04-02-1628", "23-01-1629", "11-02-1630", "31-01-1631", "20-01-1632", "07-02-1633", "28-01-1634", "16-02-1635", "06-02-1636", "25-01-1637", "13-02-1638", "02-02-1639", "22-01-1640", "09-02-1641", "29-01-1642", "17-02-1643", "07-02-1644", "27-01-1645", "15-02-1646", "04-02-1647", "24-01-1648", "10-02-1649", "31-01-1650", "20-01-1651", "08-02-1652", "28-01-1653", "16-02-1654", "05-02-1655", "25-01-1656", "12-02-1657", "01-02-1658", "22-01-1659", "10-02-1660", "29-01-1661", "18-02-1662", "07-02-1663", "27-01-1664", "14-02-1665", "03-02-1666", "23-01-1667", "11-02-1668", "31-01-1669", "20-01-1670", "08-02-1671", "29-01-1672", "16-02-1673", "05-02-1674", "25-01-1675", "13-02-1676", "01-02-1677", "22-01-1678", "10-02-1679", "30-01-1680", 
	"17-02-1681", "06-02-1682", "26-01-1683", "14-02-1684", "03-02-1685", "23-01-1686", "11-02-1687", "01-02-1688", "20-01-1689", "08-02-1690", "28-01-1691", "16-02-1692", "04-02-1693", "24-01-1694", "12-02-1695", "02-02-1696", "22-01-1697", "10-02-1698", "30-01-1699", "18-02-1700", "07-02-1701", "27-01-1702", "15-02-1703", "04-02-1704", "24-01-1705", "12-02-1706", "02-02-1707", "22-01-1708", "09-02-1709", "29-01-1710", "16-02-1711", "06-02-1712", "25-01-1713", "13-02-1714", "03-02-1715", "23-01-1716", "10-02-1717", "30-10-1718", "18-02-1719", "07-02-1720", "27-01-1721", "15-02-1722", "04-02-1723", "25-01-1724", "12-02-1725", "01-02-1726", "21-01-1727", "09-02-1728", "28-01-1729", "16-02-1730", "06-02-1731", "26-01-1732", "13-02-1733", "03-02-1734", "23-01-1735", 
	"11-02-1736", "30-01-1737", "18-02-1738", "07-02-1739", "28-01-1740", "15-02-1741", "04-02-1742", "25-01-1743", "12-02-1744", "31-01-1745", "21-01-1746", "08-02-1747", "29-01-1748", "16-02-1749", "06-02-1750", "26-01-1751", "14-02-1752", "02-02-1753", "22-01-1754", "10-02-1755", "30-01-1756", "17-02-1757", "07-02-1758", "28-01-1759", "16-02-1760", "04-02-1761", "24-01-1762", "12-02-1763", "01-02-1764", "20-01-1765", "08-02-1766", "29-01-1767", "17-02-1768", "06-02-1769", "26-01-1770", "14-02-1771", "03-02-1772", "22-01-1773", "10-02-1774", "30-01-1775", "18-02-1776", "07-02-1777", "27-01-1778", "15-02-1779", "04-02-1780", "23-01-1781", "11-02-1782", "01-02-1783", "21-01-1784", "08-02-1785", "29-01-1786", "17-02-1787", "06-02-1788", "25-01-1789", "13-02-1790", 
	"02-02-1791", "23-01-1792", "10-02-1793", "30-01-1794", "20-01-1795", "08-02-1796", "27-01-1797", "15-02-1798", "04-02-1799", "24-01-1800", "12-02-1801", "02-02-1802", "22-01-1803", "10-02-1804", "30-01-1805", "17-02-1806", "06-02-1807", "27-01-1808", "13-02-1809", "03-02-1810", "24-01-1811", "12-02-1812", "31-01-1813", "20-01-1814", "08-02-1815", "28-01-1816", "15-02-1817", "04-02-1818", "25-01-1819", "13-02-1820", "02-02-1821", "22-01-1822", "10-02-1823", "30-01-1824", "17-02-1825", "06-02-1826", "26-01-1827", "14-02-1828", "03-02-1829", "24-01-1830", "12-02-1831", "01-02-1832", "19-02-1833", "08-02-1834", "28-01-1835", "16-02-1836", "04-02-1837", "25-01-1838", "13-02-1839", "02-02-1840", "22-01-1841", "09-02-1842", "29-01-1843", "17-02-1844", "06-02-1845", 
	"26-01-1846", "14-02-1847", "04-02-1848", "23-01-1849", "11-02-1850", "31-01-1851", "19-02-1852", "07-02-1853", "28-01-1854", "16-02-1855", "05-02-1856", "25-01-1857", "13-02-1858", "02-02-1859", "22-01-1860", "09-02-1861", "29-01-1862", "17-02-1863", "07-02-1864", "26-01-1865", "14-02-1866", "04-02-1867", "24-01-1868", "10-02-1869", "30-01-1870", "18-02-1871", "08-02-1972", "28-01-1873", "16-02-1874", "05-02-1875", "25-01-1876", "12-02-1877", "01-02-1878", "21-01-1879", "09-02-1880", "29-01-1881", "17-02-1882", "07-02-1883", "27-01-1884", "14-02-1885", "03-02-1886", "23-01-1887", "11-02-1888", "30-01-1889", "20-01-1890", "08-02-1891", "29-01-1892", "16-02-1893", "05-02-1894", "25-01-1895", "13-02-1896", "01-02-1897", "21-01-1898", "09-02-1899", "30-01-1900", 
	"18-02-1901", "07-02-1902", "28-01-1903", "15-02-1904", "03-02-1905", "24-01-1906", "12-02-1907", "01-02-1908", "21-01-1909", "09-02-1910", "29-01-1911", "17-02-1912", "05-02-1913", "25-01-1914", "13-02-1915", "03-02-1916", "22-01-1917", "10-02-1918", "31-01-1919", "19-02-1920", "07-02-1921", "27-01-1922", "15-02-1923", "04-02-1924", "23-01-1925", "12-02-1926", "01-02-1927", "22-01-1928", "09-02-1929", "29-01-1930", "16-02-1931", "05-02-1932", "25-01-1933", "13-02-1934", "03-02-1935", "24-01-1936", "11-02-1937", "31-01-1938", "19-02-1939", "08-02-1940", "27-01-1941", "15-02-1942", "05-02-1943", "25-01-1944", "13-02-1945", "02-02-1946", "22-01-1947", "10-02-1948", "29-01-1949", "17-02-1950", "06-01-1951", "27-01-1952", "14-02-1953", "03-02-1954", "24-01-1955", 
	"12-02-1956", "31-01-1957", "18-02-1958", "08-02-1959", "28-01-1960", "15-02-1961", "05-02-1962", "25-01-1963", "13-02-1964", "02-02-1965", "21-01-1966", "09-02-1967", "20-01-1968", "17-02-1969", "06-02-1970", "27-01-1971", "15-02-1972", "03-02-1973", "23-01-1974", "11-02-1975", "31-01-1976", "18-02-1977", "07-02-1978", "18-01-1979", "16-02-1980", "05-02-1981", "25-01-1982", "13-02-1983", "02-02-1984", "20-02-1985", "09-02-1986", "29-01-1987", "17-02-1988", "06-02-1989", "27-01-1990", "15-01-1991", "04-02-1992", "23-01-1993", "10-02-1994", "31-01-1995", "19-02-1996", "07-02-1997", "28-01-1998", "16-02-1999", "05-02-2000", "24-01-2001", "12-02-2002", "01-02-2003", "22-01-2004", "09-02-2005", "29-01-2006", "18-02-2007", "07-02-2008", "26-01-2009", "14-02-2010", 
	"03-02-2011", "23-02-2012", "10-02-2013", "31-01-2014", "19-02-2015", "08-02-2016", "28-01-2017", "16-02-2018", "05-02-2019" );

	var message = '';
	var res=new Array();
	/*
	message = 'dates: central date: ' + calendar[y-calendar_start];
	message += '<br>dates: previous date: ' + calendar[y-calendar_start-1];
	message += '<br>dates: following date: ' + calendar[y-calendar_start+1];
	*/
	el_num = y - calendar_start ;
	var date=calendar[y-calendar_start].split("-");
	dmonth=Number(date[1]); dday=Number(date[0]); dyear=Number(date[2]); 
	dmonth--;
	
	var cDate = new Date(); var iDate = new Date();
	cDate.setFullYear(dyear, dmonth, dday); // data di capodanno cinese
	iDate.setFullYear(y, (m - 1), d); // data di input
	
	if (iDate < cDate) el_num--; // e' il segno precedente

	/*
	if (iDate < cDate) {
			message += '<br>input date BEFORE chinese year <br>' + iDate + ' less ' + cDate + ' ';
	} else {
			message += '<br>input date AFTER chinese year <br>' + iDate + ' >= ' + cDate + ' ';	
	}

	message += '<br>element number (starting 0):' + el_num;
	*/

	message += ' ' + segni[el_num % 12];
	res[0] = segni[el_num % 12];
	message += '<br>' + elementi[el_num % 10];
	res[1] = elementi[el_num % 10];
	
	if (y % 2 == 0) {
		message += ' yang';
		res[2] = 'yang';
	} else {
		message += ' yin';
		res[2] = 'yin';
	}

	
	// document.write(message);
	return res;
	
} // end function calendrics

