var CheckBoxes = Class.create();
CheckBoxes.prototype =
{
	initialize: function(imgF, imgT, w, h)
	{
		// constructor
		this.imgFalse	= imgF;
		this.imgTrue		= imgT;
		this.imgWidth	= w;
		this.imgHeight	= h;
	},
	replaceChecks: function ()
	{
		//get all the input fields on the page
		var i = document.getElementsByTagName('input');
		this.inputs = $A(i);
		//cycle trough the input fields 
		for(var i=0; i < this.inputs.length; i++)
		{
			var node = this.inputs[i];
			//check if the input is a checkbox 
			if(node.getAttribute('type') == 'checkbox')
			{  
				//create a new image 
				var img = document.createElement('img'); 
				//check if the checkbox is checked 
				if(node.checked)
				{
					img.src = this.imgTrue;
				}
				else
				{
					img.src = this.imgFalse; 
				} 
				
				//set image ID and onclick action 
				img.id = 'checkImage'+i; 
				img.n = i;
				//set image 
				var me = this;
				img.onclick = function () {
					me.checkChange(this.n);
				};
				img.className = "colorme";
				img.width = this.imgWidth;
				img.height = this.imgHeight;
				
				//place image in front of the checkbox 
				node.parentNode.insertBefore(img, node); 
				 
				//hide the checkbox 
				node.style.display='none'; 
			}
		}
	},
	
	//change the checkbox status and the replacement image 
	checkChange: function (i)
	{
		var inp = this.inputs[i];
		if(inp.checked)
		{
			inp.checked = ''; 
			$('checkImage'+i).src=this.imgFalse;
		}
		else
		{
			inp.checked = 'checked'; 
			$('checkImage'+i).src=this.imgTrue; 
		}
		return false;
	}
};