/**
 * @author Diego
 */
function welcomeSendMessage(where, id, uid, subj){
	var msg = _._id('wall-message');
	if(msg.value==''){
		alert('{JLANG:WELCOME_FIELD_EMPTY}');
		msg.focus();
	}else{
		var v = msg.value;
		if(where=='wall'){
			_.xhttp.post('/instruments/comment.php', 
				{
				  t:		'public_utenti',
				  i:		id,
				  author:	uid,
				  comment:	v,
				  ajax:		'y'
				 },
				 'refreshWall(%%BUFFER%%,"' + id + '")'
			);
		}else if(where == 'inbox'){
			if(subj == null){
				_.PopupBox.display('ybox-send');	
			}else{
				_.xhttp.post('/instruments/send-ybox.php', 
					{
						 f:		uid,
						 t:		id,
						 s:		subj,
						 b:		v,
						 ajax:	'y'
					 },
					 'messageSent(%%BUFFER%%)'
				);
			}
			
		}
	}
}

function messageSent(buffer){
	alert(buffer);
	_._id('wall-message').value = '';
	_.PopupBox.hide('ybox-send');
}

function refreshWall(buffer, id){
	if(buffer=='ok'){
		var url = '/instruments/wall.php?id=' + id;
		_.xhttp.get(url,
			{
				ajax: 'y',
				area:	'COMMENTS'
			},
			drawComments
		);
		_._id('wall-message').value = '';
	}
}

function drawComments(buffer){
	_._id('wall-info').innerHTML = buffer;
}


