
var head = "";
var tail = "<input type=button name=go value=go onclick=\"reloadPage()\">";
var orientation = "h";

var xmlhttp, alerted;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   alert("You must have Microsofts XML parsers available")
  }
 }
@else
 alert("You must have JScript version 5 or above.")
 xmlhttp=false
 alerted=true
@end @*/
if (!xmlhttp && !alerted) {
 // Non ECMAScript Ed. 3 will error here (IE<5 ok), nothing I can
 // realistically do about it, blame the w3c or ECMA for not
 // having a working versioning capability in  <SCRIPT> or
 // ECMAScript.
    try {
        xmlhttp = new XMLHttpRequest();
    }
    catch (e) {
        alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above.");
    }
}
function RSchange() {
    if (xmlhttp.readyState == 4) {
//        document.leversForm.action = document.URL;
//        document.leversForm.submit();
	        drawLevers();
    }
}
function go(lever, val) {
    if (xmlhttp) {
        xmlhttp.open("GET", "/marvelit/levers.jsp?" + escape(lever) + "=" + escape(val), true);
        xmlhttp.onreadystatechange = RSchange;
        xmlhttp.send(null);
    }
}

function reloadPage() {
        document.leversForm.action = document.URL;
        document.leversForm.submit();    
}

var leverList = new Array();

function add(n) {
    leverList[leverList.length] = n;
}

function showLevers() {
	if (document.getElementById("levers") == null) {
		return;
	}
    if (xmlhttp.responseText != null && xmlhttp.responseText.length > 0 && xmlhttp.status == 200) {
        document.getElementById("levers").innerHTML = head + xmlhttp.responseText + tail;
    }
}

function drawLevers() {
    if (xmlhttp && leverList.length > 0) {
        xmlhttp.open("GET", "/marvelit/leversGen.jsp?orientation=" + orientation + "&ids=" + leverList.join(), true);
        xmlhttp.onreadystatechange = showLevers;
        xmlhttp.send(null);
    }
}

window.onload = drawLevers;
