	var scrollbar;
	
	function scroll(e, div) {
		e = e || event;
		
		if (e.which) {
			keynum = e.which;
		}
		else {
			keynum = e.keyCode;
		}
		// alert(keynum);
		
		if (keynum == 38) {
			div.scrollTop -= 50;
			e.returnValue = false;
			return false;
		}
		if (keynum == 40) {
			div.scrollTop += 50;
			e.returnValue = false;
			return false;
		}
		return true;
	}
	
	function scrollDown() {
		var div = document.getElementById("scrollbar_content");
		if (scrolling) {
			div.scrollTop += 50;
			setTimeout("scrollDown()", 100);
		}
		
	}

	function scrollUp() {
		var div = document.getElementById("scrollbar_content");
		if (scrolling) {
			div.scrollTop -= 50;
			setTimeout("scrollUp()", 100);
		}

	}


	function ScrollBar(button_up, button_down, scroll_div) {

		scrolling = false;
		this.div = document.getElementById(scroll_div);
		this.div.onkeydown = function() { 
			scroll(event, this);
		}

		this.toTop = function() {
			this.div.scrollTop = 0;
		}
		
		this.button_up = document.getElementById(button_up);
		this.button_down = document.getElementById(button_down);
		this.button_up.parent = this;
		this.button_down.parent = this;

		this.button_up.onclick = function() { this.parent.div.scrollTop -= 50; }
		this.button_down.onclick = function() { this.parent.div.scrollTop += 50; }
		
		this.button_up.onmousedown = function() { 
			scrolling = true;
			setTimeout('scrollUp()', 100);
		}

		this.button_up.onmouseup = function() { scrolling = false; clearTimeout(); }

		this.button_down.onmousedown = function() { 
			scrolling = true;
			setTimeout('scrollDown()', 100);
		}

		this.button_down.onmouseup = function() { scrolling = false; clearTimeout(); }



	}

	function createscroller() {
		scrollbar = new ScrollBar("bup","bdown", "scrollbar_content");
		// fade();
	}


	function gotoPatientPage() {
		location.href="./patient_signs.py";

	}

	function gotoHealthcarePage() {
		location.href="./healthcare_testing.py";

	}

	function gotoLabPage() {
		location.href = "./lab_testing.py";
	}

	var opacity = 0;
	
	function fade() { 

		var content = document.getElementById("scrollbar_content");
		if (content) {
			var style = content.style;
			style.filter = "alpha(opacity=" + (opacity * 100) + ")";
			style.opacity=opacity; 
			opacity+=0.05; 
			if(opacity < 1) setTimeout('fade()', 10);
		} 
	}

	function getContent(pg) {

		var req;
    		if (window.XMLHttpRequest) {
         		req = new XMLHttpRequest();
    		}
    		else if (window.ActiveXObject) {
        		req = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    
    		req.open('GET', pg , true);
    		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    		req.onreadystatechange = function() {
        		if (req.readyState == 4) {
          			ModifySelects(req.responseText,selectbox);
        		}
    		}	
    		req.send("cat=" + currentid);
	}
		

function doPosterSubmit() {

	var f = document.forms[0];
	var post = "";
	var error = "";
	var checked = 0;
	
	for (var i=0; i < f.elements.length; i++) {
		if (f.elements[i].id.indexOf("_req") >=0 ) {
			if (f.elements[i].value.length) {
				document.getElementById(f.elements[i].name + '_label').style.color = "";
			}
			else {
				document.getElementById(f.elements[i].name + '_label').style.color = "red";
				error = "Please fill in the missing required fields.";
			}
		}
		if (f.elements[i].name.indexOf("chkPoster") >= 0 ) {
			checked = checked || f.elements[i].checked;
		}
	}
	if (!checked) {
		error = "Please choose at least one poster type.\n\n" + error;
	}
	
	if (error.length) { alert(error); return; }
	
	
	for (var i=0; i < f.elements.length; i++) {
		
		var element = f.elements[i];
		if (post.length) { post += "&"; }
		
		if (element.name.indexOf("chk") >= 0 ) {
			if (element.checked) {
				post += element.name + '=on';
			}
		}
		else if (element.value.length) {
			post += element.name + '=' + escape(element.value);	
		}
	}

    var req;
    if (window.XMLHttpRequest) {
         req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
     alert("Sorry but your browser doesn't seem to support AJAX.  Please try a different browser.");  
     return;
    }

    req.open('POST', 'poster_request.pl' , true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
		  scrollbar.toTop();
          document.getElementById("scrollbar_content").innerHTML = req.responseText;
        }
    }
	// alert(post);
    req.send(post);

}

