/* CHECKBOX */

/* METHODS */

CustomTag.CheckBox_Identity = function(oldid, newid)
{
	document.getElementById(oldid).setAttribute("id", newid);
	document.getElementById("CheckBox_" + oldid).setAttribute("id", "CheckBox_" + newid);
	
	document.getElementById("CheckBox_" + oldid + "_Left").setAttribute("id", "CheckBox_" + newid + "_Left");
	document.getElementById("CheckBox_" + oldid + "_Image").setAttribute("id", "CheckBox_" + newid + "_Image");
	document.getElementById("CheckBox_" + oldid + "_Right").setAttribute("id", "CheckBox_" + newid + "_Right");
};

CustomTag.CheckBox_Value = function(id, value)
{
	if (value != null)
		document.getElementById(id).value = value;
	else
		return (document.getElementById(id).value);
};

CustomTag.CheckBox_Checked = function(id, stat)
{
	if (stat != null)
	{
		document.getElementById(id).checked = !document.getElementById(id).checked;
		CustomTag.CheckBox_Click(id);
	}
	else
		return (document.getElementById(id).checked);
};

CustomTag.CheckBox_ReadOnly = function(id, stat)
{
	var box = document.getElementById("CheckBox_" + id);
	
	if (stat != null)
	{
		if (stat == true)
		{
			box.setAttribute("readonly", "readonly");
			box.style["color"] = "#999999";
	
			var image = document.getElementById("CheckBox_" + id + "_Image");
			image.style["backgroundImage"] = image.style["backgroundImage"].replace("checkbox.gif", "checkbox_readonly.gif");
		}
		else
		{
			box.removeAttribute("readonly");
			box.style["color"] = "#000000";
	
			var image = document.getElementById("CheckBox_" + id + "_Image");
			image.style["backgroundImage"] = image.style["backgroundImage"].replace("checkbox_readonly.gif", "checkbox.gif");
		}
	}
	else
		return (box.getAttribute("readonly"));
};

CustomTag.CheckBox_Hidden = function(id, stat)
{
	if (stat != null)
	{
		if (stat == true)
			document.getElementById("CheckBox_" + id).style["display"] = "none";
		else
			document.getElementById("CheckBox_" + id).style["display"] = "";
	}
	else
		return (document.getElementById("CheckBox_" + id).style["display"]);
};


/* EVENTS */

CustomTag.CheckBox_Click = function(id)
{
	var box = document.getElementById(id);

	if (box.checked)
		document.getElementById("CheckBox_" + id + "_Image").style["backgroundPosition"] = "bottom";
	else
		document.getElementById("CheckBox_" + id + "_Image").style["backgroundPosition"] = "top";
	
	var onchange = document.getElementById("CheckBox_" + id).getAttribute("onchange");
	if (onchange)
		eval(onchange);
};

