// Dynamic Form BEGIN
function initSelectedItem(sDivSelected,oItemSelected)
{
var oItemIsChecked;
var aDiv = new Array()
/* 	"var num" sets the count of the array to 0 (if there are a lot of div
tags being counted before getting to the ones I want.)
NOTE: This could cause problems if a div other than the ones being used
has an ID. */
var num = 0;
// get div objects and store them into an array
for (var n = 0; n < document.getElementsByTagName("Div").length; n ++)
{
var oDiv = document.getElementsByTagName("Div")[n];
if (String(oDiv.id) != "")
{	
aDiv[num ++] = document.getElementById(oDiv.id)
}
}
// if user selects the top form shown, reset all and only show the top form
if(oItemSelected.parentNode.id == aDiv[0].id)
{
hideDivs(oItemSelected,aDiv)
resetAllRadioBtns(oItemSelected)
}
// get the div tag associated with the item
var oDiv = document.getElementById(sDivSelected)
// loop through the divs children and set all to false that are
// not selected. if the item is selected, show the appropriate divs
for (var i = 0; i <= oDiv.childNodes.length; i ++)
{
var oItem = oDiv.childNodes[i]
if (String(oItem).indexOf("[object") != -1)
{	
if (String(oItem.name) != "undefined")
{
var sDivId = oItem.id + "Div"
if ((oItem.name.indexOf("_us@") != -1) && (oItem.name == oItemSelected.name))
{
document.forms["contactus"].elements["SKU"].value = oItem.title
}
if (oItem.name != oItemSelected.name)
{
oItem.checked = false
if (oItem.id != oItemSelected.id)
{
// set all items in the next form as unselected.
for (var n = 0; n <= document.getElementById(sDivId).childNodes.length; n ++)
{
var oElement = document.getElementById(sDivId).childNodes[n]
if (String(oElement) == "[object]")
{
if (oElement.type != "undefined" && oElement.type == "radio")
oElement.checked = false;
}			
document.getElementById(sDivId).style.display = "none";
}
}
}
else
document.getElementById(sDivId).style.display = "block";	
}
}
}
}
/************************************************************************
hideDivs(oItemSelected,aDiv)
-------------------------------------------------------------------------
Purpose:	sets the display property on all div tags to none unless the
item selected belongs to the div.

*************************************************************************/
function hideDivs(oItemSelected,aDiv)
{
for (var i = 0; i < aDiv.length; i ++)
{
if (oItemSelected.parentNode.id != aDiv[i].id)
aDiv[i].style.display = "none"
else
aDiv[i].style.display = "block"
}
}
/************************************************************************
resetAllRadioBtns(oItemSelected)
-------------------------------------------------------------------------
Purpose:	Resets the value of all radio buttons to false.

************************************************************************/
function resetAllRadioBtns(oItemSelected)
{
var oForms = document.forms["contactus"];
for (var n = 0; n < oForms.elements.length; n ++)
{
var oItem = oForms.elements[n];
if (oItem.type == "radio")
{
if (oItem.name != oItemSelected.name)
oItem.checked = false;
}
}
}
// Dynamic Form END