var iAnswerFormContainer = 0;

function hideMessages(fms_id){
	oThis = document.getElementById(fms_id);
	fm_id = fms_id.substring(3);
	if(fm = document.getElementById('f_messages_' + fm_id)){
		if(oThis.className == 'fms_minus'){
			fm.style.display = 'none';
			oThis.className = 'fms_plus';
		} else {
			fm.style.display = '';
			oThis.className = 'fms_minus';
		}
	}
	return false;
}

function showAnswerForm(fm_id){
	iTargetId = iAnswerFormContainer == fm_id ? 0 : fm_id;
	if(oContainer = document.getElementById('fm_answer_' + iAnswerFormContainer)){
		if(oTarget = document.getElementById('fm_answer_' + iTargetId)){
			oTarget.innerHTML = oContainer.innerHTML;
			oContainer.innerHTML = '';
			iAnswerFormContainer = iTargetId;
			if(oParentInput = document.add_message.parent){
				oParentInput.value = iTargetId;
			}
		}
	}
	return false;
}

function showAttachContainers(sToDo, iFrom, iTo){
	oContainer = document.getElementById('attach_container');
	if(oContainer){
		if(sToDo == 'add'){
			var iCur = iFrom;
			while(oCur = document.getElementById('attachment_' + iCur)){
				iCur++;
			}
			if(iCur <= iTo){
				var oAttach = document.createElement('input');
				oAttach.setAttribute('type', 'file');
				oAttach.setAttribute('id', 'attachment_' + iCur);
				oAttach.setAttribute('name', 'attachment_' + iCur);
				oAttach.setAttribute('size', '67');

				var oName = document.createElement('input');
				oName.setAttribute('type', 'text');
				oName.setAttribute('id', 'attachment_name_' + iCur);
				oName.setAttribute('name', 'attachment_name_' + iCur);
				oName.setAttribute('size', '80');
				oName.setAttribute('maxlength', '255');

				var oBreak1 = document.createElement('br');
				oBreak1.setAttribute('id', 'br1_' + iCur);
				var oBreak2 = document.createElement('br');
				oBreak2.setAttribute('id', 'br2_' + iCur);
				var oBreak3 = document.createElement('br');
				oBreak3.setAttribute('id', 'br3_' + iCur);

				oContainer.appendChild(oBreak1);
				oContainer.appendChild(oBreak2);

				oContainer.appendChild(oName);
				oContainer.appendChild(oBreak3);
				oContainer.appendChild(oAttach);

				oContainer.style.height = oAttach.offsetHeight * (iCur - iFrom + 1) * 2.9;
			}
		}

		if(sToDo == 'del'){
			var iCur = iTo;
			while(!(oAttach = document.getElementById('attachment_' + iCur))){
				iCur--;
			}
			if(iCur > iFrom){
				oContainer.style.height = oAttach.offsetHeight * (iCur - iFrom) * 2.9;
				oName = document.getElementById('attachment_name_' + iCur);
				oBreak1 = document.getElementById('br1_' + iCur);
				oBreak2 = document.getElementById('br2_' + iCur);
				oBreak3 = document.getElementById('br3_' + iCur);
				oContainer.removeChild(oAttach);
				oContainer.removeChild(oName);
				oContainer.removeChild(oBreak1);
				oContainer.removeChild(oBreak2);
				oContainer.removeChild(oBreak3);
			}
		}
	}
}

