function showLeaveWarning(url)
{
	var go = confirm("You are about to leave the Fidelity web site for a web site that is unaffiliated with Fidelity. Fidelity has not been involved in the preparation of the content supplied at the unaffiliated site and does not guarantee or assume any responsibility for its content.");
	if (go)
	{
		window.open(url);
	}
	else
	{
		return false;
	}
}
function isAlphanumeric(string)
{
	if (string.search)
	{
		if (( string.search(/[^\w\s]/) != -1) || (string.search(/[\_]/) != -1))
		{
			return false;
		}
	}
	return true;
}

function checkCusipForm()
{
	with (document.cusipForm)
	{
		var alert_text = "The cusip entered is invalid. Fixed Income cusips must be nine characters in length. The characters can be letters, numbers, or a combination of both letters and numbers only. Characters other than letters and numbers are invalid. Please reenter the cusip. To search for a specific bond / Fixed Income security or cusip, please select the Search Inventory link or call 800-544-5372 to confirm you have the correct cusip.";
		// The cusip field cannot be empty, and must contain only alphanumeric characters
		if (cusip.value.length == 0)
		{
			alert("Please enter a CUSIP to complete your search by CUSIP.");
			return false;
		}
		else
		{
			if (!isAlphanumeric(cusip.value))
			{
				alert(alert_text);
				return false;
			}
		}
	}
	return true;
}

function selectAllAcrossOffering()
{
	with (document.theForm)
	{
		if (acrossAll.checked)
		{
			acrossTreas.checked = false;
			acrossMuni.checked = false;
			acrossCorp.checked = false;
			acrossAgency.checked = false;
			acrossCD.checked = false;
			acrossHighYieldCorp.checked = false;
		}
		toggleLayer();
	}
}

function selectAllAcrossOfferingNI()
{
	with (document.theForm)
	{
		if (acrossAll.checked)
		{
			acrossTreas.checked = false;
			acrossMuni.checked = false;
			acrossCorp.checked = false;
			acrossAgency.checked = false;
			acrossCD.checked = false;
			acrossCorpNote.checked = false;
		}
	}
}

function unSelectAllAcrossOfferingNI()
{
	if (document.theForm.acrossAll.checked)
	{
		document.theForm.acrossAll.checked = false;
	}
}

function unSelectAllAcrossOffering()
{
		if (document.theForm.acrossAll.checked)
		{
			document.theForm.acrossAll.checked = false;
		}
	toggleLayer();
}

function toggleLayer()
{
	var showMessage = document.theForm.acrossAll.checked || document.theForm.acrossHighYieldCorp.checked;
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById("highYieldMessage").style;
		if (showMessage)
		{
			style2.display = "block";
		}
		else
		{
			style2.display = "";
		}
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all["highYieldMessage"].style;
		if (showMessage)
		{
			style2.display = "block";
		}
		else
		{
			style2.display = "";
		}
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers["highYieldMessage"].style;
		if (showMessage)
		{
			style2.display = "block";
		}
		else
		{
			style2.display = "";
		}
	}
}

function isCheckedNI()
{
	var newCount = 0
	with (document.theForm)
	{
		if (acrossTreas.checked)
		{
			newCount = newCount + 1
		}
		if (acrossMuni.checked)
		{
			newCount = newCount + 1
		}
		if (acrossCorp.checked)
		{
			newCount = newCount + 1
		}
		if (acrossAgency.checked)
		{
			newCount = newCount + 1
		}
		if (acrossAll.checked)
		{
			newCount = newCount + 1
		}
		if (acrossCD.checked)
		{
			newCount = newCount + 1
		}
		if (acrossCorpNote.checked)
		{
			newCount = newCount + 1
		}
		if (newCount > 0)
		{
			return true;
		}
	}
	//end of with
	return false;
}

function isChecked()
{
	var newCount = 0
	with (document.theForm)
	{
		if (acrossTreas.checked)
		{
			newCount = newCount + 1
		}
		if (acrossMuni.checked)
		{
			newCount = newCount + 1
		}
		if (acrossCorp.checked)
		{
			newCount = newCount + 1
		}
		if (acrossAgency.checked)
		{
			newCount = newCount + 1
		}
		if (acrossAll.checked)
		{
			newCount = newCount + 1
		}
		if (acrossCD.checked)
		{
			newCount = newCount + 1
		}
		if (acrossHighYieldCorp.checked)
		{
			newCount = newCount + 1
		}
		if (newCount > 0)
		{
			return true;
		}
	}
	//end of with
	return false;
}
//end isChecked function

function checkForm()
{
	if (!isChecked())
	{
		alert("Please select at least one bond type.");
		return false;
	}

	with (document.theForm)
	{
		if (checkNum(mincoupon, "coupon rate") == false)
			return false;

		if (checkNum(mincoupon, "coupon rate") == false)
			return false;

		if (checkNum(maxcoupon, "coupon rate") == false)
			return false;

		if (checkNum(minprice, "ask price") == false)
			return false;

		if (checkNum(maxprice, "ask price") == false)
			return false;

		if (checkNum(minyield, "ask yield") == false)
			return false;

		if (checkNum(maxyield, "ask yield") == false)
			return false;

		if (checkDate(minmaturity, "maturity date") == false)
			return false;

		if (checkDate(maxmaturity, "maturity date") == false)
			return false;

		if (doDateCheck(minmaturity, maxmaturity, 'Maturity Date') == false)
			return false;

		if (doComparison(mincoupon, maxcoupon, 'Coupon Rate') == false)
			return false;

		if (doComparison(minprice, maxprice, ' Ask Price') == false)
			return false;

		if (doComparison(minyield, maxyield, 'Ask Yield') == false)
			return false;
	}
	return true;
}
//end checkForm function

function checkFormNI()
{
	if (!isCheckedNI())
	{
		alert("Please select at least one bond type.");
		return false;
	}

	with (document.theForm)
	{
		if (checkNum(mincoupon, "coupon rate") == false)
			return false;

		if (checkNum(mincoupon, "coupon rate") == false)
			return false;

		if (checkNum(maxcoupon, "coupon rate") == false)
			return false;

		if (checkNum(minprice, "ask price") == false)
			return false;

		if (checkNum(maxprice, "ask price") == false)
			return false;

		if (checkNum(minyield, "ask yield") == false)
			return false;

		if (checkNum(maxyield, "ask yield") == false)
			return false;

		if (checkDate(minmaturity, "maturity date") == false)
			return false;

		if (checkDate(maxmaturity, "maturity date") == false)
			return false;

		if (doComparison(mincoupon, maxcoupon, 'Coupon Rate') == false)
			return false;

		if (doComparison(minprice, maxprice, ' Ask Price') == false)
			return false;

		if (doComparison(minyield, maxyield, 'Ask Yield') == false)
			return false;
	}
	return true;
}
//end checkFormNI function

function setFocus()
{
	document.theForm.mincoupon.focus();
}