// Jon Glassman (glassman@iquest.net)
// All rights reserved.  October 4, 1996
// This script may be used only with the permission of the author.

var calculate
var atnum = ""
var atsym = ""
var atnam = ""
var atmas = ""

function per(period)

{
	document.write("<tr align=center><th bgcolor='CCCCCC'>" + period + "</th>");
}

function atinforeset()
{
	if (calculate == 1)
	{
		document.boxes.two.value = ""
		setb2()
	}
	atnum = ""
	atsym = ""
	atnam = ""
	atmas = ""
}

function setb2()
{
	document.atominfo.box2pt.value = document.boxes.two.value
}

function el(atomicnumber,symbol,element,colors,mass)
{
	if (colors == "l"){var backcolor="CCCCFF";}
	if (colors == "m"){var backcolor="FFCCCC";}
	if (colors == "r"){var backcolor="FFFFCC";}
	if (colors == "d"){var backcolor="CCFFCC";}
	if (colors == "e"){var backcolor="FFFFFF";}
	if (colors == "u"){var backcolor="FFFFCC";}

	document.write	("<td bgcolor='" + backcolor + "'");
	document.write	(" onMouseOver=atinfo(");
	document.write	("'" + atomicnumber + "','" + symbol + "',");

	if (colors == "e" || colors == "u")
	{
		document.write	("'" + element + "','unknown',0)");
		document.write	(" onMouseOut=infoclear()>");
		document.write	("<small><font color='999999'>" + atomicnumber);
		document.write	("</small><br>" + symbol + "</font></td>");
	}

	else
	{
		document.write	("'" + element + "'," + mass + ",0)");
		document.write	(" onMouseOut=infoclear()>");
		document.write	("<small>" + atomicnumber + "</small>");
		document.write	("<br><a href='#pt' onClick=atinfo(");
		document.write	("'" + atomicnumber + "','" + symbol + "',");
		document.write	("'" + element + "'," + mass + ",1)");
		document.write	(">" + symbol + "</a></td>");
	}
}

function atinfo(atomicnumber,symbol,element,mass,saver)
{
	if (saver == 1)
	{
		atnum = atomicnumber;
		atsym = symbol;
		atnam = element;
		atmas = mass;
		if (calculate == 1)
		{
			if (document.boxes.two.value == "")
			{
				document.boxes.two.value = mass
			}

			else
			{
				document.boxes.two.value = eval(document.boxes.two.value-(0-mass))
			}
			setb2();
		}
	}

	document.atominfo.elname.value = element;
	document.atominfo.elsym.value = symbol;
	document.atominfo.elnum.value = atomicnumber;
	document.atominfo.elmass.value = mass;
}

function infoclear()
{
	document.atominfo.elname.value = atnam;
	document.atominfo.elsym.value = atsym;
	document.atominfo.elnum.value = atnum;
	document.atominfo.elmass.value = atmas;
}

function brk(lng)
{
	document.write("<td colspan=" + lng + "></td>");
}

function endl()
{
	document.write("</tr>");
}

