function button1_onclick() 
{
	var strLoc;
	var intNm;
	
	if (document.f1.radio1.checked == true)
	{
		intNm = parseInt(document.f1.text1.value);
		if (isNaN(intNm))
		{
			window.alert("Please enter a numeric bib number");
			return;
		}
		if (intNm > 0)
		{
			strLoc = document.f1.ScptName.value + "?Link=" + document.f1.lnk.value + "&Type=1&Bib=" + document.f1.text1.value;
		}
		else
			{
				window.alert("Bib Number must be greater than zero");
				return;
			}
	}
		
	if (document.f1.radio2.checked == true)
	{
		if (document.f1.text2.value == "" && document.f1.text3.value == "" && document.f1.text4.value == "" 
			&& document.f1.text5.value == "" && document.f1.text6.value == "")
		{
			window.alert("Please enter either first name, last name, city, state, or country");
			return;
		}
		strLoc = document.f1.ScptName.value + "?Link=" + document.f1.lnk.value + "&Type=3&LName=" + document.f1.text2.value
			+ "&FName=" + document.f1.text3.value + "&City=" + document.f1.text4.value + "&State="
			+ document.f1.text5.value + "&Country=" + document.f1.text6.value;
	}
	
	if (document.f1.radio3.checked == true)
	{
		strLoc = document.f1.ScptName.value + "?Link=" + document.f1.lnk.value + "&Type=2&Div=" + document.f1.select1.options[document.f1.select1.selectedIndex].value + "&Ind=" + document.f1.select1.selectedIndex;
	}
	
	location.href = strLoc;
}

function window_onload() 
{
	if (document.f1.SelType.value == 1)	
	{
		radio1_onclick();
	}
	else
	{
		if (document.f1.SelType.value == 3)
		{
			radio2_onclick();
		}
		else
		{
			radio3_onclick();
		}
	}
}

function radio1_onclick() 
{
	document.f1.radio1.checked = true;
	document.f1.radio2.checked = false;
	document.f1.radio3.checked = false;
	document.f1.text1.style.color = "black";
	document.f1.text2.style.color = "lightgrey";
	document.f1.select1.style.color = "lightgrey";
	bib.style.backgroundColor = "#E6EBEE";
	division.style.backgroundColor = "#FFFFFF";
	namesel.style.backgroundColor = "#FFFFFF";
	if (document.f1.SelBib.value > 0)
	{
		document.f1.text1.value = document.f1.SelBib.value;
		document.f1.SelBib.value = -1;
	}
	document.f1.text1.focus();
}

function radio2_onclick(cntl) 
{
		document.f1.radio1.checked = false;
		document.f1.radio2.checked = true;
		document.f1.radio3.checked = false;
		document.f1.text2.style.color = "black";
		document.f1.text1.style.color = "lightgrey";
		document.f1.select1.style.color = "lightgrey";
		bib.style.backgroundColor = "#FFFFFF";
		division.style.backgroundColor = "#FFFFFF";
		namesel.style.backgroundColor="#E6EBEE";
		if (document.f1.SelFN.value == "" && document.f1.SelLN.value == "" && 
			document.f1.SelCity.value == "" && document.f1.SelState.value == "" &&
			document.f1.SelCountry.value == "")
		{
			document.f1.SelFN.value = "";
		}
		else
		{
			document.f1.text2.value = document.f1.SelLN.value;
			document.f1.text3.value = document.f1.SelFN.value;
			document.f1.text4.value = document.f1.SelCity.value;
			document.f1.text5.value = document.f1.SelState.value;
			document.f1.text6.value = document.f1.SelCountry.value;
			document.f1.SelLN.value = "";
			document.f1.SelFN.value = "";
			document.f1.SelCity.value = "";
			document.f1.SelState.value = "";
			document.f1.SelCountry.value = "";
		}
		if (cntl != 'undefined' && cntl != null) 
		{
			if (cntl.id == "radio2")
				document.f1.text3.focus();
			else
				cntl.focus();
		}
		else
		{
			document.f1.text3.focus();
		}
}

function radio3_onclick() 
{
	document.f1.radio3.checked = true;
	document.f1.radio2.checked = false;
	document.f1.radio1.checked = false;
	document.f1.select1.style.color = "black";
	document.f1.text2.style.color = "lightgrey";
	document.f1.text1.style.color = "lightgrey";
	bib.style.backgroundColor="#FFFFFF";
	division.style.backgroundColor = "#E6EBEE";
	namesel.style.backgroundColor = "#FFFFFF";
	if (document.f1.SelInd.value > -1)
	{
		document.f1.select1.selectedIndex = document.f1.SelInd.value;
		document.f1.SelInd.value = -1;
	}
}

function key_onkeypress() 
{
	if (event.keyCode == 13)
		button1_onclick();
}

function radio1_onfocus() 
{
	radio1_onclick();
}

function radio2_onfocus(cntl) 
{
	radio2_onclick(cntl);
}

function radio3_onfocus() 
{
	radio3_onclick();
}

