
if ( ! u2r_script_url) {
	var u2r_script_url = 'http://localhost/_scripts/';
}
if ( ! u2r_webdir_pics) {
	var u2r_webdir_pics = 'http://localhost/_gfx/'; 
}

function u2r_e3l_toMode(_input, id, value) {
	
	if (_input.value == value) { 
		document.getElementById(id).style.display = 'block';
	}
	else {
		document.getElementById(id).style.display = 'none';
	}
}

function u2r_createMessageForm(_div, nickName, x, y, id_u2r_from, id_u2r_to) {
		
	code = '';
	formAction = '';
	
	if (x > 0 || y > 0) {
		addyStyle = 'position: absolute; left: '+x+'; top: '+y+'; display: block;';
	}
	
	jsOnClick = 'document.getElementById(\''+_div.id+'\').style.display=\'none\';';
	formId = 'f2m_'+_div.id;
	
	code += '<table cellspacing="2" cellpadding="2">';
	code += '<form action="'+formAction+'" id="'+formId+'" method="post">';
	code += '<input type="hidden" name="id_u2r_from" value="'+id_u2r_from+'" />';
	code += '<input type="hidden" name="id_u2r_to" value="'+id_u2r_to+'" />';
	code += '<input type="hidden" name="action" value="send" />';
	code += '<tr>';
	code += '<td><img src="'+u2r_webdir_pics+'mail/subscribe5.gif" /></td>';
	code += '<td width="5" nowrap></td>';
	code += '<td><b style="font-size: 12px;">Nachricht senden</b></td>';
	code += '</tr>';
	code += '<tr>';
	code += '<td colspan="3">Empfänger: <b>'+nickName+'</b></td>';
	code += '</tr>';
	code += '<tr>';
	code += '<td colspan="3"><input type="text" name="subject" /></td>';
	code += '</tr>';
	code += '<tr>';
	code += '<td colspan="3"><textarea name="body" cols="40" rows="4"></textarea></td>';
	code += '</tr>';
	code += '<tr>';
	code += '<td colspan="3"><input type="button" value="<-" onClick="'+jsOnClick+'" /> <input type="button" value="Senden" onClick="u2r_sendMessage(\''+formId+'\', \''+_div.id+'\', \''+x+'\', \''+y+'\');" /></td>';
	code += '</tr>';
	code += '</form>';
	code += '</table>';

	o1t_innerHTML(_div, o1t_createCase(code, 2, null, null, null, null, addyStyle));

	_div.style.display = 'block';
}

function u2r_readMessage(messageId, divId, scriptUrl) {
	
	var paramCode = '';
	var _div = document.getElementById(divId);
	var _icon = document.getElementById('m5e_icon_'+messageId);
	
	var _loadDiv = document.createElement('div');
	var _loadImage = document.createElement('img');
	
	_loadImage.src = u2r_webdir_pics+'loading2.gif';

	_loadDiv.setAttribute('align', 'center');
	_loadDiv.appendChild(_loadImage);
	
	_div.innerHTML = '';
	_div.style.display = 'block';
	_div.appendChild(_loadDiv);
	
	_icon.src = u2r_webdir_pics+'mail/message_read.gif';	
	
	paramCode += '?id='+messageId;
	paramCode += '&mode=message';
	paramCode += '&param=read';
	
	if ( ! scriptUrl) {
		url = u2r_script_url+'_script_m5e.php';
	}
	else {
		url = scriptUrl;
	}

	window.scrollTo(0, 0);
	_div.innerHTML = a2x_sendRequest( url , paramCode, 'POST');
	_div.style.display = 'block';
}

function u2r_sendMessage(formId, divId, x, y, scriptUrl) { 
		
	if (x > 0 || y > 0) {
		addyStyle = 'position: absolute; left: '+x+'; top: '+y;
	}

	var Inputs = document.getElementById(formId).getElementsByTagName('input');
	var paramCode = '?';
	var _div = document.getElementById(divId);
	
	for (i=0; i < Inputs.length; i++) {
		
		if (Inputs[i].type == 'button') {
			continue;	
		}
		
		paramCode += Inputs[i].name;
		paramCode += '=';
		paramCode += Inputs[i].value;		
		paramCode += '&';	
	}
	
	Inputs = document.getElementById(formId).getElementsByTagName('textarea');
	
	for (i=0; i < Inputs.length; i++) {
		
		if (Inputs[i].type == 'button') {
			continue;	
		}
		
		paramCode += Inputs[i].name;
		paramCode += '=';
		paramCode += Inputs[i].value;		
		paramCode += '&';	
	}
	
	if ( ! scriptUrl) {
		url = u2r_script_url+'_script_m5e.php';
	}
	else {
		url = scriptUrl;
	}
	code = a2x_sendRequest( url , paramCode, 'POST');
	
	if (code == 1) {
		pic = o1t_webdir_pics+'buttons/button_accept.gif';
		text = 'Die Nachricht wurde erfolgreich versendet';	
	} else {
		pic = o1t_webdir_pics+'buttons/nok.gif';
		text = 'Die Nachricht wurde nicht versendet';
	}
	
	table = '';
	table += '<table cellspacing="0" cellpadding="0">';
	table += '<tr>';
	table += '<td><img src="'+pic+'" /></td>';
	table += '<td width="5" nowrap></td>';
	table += '<td>'+text+'</td>';
	table += '<td width="5" nowrap></td>';
	table += '<td><img src="'+o1t_webdir_pics+'buttons/close[1].png" style="cursor: pointer;" onClick="document.getElementById(\''+divId+'\').style.display=\'none\';" /></td>';
	table += '</tr>';
	table += '</table>';
	
	_div.innerHTML = o1t_createCase(table, 10, null, null, null, null, addyStyle);
}

function u2r_answerMessage(id_input, id_u2r_to, id_m5e, id_form) { 
	
	var _input = document.getElementById(id_input);
	var _button = document.getElementById(id_input+'_button');
	var _form = document.getElementById(id_form);
	
	_input.rows = 10;
	_input.style.display = 'block';
	_button.style.display = 'block';
	_form.id_u2r_to.value = id_u2r_to;
	_form.id_parent.value = id_m5e;
	_input.focus();
	_input.onclick = 'this.value=\'\';';
}
