/* BROWSER INFORMATION */
isDOM = document.getElementById;
isMSIE = document.all && document.all.item;
isOpera = window.opera;
isOpera5 = isOpera && isDOM;
isMSIE5 = isDOM && isMSIE && !isOpera;
isMozilla = isDOM && !isMSIE && !isOpera;

function CheckboxReplace (path)
{
	var inputCol = document.getElementsByTagName('input');
	for (i = 0; i < inputCol.length; i++)
		if (inputCol[i].type == 'checkbox')	
		{
			var ico = document.createElement('img');
			ico.setAttribute('src',path)
			ico.className += inputCol[i].className;
			if (inputCol[i].checked) ico.className += ' chkOn';
			else ico.className += ' chkOff';
			if (inputCol[i].disabled) 
			{
				ico.className = ico.className.replace('chkOn', 'chkOnDis');
				ico.className = ico.className.replace('chkOff', 'chkOffDis');
			}
			inputCol[i].parentNode.insertBefore(ico,inputCol[i]);
			inputCol[i].previousSibling.onclick = checkboxClick;
			
			if (inputCol[i].id) 
				for (j = 0; j < document.getElementsByTagName('label').length; j++)
					if (document.getElementsByTagName('label')[j].htmlFor == inputCol[i].id)
						document.getElementsByTagName('label')[j].onclick = labelClick;
			
			inputCol[i].style.display = 'none';
			inputCol[i].onpropertychange = checkboxPropertyChange;
		}	
}

function checkboxClick ()
{
	if (this.className.indexOf('Dis') < 0)
	{
	if (this.className.indexOf('chkOn') >= 0)
	{
		this.className = this.className.replace('chkOn','chkOff');
		this.nextSibling.checked = false;
	}
	else 
	{
		this.className = this.className.replace('chkOff','chkOn');
		this.nextSibling.checked = true;
	}
	this.nextSibling.fireEvent('onclick');
	if (this.nextSibling.onclick != null) this.nextSibling.onclick.call(this.nextSibling);
	}
}

function labelClick ()
{
	var ic = document.getElementById(this.htmlFor).previousSibling;	
	if (ic.className.indexOf('Dis') < 0)
	{
		if (ic.className.indexOf('chkOn') >= 0)
		{
			ic.className = ic.className.replace('chkOn','chkOff');
			if (!isMozilla && !isOpera) ic.nextSibling.checked = false;
		}
		else 
		{
			ic.className = ic.className.replace('chkOff','chkOn');
			if (!isMozilla && !isOpera) ic.nextSibling.checked = true;
		}
		if (ic.nextSibling.onclick != null) ic.nextSibling.onclick.call(ic.nextSibling);
	}
}

function checkboxPropertyChange ()
{
	if (this.checked) this.previousSibling.className = this.previousSibling.className.replace('chkOff', 'chkOn');
	else this.previousSibling.className = this.previousSibling.className.replace('chkOn', 'chkOff');
	if (this.disabled) 
	{
		this.previousSibling.className = this.previousSibling.className.replace('chkOn', 'chkOnDis');
		this.previousSibling.className = this.previousSibling.className.replace('chkOff', 'chkOffDis');
	}
}
