function Form_OnSubmit(form)
{
	if (temp = document.activeElement)
		temp.blur();
	var tohide = form.getElementsByTagName('input');
	for (i = 0; i < tohide.length; i++)
	{
		tohide[i].blur();
		if ((temp = form[tohide[i].name + '_name']) && form[tohide[i].name])
			temp.disabled = true;
	}
	return true;
}

function Checkbox_OnClick(checkbox, image, checked, normal)
{
	if (String(image.src).substr(String(image.src).length - String(checked).length) != checked)
	{
		checkbox.disabled = false;
		image.src = checked;
	}
	else
	{
		checkbox.disabled = true;
		image.src = normal;
	}
}

function Radio_OnClick(form, radio, image, checked, normal)
{
	if (temp = form.getElementsByTagName('img'))
	{
		for (i = 0; i < temp.length; i++)
		{
			tempname = String('radioimage_' + radio.name + '_');
			if (String(temp[i].id).substr(0, tempname.length) == tempname)
				temp[i].src = normal;
		}
	}
	radio.value = String(image.id).substr(tempname.length);
	image.src = checked;
}

function DropDown_InitAll()
{
	if ((bodies = document.documentElement.getElementsByTagName('body')) && bodies.length)
	{
		bodies[0].onclick = DropDown_HideAll;
	}
}

function DropDown_HideAll()
{
	dropdowns = document.getElementsByTagName('div');
	for (i = 0; i < dropdowns.length; i++)
	{
		if (String(dropdowns[i].id).substr(0, 9) == 'dropdown_')
			dropdowns[i].style.display = 'none';
	}
}

function DropDown_DropDown(dropdown)
{
	if (temp = document.getElementById('dropdown_' + dropdown.name))
	{
		if (temp.style.display == 'none')
			DropDown_Show(dropdown);
		else
			temp.style.display='none';
	}
}

function DropDown_Show(dropdown)
{
	DropDown_HideAll();
	if (temp = document.getElementById('dropdown_' + dropdown.name))
	{
		temp.style.display = '';
		if (temp.childNodes[0].clientHeight <= temp.clientHeight)
		{
			temp.style.height = temp.childNodes[0].clientHeight + 'px';
			temp.childNodes[0].style.width = temp.clientWidth + 'px';
		}
		else
			temp.style.height = '';
	}
}

function DropDown_OnMouseOver(dropdown, value, option)
{
	option.className = 'hover';
}

function DropDown_OnMouseOut(dropdown, value, option)
{
	if (dropdown.value != value)
		option.className = '';
	else
		option.className = 'selected';
}

function DropDown_OnClick(dropdown, value, option)
{
	if (temp = document.getElementById('dropdown_' + dropdown.name).getElementsByTagName('td'))
	{
		for (i = 0; i < temp.length; i++)
			temp[i].className = '';
		option.className = 'selected';
		dropdown.value = value;
		dropdown.form[dropdown.name + '_name'].value = option.childNodes[0].nodeValue;
		document.getElementById('dropdown_' + dropdown.name).style.display = 'none';
	}
}

function DropDown_OnChange(dropdown)
{
	if (temp = dropdown.form[dropdown.name + '_name'])
	{
		dropdown.value = temp.value;
	}
}

function DropDown_ChangeOptions(dropdown, values, descriptions)
{
	if (temp = document.getElementById('dropdown_' + dropdown.name))
	{
		options = '<table cellpadding="0" cellspacing="0">';
		for (i = 0; i < values.length; i++)
		{
			options += "<tr class=\"option\"><td onmouseover=\"DropDown_OnMouseOver(document." + dropdown.form.name + '.' + dropdown.name + ', \'' + values[i];
			options += "', this)\" onmouseout=\"DropDown_OnMouseOut(document." + dropdown.form.name + '.' + dropdown.name + ', \'' + values[i];
			options += "', this)\" onmousedown=\"DropDown_OnClick(document." + dropdown.form.name + '.' + dropdown.name + ', \'' + values[i];
			options += "', this)\">" + descriptions[i] + '</td></tr>';
		}
		options += '</table>';
		temp.innerHTML = options;
		dropdown.value = values[0];
		dropdown.form[dropdown.name + '_name'].value = descriptions[0];
	}
}

