function quiz_xmlhttpPost(type, strURL, str, wait, readystateID, readystateSym) {
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
	    self.xmlHttpReq.open(type, strURL, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded', wait);
        self.xmlHttpReq.setRequestHeader( 'Content-length', str.length );
	    self.xmlHttpReq.onreadystatechange = function() {
		    if (self.xmlHttpReq.readyState == 0) {
	       		}
		    if (self.xmlHttpReq.readyState == 1) {
	       		}
		    if (self.xmlHttpReq.readyState == 2) {
	       		}
		    if (self.xmlHttpReq.readyState == 3) {
	       		}
		    if (self.xmlHttpReq.readyState == 4) {
				quiz_updatepage(self.xmlHttpReq.responseText);
	       		}
		    }
		 self.xmlHttpReq.send(str);
    } else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    self.xmlHttpReq.open(type, strURL, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        self.xmlHttpReq.setRequestHeader( 'Content-length', str.length );
	    self.xmlHttpReq.onreadystatechange = function() {
		    if (self.xmlHttpReq.readyState == 0) {
	       		}
		    if (self.xmlHttpReq.readyState == 1) {
	       		}
		    if (self.xmlHttpReq.readyState == 2) {
	       		}
		    if (self.xmlHttpReq.readyState == 3) {
	       		}
		    if (self.xmlHttpReq.readyState == 4) {
				quiz_updatepage(self.xmlHttpReq.responseText);
	       		}
	    	}
	    self.xmlHttpReq.send(str);
   		}
	}

function quiz_updatepage(str){

	from = getdecode("from", str);
	
	if (from == "quiz") {
		q_status = getdecode("q_status", str);
		q_comment = getdecode("comment", str);
		quiz_color = getdecode("quiz_color", str);

		
		if (quiz_color != "nc")  {
			liste = quiz_color.split("-");
			for (i=0;i<=liste.length-1;i++) {
		        temp = liste[i].split("_");
				
				x1 = temp[0];
				x2 = temp[1];
				
				if (x2 == 1) {
					document.getElementById("status_" + x1).style.backgroundColor = "green";
					}
				if (x2 == 2) {
					document.getElementById("status_" + x1).style.backgroundColor = "red";
					}			
				}
			}
	
	  	if (q_status == "ch") {
//	document.getElementById("top").className = 'log';
//	document.getElementById("top").innerHTML = str + "<br><br>" + q_comment  + "<br><br>" + self;		
			site = document.getElementById("quiz_comments").innerHTML;
			
			site = site.replace("</TABLE>", q_comment + "</TABLE>");
			site = site.replace("</table>", q_comment + "</TABLE>");
			
			document.getElementById("quiz_comments").innerHTML = site;
			
			}
		}
	
	if (from == "sendRed") {
		}
	if (from == "q_try") {
		}
	}

function quiz_getData() {
	$quiz_request = new quiz_xmlhttpPost("POST", "./g_js/quiz.php", "from=quiz", "false", "", "");
	}

function sendRed(c_id) {
	document.getElementById("status_" + c_id).style.backgroundColor = "red";
	$sendRed_request = new quiz_xmlhttpPost("POST", "./g_js/quiz.php", "from=sendRed&c_id="+c_id, "false", "", "");
	}

function q_try() {
		
		q_newComment = document.getElementById("newComment").value;
		$new_try = new quiz_xmlhttpPost("POST", "./g_js/quiz.php", "from=q_try&q_newComment="+q_newComment, "false", "q_load", '<img src="./g_pics/sm_gaehn.gif" border="0" />');
		document.getElementById("newComment").value = "";
		return false;
	}