function periodictable(calcul)
{
	calculate = calcul;
	var i=3

	document.write ("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH='100%'>");
	document.write ("<TR ALIGN=CENTER><TH WIDTH='8%' BGCOLOR='CCCCCC'>Group</TH>");
	document.write ("<TH WIDTH='5%' BGCOLOR='CCCCCC'>1</TH>");
	document.write ("<TH WIDTH='5%' BGCOLOR='CCCCCC'>2</TH>");
	document.write ("<TH WIDTH='2%' BGCOLOR='CCCCCC'></TH>");
	for(i;i<19;i++)
	{
		document.write ("<TH WIDTH='5%' BGCOLOR='CCCCCC'>" + i + "</TH>");
	}
	document.write ("</TR>");
	document.write ("<TR ALIGN=CENTER><TH BGCOLOR='CCCCCC'>");

	document.write ("Period</TH><TD COLSPAN=3></TD>");
	document.write ("<form name='atominfo'>");

	if (calculate == 1)
	{
		document.write ("<td colspan=4 rowspan=2 align=center bgcolor=CCCCDD>");
		document.write ("<b>VALUE IN<br>BOX 2 ABOVE</b><br>");
		document.write ("<input type=text name='box2pt' size=10></td>");
		document.write ("<td colspan=3 rowspan=2 align=center bgcolor=CCCCDD>");
	}
	else
	{	document.write ("<td colspan=7 rowspan=2 align=center bgcolor=CCCCDD>");}

	document.write ("<b>ELEMENT<br>NAME</b><br>");
	document.write ("<input type=text name='elname' size=13></td>");
	document.write ("<td colspan=2 rowspan=2 align=center bgcolor=CCCCDD>");
	document.write ("<input type=reset value='Reset' onClick='atinforeset()'></td>");
	brk("7");
	document.write ("</TR>");



	per("1");
	el(		"1",	"H",	"Hydrogen",	"l",	1.00794		);
	brk("2");

	brk("6");
	el(		"2",	"He",	"Helium",	"r",	4.0020602	);
	endl();

	per("2");
	el(		"3",	"Li",	"Lithium",	"l",	6.941		);
	el(		"4",	"Be",	"Beryllium",	"l",	9.012182	);
	brk("1");

	document.write ("<td rowspan=2 colspan=9 bgcolor=CCCCDD>");
	document.write ("<table border=0 cellspacing=0 cellpadding=0 height=100% width=100%>");
	document.write ("<td width=33% bgcolor=CCCCDD align=center>");
	document.write ("<b>ELEMENT<br>SYMBOL</b><br><input type=text name='elsym' size=3></td>");
	document.write ("<td width=34% bgcolor=CCCCDD align=center>");
	document.write ("<b>ATOMIC<br>NUMBER</b><br><input type=text name='elnum' size=3></td>");
	document.write ("<td width=33% bgcolor=CCCCDD align=center>");
	document.write ("<b>ATOMIC<br>MASS</b><br><input type=text name='elmass' size=10></td>");
	document.write ("</table></td></form>");

	brk("1");
	el(		"5",	"B",	"Boron",	"r",	10.811		);
	el(		"6",	"C",	"Carbon",	"r",	12.011		);
	el(		"7",	"N",	"Nitrogen",	"r",	14.00674	);
	el(		"8",	"O",	"Oxygen",	"r",	15.9994		);
	el(		"9",	"F",	"Fluorine",	"r",	18.9984032	);
	el(		"10",	"Ne",	"Neon",		"r",	20.1797		);
	endl();

	per("3");
	el(		"11",	"Na",	"Sodium",	"l",	22.989768	);
	el(		"12",	"Mg",	"Magnesium",	"l",	24.3050		);
	brk("1");

	brk("1");
	el(		"13",	"Al",	"Aluminum",	"r",	26.981539	);
	el(		"14",	"Si",	"Silicon",	"r",	28.0855		);
	el(		"15",	"P",	"Phosphorus",	"r",	30.97362	);
	el(		"16",	"S",	"Sulfur",	"r",	32.066		);
	el(		"17",	"Cl",	"Chlorine",	"r",	35.4527		);
	el(		"18",	"Ar",	"Argon",	"r",	39.948		);
	endl();

	per("4");
	el(		"19",	"K",	"Potassium",	"l",	39.0983		);
	el(		"20",	"Ca",	"Calcium",	"l",	40.078		);
	brk("1");
	el(		"21",	"Sc",	"Scandium",	"m",	44.955910	);
	el(		"22",	"Ti",	"Titanium",	"m",	47.867		);
	el(		"23",	"V",	"Vanadium",	"m",	50.9415		);
	el(		"24",	"Cr",	"Chromium",	"m",	51.9961		);
	el(		"25",	"Mn",	"Manganese",	"m",	54.93085	);
	el(		"26",	"Fe",	"Iron",		"m",	55.845		);
	el(		"27",	"Co",	"Cobalt",	"m",	58.93320	);
	el(		"28",	"Ni",	"Nickel",	"m",	58.6934		);
	el(		"29",	"Cu",	"Copper",	"m",	63.546		);
	el(		"30",	"Zn",	"Zinc",		"m",	65.39		);
	el(		"31",	"Ga",	"Gallium",	"r",	69.723		);
	el(		"32",	"Ge",	"Germanium",	"r",	72.61		);
	el(		"33",	"As",	"Arsenic",	"r",	74.92159	);
	el(		"34",	"Se",	"Selenium",	"r",	78.96		);
	el(		"35",	"Br",	"Bromine",	"r",	79.904		);
	el(		"36",	"Kr",	"Krypton",	"r",	83.80		);
	endl();

	per("5");
	el(		"37",	"Rb",	"Rubidium",	"l",	85.4678		);
	el(		"38",	"Sr",	"Strontium",	"l",	87.62		);
	brk("1");
	el(		"39",	"Y",	"Yttrium",	"m",	88.90585	);
	el(		"40",	"Zr",	"Zirconium",	"m",	91.224		);
	el(		"41",	"Nb",	"Niobium",	"m",	92.90638	);
	el(		"42",	"Mo",	"Molybdenum",	"m",	95.94		);
	el(		"43",	"Tc",	"Technetium",	"m",	98		);
	el(		"44",	"Ru",	"Ruthenium",	"m",	101.07		);
	el(		"45",	"Rh",	"Rhodium",	"m",	102.90550	);
	el(		"46",	"Pd",	"Palladium",	"m",	106.42		);
	el(		"47",	"Ag",	"Silver",	"m",	107.8682	);
	el(		"48",	"Cd",	"Cadmium",	"m",	112.411		);
	el(		"49",	"In",	"Indium",	"r",	114.818		);
	el(		"50",	"Sn",	"Tin",		"r",	118.710		);
	el(		"51",	"Sb",	"Antimony",	"r",	121.760		);
	el(		"52",	"Te",	"Tellurium",	"r",	127.60		);
	el(		"53",	"I",	"Iodine",	"r",	126.90447	);
	el(		"54",	"Xe",	"Xenon",	"r",	131.29		);
	endl();

	per("6")
	el(		"55",	"Cs",	"Cesium",	"l",	132.905452	);
	el(		"56",	"Ba",	"Barium",	"l",	137.3277	);
	document.write	("<td bgcolor='FFFFFF'>*</td>");
	el(		"71",	"Lu",	"Lutetium",	"m",	174.9671	);
	el(		"72",	"Hf",	"Hafnium",	"m",	178.492		);
	el(		"73",	"Ta",	"Tantalum",	"m",	180.94791	);
	el(		"74",	"W",	"Tungsten",	"m",	183.841		);
	el(		"75",	"Re",	"Rhenium",	"m",	186.2071	);
	el(		"76",	"Os",	"Osmium",	"m",	190.233		);
	el(		"77",	"Ir",	"Iridium",	"m",	192.2173	);
	el(		"78",	"Pt",	"Platinum",	"m",	195.0782	);
	el(		"79",	"Au",	"Gold",		"m",	196.966552	);
	el(		"80",	"Hg",	"Mercury",	"m",	200.592		);
	el(		"81",	"Tl",	"Thallium",	"r",	204.38332	);
	el(		"82",	"Pb",	"Lead",		"r",	207.21		);
	el(		"83",	"Bi",	"Bismuth",	"r",	208.980382	);
	el(		"84",	"Po",	"Polonium",	"r",	210		);
	el(		"85",	"At",	"Astatine",	"r",	210		);
	el(		"86",	"Rn",	"Radon",	"r",	222		);
	endl();

	per("7");
	el(		"87",	"Fr",	"Francium",	"l",	223		);
	el(		"88",	"Ra",	"Radium",	"l",	226		);
	document.write	("<td bgcolor='FFFFFF'>**</td>");
	el(		"103",	"Lr",	"Lawrencium",	"m",	262		);
	el(		"104",	"Rf",	"Rutherfordium","m",	261		);
	el(		"105",	"Db",	"Dubnium",	"m",	262		);
	el(		"106",	"Sg",	"Seaborgium",	"m",	266		);
	el(		"107",	"Bh",	"Bohrium",	"m",	264		);
	el(		"108",	"Hs",	"Hassium",	"m",	269		);
	el(		"109",	"Mt",	"Meitnerium",	"m",	268		);
	el(		"110",	"Uun",	"Ununnilium",	"m",	269		);
	el(		"111",	"Uuu",	"Unununium",	"m",	272		);
	el(		"112",	"Uub",	"Ununbium",	"m",	277		);
	el(		"113",	"Uut",	"Ununtrium",	"e",	0		);
	el(		"114",	"Uuq",	"Ununquadium",	"r",	285		);
	el(		"115",	"Uup",	"Ununpentium",	"e",	0		);
	el(		"116",	"Uuh",	"Ununhexium",	"r",	289		);
	el(		"117",	"Uus",	"Ununseptium",	"e",	0		);
	el(		"118",	"Uuo",	"Ununoctium",	"r",	293		);
	endl();

	document.write	("<tr align=center><th bgcolor='FFFFFF'>-</th>");
	brk("19");
	endl();

	document.write	("<tr align=center><th colspan='3' bgcolor='CCCCCC'>*Lanthanides</th>");
	document.write	("<td bgcolor='FFFFFF'>*</td>");
	el(		"57",	"La",	"Lanthanum",	"d",	138.90552	);
	el(		"58",	"Ce",	"Cerium",	"d",	140.1161	);
	el(		"59",	"Pr",	"Praseodymium",	"d",	140.907652	);
	el(		"60",	"Nd",	"Neodymium",	"d",	144.243		);
	el(		"61",	"Pm",	"Promethium",	"d",	145		);
	el(		"62",	"Sm",	"Samarium",	"d",	150.363		);
	el(		"63",	"Eu",	"Europium",	"d",	151.9641	);
	el(		"64",	"Gd",	"Gadolinium",	"d",	157.253		);
	el(		"65",	"Tb",	"Terbium",	"d",	158.925342	);
	el(		"66",	"Dy",	"Dysprosium",	"d",	162.503		);
	el(		"67",	"Ho",	"Holmium",	"d",	164.930322	);
	el(		"68",	"Er",	"Erbium",	"d",	167.263		);
	el(		"69",	"Tm",	"Thulium",	"d",	168.934212	);
	el(		"70",	"Yb",	"Ytterbium",	"d",	173.043		);
	endl();

	document.write	("<tr align=center><th colspan='3' bgcolor='CCCCCC'>**Actinides</th>");
	document.write	("<td bgcolor='FFFFFF'>**</td>");
	el(		"89",	"Ac",	"Actinium",	"d",	227		);
	el(		"90",	"Th",	"Thorium",	"d",	232.03811	);
	el(		"91",	"Pa",	"Protactinium",	"d",	231.035882	);
	el(		"92",	"U",	"Uranium",	"d",	238.02891	);
	el(		"93",	"Np",	"Neptunium",	"d",	237		);
	el(		"94",	"Pu",	"Plutonium",	"d",	244		);
	el(		"95",	"Am",	"Americium",	"d",	243		);
	el(		"96",	"Cm",	"Curium",	"d",	247		);
	el(		"97",	"Bk",	"Berkelium",	"d",	247		);
	el(		"98",	"Cf",	"Californium",	"d",	251		);
	el(		"99",	"Es",	"Einsteinium",	"d",	252		);
	el(		"100",	"Fm",	"Fermium",	"d",	257		);
	el(		"101",	"Md",	"Mendelevium",	"d",	258		);
	el(		"102",	"No",	"Nobelium",	"d",	259		);
	endl();

	document.write ("</table>");
}
