function QMSend(id) {
	var txt=$('qmsg').value;
	if (txt.length>1 && $('qmsg').value!='QuickMessage' ) {
		new Request({url:'/ajax/msg.php',method:'get'}).send('message='+encodeURIComponent(txt)+'&id='+id);
		$('msgdiv').innerHTML='<b>Message gesendet!</b>';
	}
}

function sendit(e) {
	if (stayopen!=1) {
		return true;
	} else {
		new Request({url:'/ajax/msg.php',method:'get',onComplete:handleResponseMessage}).send('message='+encodeURIComponent($('body').value)+'&id='+$('id').value);
		$('body').value='';
		if (e && e.preventDefault)
		    e.preventDefault(); // DOM style
	  	return false; // IE style
	}
}

function getHistory(id) {
	new Request.HTML ({url:'/ajax/v3_msghistory.php?id='+$('id').value,update:$('history'),onComplete:function() {
	    $('info2').innerHTML = "<b>Es ist eine neue Nachricht vorhanden!</b>";
    	timerID = setTimeout("clearInfo('info2','')", 5000);
		window.focus();
	} }).get();
}

function msgstayOpen() {
	new Request({url:'/ajax/v3_msg.php',method:'get'}).send('msgstayopen=1&id='+$('id').value);
	stayopen=1;
	$('stayopen').innerHTML ='Fenster bleibt geöffnet';
}

function handleResponseMessage(text,nodes) {
    var cont = nodes.getElementsByTagName("p")[0];
    var content = cont.firstChild.data;

	$('info').innerHTML = 'Nachricht gesendet...';
		
    if (cont.getAttribute( 'close' )!=1) {
	var re= '<input onClick=\"sendit();\" value=\"Senden\" class=\"button\" style="margin: 0px; width: 200px;\" tabindex=\"2\" type=\"button\" />';
	timerID = setTimeout("clearInfo('info','"+re+"')", 1000);
	$('body').focus();

	var nhist='<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td bgcolor="#EFEFEF"><b>Deine Nachricht:</b> </td></tr><tr><td bgcolor="#FFFFFF"><b>'+content+'</b></td></tr></table>';
		
	$('history').innerHTML = nhist+$('history').innerHTML;
    }

}

function clearInfo(info,what) {
	$(info).innerHTML=what;
	$('body').focus();
}