//<script>
/* this file is automatically generated. View the PHP source for comments.
 */
          
kl_to_ca = {
'2.6.23.1-rbtree-web100':{'1':1,'2':1,'4':1,'5':1,'6':1,'8':1,'9':1,'10':1,'11':1,'12':1,'13':1,'14':1},
'2.6.19-web100-nolock':{'1':1,'2':1,'4':1,'5':1,'6':1,'14':1},
'2.6.23.1-rb-ctcp-extra_web100':{'1':1,'2':1,'4':1,'5':1,'6':1,'8':1,'9':1,'10':1,'11':1,'12':1,'13':1,'14':1,'15':1},
'2.6.23.1-ctcp-extra_web100':{'1':1,'2':1,'4':1,'5':1,'6':1,'14':1,'15':1},
'2.6.20.10-fast-web100':{'1':1,'2':1,'4':1,'5':1,'6':1,'7':1,'14':1},
'2.6.17.7-fast-web100':{'1':1,'2':1,'4':1,'5':1,'6':1,'7':1,'14':1}
};

use_disable = false;

/* this is the warning that is inserted into the document when an invalid
 * selection is made. */
warning_img = document.createElement("img");
warning_img.setAttribute("src", "warning_16.png");
warning_img.setAttribute("alt", "Error");
warning_img.setAttribute("title", "The selected kernel does not implement the selected protocol.");
warning_img.style.marginLeft = "4px";
warning_img.style.marginRight = "4px";

warning_el = document.createElement("span");
warning_el.style.visibility = 'hidden';
warning_el.appendChild(warning_img);
warning_el.appendChild(
	/* this is just placeholder text */
	document.createTextNode("Not implemented!")
);

/* set_err: displays the error message */
function set_err(){
	/* remove the warning text and replace it with an appropriate error
 	 * message */
	warning_el.removeChild(warning_el.childNodes[1]);
	/* did you ever want to know how to get the text displayed in a <select>
 	 * element? Well, now you do :-) */
	var cc = document.getElementById("protocol")
		.options[document.getElementById("protocol").selectedIndex]
		.firstChild.nodeValue;

	var kl = document.getElementById("kernel").value;

	warning_el.appendChild(
		document.createTextNode('Kernel ' + kl
			+ ' does not implement "' + cc
			+ '".')
	);
	/* show the error message */
	warning_el.style.visibility = 'visible';

	/* disable the submit button */
	document.getElementById("submit").disabled = "disabled";
}

function clear_err(){
	if (!use_disable){
		document.getElementById("protocol").style.color = "#000000";
		document.getElementById("kernel").style.color = "#000000";
	}
	/* hide the error message. It still takes up space on the page so the
 	 * page elements do not jump around alarmingly. */
	warning_el.style.visibility = 'hidden';

	/* enable the submit button */
	document.getElementById("submit").disabled = "";
}

function set_option_state(el, state){
	if (!use_disable)
		if (state){
			el.style.color = "#000000";
		}else {
			el.style.color = "#a0a0a0";
			if (el.selected && !use_disable)
				el.parentNode.style.color = "#a0a0a0";
		}
	else
		el.disabled = !state;
}
	

function select_ca(){
	if (!(document.getElementById))
		/* if you're using such an old browser that you cannot do this,
 		 * I don't want to even try to make this work. */
		return;

	var new_ca = document.getElementById("protocol").value;
	var ca_opts = document.getElementById("protocol").options;
	var new_kl = document.getElementById("kernel").value;
	var kl_opts = document.getElementById("kernel").options;

	clear_err();

	/* set option colors to indicate which choices are valid. Don't use
 	 * 'disabled' because we want the user to be able to select an invalid
 	 * choice, for example to select 'fast' and then see which kernels are
 	 * available without first choosing the correct kernel. This approach
 	 * doesn't work on Safari because Safari uses standard Mac OS widgets
 	 * for form elements, so you can't change the color of the menu choices.
 	 * It also doesn't work for blind people, of course. */

	for (var i = 0; i < ca_opts.length; i++){
		var ca_id = ca_opts[i].value;
		if (!kl_to_ca[new_kl] || kl_to_ca[new_kl][ca_id]){
			set_option_state(ca_opts[i], true);
		} else {
			set_option_state(ca_opts[i], false);
		}
	}

	if (!kl_opts)
		return;
	for (var i = 0; i < kl_opts.length; i++){
		var kl_ver = kl_opts[i].value;
		if (!kl_to_ca[kl_ver] || kl_to_ca[kl_ver][new_ca]){
			set_option_state(kl_opts[i], true);
		} else {
			set_option_state(kl_opts[i], false);
		}
	}
}

/* this function is the window.onload handler. */
function init_kernel_select(){
	/* insert the error text so that it takes up space on the page, although
 	 * it is hidden (because its CSS visibility property is initially
 	 * 'hidden'.*/
	if (el = document.getElementById("err_msg"))
		el.appendChild(warning_el);
	select_ca();
}

/* this doesn't work if window.onload is already set (well, it works, it just
 * discards the previous value.) */
window.onload = init_kernel_select;

