var mFolderName = '';

function messagesPage(pgN){
	$.post('messages.php', { folder: mFolderName, pg: pgN } , function(data){
		newContext("MesgPg"+pgN);
		$("#MesgPg"+pgN).append(data);
	});	
}

function loadMessages(){
	$.get('messages.php', {} , function(data){
		resetContext();
		newContext("Mesgs");
		$("#Mesgs").append(data);
	});
}

function messagesViewFolder( fName ){
	mFolderName = fName;
	$.post('messages.php', { folder: fName } , function(data){
		newContext("Mesgs"+fName);
		$("#Mesgs"+fName).append(data);
	});
}

function messagesRead( mID ){
	$.post('messages.php', { view: 'read_msg' , messageid: mID } , function(data){
		newContext("Mesg"+mID);
		$("#Mesg"+mID).append(data);
		leftMenuLoad();	
	});
}

function messagesSendMassView(){
	$.post('messages.php', { view: 'send_mass_email' } , function(data){
		newContext("MesgSendMass");
		$("#MesgSendMass").append(data);	
	});
}

function messagesSendAdminView(){
	$.post('messages.php', { view: 'send_admin_email' } , function(data){
		newContext("MesgSendAdmin");
		$("#MesgSendAdmin").append(data);	
	});
}

function messagesReply(mesgid, Subject){
	replyBody = $("#frmReplyBody").attr('value');
	$.post('messages.php', { view: 'read_msg' , act: 'send_reply', messageid: mesgid , reply_subject: Subject , reply_body: replyBody } , function(data){
		newContext("MesgReply");
		$("#MesgReply").append(data);
	});
}
