//global variables that can be used by ALL the function son this page.
var imgFalse = 'theme/evrGames/images/chBoxFalse.gif';
var imgTrue = 'theme/evrGames/images/chBoxTrue.gif';

function replaceChecks() {
	
	d=document;
	E=d.documentElement;
	b=d.body;
	if(!E)return;

	//cycle trough the input fields
	for(i=0;a=b.getElementsByTagName("input")[i];i++)
	{
		//check if the input is a checkbox
		if(a.getAttribute('type') == 'checkbox') 
		{
			//create a new image
			var img = document.createElement('img');
			
			//check if the checkbox is checked
			if(a.checked) {
				img.src = imgTrue;
			} else {
				img.src = imgFalse;
			}

			//set image ID and onclick action
			img.id = 'checkImage'+i;
			//set image 
			img.onclick = new Function('checkChange('+i+')');
			//place image in front of the checkbox
			a.parentNode.insertBefore(img, a);
			
			//hide the checkbox
			a.style.display='none';
		}
	}
}

//change the checkbox status and the replacement image
function checkChange(i) {

	d=document;
	E=d.documentElement;
	b=d.body;
	if(!E)return;
	
	if(b.getElementsByTagName("input")[i].checked) {
		b.getElementsByTagName("input")[i].checked = '';
		document.getElementById('checkImage'+i).src=imgFalse;
	} else {
		b.getElementsByTagName("input")[i].checked = 'checked';
		document.getElementById('checkImage'+i).src=imgTrue;
	}
}

/*
///////// TEST //////////////
var imgSelectBG = 'theme/evrGames/images/inputTextStandardBG.jpg';
var selectArrow = 'theme/evrGames/images/selectFieldArrow.jpg';
var selectClassName = 'field_standardSelectField';

function replaceSelects() {
	d=document;
	E=d.documentElement;
	b=d.body;
	if(!E)return;

	//cycle trough the input fields
	for(i=0;a=b.getElementsByTagName("select")[i];i++)
	{	
		//create a new div
		var sDiv = document.createElement('div');
		sDiv.className = selectClassName;
		
		var sArr = document.createElement('img');
		sArr.src = selectArrow;
		sArr.onclick = new Function('replSelShow('+i+')');
		
		var sUl = document.createElement('ul');
		sUl.id = 'ul'+i;
		
		for(y=0;opt=a.options[y];y++)
		{
			var optDiv = document.createElement('li');
			var optA = document.createElement('a');
			optA.onclick = new Function('replSelMoveValue('+i+', '+y+')');
			
			optA.appendChild(document.createTextNode(opt.text));
			optDiv.appendChild(optA);
			
			sUl.appendChild(optDiv);
		}
		
		//img.src = imgSelectBG;
		
		//set image ID and onclick action
		//img.id = 'checkImage'+i;
		//set image 
		//img.onclick = new Function('checkChange('+i+')');
		//place image in front of the checkbox
		a.parentNode.insertBefore(sDiv, a);
		sDiv.appendChild(sArr);
		sDiv.appendChild(sUl);
		
		//hide the checkbox
		//a.style.display='none';
		sUl.style.display='none';
	}
}

function replSelShow(i) 
{
	var selectStatus = document.getElementById('ul'+i);
	if(selectStatus.style.display=='none')
	{
		selectStatus.style.display='';
	} else {
		selectStatus.style.display='none';
	}
	
}

function replSelMoveValue(i, y) 
{
	d=document;
	E=d.documentElement;
	b=d.body;
	if(!E)return;
	
	b.getElementsByTagName("select")[i].options[y].selected = 'selected';
}
///////// TEST //////////////
*/
if(navigator.appName!="Opera")
	addEvent(window,'load',replaceChecks);
	
//addEvent(window,'load',replaceSelects);
