
	function notesAdd(pR, pAssoc, pDataType) {
		
		strError = "";
		objButton = document.getElementById('buttonNotesAdd'+pR);
		objNotes = document.getElementById('notesTextArea'+pR);
		strNotes = objNotes.value;
//		strNotes = strNotes.replace(/[\n\r]/g, '<br>');
		strNotes = trim(removeMultipleWhiteSpaces(strNotes));
		strNotes = replaceWhiteSpacesWithPipe(strNotes);
		bolVisiteur = document.getElementById('visiteur').value;
		
		//Notes longer than 750 ?
		if (strNotes.length > 750) {
			strError = strError + 'Annotation: Vous dépassez le maximum de 750 caractères. Réduisez le nombre de caractères et essayez à nouveau.\n';
		}
		
		//Notes is empty
		if (strNotes == "") {
			strError = strError + 'Annotation: Veuillez prendre des annotations\n';
		} 

		if (strError != "") {
			alert(strError);
		} else {

			strError = "";
			
			if (bolVisiteur == "False") {
				iType = document.getElementById('notesType'+pR).value;
				strDueDate = document.getElementById('notesDueDate'+pR).value;
				if (iType == 1) {
					strDueDate = "";
				} else {					
					strDueDate = replaceWhiteSpacesWithPipe(strDueDate + " " + document.getElementById('notesHour'+pR).value + ":" + document.getElementById('notesMin'+pR).value + ":00");
				}
			}

			if (strError != "") {
				alert(strError);
			} else {
			
				objButton.enabled = false;
				objNotes.value = "";
				if (bolVisiteur == "False") {
					//window.location = "HttpNotes.asp?action=add&assoc=" + pAssoc + "&dataType=" + pDataType + "&notes=" + strNotes + "&type=" + iType + "&dueDate=" + strDueDate;
					doHttpRequest("HttpNotes.asp", "action=add&assoc=" + pAssoc + "&dataType=" + pDataType + "&notes=" + strNotes + "&type=" + iType + "&dueDate=" + strDueDate); 
				} else {
					doHttpRequest("HttpNotes.asp", "action=add&assoc=" + pAssoc + "&dataType=" + pDataType + "&notes=" + strNotes + "&type=&dueDate="); 
				}
				
				objAllNotes = document.getElementById('advertNotesContent'+pR);
				objAllNotes.innerHTML = strError + objAllNotes.innerHTML;
				objButton.enabled = true;
	
				objNotes = document.getElementById('notesTextArea'+pR);
				objNotes.rows = 1;
				objNotes.value = "Annotations";
				objNotes.style.color = "silver";
	
				if (bolVisiteur == "False") {
					objAdvertNotesExtras = document.getElementById('advertNotesExtras'+pR);
					objAdvertNotesExtras.style.display = "none";	
				}

				objAdvertNotesButton = document.getElementById('advertNotesButton'+pR);
				objAdvertNotesButton.style.display = "none";	

			}
		}
		
	}


	function notesModify(pR, pNote, pDataType) {
		
		strError = "";
		objButton = document.getElementById('buttonNotesAdd'+pR);
		objNotes = document.getElementById('notesTextArea'+pR);
		strNotes = objNotes.value;
//		strNotes = strNotes.replace(/[\n\r]/g, '<br>');
		strNotes = trim(removeMultipleWhiteSpaces(strNotes));
		strNotes = replaceWhiteSpacesWithPipe(strNotes);
		
		//Notes longer than 750 ?
		if (strNotes.length > 750) {
			strError = strError + 'Annotation: Vous dépassez le maximum de 750 caractères. Réduisez le nombre de caractères et essayez à nouveau.\n';
		}
		
		//Notes is empty
		if (strNotes == "") {
			strError = strError + 'Annotation: Veuillez prendre des annotations\n';
		} 

		if (strError != "") {
			alert(strError);
		} else {

			strError = "";
			
			iType = document.getElementById('notesType'+pR).value;
			strDueDate = document.getElementById('notesDueDate'+pR).value;
			if ( (iType != 1) && (strDueDate != "") ) {
				strDueDate = replaceWhiteSpacesWithPipe(strDueDate + " " + document.getElementById('notesHour'+pR).value + ":" + document.getElementById('notesMin'+pR).value + ":00");
			}

			if (strError != "") {
				alert(strError);
			} else {
			
				objButton.enabled = false;
				objNotes.value = "";
				//window.location = "HttpNotes.asp?action=modify&assoc=" + pAssoc + "&dataType=" + pDataType + "&notes=" + strNotes + "&type=" + iType + "&dueDate=" + strDueDate;
				doHttpRequest("HttpNotes.asp", "action=modify&note=" + pNote + "&dataType=" + pDataType + "&notes=" + strNotes + "&type=" + iType + "&dueDate=" + strDueDate); 
				objButton.enabled = true;
	
				objAdvertNotesExtras = document.getElementById('bureauRowModify'+pR);
				objAdvertNotesExtras.style.display = "none";	

				document.forms[0].submit();
				return true;	

			}
		}
		
	}

	function notesRemove(pNote, pDataType) {
	
		strError = "";

		var answer = confirm ("Voulez-vous vraiment supprimer cette annotation ?")
		if (answer) {
			doHttpRequest("HttpNotes.asp", "action=remove&note=" + pNote + "&dataType=" + pDataType); 
			if (strError == "") {
				document.forms[0].submit();
				return true;	
			}
		}	
	}		
	
	function setNotesTextArea(pR) {

		objNotes = document.getElementById('notesTextArea'+pR);
		objNotes.rows = 3;
		if (objNotes.value == "Annotations") {
			objNotes.value = "";
		}
		objNotes.style.color = "black";

		bolVisiteur = document.getElementById('visiteur').value;
		if (bolVisiteur == "False") {
			objAdvertNotesExtras = document.getElementById('advertNotesExtras'+pR);
			objAdvertNotesExtras.style.display = "block";	
		}

		objAdvertNotesButton = document.getElementById('advertNotesButton'+pR);
		objAdvertNotesButton.style.display = "block";	
		
	}
	
	function setNotesDateTime(pR) {

		iNotesType = document.getElementById('notesType'+pR).value;
		objNotesDateHourMin = document.getElementById('notesDateHourMin'+pR);
		
		if (iNotesType != 1) {
			objNotesDateHourMin.style.visibility = "visible";
		} else {
			objNotesDateHourMin.style.visibility = "hidden";
		}
	
	}
