// source: http://brainerror.net/scripts/javascript/checkbox/
var imgfalse = '/img/sidebar-check-0.jpg';
var imgtrue = '/img/sidebar-check-1.jpg';

// replace search bar checks with images
function replacechecks(prefix)
{
	for ( x = 1 ; x <= 2 ; x++ )
	{
		var checkx = document.getElementById(prefix + "-check-" + x);					// prefix-check-x
		var labelx = document.getElementById(prefix + "-check-" + x + "-l");				// prefix-check-x-l (label)
		var imgx = document.createElement('img');									// create a new image
		if ( checkx.checked ) imgx.src = imgtrue; else imgx.src = imgfalse;				// check if the checkbox is checked
		imgx.id = prefix + "-check-" + x + "-i" ; imgx.className = 'checkbox' ;				// set image ID and onclick action
		imgx.onclick = new Function ( 'checkchange(\'' + prefix + '\',' + x + '); return false;' ) ;	// set image event
		labelx.onclick = new Function ( 'checkchange(\'' + prefix + '\',' +  x + '); return false;' ) ;	// set label event
		checkx.parentNode.insertBefore( imgx , checkx ) ;							// place image in front of the checkbox
		checkx.style.display = 'none';												// hide the checkbox
	}
}

// change the checkbox status and the replacement image
function checkchange(prefix , i)
{
	check = document.getElementById(prefix + "-check-" + i);
	document.getElementById( prefix + "-check-1-i" ).src=imgfalse;
	document.getElementById( prefix + "-check-2-i" ).src=imgfalse;
	document.getElementById( prefix + "-check-" + i + "-i" ).src=imgtrue;
	document.getElementById( prefix + "-check-" + i ).checked="checked";
}