//this function runs when the page is loaded, put all your other onload stuff in here too. 
function init() {
    replaceChecks('tick');
    replaceChecks('desc');
    preloadPics();
}

function preloadPics() {

	pics = new Array('tick_check','tick_uncheck','desc_check','desc_uncheck');
	base = 'http://storygames.kr/images/';
	ext = '.gif';
	
	for (i=0; i<pics.length; i++) {
		
		pic = new Image();
		pic.src = base + pics[i] + ext;
		
	}

}

function replaceChecks(id) { 

	//alert("tEST MESSAGE");

	box = document.getElementById(id);
     
            if(box.checked) {
		document.getElementById(id + '_img').src = 'http://storygames.kr/images/' + id + '_check.gif';
		document.getElementById(id + '_img').alt = document.getElementById(id + '_img').getAttribute('activealt');
		document.getElementById(id + '_img').title = document.getElementById(id + '_img').getAttribute('activetitle');
            }
            else {
		document.getElementById(id + '_img').src = 'http://storygames.kr/images/' + id + '_uncheck.gif';
		document.getElementById(id + '_img').alt = document.getElementById(id + '_img').getAttribute('inactivealt');
		document.getElementById(id + '_img').title = document.getElementById(id + '_img').getAttribute('inactivetitle');
            }

	//hide checkbox
	document.getElementById(id).style.display='none'; 
}

//change the checkbox status and the replacement image 
function checkChange(id) {

box = document.getElementById(id);

    if(box.checked) {
        box.checked = ''; 
        document.getElementById(id + '_img').src='http://storygames.kr/images/' + id + '_uncheck.gif';
	document.getElementById(id + '_img').alt = document.getElementById(id + '_img').getAttribute('inactivealt');
	document.getElementById(id + '_img').title = document.getElementById(id + '_img').getAttribute('inactivetitle');
    } else {
        box.checked = 'checked'; 
        document.getElementById(id + '_img').src='http://storygames.kr/images/' + id + '_check.gif'; 
	document.getElementById(id + '_img').alt = document.getElementById(id + '_img').getAttribute('activealt');
	document.getElementById(id + '_img').title = document.getElementById(id + '_img').getAttribute('activetitle');
    }
}

window.onload = init;