// DOM?
var can_dom = document.getElementById;

// Strange older browsers
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);

// KHTMLbased stuff seems to do something the other browsers don't.
// Neccesary for del.icio.us.
var khtml;
if (navigator.userAgent.indexOf("KHTML") != -1) {
	khtml = true;
}

// Small pretty much universal getelementbyid-like function.
function getById(id){
	if(ns4){
		return ( document.layers[id] );
	} else if(ie4){
		return ( document.all[id] );
	} else if(can_dom){
		return ( document.getElementById(id) );
	} else {
		return false;
	}
}

// Preload some stuff
if ( document.images ) {
	image1 = new Image();
	image1.src = 'check_checked.gif';
	
	image2 = new Image();
	image2.src = 'check_unchecked.gif';
}
  

// Initial checkbox setup.
function box_setup ( ) {
	var chk_count = 1;
	var cur_box;
	cur_box = getById ( "chk_" + chk_count );
	while ( cur_box ) {
		cont = getById ( "chkc_" + chk_count ); 
		cur_box.style.visibility="hidden";
		if ( cur_box.checked ) {
			cont.style.backgroundImage="url('check_checked.gif')";
			cont.style.backgroundColor="#990000";
			cont.lastChild.firstChild.style.color="#FFFFFF";
			cont.style.border = "1px white dashed";
		} else {
			cont.style.backgroundImage="url('check_unchecked.gif')";
			cont.style.backgroundColor="#FFFFFF";
			cont.lastChild.firstChild.style.color="#000000";
			cont.style.border="1px silver dashed";
		}
		chk_count = chk_count + 1;
		cur_box = getById ( "chk_" + chk_count );
	}
}

function check_box ( which ) {
	var box;
	box = getById ( "chk_" + which );
	cont = getById ( "chkc_" + which ); 
	if ( box ) {
		if ( box.checked ) {
			box.checked = false;
			cont.style.backgroundImage="url('check_unchecked.gif')";
			cont.style.backgroundColor="#FFFFFF";
			cont.lastChild.firstChild.style.color="#000000";
			cont.style.border="1px silver dashed";
		} else {
			box.checked = true;
			cont.style.backgroundImage="url('check_checked.gif')";
			cont.style.backgroundColor="#990000";
			cont.lastChild.firstChild.style.color="#FFFFFF";
			cont.style.border="1px white dashed";
		}
	}
}

