﻿
var imgFalse = 'images/cbxFalse.png';
var imgTrue = 'images/cbxTrue.png';


//this function runs when the page is loaded, put all your other onload stuff in here too.
function initCBX() {
	replaceCheck('NoMail');
	replaceCheck('NoSMS');
	replaceCheck('NoCourrier');
	
}


function RazCBX()
{
checkChange('NoMail');
checkChange('NoSMS');
checkChange('NoCourrier');
}

//change the checkbox status and the replacement image
function checkChange(idCheck) {
 
  var input;
	//get all the input fields on the page
	input = document.getElementById(idCheck);

	if(input.checked) {
		input.checked = '';
		document.getElementById('checkImage_'+idCheck).src=imgFalse;
	} else {
		input.checked = 'checked';
		document.getElementById('checkImage_'+idCheck).src=imgTrue;
	}
	
}



function replaceCheck(idCheck) {
	var input;
	//get all the input fields on the page
	input = document.getElementById(idCheck);

	//cycle trough the input fields
	//for(var i=0; i < inputs.length; i++) {

		//check if the input is a checkbox
		if(input.type == 'checkbox') {
			
			//create a new image
			var img = document.createElement('img');
			
			//check if the checkbox is checked
			if(input.checked) {
				img.src = imgTrue;
			} else {
				img.src = imgFalse;
			}

			//set image ID and onclick action
			img.id = 'checkImage_'+idCheck;
			//set image 
			
			img.onclick = new Function('checkChange("'+idCheck+'")');
			
			//place image in front of the checkbox
			input.parentNode.insertBefore(img, input);
			
			//hide the checkbox
			input.style.display='none';
		}
//	}
}


