	var signature = new Array("--------------");

	var ajaxExpandCalled = false;
	var ajaxFromWrite = false;

function openBrWin(cible,name,w,h,params) {
	l = (document.body.clientWidth-w)/2;
	t = (document.body.clientHeight-h)/2;
	params = "left=" + String(l) + ",top=" + String(t) + "," + params + ",width=" + String(w) + ",height=" + String(h)
	window.open(cible,name,params);
}

function resizeElems() {

	// definition de la largeur d'affichage du site (ici totale - largeur de l'ascenseur)
	/*  Modifications pour resize ecran */
	var lg = (document.body.clientWidth - 20);

	var minSize = 980;
	var maxSize = 1024;

    //correction bug sophia defect sur la page add attach
    //if(document.getElementById("joinLink")!=null)
    //lg=900; 

	if(rightAdvertisement=="TRUE"){
		lg=800;
	}else{
	   	if (lg < minSize) lg= minSize;
	   	if (lg > maxSize) lg = maxSize;
	}

   	lg= lg+ "px";
   	
	/*  fin modifications pour resize ecran */
	if (document.getElementById("hfCfgH")) document.getElementById("hfCfgH").style.width = lg;
	if (document.getElementById("header")) document.getElementById("header").style.width = lg;
	if (document.getElementById("infos")) document.getElementById("infos").style.width = lg;
	if (document.getElementById("actions")) document.getElementById("actions").style.width = lg;
	document.getElementById("corps").style.width = lg;
	if (document.getElementById("footer"))
    document.getElementById("footer").style.width = lg;
	if(rightAdvertisement=="TRUE")
		if (document.getElementById("sl")!=null)
			document.getElementById("sl").style.visibility = "visible";
}

function BlurLinks () {
	if (document.getElementById) {
		lnks = document.getElementsByTagName ('a');
		for (i = 0; i < lnks.length; i++) lnks [i].onfocus = new Function ("if (this.blur) this.blur ()");
	}
}

var CURRENT_OBJ, CURRENT_OBJ2;
function tabRollOver(id,imgon)
{
	if(imgon)
	{
		document.getElementById(id).style.backgroundColor= "#93AAD3";
		document.getElementById(id).style.color= "white";
		if ( document.getElementById && !document.all ) {
			document.getElementById(id).style.cursor="pointer";
		}
	}
	else
	{
		if (CURRENT_OBJ != id) {
			document.getElementById(id).style.backgroundColor= "transparent";
			document.getElementById(id).style.color= "black";
			if ( document.getElementById && !document.all ) {
				document.getElementById(id).style.cursor="cross";
			}
		}
	}
}

function tabRollOver2(id,imgon)
{
	if(imgon)
	{
		document.getElementById(id).style.backgroundColor= "#93AAD3";
		document.getElementById(id).style.color= "white";
		if ( document.getElementById && !document.all ) {
			document.getElementById(id).style.cursor="pointer";
		}
	}
	else
	{
		if (CURRENT_OBJ2 != id) {
			document.getElementById(id).style.backgroundColor= "transparent";
			document.getElementById(id).style.color= "black";
			if ( document.getElementById && !document.all ) {
				document.getElementById(id).style.cursor="cross";
			}
		}
	}
}
var COBJ
function highlightError (o) {
	COBJ = o;
	tmp = o.style.backgroundColor;
	o.style.backgroundColor = "#C33";
	setTimeout("restoreError(tmp)",1000);
	o.focus();
}
function restoreError (tmp) {
	COBJ.style.backgroundColor = tmp
}

function initHome () {
	document.getElementById ("email").style.display = "none";
	document.getElementById ("perso").style.display = "none";
	document.getElementById ("infos").style.height= "8px";
}

function showHideJunk (status) {
	if (status == "show") {
		if (inboxIsMessageSelected('listmsgrecus', 'msg_id', true)) document.getElementById ("blocJunk").style.display = "block";
	}
	else if (status == "hide") {
		document.getElementById ("blocJunk").style.display = "none";
	}
}

function showHideJunkOnly (status) {
	if (status == "show") {
		document.getElementById ("blocJunk").style.display = "block";
	}
	else {
		document.getElementById ("blocJunk").style.display = "none";
	}
}

function seeMailHeader (fromprint) {

	if (document.getElementById ("hdMailCt").style.display == "none" || !document.getElementById ("hdMailCt").style.display) {
		document.getElementById ("hdMail").style.borderBottom = "0";
		document.getElementById ("hdImg").src = absolutePathForStaticResources + "Images/Style_R/picto_closeHeader.gif";
		document.getElementById ("hdLabel").innerHTML = BT_CLOSEHEADER;
		document.getElementById ("hdMailCt").style.display = "block";
		document.getElementById ("tableHdMailCt").style.display = "";
		document.getElementById ("tableHdMailCt").style.visibility = "visible";

	}else {
		document.getElementById ("hdMail").style.borderBottom = "1px solid " + "#999999";
		document.getElementById ("hdImg").src = absolutePathForStaticResources + "Images/picto_seeHeader.gif";
		document.getElementById ("hdLabel").innerHTML = BT_SEEHEADER;
		document.getElementById ("hdMailCt").style.display = "none";
		document.getElementById ("tableHdMailCt").style.display = "none";
		document.getElementById ("tableHdMailCt").style.visibility = "hidden";
	}
	//2 fois !!! pour etre pris en compte par IE
	if (fromprint){
	  // taille fixe
	}else{
  	resizeElems ();
  	resizeElems ();
  }
}

function sortColumnAdd (c) {
 	for (i = 1; i <= 5; i++)
 	{
		if (document.getElementById ("tri"+i) != null)
 		{
 			document.getElementById ("tri"+i).style.backgroundColor = "#EDF2F6";
 		}
 	}
 	document.getElementById ("tri"+c).style.backgroundColor = "#D3D7E3";
}

function sortColumn (c) {
	var triDate1 = 0;
	var triDate2 = 1;
	var triDate3 = 4;
	var triFrom1 = 2;
	var triFrom2 = 6;
	var triSub1 = 3;
	var triSub2 = 7;
	var triSize1 = 10;
	var triSize2 = 11;
	var triFolder1 = 12;
	var triFolder2 = 13;
	if ((c==triDate1)||(c==triDate2)||(c==triDate3)){
		document.getElementById("triDate").style.backgroundColor = "#D3D7E3";
		document.getElementById("triFrom").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSubject").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSize").style.backgroundColor = "#EDF2F6";
		if (document.getElementById("triFolder")!=null)
			document.getElementById("triFolder").style.backgroundColor = "#EDF2F6";
	}else if ((c==triFrom1)||(c==triFrom2)){
		document.getElementById("triDate").style.backgroundColor = "#EDF2F6";
		document.getElementById("triFrom").style.backgroundColor = "#D3D7E3";
		document.getElementById("triSubject").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSize").style.backgroundColor = "#EDF2F6";
		if (document.getElementById("triFolder")!=null)
			document.getElementById("triFolder").style.backgroundColor = "#EDF2F6";
	}else if ((c==triSub1)||(c==triSub2)){
		document.getElementById("triDate").style.backgroundColor = "#EDF2F6";
		document.getElementById("triFrom").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSubject").style.backgroundColor = "#D3D7E3";
		document.getElementById("triSize").style.backgroundColor = "#EDF2F6";
		if (document.getElementById("triFolder")!=null)
			document.getElementById("triFolder").style.backgroundColor = "#EDF2F6";
	}else if ((c==triSize1)||(c==triSize2)){
		document.getElementById("triDate").style.backgroundColor = "#EDF2F6";
		document.getElementById("triFrom").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSubject").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSize").style.backgroundColor = "#D3D7E3";
		if (document.getElementById("triFolder")!=null)
			document.getElementById("triFolder").style.backgroundColor = "#EDF2F6";
	}else if ((c==triFolder1)||(c==triFolder2)){
		document.getElementById("triDate").style.backgroundColor = "#EDF2F6";
		document.getElementById("triFrom").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSubject").style.backgroundColor = "#EDF2F6";
		document.getElementById("triSize").style.backgroundColor = "#EDF2F6";
		if (document.getElementById("triFolder")!=null)
			document.getElementById("triFolder").style.backgroundColor = "#D3D7E3";
	}
}

function checkSpell (status) {
	if (status == "show") document.getElementById ("checkSpellWin").style.visibility = "visible";
	else document.getElementById ("checkSpellWin").style.visibility = "hidden";
}

function richText (status, from) {
	if (status == "show") {
		if (bTextMode) {
			bTextMode=false;
			SetText(document.composeform.msg_text.value);
			table_visible="table_HTML";
			MESSAGE="MESSAGE_HTML";
			signature = getArrayFromSignature(signature_html);
			cacher(document.getElementById("table_text"));

			if ( document.getElementById("spanTheme") != null && document.getElementById("blocTheme") != null ) {
				afficher(document.getElementById("spanTheme"));
				afficher(document.getElementById("blocTheme"));
			}

			afficher(document.getElementById("table_HTML"));
		}
	} else {
		if (!bTextMode) {
			if (confirm(getMessage(msgWriteRichTextToPlaintext))) {
				document.composeform.msg_body.value=GetText();
			    document.composeform.msg_text.value=document.composeform.msg_body.value;
			    // document.composeform.msg_text.value=GetText();

				// alert ("document.composeform.msg_body.value "+document.composeform.msg_body.value);
			    // alert ("document.composeform.msg_text.value "+document.composeform.msg_text.value);
			    table_visible="table_text";
			    MESSAGE="MESSAGE_TEXT";
			    signature = getArrayFromSignature(signature_text);
			    bTextMode=true;

				cacher(document.getElementById("table_HTML"));
				if ( document.getElementById("spanTheme") != null && document.getElementById("blocTheme") != null ) {
					cacher(document.getElementById("spanTheme"));
					cacher(document.getElementById("blocTheme"));
				}
				afficher(document.getElementById("table_text"));
			}else {
				bTextMode=false;
				// Recoche la case HTML
				radioEvent("composeform", "formatMail" , ((from=='signature')?"0":"1"));
			}
		}
	}
}


function highPriority () {
// Rien a faire!
}

function keepCopy () {
// Rien a faire!
}

function markUnread (folderName,msg_id,aFormName,aCheckboxName,aValue) {
	if (isCheckboxChecked(aFormName, aCheckboxName, aValue)) {
		unread_me.document.UNREAD_FORM.action="markAsUnread_submit.html"
	} else {
		unread_me.document.UNREAD_FORM.action="markAsRead_submit.html"
	}
	unread_me.document.UNREAD_FORM.FOLDER.value=folderName;
	unread_me.document.UNREAD_FORM.IDMSG.value=msg_id
	unread_me.document.UNREAD_FORM.submit();
}

function noHome () {
	SKIP_WELCOME_FRAME.document.SKIP_FORM.action = "setting_submit.html";
	if (document.FORM_STOP.skip.value == "1")
		SKIP_WELCOME_FRAME.document.SKIP_FORM.skip_welcome.value = "1";
	SKIP_WELCOME_FRAME.document.SKIP_FORM.submit();
}

function noConfirm () {
	SKIP_CONFIRM_SENT_FRAME.document.SKIP_FORM.action = "setting_submit.html";
	if (document.composeform.skip.value == "OK") // c.a.d noConfirm
		SKIP_CONFIRM_SENT_FRAME.document.SKIP_FORM.conf_send_msg.value = "NOK";
	SKIP_CONFIRM_SENT_FRAME.document.SKIP_FORM.submit();
}

function verifSearch () {
	valid = true;
	document.search.searchFor.value = document.search.searchFor2.value;

	if (document.search.searchFor2.value == "") {
		alert (INFO_GET_CONTENT);
		document.search.searchFor2.focus ();
		valid = false;
	}
	else
	if (document.search.when.value != "no")
	{
		if (document.search.day.value == 0 || document.search.month.value == 0 || document.search.year.value == 0)
		{
			alert (INFO_GET_DATE);
			valid = false;
		} else {
			//modif verification date valide!
			valid = verifDate(document.search.day.value,document.search.month.value,document.search.year.value);
			if(!valid) {
          		alert(INFO_GET_DATE_VALIDE);
      		}
		}

	}

	if (valid)
	{
		ValidSearch();
	}
}

function verifDate(jour, mois, annee) {

	var ok = false;

	var d2=new Date(annee,(mois-1),jour);
	var j2=d2.getDate();
    var m2=d2.getMonth()+1;
    var a2=d2.getYear();
    if (a2<=1900) {a2=1900+a2}
    if ( (jour==j2)&&(mois==m2)&&(annee==a2) )
    {
		ok = true;
	}

	return ok;
}

function mailInfo (st) {
	if (st) {
		document.getElementById("demiBloc2").style.display = "none";
		document.getElementById("demiBloc3").style.display = "block";
	}
	else {
		document.getElementById("demiBloc2").style.display = "block";
		document.getElementById("demiBloc3").style.display = "none";
	}
}

function validApproved (o) {
	if (!isTextFieldEmpty(o) && isEmailAddressValid(o.value)) {
		alert (INFO_VALIDATION_OK);
	}
	else {
		alert (INFO_VALIDATION_NOTCORRECT_ADDRESS);
		o.focus();
	}
}

function validBkAdr (o) {
	if (!isTextFieldEmpty(o) && isEmailAddressValid(o.value)) {
		alert (INFO_VALIDATION_OK);
	}
	else {
		alert (INFO_VALIDATION_NOTCORRECT_ADDRESS);
		o.focus();
	}
}

function validBkSbj (o) {
	if (!isTextFieldEmpty(o)) {
		alert (INFO_VALIDATION_OK);
	}
	else {
		alert (INFO_VALIDATION_NOTCORRECT_SUBJECT);
		o.focus();
	}
}

// Initialisation de la liste a vide.
var wFilters = new Array();
var count_filters =0;

/*
// DEPRACATED
function initFilters () {
	var ch = "";

	for (i=0; i < wFilters.length; i++) {
		ch += "<a href='javascript:setFilt(" + i + ", \"0\")' id='0" + i + "'><span class='item1'>" + wFilters[i] + "</span><span class='item2'></span><span id='d" + i + "' class='item3'></span></a>";
	}
	document.getElementById("liste").innerHTML = ch ;
	document.getElementById("liste").style.height = 3 * 26;
}
*/

// Ajoute un filtre a la liste des filtres
function addFilter(filtername) {
	if (filtername != ""){
		//alert(count_filters);
		wFilters[count_filters]=filtername;
		count_filters = count_filters+1;
	}
}

/*
// DEPRACATED
function setFilter (id) {
	if (CURRENT_OBJ != null) {
		document.getElementById(CURRENT_OBJ).style.backgroundColor="transparent";
		document.getElementById(CURRENT_OBJ).style.color="black";
	}
	CURRENT_OBJ = id;
	document.customFilterEditForm.SELECTED_FILTER_NAME.value = wFilters[Number(CURRENT_OBJ.substr(2))];
	majInfoFilter();
}
*/

function setFilt (n, idListItem) {
	
	if (document.customFilterAddForm.SELECTED_FILTER_NAME.value == '') {
		var borderBottomColor = "#F60";
		if (n != oldN) {
			if (oldN != 0) {
				document.getElementById(idListItem + oldN).className = "";
				document.getElementById(idListItem + oldN).style.borderBottomColor = "#CCC";
				document.getElementById(idListItem + (oldN-1)).style.borderBottomColor = "#CCC";
			} else {
				document.getElementById(idListItem + oldN).className = "";
				document.getElementById(idListItem + oldN).style.borderBottomColor = "#ccc";
			}
			if (n != 0) {
				document.getElementById(idListItem + n).className = "current";
				document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
				document.getElementById(idListItem + (n-1)).style.borderBottomColor = borderBottomColor;
			} else  {
				document.getElementById(idListItem + n).className = "current";
				document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
			}
		} else if ((n==0)&&(oldN==0)) {
			document.getElementById(idListItem + n).className = "current";
			document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
		}
	}
	
	oldN = n;
	CURRENT_OBJ = n;
	document.customFilterEditForm.SELECTED_FILTER.value = wFilters[Number(CURRENT_OBJ)];
	setbuttonstatus(true);
	//majInfoFilter();
	
//	if (document.customFilterAddForm.SELECTED_FILTER_NAME.value != '') {
	if (action==EDIT_FILTER) {
		document.customFilterEditForm.action="filters.html";
		document.customFilterEditForm.submit();
	} else {
		resetFilterForm();
	}
	
}

/*
function manageFilters(act) {
	var TMP_OBJ;
	if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "add" :	if (document.customFilterAddForm.SELECTED_FILTER_NAME.value == "") {
								alert (INFO_VALIDATION_ADD_INFORMATION_NEW_FILTER);
								tmp = document.customFilterAddForm.SELECTED_FILTER_NAME.style.background;
								document.customFilterAddForm.SELECTED_FILTER_NAME.style.background = "red";
								setTimeout("document.customFilterAddForm.SELECTED_FILTER_NAME.style.background = tmp",1000);
								document.customFilterAddForm.SELECTED_FILTER_NAME.focus();
							}
							else
							{
								addFilter(document.customFilterAddForm.SELECTED_FILTER_NAME.value);
							}
							break;
			case "del" :	wFilters.splice(Number(CURRENT_OBJ.substr(2)), 1);
							CURRENT_OBJ = null;
							break;
			case "upd" :
							break;
			case "up" :		if (Number(CURRENT_OBJ.substr(2)) != 0) {
								TMP_OBJ = wFilters [Number(CURRENT_OBJ.substr(2))-1];
								wFilters [Number(CURRENT_OBJ.substr(2))-1] = wFilters [Number(CURRENT_OBJ.substr(2))];
								wFilters [Number(CURRENT_OBJ.substr(2))] = TMP_OBJ;
								CURRENT_OBJ = "id" + String(Number(CURRENT_OBJ.substr(2))-1);
							}
							break;
			case "dn" :		if (Number(CURRENT_OBJ.substr(2)) != wFilters.length-1) {
								TMP_OBJ = wFilters [Number(CURRENT_OBJ.substr(2))+1];
								wFilters [Number(CURRENT_OBJ.substr(2))+1] = wFilters [Number(CURRENT_OBJ.substr(2))];
								wFilters [Number(CURRENT_OBJ.substr(2))] = TMP_OBJ;
								CURRENT_OBJ = "id" + String(Number(CURRENT_OBJ.substr(2))+1);
							}
							break;
		}
		initFilters();
		if (CURRENT_OBJ != null) {
//			document.getElementById(CURRENT_OBJ).style.backgroundColor= "#93AAD3";
//			document.getElementById(CURRENT_OBJ).style.color="black";
/*		}
	}
	else alert (INFO_VALIDATION_SELECT_FILTER_BEFORE);
}
*/

var wAddress = ["toto.sdfv@vsd.com", "dgfdef.sdfv@hjjh.com", "hgtg.sdfv@vghjgsd.com", "fhng.sdfv@vhnghgsd.com", "wxcv.sdsdfsdfv@dssdvsd.com"];
function initAddress () {
	var ch = "<table border='0' cellspacing='0' cellpadding='0' id='filtersList'>";

	for (i=0; i < wAddress.length; i++) ch += "<tr bgcolor='' id='id" + i + "' onMouseOver='tabRollOver(\"id" + i + "\", true)' onMouseOut='tabRollOver(\"id" + i + "\", false)'><td><a href='javascript:setAddress(\"id" + i + "\")'>" + wAddress[i] + "</a></td></tr>";
	document.getElementById("adrL").innerHTML = ch + "</table>";
}

function setAddress (id) {
	if (CURRENT_OBJ != null) {
		document.getElementById(CURRENT_OBJ).style.backgroundColor= "transparent";
		document.getElementById(CURRENT_OBJ).style.color= "black";
	}
	CURRENT_OBJ = id;
}

function manageAddress(act) {
	var TMP_OBJ;
	if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "add" :	if (document.FORM_SMSPARAM.EXP_NAME.value == "") {
								alert (INFO_VALIDATION_ADD_INFORMATION_NEW_ADDRESS);
								highlightError (document.FORM_SMSPARAM.EXP_NAME);
							}
							break;
			case "del" :	wAddress.splice(Number(CURRENT_OBJ.substr(2)), 1);
							CURRENT_OBJ = null;
							break;
		}
		initAddress();
		if (CURRENT_OBJ != null) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
	}
	else alert (INFO_VALIDATION_SELECT_ADDRESS_BEFORE);
}

var wWords = ["roulette", "rendez-vous", "vacances", "travail", "loisirs"];
function initWords () {
	var ch = "<table border='0' cellspacing='0' cellpadding='0' id='filtersList'>";

	for (i=0; i < wWords.length; i++) ch += "<tr bgcolor='' id='it" + i + "' onMouseOver='tabRollOver2(\"it" + i + "\", true)' onMouseOut='tabRollOver2(\"it" + i + "\", false)'><td><a href='javascript:setWords(\"it" + i + "\")'>" + wWords[i] + "</a></td></tr>";
	document.getElementById("wrdL").innerHTML = ch + "</table>";
}

function setWords (id) {
	if (CURRENT_OBJ2 != null) {
		document.getElementById(CURRENT_OBJ2).style.backgroundColor="transparent";
		document.getElementById(CURRENT_OBJ2).style.color="black";
	}
	CURRENT_OBJ2 = id;
}

function manageWords(act) {
	var TMP_OBJ;
	if (CURRENT_OBJ2 != null || act == "add") {
		switch (act) {
			case "add" :	if (document.FORM_SMSPARAM.OBJ_WORDS.value == "") {
								alert (INFO_VALIDATION_ADD_INFORMATION_NEW_ADDRESS);
								highlightError (document.FORM_SMSPARAM.OBJ_WORDS);
							}
							break;
			case "del" :	wWords.splice(Number(CURRENT_OBJ2.substr(2)), 1);
							CURRENT_OBJ2 = null;
							break;
		}
		initWords();
		if (CURRENT_OBJ2 != null) {
			document.getElementById(CURRENT_OBJ2).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ2).style.color="black";
		}
	}
	else alert (INFO_VALIDATION_SELECT_ADDRESS_BEFORE);
}

var LETCOPY_SERVER;
function setCopyOnServer () {
	LETCOPY_SERVER = !LETCOPY_SERVER;
}

var USE_POLLING_AUTO;
function setPollingAuto() {
	USE_POLLING_AUTO = !USE_POLLING_AUTO;
}


function setPops (id) {
	if (CURRENT_OBJ != null) {
		document.getElementById(CURRENT_OBJ).style.backgroundColor="transparent";
		document.getElementById(CURRENT_OBJ).style.color="black";
	}
	CURRENT_OBJ = id;
	if(CURRENT_OBJ != tempOBJ){
  	  activebutton("majbttn");
	  vEdition=false;
	}else{
	  desactivebutton("majbttn");
	  vEdition=true;
	}

}

function managePops(act) {
	var TMP_OBJ;
	if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "add" :
						if (count>folderLimit && document.folderExt.accountId.value.length==0){
							showHideJunkOnly("show");
							document.getElementById ("blocJunk").style.display = "block";
							break;
						}else{
							showHideJunkOnly("hide");
						}

							if (isTextFieldEmpty(document.folderExt.account)) {
								alert (INFO_GET_VALID_ADDRESS);
								highlightError (document.folderExt.account);
								break;
							}
							else if (isTextFieldEmpty(document.folderExt.popServer)) {
								alert (INFO_GET_VALID_SERVER);
								highlightError (document.folderExt.popServer);
								break;
							}
							else if ((!isTextFieldEmpty(document.folderExt.login) && isTextFieldEmpty(document.folderExt.passwd)) || (isTextFieldEmpty(document.folderExt.login) && !isTextFieldEmpty(document.folderExt.passwd)) || (isTextFieldEmpty(document.folderExt.login) && isTextFieldEmpty(document.folderExt.passwd))) {

								alert (INFO_GET_LOGIN_PASSWORD);
								if (isTextFieldEmpty(document.folderExt.login) && !isTextFieldEmpty(document.folderExt.passwd)) highlightError (document.folderExt.login);
								else if (!isTextFieldEmpty(document.folderExt.login) && isTextFieldEmpty(document.folderExt.passwd)) highlightError (document.folderExt.passwd);
								else {
									 highlightError (document.folderExt.login);
									 setTimeout("highlightError (document.folderExt.passwd)", 1000);
								}
								break;
							}
							var exist=false;
							var myAccount = document.folderExt.account.value;
							if(document.folderExt.account.value!=modified_Account){
								for(var i=0; i<count; i++) {
									if(myAccount==tab[i]){
   										exist=true;
   									}
 		 						}
 		 					}
							if(exist){
   									alert (INFO_EXIST_ADDRESS);
   									break;
							}else{

								document.folderExt.leave.value=""+LETCOPY_SERVER;

                var pollingCategory = document.init.pollingCategory.value;
                document.folderExt.pollingType.value=document.init.pollingType.value;
                if (pollingCategory == "pollingWithSettings"){
                    var daysSelectedValue = document.folderExt.hour_content.value;
                    if (validAutoPolling(daysSelectedValue) == "OK"){
                      SelectedDays();
		      SelectedTime();
  		      document.folderExt.action="pops_submit.html";
  		      document.folderExt.submit();
                    }

                }else if (pollingCategory == "pollingNoSettings"){
                    document.folderExt.pollingAuto.value=""+USE_POLLING_AUTO;
                    document.folderExt.action="pops_submit.html";
		    document.folderExt.submit();

                }else{
                   document.folderExt.pollingAuto.value=""+USE_POLLING_AUTO;
                   document.folderExt.action="pops_submit.html";
		   document.folderExt.submit();
                }

                break;

            }


			case "del" :
							document.folderExt.checkId.value = CURRENT_OBJ;
							CURRENT_OBJ = null;


					if ( window.confirm(CONFIRM_DELETE_REMOTE) )
					{
						document.folderExt.action="pops_submit_delete.html";
						document.folderExt.submit();
					}
							break;
			case "upd" :
						if(!vEdition){
							Edit(CURRENT_OBJ);
						}
							break;
		}

		if (CURRENT_OBJ != null) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
	}
	else
	if(!vEdition){
		alert (INFO_VALIDATION_SELECT_ADDRESS_BEFORE);
	}
}

// Desactive un bouton
function desactivebutton(buttonname){
	document.getElementById(buttonname).style.color= "#999999";
//	if ( document.getElementById && !document.all ) {
		document.getElementById(buttonname).style.cursor="default";
//	}
}

// Active un bouton
function activebutton(buttonname){
	document.getElementById(buttonname).style.color= "black";
//	if ( document.getElementById && !document.all ) {
		document.getElementById(buttonname).style.cursor="pointer";
//	}
}

function validPOPs () {
	self.location = "inbox.html";
}

function confirm_sentFax () {
	if (document.composeform.msg_to.value == "") {
		alert (INFO_GET_RECIPIENT_FAX);
		tmp = document.composeform.msg_to.style.background;
		document.composeform.msg_to.style.background = "red";
		setTimeout("document.composeform.msg_to.style.background = tmp",1000);
		document.composeform.msg_to.focus();
	}else if(document.composeform.msg_to_name.value == ""){
		alert (INFO_GET_DESTINATAIRE_FAX);
		tmp = document.composeform.msg_to_name.style.background;
		document.composeform.msg_to_name.style.background = "red";
		setTimeout("document.composeform.msg_to_name.style.background = tmp",1000);
		document.composeform.msg_to_name.focus();
	}else if(document.composeform.msg_subject.value == ""){
		alert (INFO_GET_OBJET_FAX);
		tmp = document.composeform.msg_subject.style.background;
		document.composeform.msg_subject.style.background = "red";
		setTimeout("document.composeform.msg_subject.style.background = tmp",1000);
		document.composeform.msg_subject.focus();
	}
	else if (document.composeform.msg_text.value == "") {
		if (confirm (INFO_EMPTY_MSG_TO_SEND)) {
		    MailToFax_Valid();
		}
		else document.composeform.msg_text.focus ();
	}
	else {
	    MailToFax_Valid();
	}
}



function setSentMails (aFormName, aCheckboxName, aValue, obj) {
	verifTA (aFormName, aCheckboxName, aValue, obj);
}

function emptyTA (aFormName, aCheckboxName, aValue, ta) {
	// Changement du contr?le pour vide la
	if (!isCheckboxChecked(aFormName, aCheckboxName, aValue)) ta.value = "";
}

function verifTA (aFormName, aCheckboxName, aValue, obj) {
	if (isCheckboxChecked(aFormName, aCheckboxName, aValue) && obj.value == "") {
		alert (INFO_FILL_FIELD);
		obj.focus();
	}
}

function verifCGUok (aFormName, aCheckboxName, aValue) {
	if (!isCheckboxChecked(aFormName, aCheckboxName, aValue)) alert (INFO_KNOW_CONDITION)
	else document.composeformSMS_INSCR.submit();
}

//function validForward(aFormName, aRadioName, aValue, aCheckboxName, aRadioName2, aValue2) {
function validMailForward(aFormName, aRadioName, aValue, aCheckboxName, aRadioName2, aValue2) {
	if (document.redirectFilterForm.email.value == "" || (document.redirectFilterForm.email.value != "" && !isEmailAddressValid(document.redirectFilterForm.email.value))) {
		alert (INFO_GET_RECIPIENT_ADDRESS);
		highlightError (document.redirectFilterForm.email);
		return "NOK";
	}
	if (isRadioChecked(aFormName, aRadioName, aValue)) {
		tmp = false;
		for (i=1; i<8; i++) {
			if (isCheckboxChecked(aFormName, aCheckboxName, aCheckboxName+String(i)))
			tmp = true;
		}
		if (!tmp) {
			alert (INFO_GET_DAYS_TO_TRANSFERT);
			return "NOK";
			}
	}
	if ((isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursComboLabel").innerHTML >= "<") || (isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursCombo2Label").innerHTML >= "<")) {
		alert (INFO_GET_BEGIN_END_TRANSFERT);
		if (document.getElementById("HoursComboLabel").innerHTML >= "<") highlightError (document.getElementById("HoursComboLabel"));
		else highlightError (document.getElementById("HoursCombo2Label"));
		return "NOK";
	}
	if (document.getElementById("HoursComboLabel").innerHTML > document.getElementById("HoursCombo2Label").innerHTML) {
		alert (INFO_VALIDATION_BEGIN_LOWER_END_HOUR);
		highlightError (document.getElementById("HoursComboLabel"));
		return "NOK";
	}
	if ((isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursComboLabel").innerHTML == document.getElementById("HoursCombo2Label").innerHTML) && (isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("MinutesComboLabel").innerHTML >= document.getElementById("MinutesCombo2Label").innerHTML)) {
		alert (INFO_VALIDATION_BEGIN_LOWER_END_HOUR);
		highlightError (document.getElementById("MinutesComboLabel"));
		return "NOK";
	}
	return "OK";
}

function validForgot (step) {
	switch (step) {
		case 1 :	if (document.FORM_FP.EMAIL.value == "" || !isEmailAddressValid(document.FORM_FP.EMAIL.value)) {
						alert (INFO_VALIDATION_CORRECT_YOUR_EMAIL);
						highlightError (document.FORM_FP.EMAIL);
					}
					else if (document.FORM_FP.CP.value == "") {
						alert (INFO_VALIDATION_EMPTY_ZIPCODE);
						highlightError (document.FORM_FP.CP);
					}
					else window.location.href = "forgotten_password2.htm";
					break;
		case 2 :	if (document.FORM_FP.ANS.value == "") {
						alert (INFO_VALIDATION_EMPTY_ANSWER);
						highlightError (document.FORM_FP.ANS);
					}
					else window.location.href = "forgotten_password3.htm";
					break;
		case 3 :	if (document.FORM_FP.PW.value == "" || document.FORM_FP.PW.value.length < 4 || document.FORM_FP.PW.value.length > 24) {
						alert (INFO_VALIDATION_CORRECT_PASSWORD);
						highlightError (document.FORM_FP.PW);
					}
					else if (document.FORM_FP.PW2.value == "" || document.FORM_FP.PW2.value.length < 4 || document.FORM_FP.PW2.value.length > 24) {
						alert (INFO_VALIDATION_EMPTY_CONFIRM);
						highlightError (document.FORM_FP.PW2);
					}
					else if (document.FORM_FP.PW.value != document.FORM_FP.PW2.value) {
						alert (INFO_VALIDATION_DIFFERENT_PASSWORD);
						document.FORM_FP.PW.value = "";
						document.FORM_FP.PW2.value = "";
						document.FORM_FP.PW.focus();
					}
					else window.location.href = "forgotten_password4.htm";
					break;
	}
}

function displayDetails() {
	document.getElementById("moreDetails").style.display = "block";
	document.getElementById("labelMore").style.display = "none";
}

function validQuickAdd() {
	
	if (document.modadr.fullname.value == ""){
		window.alert(INFO_VALIDATION_EMPTY_NICKNAME);
	}
	else if (document.modadr.fullname.value == "nopseudo") {
		
		// On force la valorisation du Pseudo pour le cas nopseudo
		if (document.modadr.firstname.value != "" && document.modadr.firstname.value.indexOf(";") ==-1 && document.modadr.firstname.value.indexOf(",") ==-1){
			if (document.modadr.surname.value != "" && document.modadr.surname.value.indexOf(";") ==-1 && document.modadr.surname.value.indexOf(",") ==-1) {
				document.modadr.fullname.value = document.modadr.firstname.value + ' ' + document.modadr.surname.value;
			}
			else{
				document.modadr.fullname.value = document.modadr.firstname.value;
			}
		} else if (document.modadr.surname.value != "" && document.modadr.surname.value.indexOf(";") ==-1 && document.modadr.surname.value.indexOf(",") ==-1) {
			document.modadr.fullname.value = document.modadr.surname.value;
		} else if (document.modadr.email1.value != "" && isEmailAddressValid(document.modadr.email1.value)){
			document.modadr.fullname.value = document.modadr.email1.value.substring(0, document.modadr.email1.value.lastIndexOf("@"));
		}
		
		// En cas d'erreur on reinitialise la valeur du champ fullname		
		if (document.modadr.email1.value == "") {
			alert (INFO_VALIDATION_EMPTY_EMAIL);
			document.modadr.fullname.value = "nopseudo";
		}
		else if (!isEmailAddressValid(document.modadr.email1.value)) {
			alert (INFO_VALIDATION_CORRECT_EMAIL);
			document.modadr.fullname.value = "nopseudo";
		}
		else {
			document.modadr.submit();
		}		
	}
	else {
		if(document.modadr.fullname.value.indexOf(";")!=-1 || document.modadr.fullname.value.indexOf(",")!=-1){
			alert(INFO_VALIDATION_NICKNAME_MUST_NOT_CONTAIN);
		}
		else if (document.modadr.email1.value == "") {
			alert (INFO_VALIDATION_EMPTY_EMAIL);
		}
		else if (!isEmailAddressValid(document.modadr.email1.value)) {
			alert (INFO_VALIDATION_CORRECT_EMAIL);
		}
		else {
			document.modadr.submit();
		}
	}
}

function validDetails(newAdd) {
	if (document.modadr.fullname.value == ""){
		document.modadr.fullname.value = "nopseudo";
	}
	if (document.modadr.email1.value == "") {
			alert (INFO_VALIDATION_EMPTY_EMAIL);
	} else if (!isEmailAddressValid(document.modadr.email1.value)) {
			alert (INFO_VALIDATION_CORRECT_EMAIL);
	} else if (document.modadr.fullname.value == ""){
		  window.alert(INFO_VALIDATION_EMPTY_NICKNAME);
	} else if ((document.modadr.firstname.value == "" && document.modadr.surname.value == "" && document.modadr.fullname.value == "") && (document.modadr.email1.value == "" || !isEmailAddressValid(document.modadr.email1.value))) {
		if (document.modadr.email1.value != "" && !isEmailAddressValid(document.modadr.email1.value)) {
			alert (INFO_VALIDATION_CORRECT_EMAIL);
			highlightError (document.modadr.email1);
		}
		else alert (INFO_VALIDATION_EMPTY_ALL);
	}
	else {
		if (newAdd)
		{
			if (document.modadr.CARDID.value == "")
			{
				if (document.modadr.fullname.value == "nopseudo" && document.modadr.firstname.value != "" && document.modadr.surname.value != "") {
					document.modadr.fullname.value = document.modadr.firstname.value + " " + document.modadr.surname.value;
				} else if (document.modadr.fullname.value == "nopseudo" && document.modadr.firstname.value != ""){
					document.modadr.fullname.value = document.modadr.firstname.value;
				} else if (document.modadr.fullname.value == "nopseudo" && document.modadr.surname.value != "") {
					document.modadr.fullname.value = document.modadr.surname.value;
				} else {
					document.modadr.fullname.value == document.modadr.email1.value.substring(0, document.modadr.email1.value.lastIndexOf("@", 0));
				}
		
				document.modadr.action = "ct_add_and_add_new.html";
				document.modadr.submit();
			}
			else
			{
				document.modadr.action = "ct_update_and_add_new.html";
				document.modadr.submit();
			}
		}
		else
		{
			if (document.modadr.CARDID.value == "")
			{
				if (document.modadr.fullname.value == "nopseudo" && document.modadr.firstname.value != "" && document.modadr.surname.value != "") {
					document.modadr.fullname.value = document.modadr.firstname.value + " " + document.modadr.surname.value;
				} else if (document.modadr.fullname.value == "nopseudo" && document.modadr.firstname.value != ""){
					document.modadr.fullname.value = document.modadr.firstname.value;
				} else if (document.modadr.fullname.value == "nopseudo" && document.modadr.surname.value != "") {
					document.modadr.fullname.value = document.modadr.surname.value;
				} else {
					document.modadr.fullname.value == document.modadr.email1.value.substring(0, document.modadr.email1.value.lastIndexOf("@", 0));
				}
				document.modadr.action = "ct_add.html";
				document.modadr.submit();
			}
			else
			{
				if (document.modadr.popup){					
					document.modadr.action = "ct_update_popup.html";
				}else{
					document.modadr.action = "ct_update.html";
				}
				document.modadr.submit();
			}
		}
	}
}

function validDistList() {
	var i=0;
	for (i=0; i<document.modlist.selectcontact2.options.length; i++)
	{
		if (document.modlist.ADD.value != "")
		{
			document.modlist.ADD.value = document.modlist.ADD.value + ",";
		}
		document.modlist.ADD.value = document.modlist.ADD.value + document.modlist.selectcontact2.options[i].value;
	}

	if (document.modlist.GROUPID.value == "")
	{
		document.modlist.action = "ctDistL_add.html";
		document.modlist.submit();
	}
	else
	{
		document.modlist.action = "ctDistL_update.html";
		document.modlist.submit();
	}
}

function validChPW() {
	if (document.prefs.cpasswd.value == "") {
		alert (INFO_VALIDATION_CORRECT_PASSWORD);
		highlightError (document.prefs.cpasswd);
	}
	else if (document.prefs.newpasswd.value == "") {
		alert (INFO_VALIDATION_EMPTY_NEWPASSWORD);
		highlightError (document.prefs.newpasswd);
	}
	else if (document.prefs.renewpasswd.value == "") {
		alert (INFO_VALIDATION_EMPTY_CONFIRM_PASSWORD);
		highlightError (document.prefs.renewpasswd);
	}
	else if (document.prefs.newpasswd.value != document.prefs.renewpasswd.value) {
		alert (INFO_VALIDATION_DIFFERENT_PASSWORD);
		document.prefs.newpasswd.value = "";
		document.prefs.renewpasswd.value = "";
		document.prefs.newpasswd.focus();
	}
	else {
		document.prefs.submit();
	}
}
// Ajout pour le test du mot de passe courant pour Mobistar
function validChPW(valeur) {
	if(valeur == true) {
		if (document.prefs.cpasswd.value == "") {
			alert (INFO_VALIDATION_CORRECT_PASSWORD);
			highlightError (document.prefs.cpasswd);
		}
		else if (document.prefs.newpasswd.value == "") {
			alert (INFO_VALIDATION_EMPTY_NEWPASSWORD);
			highlightError (document.prefs.newpasswd);
		}
		else if (document.prefs.renewpasswd.value == "") {
			alert (INFO_VALIDATION_EMPTY_CONFIRM);
			highlightError (document.prefs.renewpasswd);
		}
		else if (document.prefs.newpasswd.value != document.prefs.renewpasswd.value) {
			alert (INFO_VALIDATION_DIFFERENT_PASSWORD);
			document.prefs.newpasswd.value = "";
			document.prefs.renewpasswd.value = "";
			document.prefs.newpasswd.focus();
		}
		else {
			document.prefs.submit();
		}
	}
	else if(valeur == false) {
		if (document.prefs.newpasswd.value == "") {
			alert (INFO_VALIDATION_EMPTY_NEWPASSWORD);
			highlightError (document.prefs.newpasswd);
		}
		else if (document.prefs.renewpasswd.value == "") {
			alert (INFO_VALIDATION_EMPTY_CONFIRM);
			highlightError (document.prefs.renewpasswd);
		}
		else if (document.prefs.newpasswd.value != document.prefs.renewpasswd.value) {
			alert (INFO_VALIDATION_DIFFERENT_PASSWORD);
			document.prefs.newpasswd.value = "";
			document.prefs.renewpasswd.value = "";
			document.prefs.newpasswd.focus();
		}
		else {
			document.prefs.submit();
		}
	}
}
// Fin de l'ajout Mobistar
function validDelAcc() {
	if (document.prefs.email.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_EMAIL);
		highlightError (document.prefs.email);
	}
	else if (document.prefs.email.value != "" && !isEmailAddressValid(document.prefs.email.value)) {
		alert (INFO_VALIDATION_CORRECT_YOUR_EMAIL);
		highlightError (document.prefs.email);
	}
	else if (document.prefs.password.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_PASSWORD);
		highlightError (document.prefs.password);
	}
	else if (document.prefs.re_password.value == "") {
		alert (INFO_VALIDATION_EMPTY_CONFIRM);
		highlightError (document.prefs.re_password);
	}
	else if (document.prefs.password.value != document.prefs.re_password.value) {
		alert (INFO_VALIDATION_DIFFERENT_PASSWORD);
		document.prefs.password.value = "";
		document.prefs.re_password.value = "";
		document.prefs.password.focus();
	}
	else {
		if (confirm (DELETE_ACCOUNT_CONFIRM)){
			document.prefs.submit();
		}else{
			self.location = "settings.html";
		}
	}
}

function insertAdr(act, o) {
	switch (act) {
		case "add" :	if (document.FORM_INSERT.B0.options.selectedIndex >= 0) {
							o.options[o.options.length] = new Option(document.FORM_INSERT.B0.options[document.FORM_INSERT.B0.options.selectedIndex].text,document.FORM_INSERT.B0.options[document.FORM_INSERT.B0.options.selectedIndex].value);
						}
						else alert (INFO_VALIDATION_SELECT_ADDRESS);
						break;
		case "del" :	if (o.options.selectedIndex >= 0) {
							o.options[o.options.selectedIndex] = null
						}
						else alert (INFO_VALIDATION_SELECT_ADDRESS);
						break;
	}
}

function validSignIn() {
	if (document.FORM_LOGOUT.LOGIN.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_EMAIL);
		highlightError (document.FORM_LOGOUT.LOGIN);
	}
	else if (document.FORM_LOGOUT.PASSWORD.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_PASSWORD);
		highlightError (document.FORM_LOGOUT.PASSWORD);
	} else {
		if (document.FORM_LOGOUT.DOMAINE){
			document.FORM_LOGOUT.LOGIN.value=trim(document.FORM_LOGOUT.LOGIN.value)+"@"+trim(document.FORM_LOGOUT.DOMAINE.value);
		}
		document.FORM_LOGOUT.submit();
	}
}

function validSearchWeb() {
	if (document.FORM_LOGOUT.WEB.value == "") {
		alert (INFO_VALIDATION_EMPTY_SEARCH);
		highlightError (document.FORM_LOGOUT.WEB);
	}
}

function validParamAlerteSms(aFormName, aRadioName, aValue, aCheckboxName, aRadioName2, aValue2) {

	if (isRadioChecked(aFormName, aRadioName, aValue)) {
		tmp = false;
		for (i=1; i<8; i++) {
			if (isCheckboxChecked(aFormName, aCheckboxName, aCheckboxName+String(i)))
			tmp = true;
		}
		if (!tmp) {
			alert (INFO_VALIDATION_SELECT_DAYS_ALERT);
			return "NOK";
			}
	}
	if ((isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursComboLabel").innerHTML >= "<") || (isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursCombo2Label").innerHTML >= "<")) {
		alert (INFO_VALIDATION_BEGIN_END_HOUR_ALERT);
		if (document.getElementById("HoursComboLabel").innerHTML >= "<") highlightError (document.getElementById("HoursComboLabel"));
		else highlightError (document.getElementById("HoursCombo2Label"));
		return "NOK";
	}
	if (document.getElementById("HoursComboLabel").innerHTML > document.getElementById("HoursCombo2Label").innerHTML) {
		alert (INFO_VALIDATION_BEGIN_LOWER_END_HOUR);
		highlightError (document.getElementById("HoursComboLabel"));
		return "NOK";
	}
	if ((isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("HoursComboLabel").innerHTML == document.getElementById("HoursCombo2Label").innerHTML) && (isRadioChecked(aFormName, aRadioName2, aValue2) && document.getElementById("MinutesComboLabel").innerHTML >= document.getElementById("MinutesCombo2Label").innerHTML)) {
		alert (INFO_VALIDATION_BEGIN_LOWER_END_HOUR);
		highlightError (document.getElementById("MinutesComboLabel"));
		return "NOK";
	}
	return "OK";
}

function validSignIn2() {
	if (document.FORM_LOGIN.LOGIN.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_EMAIL);
		highlightError (document.FORM_LOGIN.LOGIN);
	}
	else if (document.FORM_LOGIN.PASSWORD.value == "") {
		alert (INFO_VALIDATION_EMPTY_YOUR_PASSWORD);
		highlightError (document.FORM_LOGIN.PASSWORD);
	} else {
		if (document.FORM_LOGIN.DOMAINE){
			document.FORM_LOGIN.LOGIN.value=trim(document.FORM_LOGIN.LOGIN.value)+"@"+trim(document.FORM_LOGIN.DOMAINE.value);
		}
		document.FORM_LOGIN.submit();
	}
}

/* ******************************** */
/*                                  */
/*     Declaration of messages      */
/*                                  */
/* ******************************** */

// --------------------------------
// Messages for login page
// --------------------------------
var msgLoginMandatoryFields 	= "You need to enter both your email address and password";

// --------------------------------
// Messages for welcome page
// --------------------------------

// --------------------------------
// Messages for inbox page
// --------------------------------
var msgInboxNoSelection 	= "Please select a message";

// --------------------------------
// Messages for read mail page
// --------------------------------

// --------------------------------
// Messages for write mail page
// --------------------------------
var msgWriteIncorrectEmailAddress 	= "The email address you have entered is not valid.  Tip.  It must contain an \u0040 symbol and no spaces.  ";
var msgWriteNoSignature 		= "A signature has not yet been set up.  You can create one by going to Settings.";
var msgWriteNeitherSubjectBody 		= "Your message is empty.  You need to enter a subject or write in the message body.";
var msgWriteRichTextToPlaintext 	= "Please note, changing to plain text will lose your formatting.";

// --------------------------------
// Messages for read mail page
// --------------------------------
var msgPermanentlyDeleted 		= "This will permanently delete the message\u0028s\u0029.  Are you sure?";

// ---------------------------------
// Messages for folders management
// ---------------------------------
var folderNameCanNotBeEmpty 		= "You need to give your folder a name";
var noFolderSelected 			= "Please select a folder";
var confirmDeleteFolder 		= "Are you sure you want to delete  __FOLDER_DISPLAY_NAME__ and all of its contents?";
var confirmDeleteFolderSubFolder	= "Are you sure you want to definitely delete folder __FOLDER_DISPLAY_NAME__, subfolder __LIST_SUB_FOLDERS__ and all content ?";
var confirmDeleteFolderSubFolders	= "Do you really want to delete folder __FOLDER_DISPLAY_NAME__ and subfolders __LIST_SUB_FOLDERS__ ?";
var confirmDeleteFolderSubFolderSeparator	= ", ";
var confirmEmptyFolderDefinitely 	= "Are you sure you want to permanently delete the contents of  __FOLDER_DISPLAY_NAME__";
var confirmEmptyFolderTrash 		= "Are you sure you want to delete the contents  __FOLDER_DISPLAY_NAME__";
var nameNewFolder 			= "New Folder";


/* ******************************** */
/*                                  */
/*      Constant declarations       */
/*                                  */
/* ******************************** */

// Address separator in address list
var ADDRESS_SEPARATOR = ";";


/* ******************************** */
/*                                  */
/*       Common functions           */
/*                                  */
/* ******************************** */

// ------------------------------------------------
// Function getMessage :
// Get the specified message unescaping the special
// characters.
//
// Params :
//	- aMessage : the string to transform
//
// Returns : the specified string by replacing
// ascii code with appropriate characters
// ------------------------------------------------
function getMessage(aMessage) {
	try {
		return unescape(aMessage);
	}
	catch(anException) {
		return aMessage;
	}
}

// ------------------------------------------------
// Function isTextFieldEmpty :
// Check if the text field is empty or not
//
// Params :
//	- anObject : the text field object
//
// Returns : true if the specified field is empty
// and false if it contains 1 or more characters
// ------------------------------------------------
function isTextFieldEmpty(anObject) {
	if (anObject) {
		if (anObject.value == "") {
			return true;
		} else {
			return false;
		}
	}
	return true;
}

// ------------------------------------------------
// Function trim :
// Remove front and trailing spaces from the
// specified string.
//
// Params :
//	- aString : the string to trim
//
// Returns : the string without front and trailing
// spaces
// ------------------------------------------------
function trim(aString) {
	return aString.replace(/(^\s*)|(\s*$)/g, "");
}

// ------------------------------------------------
// Function isEmailAddressValid :
// Validate the specified e-mail address.
//
// Params :
//	- anAddress : the address to validate
//
// Returns : true if the address format is valid, and
// false if it is not valid.
// ------------------------------------------------
function isEmailAddressValid(anAddress) {
   var regExpr = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,}$/
   return (regExpr.exec(anAddress)!=null);
}

// ------------------------------------------------
// isEmailAddressListValid :
// Check if the each address in specified list is
// valid.
//
// Params :
//	- anAddressList : the list of address (separator
//    is defined as a constant)
//
// Returns : true if each address is valid
// ------------------------------------------------
function isEmailAddressListValid(anAddressList) {

	if (!anAddressList) {
		return false;
	}

	// Extract each address
	var regExpr = new RegExp("[" + ADDRESS_SEPARATOR + "]", "g");
	var addrTab = anAddressList.split(regExpr);

	if (addrTab == null || addrTab.length == 0) {
		return false;
	}
	// Validate each address
	for (var i=0 ; i<addrTab.length ; i++) {
		if (!isEmailAddressValid(trim(addrTab[i]))) {
			return false;
		}
	}
	return true;
}

// ------------------------------------
//
// Get the image object from its name
//
// ------------------------------------
function getImage(imageName) {
	var images = document.images;
	for (var i=0 ; i<images.length ; i++) {
  		if (images[i].name == imageName) {
  			return images[i];
  		}
	}
}

/* ******************************** */
/*                                  */
/*       Login page functions       */
/*                                  */
/* ******************************** */

// ------------------------------------------------
// Function checkFormLogin :
// Checks the login form. If one of the fields is
// empty, shows an error message and returns false
//
// Params :
//	- aForm : the form object to validate
//
// Returns : true if the form is valid false if
// it is not valid
// ------------------------------------------------
function checkFormLogin(aForm) {
	if (aForm) {
		if (isTextFieldEmpty(aForm.username) || isTextFieldEmpty(aForm.password)) {
			alert(getMessage(msgLoginMandatoryFields));
			return false;
		} else {
			return true;
		}
	}
	return false;
}

/* ******************************** */
/*                                  */
/*      Welcome page functions      */
/*                                  */
/* ******************************** */
function readMessageRedirect(msgUid,check)
{
	document.formread.IDMSG.value=msgUid;
	if (check) {
		document.formread.check.value=check;
	}
	document.formread.submit();
}

function showHideStatusBoard()
{
	if ( document.getElementById ("innerDemiBloc").style.display == "none" ) {
		document.getElementById ("innerDemiBloc").style.display = "";
		document.getElementById ("innerDemiBloc").style.visibility = "visible";

	}else {
		document.getElementById ("innerDemiBloc").style.display = "none";
		document.getElementById ("innerDemiBloc").style.visibility = "hidden";
	}
}

/* ******************************** */
/*                                  */
/*      Inbox page functions        */
/*                                  */
/* ******************************** */

// ----------------------------------------------------------------------
//
// Select or unselect all messages checkboxes
//
// Params :
//  - aFormName : name of the form containing checkboxes
//	- selectAll : name of the checkbox used to check/uncheck all messages
//  - checkName : name of the message checkboxes field check/uncheck
// ----------------------------------------------------------------------
function inboxSelectAllMessages(aFormName, selectAll, checkName, selectValue) {
	var checkAll;

	// If image checkboxes are used
	if (document.images) {
		checkAll = isCheckboxChecked(aFormName, selectAll, selectValue);
		for(var i=0; i<checkboxArray.length ; i++) {
			if (checkboxArray[i][0] == checkName) {

				if (checkAll) {
					checkboxSelect(aFormName, checkName, checkboxArray[i][1]);
				} else {
					checkboxUnselect(aFormName, checkName, checkboxArray[i][1]);
				}
			}
		}
	}
	// If standard checkboxes are used
	else {
		checkAll = document.forms[aFormName].elements[selectAll].checked;
		var formElements = document.forms[aFormName].elements;
		for (var i=0 ; i<formElements.length ; i++) {
			//if (formElements[i] instanceof Checkbox && formElements[i].name == checkName) {
			if (formElements[i].name == checkName) {
				document.forms[aFormName].elements[i].checked = checkAll;
			}
		}
	}
}

// ----------------------------------------------------------
//
// Check if at least one message is selected
//
// param :
//  - aFormName : name of the form containing checkboxes
//	- aCheckboxName : name of the checkboxes field to verify
//  - withMessage : if true, displays an error
//                  message if no msg selected
//
// returns : true if at least one message is selected and
// false if no message selected
// ----------------------------------------------------------
function inboxIsMessageSelected(aFormName, aCheckboxName, withMessage) {

	// If image checkboxes are used
	if (document.images) {
		for(var i=0; i<checkboxArray.length ; i++) {
			if (checkboxArray[i][0] == aCheckboxName) {
				if (isCheckboxChecked(aFormName, checkboxArray[i][0], checkboxArray[i][1])) {
					return true;
				}
			}
		}
		if (withMessage) {
			alert(getMessage(msgInboxNoSelection));
		}
		return false;
	}

	// If standard checkboxes are used
	else {
		var formElements = document.forms[aFormName].elements;
		for(var i=0; i<formElements.length ; i++) {
			if (formElements[i].name == aCheckboxName) {
				if(formElements[i].checked) {
					return true;
				}
			}
		}
		if (withMessage) {
			alert(getMessage(msgInboxNoSelection));
		}
		return false;
	}
}


/* ******************************** */
/*                                  */
/*      Read page functions         */
/*                                  */
/* ******************************** */

/* ******************************** */
/*                                  */
/*      Write page functions        */
/*                                  */
/* ******************************** */

// -----------------------------------------------
// Function checkFormWrite :
// -----------------------------------------------
function checkFormWrite(aForm) {
	if (!aForm) {
		alert(getMessage(msgWriteIncorrectEmailAddress));
		return false;
	}

	// If the field is empty
	if (isTextFieldEmpty(aForm.address)) {
		alert(getMessage(msgWriteIncorrectEmailAddress));
		return false;
	}

	// If the field is not empty, check e-mail address list
	if (!isEmailAddressListValid(aForm.address.value)) {
		alert(getMessage(msgWriteIncorrectEmailAddress));
		return false;
	}
	return true;
}

// ------------------------------------------------
// Function writeNoSignature :
// Displays an error message indicating that there
// is no signature to insert
// ------------------------------------------------
function writeAlertNoSignature() {
	alert(getMessage(msgWriteNoSignature));
}

// ------------------------------------------------
// Function writeIncorrectEmailAddress :
// Displays an error message indicating that e-mail
// address is invalid
// ------------------------------------------------
function writeAlertIncorrectEmailAddress() {
	alert(getMessage(msgWriteIncorrectEmailAddress));
}

// -------------------------------------------------------------
// Function : insertSignature :
// Add or remove the signature at the end of the
// write message text area, depending of the
// specified checkbox value.
// if the checkbox value is True, append the signature
// to the text area.
// if the checkbox value is False, remove the signature
// from the text area. If there is more than one
// occurence, does nothing.
// This function is only used by the mailToFax composition page.
//
// Params :
//  - textAreaName : the name/id of the write message text area
//  - formName : the name of the form containing text area
//
// Returns :
//	true in case of success
//  false in case of failure :
//		- no signature defined (for adding signature)
//		- signature not found in text area (for removing)
//      - more than one occurence of the signature (for removing)
// -------------------------------------------------------------
function insertSignature(textAreaName, formName, checkName, checkValue) {

	// get checkbox state
	var insert = isCheckboxChecked(formName, checkName, checkValue);

	// get text area object
	var writeArea;
	if ( document.getElementById && !document.all ) {
    		var temp = eval("document."+formName);
        	writeArea = temp.elements[textAreaName];
    	}
    	else if ( document.all ) {
    		writeArea = document.forms[formName].elements[textAreaName];
    	}
   	else if( document.layers ) {
    		var temp = eval("document."+formName);
        	writeArea = temp.elements[textAreaName];
    	}


	var tableValue = "" + table_visible;
	var signTextValue = "" + signature_text;
	isSignatureTextEmpty = true;

	if (signature_text.length!=0){
		isSignatureTextEmpty = false;
	}

	// Check signature
	if ((table_visible.indexOf("table_text")!=-1)&&(isSignatureTextEmpty)) {
		checkboxUnselect(formName, checkName, checkValue);
		writeAlertNoSignature();
		return;
	}

	// If signature has to be added, add it at the end of text
	if (insert) {
		// Insert 3 blank lines
		for (var i=0 ; i<3 ; i++) {
			writeArea.value = writeArea.value + "\r\n";
		}
		// Insert each line of the signature
		for (var i=0 ; i<signature.length ; i++) {
			writeArea.value = writeArea.value + "\r\n" + signature[i];
		}
		return;
	}
	// If signature has to be removed
	else {
		// Get current text
		var currentTxt = writeArea.value;

		// Create a regular expression to search the
		// signature ignoring the escape chars (CR, LF...)
		var searchString = "\\s{0,10}" + echappeChaine(signature[0]);
		for (var i=1 ; i<signature.length ; i++) {
			searchString += "\\s{1,2}" + echappeChaine(signature[i]);
		}

		var regularExp = new RegExp(searchString, "g");

		// Get occurences
		var matchArray = currentTxt.match(regularExp);

		// If there is no occurence do nothing
		if (matchArray == null) {
			checkboxUnselect(formName, checkName, checkValue);
			return;
		}
		// If more than one do only remove the last signature (the real one)
		if (matchArray.length != 1) {
			var lastInd = currentTxt.lastIndexOf(signature[0]);
			var start=currentTxt.substring(0,lastInd);
			var end=currentTxt.substring(lastInd,currentTxt.length);
			end = end.replace(regularExp,"");
			writeArea.value=start+end;
			writeArea.value=writeArea.value.replace( /\s*$/, "" );
		} else {
	
			// There is only one occurence : replace it
			writeArea.value = currentTxt.replace(regularExp, "");
		}
		return;
	}

}

function insertMailToFaxSignatureFirst(textAreaName, formName) {

	// get text area object
	var writeArea;
	if ( document.getElementById && !document.all ) {
		var temp = eval("document."+formName);
		writeArea = temp.elements[textAreaName];
	} else if ( document.all ) {
		writeArea = document.forms[formName].elements[textAreaName];
	}	else if( document.layers ) {
		var temp = eval("document."+formName);
		writeArea = temp.elements[textAreaName];
	}

	var tableValue = "" + table_visible;
	var signTextValue = "" + signature_text;
	isSignatureTextEmpty = true;

	if (signature_text.length!=0){
		isSignatureTextEmpty = false;
	}

	// Insert 3 blank lines
	for (var i=0 ; i<3 ; i++) {
		writeArea.value = writeArea.value + "\r\n";
	}
	// Insert each line of the signature
	for (var i=0 ; i<signature.length ; i++) {
		writeArea.value = writeArea.value + "\r\n" + signature[i];
	}
	return;

}


/* AJOUT WUM*/
function echappeChaine(chaine){
	return chaine.replace(/\*/g,"\\*").replace(/\+/g,"\\+").replace(/\?/g,"\\?").replace(/\{/g,"\\{").replace(/\[/g,"\\[").replace(/\}/g,"\\}").replace(/\]/g,"\\]").replace(/\)/g,"\\)").replace(/\(/g,"\\(").replace(/\$/g,"\\$").replace(/\^/g,"\\^").replace(/\|/g,"\\|");
}

// -------------------------------------------------------------
// Divise la signature en Array selon les '\r\n'.
// -------------------------------------------------------------
function getArrayFromSignature(chaine) {
    // unescape du caractere '
    var temp = chaine.replace(/'/g,"\\'");
    // \r\n -> ','
    temp = temp.replace(/\r\n/g,"','");
    var toEval = "myArray = new Array('" + temp + "')";
    return eval(toEval);
}

	/* Functions LOT 2
	--------------------- */
	function hideSearchResults (status) {
		if (status == "show") {
			document.getElementById ("infoSearchResult").style.display = "block";
		}
		else {
			document.getElementById ("infoSearchResult").style.display = "none";
		}
	}

function createContactsFromSentDone(nbContacts) {
	if (usePab == 1) { // Cas carnet d'adresses Vox
		var theWidth = 380;
		if (nbContacts > 1)
			theWidth = 540;

		var currentUrl = escape(window.location);
		window.open("vide.htm","popupPab","location=no,width=" + theWidth + ",height=370,channelmode=no,left=20,top=20,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
		document.confirm_sent_form.action="pab_add_contacts.html?currentUrl=" + currentUrl;
		document.confirm_sent_form.target="popupPab";
		document.confirm_sent_form.submit();
	} else { // Cas carnet d'adresses WUM
		window.open("add_address_list_FromSent.html","pop_up_add_book","width=950,height=350,menubar=no,scrollbars=yes,status=no");
	}
}

function createSmsAlertFromSentDone() {
	for (i = 1; i<= nbContacts ; i++){
		document.confirm_sent_form.FILTERED_EMAILS.value+=eval("document.confirm_sent_form.selemail_"+i+".value")+",";
	}
	document.confirm_sent_form.action="read_submit_alerte_sms.html";
	document.confirm_sent_form.submit();
}

function seeMailHeaderFirstView () {
	if (document.msg_read_form.maildisplay_option.value == 1){// affiche les full-header
		document.getElementById ("hdMail").style.borderBottom = "0";
		//document.getElementById ("hdImg").src = absolutePathForStaticResources + "Images/picto_closeHeader.gif";
		document.getElementById ("hdImg").src = absolutePathForStaticResources + "Images/Style_R/picto_closeHeader.gif";
		document.getElementById ("hdLabel").innerHTML = BT_CLOSEHEADER;
		document.getElementById ("hdMailCt").style.display = "block";
	}
	//2 fois !!! pour etre pris en compte par IE
	resizeElems ();
	resizeElems ();
}

function CheckDate(j,m,a) {
      var ok=true;
      if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==true) ) {
         alert(INFO_VALIDATION_CORRECT_DAY); ok=false;
      }
      if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==true) ) {
         alert(INFO_VALIDATION_CORRECT_MONTH); ok=false;
      }
      if ( (isNaN(a)) && (ok==true) ) {
         alert(INFO_VALIDATION_CORRECT_YEAR); ok=false;
      }
      return ok;
   }

   function Assistance()
   {
	window.open("http://www.orange.co.uk/communicate/email/7104.htm");
   }


// -------------------------------------------------------------
// Gestion des Alias
// -------------------------------------------------------------

var TITLEBAR_ALIAS		= "My Alias";
var CREATE_ALIAS		= "Create your alias";
var EXMP_ALIAS			= "ex. : johnsmith@orange.net";
var LABEL_ALIAS			= "Alias Address \u003a";
var LABEL_INFO_ALIAS		= "\u002a add here the alias definition";
var INFO_ALIAS			= "Enter below the alias to add.";
var INFO_QUOTA_ALIAS_REACHED	= "You have requested the creation of four aliases for your main address. You have reached the limit on the number of possible alias.";
var LABEL_LIST_ALIAS		= "List your alias";
var CONFIRM_DELETE_ALIAS	= "Confirm deletion of alias ?";
var HREF_HOME_ALIAS		= "Manage my alias";
var INFO_EXIST_ALIAS	= "This alias already exists in your list";
var INFO_VALIDATION_SELECT_ALIAS_BEFORE	= "First choose an alias";
var LABEL_DOMAIN_ALIAS = "NOT_TRANSLATED";
var LABEL_ALIAS_BY_DEFAULT = "NOT_TRANSLATED";
var BT_PUT_BY_DEFAULT = "NOT_TRANSLATED";
var NUMBER_OF_ALIAS_PART_ONE = "NOT_TRANSLATED";
var NUMBER_OF_ALIAS_PART_TWO = "NOT_TRANSLATED";
var CONFIRM_DEFAULT_ALIAS = "NOT_TRANSLATED";
var CONFIRM_DELETE_DEFAULT_ALIAS = "NOT_TRANSLATED";
var INFO_ALERT_QUOTA_ALIAS_REACHED = "NOT_TRANSLATED";
var ALERT_TEMPORISATION = "Veuillez patienter pendant la mise \u00e0 jour de votre compte... Vous serez redirigez \u00e0 la prochaine \u00e9tape dans quelque instant.";
var DELAY_TEMPORISATION = "5000";
var LABEL_HIGHLIGHT_ALIAS_BY_DEFAULT = "\u003cdefault\u003e";

function setAlias (id, isdefault) {
	if (CURRENT_OBJ != null) {
		if ((isDefaultAlias == "true")||(isDefaultAlias == "TRUE")) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#D5DCE4";
			document.getElementById(CURRENT_OBJ).style.color="black";
		} else {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="transparent";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
		CURRENT_OBJ = null;
		vEdition=false;
		isDefaultAlias = isdefault;
		activebutton("manageAliasDefault");
		manageAliasButton();
	} else {
		CURRENT_OBJ = id;
		vEdition=true;
		isDefaultAlias = isdefault;
		if ((isDefaultAlias == "true")||(isDefaultAlias == "TRUE")) {
			desactivebutton("manageAliasDefault");
		}
	}
}

function highlightDefault(id, isDefault) {
	if ((isDefault == "true")||(isDefault == "TRUE")) {
		document.getElementById(id).style.backgroundColor="#D5DCE4";
		document.getElementById(id).style.color="white";
		document.getElementById(id).style.fontWeight = "normal";
	}
}

function manageAlias(act) {
	var TMP_OBJ;
	var aliaswithdomain = document.emailAlias.aliasWithoutDomain.value + "@" + domain_alias;
	var numberOfAliasStaying = numberOfAlias();
	var numberOfSecondaryAlias = document.init.nb_max_alias.value-numberOfAliasStaying-1;

	if ((CURRENT_OBJ != null && numberOfSecondaryAlias > 0) || (act == "add")) {
		switch (act) {
			case "add" :
				if (listeAliasFull) {
					alert (INFO_ALERT_QUOTA_ALIAS_REACHED);
					break;
				}
				if (isTextFieldEmpty(document.emailAlias.aliasWithoutDomain.value)) {
					alert (INFO_GET_VALID_ADDRESS);
					highlightError (document.emailAlias.aliasWithoutDomain);
					break;
				}
				var exist=false;
				var myAccount = aliaswithdomain;
				if(aliaswithdomain!=modified_Account){
					for(var i=0; i<count_alias; i++) {
						if(myAccount==tab[i]){
							exist=true;
						}
					}
				}
				if(exist){
					alert (INFO_EXIST_ALIAS);
					break;
				}else{
					document.emailAlias.action="alias_submit.html";
					document.emailAlias.alias.value=aliaswithdomain;
					document.emailAlias.submit();
					break;
				}
			case "del" :
				document.emailAlias.checkalias.value = CURRENT_OBJ;

				if ((isDefaultAlias == "true") || (isDefaultAlias == "TRUE")) {
					if (window.confirm(CONFIRM_DELETE_DEFAULT_ALIAS)) {
						document.emailAlias.action="alias_submit_delete.html";
						document.emailAlias.submit();
					}
				 } else {
					if (window.confirm(CONFIRM_DELETE_ALIAS) )
					{
						document.emailAlias.action="alias_submit_delete.html";
						document.emailAlias.submit();
					}
				}
				break;
			case "default" :
				document.emailAlias.checkalias.value = CURRENT_OBJ;

				if ((isDefaultAlias == "true") || (isDefaultAlias == "TRUE")) {
					break;
				}

				if (window.confirm(CONFIRM_DEFAULT_ALIAS) )
				{
					document.emailAlias.action="alias_submit_default.html";
					document.emailAlias.submit();
				}
				break;
		}
		if (CURRENT_OBJ != null) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
	} else if(!vEdition && numberOfSecondaryAlias > 0){
		alert (INFO_VALIDATION_SELECT_ALIAS_BEFORE);
	}
}

function manageAliasButton(){
	var numberOfAliasStaying = numberOfAlias();
	var numberOfSecondaryAlias = document.init.nb_max_alias.value-numberOfAliasStaying-1;
	if (numberOfSecondaryAlias == 0) {
		desactivebutton("manageAliasDefault");
		desactivebutton("manageAliasDel");
	}
}

function numberOfAlias(){
	var numberOfAliasStaying = document.init.nb_max_alias.value - count_alias;
	return numberOfAliasStaying;
}

function displayAliasSender(aliasSender){
	if (aliasSender!="") {
		if (displayNameAlias!="") {
			document.composeform.msg_from.value = "\u0022"+displayNameAlias+"\u0022 \u003C "+aliasSender+" \u003E";
			document.composeform.msg_replyto.value = "\u0022"+displayNameAlias+"\u0022 \u003C "+aliasSender+" \u003E";
			return displayNameAlias+" \u003C "+aliasSender+" \u003E";
		} else {
			document.composeform.msg_from.value = aliasSender;
			document.composeform.msg_replyto.value = aliasSender;
		}

	} else {
		aliasSender = document.composeform.msg_replyto.value;
	}
	return aliasSender;
}

function tabRollOver3(id,imgon,isDefault)
{
	if(imgon)
	{
		document.getElementById(id).style.backgroundColor="#93AAD3";
		document.getElementById(id).style.color="white";
		if ( document.getElementById && !document.all ) {
			document.getElementById(id).style.cursor="pointer";
		}
	}
	else
	{
		if (CURRENT_OBJ != id) {
			if (isDefault) {
				document.getElementById(id).style.backgroundColor="#D5DCE4";
				document.getElementById(id).style.color="black";
				if ( document.getElementById && !document.all ) {
					document.getElementById(id).style.cursor="cross";
				}
			} else {
				document.getElementById(id).style.backgroundColor="transparent";
				document.getElementById(id).style.color="black";
				if ( document.getElementById && !document.all ) {
					document.getElementById(id).style.cursor="cross";
				}
			}
		}
	}
}

function displayHighlightDefaultAlias(aliasByDefault,isDefault) {
	if ((isDefault == "true")||(isDefault == "TRUE")) {
		aliasByDefault = aliasByDefault + "&nbsp;" + LABEL_HIGHLIGHT_ALIAS_BY_DEFAULT;
	}
	return aliasByDefault;
}

// -------------------------------------------------------------
// Gestion des categories dans l'address book
// -------------------------------------------------------------

var COL_CATEGORIE			= "Category";
var CATEGORIE_LABEL			= "Category";


function sortCategorieColumnAdd (c) {
 	for (i = 1; i <= 6; i++)
 	{
		if (document.getElementById ("tri"+i) != null)
 		{
 			document.getElementById ("tri"+i).style.backgroundColor = "#EFEFEF";
 		}
 	}
 	document.getElementById ("tri"+c).style.backgroundColor = "#F9F9F9";
}

// Fonction de recuperation du jour selectionne
function SelectedDays(){

		if (document.folderExt.seldays_seldays1.value!=null && document.folderExt.seldays_seldays1.value != ""){
			document.folderExt.monday.value="checked";
		}
		if (document.folderExt.seldays_seldays2.value!=null && document.folderExt.seldays_seldays2.value != ""){
			document.folderExt.tuesday.value="checked";
		}
		if (document.folderExt.seldays_seldays3.value!=null && document.folderExt.seldays_seldays3.value != ""){
			document.folderExt.wednesday.value="checked";
		}
		if (document.folderExt.seldays_seldays4.value!=null && document.folderExt.seldays_seldays4.value != ""){
			document.folderExt.thursday.value="checked";
		}
		if (document.folderExt.seldays_seldays5.value!=null && document.folderExt.seldays_seldays5.value != ""){
			document.folderExt.friday.value="checked";
		}
		if (document.folderExt.seldays_seldays6.value!=null && document.folderExt.seldays_seldays6.value != ""){
			document.folderExt.saturday.value="checked";
		}
		if (document.folderExt.seldays_seldays7.value!=null && document.folderExt.seldays_seldays7.value != ""){
			document.folderExt.sunday.value="checked";
		}
}

// Fonction de recuperation de l'heure selectionnee
function SelectedTime(){


	  if (document.getElementById("RefreshComboLabel").innerHTML >= "<"){
			document.folderExt.refresh.value=0;
		}
		else {
			document.folderExt.refresh.value=document.getElementById("RefreshComboLabel").innerHTML;
		}
		if (document.getElementById("HoursComboLabel").innerHTML >= "<"){
			document.folderExt.beginHour.value=0;
		}
		else {
			document.folderExt.beginHour.value=document.getElementById("HoursComboLabel").innerHTML;
		}
		if (document.getElementById("MinutesComboLabel").innerHTML >= "<"){
			document.folderExt.beginMin.value=0;
		}
		else {
			document.folderExt.beginMin.value=document.getElementById("MinutesComboLabel").innerHTML;
		}
		if (document.getElementById("HoursCombo2Label").innerHTML >= "<"){
			document.folderExt.endHour.value=0;
		}
		else {
			document.folderExt.endHour.value=document.getElementById("HoursCombo2Label").innerHTML;
		}
		if (document.getElementById("MinutesCombo2Label").innerHTML >= "<"){
			document.folderExt.endMin.value=0;
		}
		else {
			document.folderExt.endMin.value=document.getElementById("MinutesCombo2Label").innerHTML;
		}

}




// Fonction de selection de la periode de refresh
function getSelectedRefresh(){
	for (i=0; i<4; i++) {
		if (refreshArray[i] == "checked" ) return i+1;
	}
	return -1;
}

// Fonction de selection de l'heure de debut
function getSelectedBeginHour(){
	for (i=0; i<23; i++) {
		if (beginHourArray[i] == "checked" ) return i;
	}
	return -1;
}

// Fonction de selection de l'heure de fin
function getSelectedEndHour(){
	for (i=0; i<23; i++) {
		if (endHourArray[i] == "checked" ) return i;
	}
	return -1;
}

// Fonction de selection des minutes de debut
function getSelectedBeginMin(){
	for (i=0; i<4; i++) {
		if (beginMinArray[i] == "checked" ) return i*15;
	}
	return -1;
}

// Fonction de selection des minutes de fin
function getSelectedEndMin(){
	for (i=0; i<4; i++) {
		if (endMinArray[i] == "checked" ) return i*15;
	}
	return -1;
}


function validAutoPolling(aValue) {

  //Jamais de polling automatic, on n'a pas besoin de r?cup?rer periodes de polling des combos
  if(aValue == "noDaysChecked"){
    return "OK";
  }

  //On a du polling automatic
  else if(aValue == "everyDaysChecked" || aValue == "selectedDaysChecked"){
    //on v?rifie que des jours ont ?t? check?s
    if (aValue == "selectedDaysChecked"){
  		tmp = false;
  		for (i=1; i<8; i++) {
  			if (isCheckboxChecked("folderExt","seldays","seldays"+String(i)))
  				tmp = true;
  		}
  		if (!tmp) {
  			alert (INFO_GET_DAYS_TO_TRANSFERT);
  			return "NOK";
  		}
    }
    if (document.getElementById("HoursComboLabel").innerHTML > document.getElementById("HoursCombo2Label").innerHTML) {
    		alert (INFO_VALIDATION_BEGIN_LOWER_END_HOUR);
    		highlightError (document.getElementById("HoursComboLabel"));
  		  return "NOK";
    }
    return "OK";
  }

}

// -------------------------------------------------------------
// Summary Alert
// -------------------------------------------------------------
var LABEL_SUMMARY_NEVER = "Never";
var LABEL_SUMMARY_EVERY_DAYS = "Always";
var LABEL_SUMMARY_PERIODICITY = "Every:";
var TITLEBAR_SUMMARY = "Daily SMS summary";
var TITLEBAR_SUMMARY_SEND_WHEN = "A summary of your email inbox is sent:";
var INFO_SUMMARY = "The SMS Summary option allows you to receive a text message telling you how many new emails you have received.<BR>You can define how often you receive these messages.";
var INFO_SUMMARY_PRICE = "Each SMS Alert, except where it is included in your tariff, will cost 10p. TTC";


function hackIEforTABS (o, s) {
  if (s) {
    document.getElementById("o"+o).style.backgroundPosition = "0% -37px";
    document.getElementById("oa"+o).style.backgroundPosition = "100% -37px";
  }else {
    document.getElementById("o"+o).style.backgroundPosition = "0% 0";
    document.getElementById("oa"+o).style.backgroundPosition = "100% 0";
  }
}

function seeMail (e) {
	if (document.getElementById ("seeMail" + e).style.display == "block") {
		document.getElementById ("mail" + e).className = document.getElementById ("mail" + e).className.substring (0, document.getElementById ("mail" + e).className.lastIndexOf (" "));
		document.getElementById ("pictoSeeMail" + e).innerHTML = "<a href='javascript:seeMail("+ e +")'><img src='http://static.wanadoo.co.uk/webmail/en_GB/Images/Images200905061123/Images/Style_R/picto_apercuD.gif' border='0'></a>";
		document.getElementById ("seeMail" + e).style.display = "none";
		document.getElementById ("blocAffichage").style.marginTop = "10px";
	}
	else {
		document.getElementById ("mail" + e).className += " noB";
		document.getElementById ("pictoSeeMail" + e).innerHTML = "<a href='javascript:seeMail("+ e +")'><img src='http://static.wanadoo.co.uk/webmail/en_GB/Images/Images200905061123/Images/Style_R/picto_apercuU.gif' border='0'></a>";
		document.getElementById ("seeMail" + e).style.display = "block";
		document.getElementById ("blocAffichage").style.marginTop = "11px";
	}
}


var BT_OK			= "OK";
var RETURN_WRITE	=  "Return to write page";
var EMAIL_MANAGE		= "Manage my emails";

var TPL_SETTINGS	= "Configurer mes templates";

var INFO_USING_TEMPLATE1 = "maximum";
var INFO_USING_TEMPLATE2 = "sur";
var TPL_CONTENT		= "contenu du mod&egrave;le";

var WITH_ORANGE 	= "With Orange email, you can get emails from your other mailboxes";
var ADD_ACCOUNT		= "Add an email account";
var EDIT_ACCOUNT	= "Modifying an email account";
var YOUR_ACCOUNTS	= "Your email accounts";
var INFO_USING2		= "maximum on total : ";

var INFO_TPL		= "Votre mod&#232;le de message a &#233;t&#233; modifi&#233; et est visible dans la liste ci-dessous";

var INFO_MODIFYACCOUNT	= "Your account has been modified and is visible in the list below";
var INFO_ADDACCOUNT		= "Your account has been added and can now be seen via Orange World";
var INFO_DELACCOUNT		= "your account has been deleted";

var INFO_ACCOUNT1	= "Pour commencer, saisissez l'adresse email ci-dessous";

var LABEL_ACCOUNT	= "Votre adresse email :";


var INFO_IMAGE		= "<b> Did you know? </ b> <BR> Orange Mobile Email is accessible only via the Orange World. With Orange Mobile Email, you can read and respond to your emails received on non-Orange (eg Tiscali, BT Internet ...). Select the right option&#39;&#39;Setting up a new account&#39;&#39;above to access your accounts non-Orange & # 40; note that some mail boxes are not accessible).";
var OW_ACCESS		= "Acc&#233;dez &#224; Orange World";


var INFO_ACCOUNT3	= "Select an account and click on the &#39;modify&#39;";

var LABEL_PROV		= "Provider";
var LABEL_MAILBOX	= "Nom de la boite";
var LABEL_MAILBOX_H	= "entrez un nom afin d'identifier ce compte";
var LABEL_ADDRESS	= "Address";
var LABEL_ADDRESS_H	= "ex. name@company.com";
var LABEL_CHANGE_M	= "Changer d'adresse";
var LABEL_LOGIN		= "username";
var LABEL_LOGIN_H	= "name used to identify you";
var LABEL_PW		= "password";
var LABEL_PW_H		= "password used to login";
var LABEL_POP3		= "email server address";
var LABEL_POP3_H	= "email server address";
var LABEL_TYPE		= "server type";
var LABEL_PORT		= "port number";

var TITLE_OTHER_ACC	=  "Setting up my other accounts";

var LABEL_CHANGE_P	= "Change provider";
var LABEL_INFOLDER	= "in folder";
var LABEL_INFOLDER_H= "Delete messages from the server";

var ERROR_ADD_ADR		= "You must enter a new address";
var ERROR_SUPR_ADR		= "You must select an address";

var READ_MAIL		= "Lecture des messages";
var LABEL_SEEHEADER	= "Show headers of messages";
var TITLE_REQUEST	= "if recipient wants an acknowledgement on receipt";
var TITLE_SAVESENT	= "save sent messages";
var LABEL_SAVESENT	= "always save my sent messages";
var TITLE_DISPCONF	= "Display confirmation page";
var LABEL_DISPCONF	= "display a confirmation page when messages have been sent";
var TITLE_RECIPIENT	= "save v-cards";
var LABEL_RECIPIENT	= "automatically add cards to my contacts";
var CALENDAR		= "Calendar";
var TODAY			= "Today";
var SHOW_TASKS		= "Visualiser mes taches";
var SHOW_EVENTS		= "Voir mes rendez-vous";
var EMAILS			= "E-mail(s)";
var SPAM			= "spam";
var TASKS			= "Tasks";
var TITLE_UPLOAD	= "Progression de t&#233;l&#233;chargement";
var TITLE_THX		= "Thanks";
var TITLE_AWAY		= "Away Message";

var WHEN_AWAY		= "Votre message d&#39;absence sera activ&#233; le";
var ADDRESS			= "Address";
var ADDRESS1		= "Address line 1";
var ADDRESS2		= "Address line 2";
var ZIPCODE			= "Code postal";
var MALE			= "Male";
var WHEN_AWAY2		= "When to use your Away Message ?";
var AWAY_OFF		= "Cancel My away message";
var AWAY_ON_BTW		= "Turn on my away message from the following dates";
var AWAY_MESS		= "My Away Message";
var SEARCH_TXT		= "Text search";
var ANYTIME			= "anytime";
var AFTER			= "More details";
var SEARCH_FOLD		= "Search folder";
var FOLDER			= "Folder";
var ANY				= "any";
var KB				= "Kb";
var HREF_HOME_MODEMAILS		= "Change my email addresses";
var HREF_HOME_MANAGEFOLD	= "Manage folders";
var TITLEBAR_HOME_MANAGEMOB	= "Param&#232;trer la messagerie mobile";
var HREF_HOME_MESSMOB		= "Messaging mobile e-mail";
var HREF_HOME_ALERTEMAIL	= "Alerts e-mail";
var HREF_HOME_TPL			= "My Templates";
var TITLEBAR_HOME_PARAMDISP	= "Display settings";

var TITLEBAR_HOME_EMAIL 	= "Modify send email settings";
var TITLEBAR_HOME_AUTOMAIL	= "Away message";

	var ADDRESS_LIST_ERROR			= "";
	var	TPL_LABEL_RIGHT_BOTTOM 		= "Choisissez un template puis cliquez sur Rafraichir pour changer les d&#233;tails";
	var	TPL_LABEL_LEFT_BOTTOM 		= "Caract&#232;res restants : ";
	var ADD_TEMPLATE 				= "Add a template";
	var EDIT_TEMPLATE 				= "Edit a template";
	var VOS_TEMPLATES 				= "Your templates";
	var BT_SAVE 					= "Save";
	var BT_DEFAULT 					= "Save as default";
	var TPL_TEXT 					= "Les templates peuvent &#234;tre utilis&#233;s lorsque vous composez les messages sur votre t&#233;l&#233;phone mobile";
	var HOME_AUTOMAIL				= "Away Message";
	var PICTO_FORTH		 			= "&gt;";
	var LABEL_COPY_MESS_IN			= "copy to:";
	var DASH_TITRE_2				= "On/Off";
	var ALERT_COST					= "Price 20 pence per alert";
	var DASH_TITRE_3				= "when you receive alerts";

	var RADIO_DASH_LABEL_1			= "on";
	var RADIO_DASH_LABEL_2			= "off";
	var INFOS_ALERTS_HOMEPAGE 		= "Back to home alerts";


	var EMAIL_ADDRESS				= "email address";
	var NOM_AFFICHE					= "display name";
	var CHANGER_NOM_AFF				= "Change Display name";
	var ADDRESSES_EMAIL    			= "Your email addresses";
	var SORTING						= "Sort by:";
	var ADD_FILTER					= "Adding a filter";
	var CURRENT_FILTERS				= "filter list";
	var EDIT_FILTER					= "editing a filter";
	var ERROR_TITLE					= "L&#39;email ne peut pas &#234;tre ajout&#233;. Veuillez v&#233;rifier les sections";
	var DASH_HOMEPAGE				= "Dashboard homepage";
	var TITLE_STATUS 				= "Status de messages";
	var ACTIVE 						= "Active";
	var NUMERO						= "<strong>98762656348</strong>";
	var OMM							= "OMM";

	var DASHBOARD					= "Dashboard";
	var SMS							= "SMS";
	var MMS							= "MMS";
	var EURO						= ". ";
	var ANTIVIRUS_MAIL				= "Mail Anti-Virus";
	var VIRUS_NAME					= "Nom des virus";
	var RECU						= "Re&#231;u";
//page blockedList
	var TITLE_MANAGE_BLKLIST1	= "You are using";
	var TITLE_MANAGE_BLKLIST2	= "from";
	var TITLE_MANAGE_BLKLIST3	= "maximum";
	var TEXT_FILTER_JUNK_ACTIONWORD	= "When an email contains one of these words, I want it to";

	var BLOCK_WORDS_LIST_COMMENTS	= "Choose a sentence and click &#34;Delete&#34;";
//page Alert Settings
    var PHONE_DETAILS_TITRE 		= "Your phone number ";
  var PHONE_DETAILS_TEXT          = "Saisissez numero de telephone ou vous souhaitez recevoir les alerts";
  var PHONE_DETAILS_TEXT2          = "Numero de telephone ou les alertes seront recues :";
	var ACTION_PHONE_SETTINGS		= "Activate or deactivate the setting";
	var GEST_TYPE_SIZE				= "Type and size of message";
	var ALERT_TYPE                  = "alert_type";
	var RADIO_TEXT_SIZE_1			= "1 SMS par message re&#231;u (email message d&#39;environ 110 characters)";
	var RADIO_TEXT_SIZE_2			= "2 SMS par message re&#231;u (email message d&#39;environ 220 characters)";
	var RADIO_TEXT_SIZE_3			= "3 SMS par message re&#231;u (email message d&#39;environ 330 characters)";
	var GET_TYPE_SIZE_COMMENTS		= "<Restriction text dependent type of alert selected>";
	var MAX_NUM_ALERTS				= "Maximum number of alerts";
	var MAX_NUM_TEXT_1				= "I would like to receive a maximum of";
	var MAX_NUM_TEXT_2				= "alerts per month";
	var MAX_NUM_TEXT_3				= "alerts per month in addition to my package of 50 SMS";
	var WHAT_ALERTS_ABOUT			= "Type of messages you want to receive alerts for";
	var RADIO_ASETINGS_1			= "All messages";
	var RADIO_ASETINGS_2			= "All messages matching the following criteria";
	var ASETTING_LABEL_1 			= "When the sender address";
	var ASETTING_LABEL_2			= "When the subject";
	var ASETTING_LABEL_3 			= "When sent to the address";
	var ALERT_DELETE  			= "You need to select something";
	var MAILSMS_SUIVIC_SMS_SENT_OVER_QUOTA = "sms sent (s) out of bundle";

	var DEST						= "destination";

	var ALERTS_PERSO_TITRE 			= "Alerts personalisation";


//fin page Alert Settings
	var ALERTS_ANYTIME				= "What hour";
	var ALERTS_ENTRE				= "Enter";

//fin page blockedList

//page giga mail settings
    var GIGA_LIST_TOP_1				= "Find more about your space available on Orange.co.uk";
	var GIGA_LIST_TOP_2				= "Find more about ?.";
//fin giga mail settings
//page Antivirus mail prefs
	var ADR_LIST_TITRE				= "Manage your e-mail addresses";
//fin page antivirus prefs
    var SAVOIR_PLUS_LIEN			= "About";
	var VCARD						= "VCard";
	var ADD_VCARD					= "Add a vcard";
	var SHOW_PAGE_OFF				= "Do not show this page";
	var MAIL_CONFIRM_SAVE			= "Save address";
	var MAIL_CONFIRM_INBOX          = "View inbox";
	var MAIL_CONFIRM_WRITE			= "Write mail";
	var LABEL_MOBILE_EMAIL_TXT		= "Text to explain the details of the mobile email page"
	var LABEL_MOBILE_EMAIL			= "Text to introduce the Email setup by the mobile phone"
	var LABEL_MOBILE_EMAIL_ALERT	= "Text to introduce the Email alerts setup for the mobile phone"
	var MOBILE_EMAIL				= "E-mail mobile";
	var OMM_LANDING_TITRE1			= "Emails from your mobile phone";
	var OMM_LANDING_TITRE2			= "Alerts on your mobile phone";
	var BT_SETUP_EMAILS				= "Set up mobile email";
	var BT_SETUP_ALERTS				= "Set up email alerts";
	var BT_ACTIVATE_ACCOUNT			= "<strong> Activate Account </ strong>";
	var BT_SIGNUP_ADSL				= "<strong> Register for broadband now </ strong>";
	var ORANGE_MAIL					= "Orange email";
	var SETUP_TITRE1				= "Would an like an Orange email account?";
	var SETUP_TITRE2				= "Do you wish to merge email accounts?";
	var SETUP_LEFT_TEXT1			= "Orange Mail is a great way to communicate with your friends and colleagues from home or the office. Keeping in touch is very simple and secure. Sign up for this service.";
	var SETUP_LEFT_TEXT2		    = "By registering for broadband you get an Orange Email account.";
	var SETUP_TITRE3                   = "MMS Email";
	var SETUP_TITRE4                   = "Les autres fonctionali&#233;s";
	var SETUP_RIGHT_TEXT1              = "Vous pouvez d&#233;cider d&#39;utiliser votre email sans passer par Orange Mail. Orange peut vous connecter jusqu&#39;&#224; 25 des plus populaires fournisseurs d&#39;acc&#232;s email comme tesco.net ou virgin.net - tous gr&#226;ce &#224; votre t&#233;l&#233;phone mobile.";
	var SETUP_RIGHT_TEXT2              = "Envoyez et recevez les emails par t&#233;l&#233;phone mobile - pas besoin de mise &#224; jour";
	var SETUP_RIGHT_TEXT3              = "Acc&#232;s  jusqu&#39;&#224; 5 comptes mail";
	var BT_ACTIVATE_THIRD_PARTIES = "<strong>Activer</strong>";
	var NOTSETUP_TITRE1                      = "Votre service OMM contient:";
	var NOTSETUP_TITRE2                      = "Service";
	var NOTSETUP_TITRE2_RES_OK         = "activ&#233;:";
	var NOTSETUP_TITRE2_RES_NOK        = "desactiv&#233;.";
	var BT_GO_TO_THIRD_PARTIES         = "<strong>Next</strong>";
	var MMS_EMAIL_MODE_ALL_MSG         = "All messages";
	var MMS_EMAIL_MODE_WHITELIST = "Whitelist mode";
	var MMS_EMAIL_MODE_BLACKLIST = "Blacklist mode";
	var MMS_EMAIL_RULES_WHITELIST = "rules in white-list";
	var MMS_EMAIL_RULES_BLACKLIST = "rules in black-list";


	var ATTACH_TOP_TITRE			= "Attached files"
	var ATTACH_LABEL				= "file"
	var ATTACH_TITRE				= "Attach files from your computer"
	var ATTACH_COMMENT				= "To delete a file attached to the list, select it and click &#39;Delete&#39;"
	var BT_ATTACHER					= "Attach"

	var CGV_AL_SMS_OK_1				= "I acknowledge having read the";
	var CGV_AL_SMS_OK_2				= "SMS Alerts Service";

var old = 2;
function chgListe (n) {
	if (n != old) {
		old = n
	}
}

function whenDel (st, ch) {
}

function whenRequestReceipt (ch) {
}

function showHeaderMail () {
}

function saveSentMail () {
}

function dispConfirmPage () {
}

function addRecipient () {
}

var alert_select_element = "You must select an element first";
var alert_fill_mail_address = "You must enter a new email address";
var alert_select_mail_address = "You must select an email address";
var alert_fill_title = "You must at least fill a title before validating";
var alert_fill_template = "You must fill the template before saving it";
var alert_chose_file = "You must choose a file first.";
var alert_fill_one_on_three_field = "You must fill at least one of the three fields above";
var alert_fill_all_fields = "You must fill all the fileds before validating";

function verifAjoutAdr () {
	if (document.FORM_WRITE_MAIL.NEW_ADR.value == "") alert (alert_fill_mail_address);
	else {
		mNames.push(FORM_WRITE_MAIL.NEW_ADR.value);
		FORM_WRITE_MAIL.NEW_ADR.value = "";
		initSelectList(mNames, "", 'liste', 'persoTemplate', "0", 1, 5);
	}
}
function deleteAdr () {
	if (CURRENT_OBJ == null) alert (alert_select_mail_address);
	else {
		mNames.splice(CURRENT_OBJ, 1);
		initSelectList(mNames, "", 'liste', 'persoTemplate', "0", 1, 5);
		CURRENT_OBJ = null;
	}
}

function verifSignat () {
	if (document.FORM_WRITE_MAIL.CHGDISPLAYNAME.value == "") alert (alert_fill_title);
	else document.FORM_WRITE_MAIL.submit();
}

function updateSignat () {
	if (CURRENT_OBJ != -1 && CURRENT_OBJ != null) {
		document.FORM_WRITE_MAIL.CHGDISPLAYNAME.value = mEmails[CURRENT_OBJ];
		document.FORM_WRITE_MAIL.ADDSIGN.value = aSignat[CURRENT_OBJ];
	}
	else alert (alert_select_element);
}

function modifPop () {
	if (CURRENT_OBJ != -1 && CURRENT_OBJ != null) {
		document.location.href = "pop_retrieval_1.html";
	}
	else alert (alert_select_element);
}

function deleteFilter (liste) {


	if (CURRENT_OBJ != -1 && CURRENT_OBJ != null) {
		//tab_notif.splice(CURRENT_OBJ, 1);
		allTriple.splice(CURRENT_OBJ,1);
		tab_notif = new Array();

		for (i=0;i<allTriple.length;i++){

    	tab_notif[i] = new Array();
    	tab_notif[i][0]=i;
    	tab_notif[i][1]=SMSTripleConditionToString(allTriple[i]);

    }
   		 lg_notif = tab_notif.length;

		initSelectListNotification(tab_notif,'liste',5);
		//initSelectList(mFilters, "", 'liste', 'emailSettingsSmsAl', "0", 1, 5);
		CURRENT_OBJ = null;
	}
	else alert (ALERT_DELETE);
}

function deleteFiles (url) {
	if (CURRENT_OBJ != -1 && CURRENT_OBJ != null) {
		alertNotNeeded();
		document.attachmentForm.action=url+"?TYPE=ONE&REMOVEPJ=NO&POSITION="+CURRENT_OBJ;
		document.attachmentForm.submit();
	}
	else alert (ALERT_NOPJSELECTED);
}

function defaultSignat () {
	if (CURRENT_OBJ == null || CURRENT_OBJ == -1) alert (alert_select_element);
	else document.FORM_WRITE_MAIL.submit();
}

function supprSignat () {
	if (CURRENT_OBJ == null || CURRENT_OBJ == -1) alert (alert_select_element);
	else document.FORM_WRITE_MAIL.submit();
}

function verifMailbox () {
	if (document.FORM_WRITE_MAIL.MAILBOX.value == "" || document.FORM_WRITE_MAIL.LOGIN.value == "" || document.FORM_WRITE_MAIL.PW.value == "") alert (alert_fill_all_fields);
	else document.FORM_WRITE_MAIL.submit();
}

function verifMailboxCpl () {
	if (document.FORM_WRITE_MAIL.MAILBOX.value == "" || document.FORM_WRITE_MAIL.LOGIN.value == "" || document.FORM_WRITE_MAIL.PW.value == "" || document.FORM_WRITE_MAIL.POP.value == "" || document.FORM_WRITE_MAIL.PORT.value == "") alert (alert_fill_all_fields);
	else document.FORM_WRITE_MAIL.submit();
}

function verifFilters () {
	if (document.FORM_EMAIL_ALSETALERTS.sendersAdr.value == "" || document.FORM_EMAIL_ALSETALERTS.sujet.value == "" || document.FORM_EMAIL_ALSETALERTS.senTo.value == "") {
		alert (alert_fill_one_on_three_field)
	}
	else {
	}
}

//? placer dans combo.js
	var cbHoursFreqLabel = "1&nbsp;hrs";

	function createComboFreqHoursContent() {
		for (i=1; i<=12; i++) {
			sep = i==1?"List":"FirstGroup";
			i = String(i);
			document.write ("<div class='combo" + "Element'><a href='javascript:comboActionHoursFreq(" + i + ");'>" + String 	(i) + "&nbsp;hrs</a></div>");
		}
	}
	function comboActionHoursFreq(cbItem) {
		setCurrentMenuLabel((String(cbItem))+'&nbsp;hrs');
		hideMenus();
	}
//fin ? placer dans combo.js

//? placer dans common.js

function initValuesEmail() {

   	document.getElementById("nomAffiche").style.display = "none";
   	document.getElementById("aliasEmail").style.display = "";
    
}		

/*
// DEPRECATED
function initFiltersList (valuesArr, listeId) {
	var ch = "";

	for (i=0; i < valuesArr.length; i++) {
		ch += "<a href='javascript:setItem(" + i + ", \"0\")' id='0" + i + "'><span class='item1'>" + valuesArr[i] + "</span><span class='item2'></span><span id='d" + i + "' class='item3'></span></a>";
		}
	document.getElementById(listeId).innerHTML = ch ;
	document.getElementById(listeId).style.height = 3 * 26;
}
*/

//cas particulier pour affichage nom de fichier avec safari
function formatSafari(nomFichier){
var pos=nomFichier.lastIndexOf("/");
return nomFichier.substring(pos+1);
}
//fin



function initSelectList(valuesArr1, valuesArr2, valuesArr3, idList, page, idListItem, nbCol, nbLines) {

	var ch = "";
	var funcName = "";
	if (page == 'adressList') {
		funcName = 'emailListe';
	} else if (page == 'filterList') {
		funcName = 'setFilt';
	} else {
		funcName = 'setItem';
	}
	
	for (i=0; i < valuesArr1.length; i++) {
		
		switch (nbCol) {
			case 1 : ch += "<a href='javascript:" + funcName + "(" + i + ", \"" + idListItem + "\")' id='" + idListItem + i + "'><span class='theItem' >" + valuesArr1[i] + "</span><span id='d" + i + "' class='item3'></span></a>";
					break;
			case 2 : ch += "<a href='javascript:" + funcName + "(" + i + ", \"" + idListItem + "\")' id='" + idListItem + i + "'><span class='theItem'>" + valuesArr2[i] + "</span><span class='item4' style='float:left; text-align:left;'>" + valuesArr1[i] + "</span></a>";
					break;
			case 3 : ch += "<a href='javascript:" + funcName + "(" + i + ", \"" + idListItem + "\")' id='" + idListItem + i + "'><span class='item1'>" + valuesArr2[i] + "&nbsp;</span><span class='item2'>" + valuesArr1[i] + "</span><span id='d" + i + "' class='item3' style='text-align:right;'>" + valuesArr3[i] + "</span></a>";
					break;
		}
	}
	var theList = 	document.getElementById(idList);
	if (theList!= undefined )
		{
			theList.innerHTML 		= ch ;
			theList.style.height 	= nbLines * 26;
		}
}

// Duplication/Specialisation de la fonction initSelectList pour ajouter un traitement pour le contr?le en sortie de la page add_attach.html
function initAttachedList(valuesArr1, idList, idListItem, nbLines) {

   //cas particulier safari
	var ua = navigator.userAgent;
	var isMac = ua.indexOf('Mac') != -1;
	var isSafari = ua.indexOf('Safari') != -1;
	//fin
	var ch = "";
	
	for (i=0; i < valuesArr1.length; i++) {
		
		//cas particulier pour safari
		if (isSafari && isMac && (valuesArr1[i].indexOf("/")!=-1))
			valuesArr1[i]=formatSafari(valuesArr1[i]);
	  //fin
		
		ch += "<a href='javascript:setItem(" + i + ", \"" + idListItem + "\");alertNeeded();' onclick='alertNotNeeded();' id='" + idListItem + i + "'><span class='theItem' >" + valuesArr1[i] + "</span></a>";
	}
	var theList = document.getElementById(idList);
	if (theList != undefined) {
		theList.innerHTML = ch ;
		theList.style.height = nbLines * 26;
	}
}

var oldy = new Array("0", "0", "0");
var oldN = '0';

function emailListe (n, idListItem) {
  var borderBottomColor = "#F60";
	if (n != oldN) {
		if (oldN != 0) {
			document.getElementById(idListItem + oldN).className = "";
			document.getElementById(idListItem + (oldN)).style.borderBottomColor = "#CCC";
			document.getElementById(idListItem + (oldN-1)).style.borderBottomColor = "#CCC";
		}
		else  {
			document.getElementById(idListItem + oldN).className = "";
			document.getElementById(idListItem + oldN).style.borderBottomColor = "#ccc";
		}
		if (n != 0) {
				document.getElementById(idListItem + n).className = "current";
				document.getElementById(idListItem + (n)).style.borderBottomColor = borderBottomColor;
				document.getElementById(idListItem + (n-1)).style.borderBottomColor = borderBottomColor;
			}
		else  {
			document.getElementById(idListItem + n).className = "current";
			document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
		}
	}
	else if ((n==0)&&(oldN==0)) {
			document.getElementById(idListItem + n).className = "current";
			document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
		}
	oldN = n;
	CURRENT_OBJ = n;
}
function updateEmail(Names, Email){
	if (CURRENT_OBJ != null && CURRENT_OBJ != -1) {
		document.getElementById("nomAffiche").innerHTML = mEmails[CURRENT_OBJ];
		document.FORM_ADDRESS_LIST.aliasEmail.value = mEmails[CURRENT_OBJ];
		document.FORM_ADDRESS_LIST.displayName.value = mNames[CURRENT_OBJ];
		document.getElementById("aliasEmail").style.display = "none";
		document.getElementById("nomAffiche").style.display = "";
		document.FORM_ADDRESS_LIST.modifyAlias.value = "1";
	}
	else alert (ERROR_ALIAS_SETDEFAULT);
}


function setItem (n, idListItem) {
   

    var borderBottomColor = "#F60";
	  if (n != oldy[idListItem]) {
		if (oldy[idListItem] != 0) {
			document.getElementById(idListItem + oldy[idListItem]).className = "";
			document.getElementById(idListItem + oldy[idListItem]).style.borderBottomColor = "#CCC";
			document.getElementById(idListItem + (oldy[idListItem]-1)).style.borderBottomColor = "#CCC";
			//document.getElementById("d" + oldy).innerHTML = "";
		}
		else  {
			document.getElementById(idListItem + oldy[idListItem]).className = "";
			document.getElementById(idListItem + oldy[idListItem]).style.borderBottomColor = "#ccc";
		}
		if (n != 0) {
				document.getElementById(idListItem + n).className = "current";
				document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
				document.getElementById(idListItem + (n-1)).style.borderBottomColor = borderBottomColor;
				//document.getElementById("d" + n).innerHTML = "d?faut";
			}
	  else  {
		   document.getElementById(idListItem + n).className = "current";
		   document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;
		}
	}
	else if ((n==0)&&(oldy[idListItem]==0)) {document.getElementById(idListItem + n).className = "current";
								 document.getElementById(idListItem + n).style.borderBottomColor = borderBottomColor;}
	oldy[idListItem] = n;
	CURRENT_OBJ = n;
}

var alert_chose_filter = "You must choose a filter first";
var alert_fill_before_new_filter = "You must provide information opposite before addinga new filter";

function manageFilters (act, wFilters) {
	var TMP_OBJ;
	if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "add" :	if ((document.FORM_FILTERS.FILTER_NAME.value == "") || (document.FORM_FILTERS.FILTER_REGLE.value == "")) {
				alert (alert_fill_before_new_filter);
							}
							break;
			case "del" :	wFilters.splice((CURRENT_OBJ), 1);
							CURRENT_OBJ = null;
							oldy = null;
							break;
			case "up" :		if (CURRENT_OBJ != 0) {
								TMP_OBJ = wFilters [CURRENT_OBJ-1];
								wFilters [CURRENT_OBJ-1] = wFilters [CURRENT_OBJ];
								wFilters [CURRENT_OBJ] = TMP_OBJ;
								CURRENT_OBJ = "id" + String(CURRENT_OBJ-1);
							}
							break;
	       case "dn" :		if (CURRENT_OBJ != wFilters.length-1) {
								TMP_OBJ = wFilters [CURRENT_OBJ+1];
								wFilters [CURRENT_OBJ+1] = wFilters [CURRENT_OBJ];
								wFilters [CURRENT_OBJ] = TMP_OBJ;
								CURRENT_OBJ = "id" + String(CURRENT_OBJ+1);
							}
							break;
		}
		initFiltersList(wFilters, 'liste');
	}
	else alert (alert_chose_filter);
}

function manageList(act, wFilters, wFilters2) {
	var TMP_OBJ, TMP_OBJ2;
	if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "del" :
/* ATOS - DEBUT MODIF */
					document.FORM_ADDRESS_LIST.aliasId.value=aliasId[CURRENT_OBJ];
					document.FORM_ADDRESS_LIST.ALIAS_ACTION.value="DELETEALIAS";
          document.FORM_ADDRESS_LIST.target="_self";
					document.FORM_ADDRESS_LIST.action="adressList.html";
          document.FORM_ADDRESS_LIST.submit();

          /*window.location = "adressList.html?aliasId="+aliasId[CURRENT_OBJ]+"&DELETEALIAS=TRUE";
					wFilters.splice((CURRENT_OBJ), 1);
					wFilters2.splice((CURRENT_OBJ), 1);
					CURRENT_OBJ = null;*/
					break;
/* ATOS - FIN MODIF */
			case "up" :		if ((CURRENT_OBJ) != 0) {
								TMP_OBJ = wFilters [CURRENT_OBJ-1];
								TMP_OBJ2 = wFilters2 [CURRENT_OBJ-1];
								wFilters [CURRENT_OBJ-1] = wFilters [CURRENT_OBJ];
								wFilters2 [CURRENT_OBJ-1] = wFilters2 [CURRENT_OBJ];
								wFilters [CURRENT_OBJ] = TMP_OBJ;
								wFilters2 [CURRENT_OBJ] = TMP_OBJ2;
								CURRENT_OBJ = "id" + String(CURRENT_OBJ-1);
							}
							break;

		}
		initSelectList(mEmails, mNames, 'liste', 'adressList', 'id',  2);
	}
	else alert (ERROR_ALIAS_SETDEFAULT);
}


//fin a placer dans common.js

// a placer dans common.js
	var cbModeTrieMailItem1	= "email address";
	var	cbModeTrieMailItem2	= "name";
	var cbModeTrieMailLabel = cbModeTrieMailItem1;

	function createComboModeTrieMailContent() {
		for (i=1; i<=2; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionModeTrieMail(" + i + ");'>" + String (eval ('cbModeTrieMailItem' + i)) + "</a></div>");
		}
	}
	function comboActionModeTrieMail(cbItem) {
		setCurrentMenuLabel(eval ("cbModeTrieMailItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :
				document.FORM_ADDRESS_LIST.sortBy.value="ALIAS";
				break;
			case 2 :
			  document.FORM_ADDRESS_LIST.sortBy.value="DISPLAY_NAME";
				break;
		}
		document.FORM_ADDRESS_LIST.sortOrder.value="ASC";
		document.FORM_ADDRESS_LIST.ALIAS_ACTION.value="SORTUSERALIAS";
		document.FORM_ADDRESS_LIST.target="_self";
		document.FORM_ADDRESS_LIST.action="adressList.html";
    document.FORM_ADDRESS_LIST.submit();
	}

//fin a placer dans common.js

//a placer dans textarea.js
var nb_chars_limit = "Number of characters is limited";
function limitText(limitField, counter, limitNum) {
	var ch = TPL_LABEL_LEFT_BOTTOM;

	if (limitField.value.length > limitNum) {
			limitField.value = limitField.value.substring(0, limitNum);
			alert(nb_chars_limit);
	} else {
			ch += limitNum - limitField.value.length;
			if (counter != "") document.getElementById(counter).innerHTML = ch;
	}
}

//fin a placer dans textarea.js

	function comboActionNum(cbItem) {
		setCurrentMenuLabel(eval(cbItem));
		hideMenus();
	}
//************************************************************

	var cbAlertFilterItem1	= EQUAL;
	var	cbAlertFilterItem2	= CONTAIN;
	var	cbAlertFilterItem3	= NOTCONTAIN;
	var cbAlertFilterItem4  = STARTWITH;
	var cbAlertFilterItem5  = ENDWITH;

	// Search Service combo label
	var cbAlertFilterLabel = cbAlertFilterItem1;

	function createComboAlertFilterContent() {
		for (i=1; i<=3; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionAlertFilter(" + i + ");'>" + String (eval ('cbAlertFilterItem' + i)) + "</a></div>");
		}
	}
	function comboActionAlertFilter(cbItem) {
		setCurrentMenuLabel(eval("cbAlertFilterItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :
						break;
			case 2 :
						break;
			case 3 :
						break;
		}
	}

function createComboAlertFilterContent_subject() {

		for (i=1; i<=5; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionAlertFilter_subject(" + i + ");'>" + String (eval ('cbAlertFilterItem' + i)) + "</a></div>");
		}
	}
	function comboActionAlertFilter_subject(cbItem) {
		setCurrentMenuLabel(eval("cbAlertFilterItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :	criteria_subject=operatorEquals;
						break;

			case 2 :	criteria_subject=operatorContains;
						break;

			case 3 :    criteria_subject=operatorDoesNotContain;
						break;

			case 4 :    criteria_subject=operatorStartWith;
						break;

			case 5 :    criteria_subject=operatorEndWith;
						break;
		}
	}function createComboAlertFilterContent_recipient() {
		for (i=1; i<=5; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionAlertFilter_recipient(" + i + ");'>" + String (eval ('cbAlertFilterItem' + i)) + "</a></div>");
		}
	}
	function comboActionAlertFilter_recipient(cbItem) {
		setCurrentMenuLabel(eval("cbAlertFilterItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :	criteria_recipient=operatorEquals;
						break;

			case 2 :	criteria_recipient=operatorContains;
						break;

			case 3 :    criteria_recipient=operatorDoesNotContain;
						break;

			case 4 :    criteria_recipient=operatorStartWith;
						break;

			case 5 :    criteria_recipient=operatorEndWith;
						break;
		}
	}function createComboAlertFilterContent_from() {
		for (i=1; i<=5; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionAlertFilter_from(" + i + ");'>" + String (eval ('cbAlertFilterItem' + i)) + "</a></div>");
		}
	}
	function comboActionAlertFilter_from(cbItem) {
		setCurrentMenuLabel(eval("cbAlertFilterItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :	criteria_from=operatorEquals;
						break;

			case 2 :	criteria_from=operatorContains;
						break;

			case 3 :    criteria_from=operatorDoesNotContain;
						break;

			case 4 :    criteria_from=operatorStartWith;
						break;

			case 5 :    criteria_from=operatorEndWith;
						break;
		}
	}

//************************************************************
//fin a placer dans combo.js
function radioUnselect(aFormName, aRadioName, aValue) {
	// Select the clicked radio :
      	// set image
      	getImage('radio_' + aFormName + '_' + aRadioName + '_' + aValue).src = eval('radioUnselectedImg.src');
      	// set hidden field value
      	document.forms[aFormName].elements[aRadioName].value = aValue;
}
function radioSelect (aFormName, aRadioName, aValue){
     	getImage('radio_' + aFormName + '_' + aRadioName + '_' + aValue).src = eval('radioSelectedImg.src');
      	// set hidden field value
      	document.forms[aFormName].elements[aRadioName].value = aValue;
    }
// utiliser dnas emailSettings SmsAl.html
var alert_days_transfert = "You must choose which days your message will be transfered";
var alert_period_transfert = "You must give the beginning and ending hour of your transfer period";
var alert_begin_before_transfert = "Beginning hour must be lower than the ending hour";

function validSmsForward(aFormName, aRadioName, aValue, aCheckboxName, aRadioName2, aValue2) {
	if (isRadioChecked(aFormName, aRadioName, aValue)) {
		tmp = false;
		for (i=1; i<8; i++) if (isCheckboxChecked(aFormName, aCheckboxName, aCheckboxName+String(i))) tmp = true;
		if (!tmp) alert (alert_days_transfert);
	}
	if (isRadioChecked(aFormName, aRadioName2, aValue2)) {
		if ((document.getElementById("HoursComboLabel").innerHTML >= "<") || (document.getElementById("HoursCombo2Label").innerHTML >= "<"))  alert (alert_period_transfert);

		if (Number(document.getElementById("HoursComboLabel").innerHTML) > Number(document.getElementById("HoursCombo2Label").innerHTML)) alert (alert_begin_before_transfert);
	}
}

function validSimple(aFormName, aRadioName, aValue, aCheckboxName) {
	if (isRadioChecked(aFormName, aRadioName, aValue)) {
		tmp = false;
		for (i=1; i<8; i++) if (isCheckboxChecked(aFormName, aCheckboxName, aCheckboxName+String(i))) tmp = true;
		if (!tmp) {
			alert (alert_transfert);
		}
	}
		if (document.getElementById("HoursComboLabel").innerHTML >= "<") {
			alert (alert_period_transfert);
		}
		else if (document.getElementById("HoursCombo2Label").innerHTML >= "<") {
			alert (alert_period_transfert);
		}
		if (Number(document.getElementById("HoursComboLabel").innerHTML) > Number(document.getElementById("HoursCombo2Label").innerHTML)) alert (alert_begin_before_transfert);
}


function checkDays(aFormName, aCheckboxName, aValue1, aRadioName, aValue2, aRadioName2, aValue3){
		 if (isCheckboxChecked(aFormName, aCheckboxName, aValue1)){
			radioUnselect(aFormName, aRadioName, aValue2);
			radioSelect(aFormName, aRadioName2, aValue3);
		}
	}

	// Display Hours label
	var cbHoursLabel = "00";

	function createComboHoursContentVal(aFormName) {
		for (i=0; i<=23; i++) {
			sep = i==1?"List":"FirstGroup";
			if (i < 10) document.write ("<div class='combo" + "Element'><a href='javascript:comboActionHoursVal(\"0" + i + "\", \"" + aFormName + "\");'>" + "0" + String (i) + "</a></div>");
			else document.write ("<div class='combo" + "Element'><a href='javascript:comboActionHoursVal(" + i + ", \"" + aFormName + "\");'>" + String (i) + "</a></div>");
			//i = "0" + String(i);
		}
	}

	function comboActionHoursVal(cbItem, aFormName) {
		setCurrentMenuLabel(eval(cbItem));
		hideMenus();
	}


//*********************************************************************
	var cbVCardItem1	= "Card personelle";
	var	cbVCardItem2	= "Card professionelle";
	// Size combo label
	var cbVCardLabel = cbVCardItem1;

	function createComboVCardContent() {
		for (i=1; i<=2; i++) {
			sep = i==1?"List":"FirstGroup";
			document.write ("<div class='combo" + sep + "Element'><a href='javascript:comboActionVCard(" + i + ");'>" + String (eval ('cbVCardItem' + i)) + "</a></div>");
		}
	}

	function comboActionVCard(cbItem) {
		setCurrentMenuLabel(eval ("cbVCardItem" + cbItem));
		hideMenus();
		switch (cbItem) {
			case 1 :
						break;
			case 2 :
						break;
		}
	}

//***********************************************************************
var COBJ
function highlightInputError (o) {
	COBJ = o;
	tmp = "#999";
	o.style.borderColor='red';
	setTimeout("restoreTmpError(tmp)",1000);
	o.focus();
}

function restoreTmpError (tmp) {
	COBJ.style.borderColor = tmp;

}

function validPopPasswordInput() {
	var newPassword = document.getElementById("newPopPassword").value;
	var confirmationPassword = document.getElementById("confirmationPopPassword").value;	
	if(newPassword == "" || confirmationPassword == "") {
		document.getElementById("popErrors").innerHTML=EMPTY_POP_PASSWORD;
		document.getElementById ("popErrors").style.display = "";
		document.getElementById ("popErrors").style.visibility = "visible";	
	}
	else if(newPassword != confirmationPassword) {
		document.getElementById("popErrors").innerHTML=DIFFERENT_POP_PASSWORD;
		document.getElementById ("popErrors").style.display = "";
		document.getElementById ("popErrors").style.visibility = "visible";	
	}
	else {
		document.FORM_UPDATE_POP_PASSWORD.POP_ACTION.value="UPDATEPOPPASSWORD";
		document.FORM_UPDATE_POP_PASSWORD.target="_self";
	   	document.FORM_UPDATE_POP_PASSWORD.action="updatePopPassword.html";
	    document.FORM_UPDATE_POP_PASSWORD.submit();
	}
}

function sendPopPassword() {
	document.FORM_SEND_POP_PASSWORD.POP_ACTION.value="SENDPOPPASSWORD";
	document.FORM_SEND_POP_PASSWORD.target="_self";
	document.FORM_SEND_POP_PASSWORD.action="sendPopPassword.html";
	document.FORM_SEND_POP_PASSWORD.submit();
}

var actionAlias = true;

function validInput() {
	if(actionAlias){
		actionAlias = false;
		var iChars = "!@#$%^&*()+=[]/{}|\:<>?";
		var iCharsAliasEmail = "!@#$%^&*()+=[]\';,/{}|\":<>?";
		var eRRors = new Array();
		var tmpLength;
		tmpLength = document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.length - 50;
		tmpLength = document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.length - tmpLength;
		var modifyAlias = document.forms["FORM_ADDRESS_LIST"].elements["modifyAlias"].value;
		var alert_alias_email = "Please you must enter an email address";
		var alert_alias_display_name = "Please you must enter an alias display name";

	  document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"].value=trim(document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"].value);
	  document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value=trim(document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value);

	  if (document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"].value == "") {
			alert (alert_alias_email);
			highlightInputError (document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"]);
			actionAlias = true;
			return;
		}else if (document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value == "") {
			alert (alert_alias_display_name);
			highlightInputError (document.forms["FORM_ADDRESS_LIST"].elements["displayName"]);
			actionAlias = true;
			return;
		}
		else {
		     if (document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.length > 50)
		     {
				 var alert_nb_char = "Number of characters is too large";
				 alert(alert_nb_char);
				 document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value = document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.substr(0, tmpLength);
				 actionAlias = true;
				 return;
			}

			for (var j = 0; j < document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"].value.length; j++) {
	 			if (iCharsAliasEmail.indexOf(document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"].value.charAt(j)) != -1)
				{
			    	eRRors [j] = j;
				}
		  	}

		  	if ((eRRors != null) && (eRRors.length != 0) && (modifyAlias == 0) ) {
				var alert_special_char = "Special characters are forbidden";
				alert(alert_special_char);
				highlightInputError (document.forms["FORM_ADDRESS_LIST"].elements["aliasEmail"]);
				actionAlias = true;
				return;
			}

			eRRors = new Array();
	 		for (var j = 0; j < document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.length; j++) {
	 		 	if (iChars.indexOf(document.forms["FORM_ADDRESS_LIST"].elements["displayName"].value.charAt(j)) != -1)
				{
			    	eRRors [j] = j;
				}
		  	}
		  	if ((eRRors != null) && (eRRors.length != 0)) {
				var alert_special_char = "Special characters are forbidden";
				alert(alert_special_char);
				highlightInputError (document.forms["FORM_ADDRESS_LIST"].elements["displayName"]);
				actionAlias = true;
				return;
			}

			if (CURRENT_OBJ != null && CURRENT_OBJ != -1 && modifyAlias == 1)
			{
				if(document.getElementById("nomAffiche").innerHTML == mEmails[CURRENT_OBJ])
				{
					document.FORM_ADDRESS_LIST.aliasId.value=aliasId[CURRENT_OBJ];
					document.FORM_ADDRESS_LIST.ALIAS_ACTION.value="SETALIASDISPLAYNAME";
					document.FORM_ADDRESS_LIST.target="_self";
					document.FORM_ADDRESS_LIST.action="adressList.html";
			        document.FORM_ADDRESS_LIST.submit();
				}
			}
			else
			{
				if(canAddAlias == true)
				{
					var email = document.FORM_ADDRESS_LIST.aliasEmail.value;
					var displayName = document.FORM_ADDRESS_LIST.displayName.value;
					if(email != null && displayName != null)
					{
					  document.FORM_ADDRESS_LIST.ALIAS_ACTION.value="CREATEALIAS";
					  document.FORM_ADDRESS_LIST.target="_self";
			 		  document.FORM_ADDRESS_LIST.action="adressList.html";
			          document.FORM_ADDRESS_LIST.submit();
					}

				}
				else {
					var quota_alias = "Your alias quota is reached.";
					alert(quota_alias);
					actionAlias = true;
					return;
				}
			}

		}
	}
}

// PJ

var CHECK_PJ = "Check attachment";
//PJ

function setSignatures (id) {
	if (CURRENT_OBJ != null) {
		document.getElementById(CURRENT_OBJ).style.backgroundColor="transparent";
		document.getElementById(CURRENT_OBJ).style.color="black";
	}
	CURRENT_OBJ = id;
	if(CURRENT_OBJ != tempOBJ){
  	  activebutton("majbttn");
	  vEdition=false;
	}else{
	  desactivebutton("majbttn");
	  vEdition=true;
	}

}
var SET_DEFAULT
function setDefault () {
	SET_DEFAULT = !SET_DEFAULT;

	if (CURRENT_OBJ != null && CURRENT_OBJ != -1) {
		document.FORM_ADDRESS_LIST.aliasId.value=aliasId[CURRENT_OBJ];
		document.FORM_ADDRESS_LIST.ALIAS_ACTION.value="SETDEFAULTALIAS";
		document.FORM_ADDRESS_LIST.target="_self";
   	 	document.FORM_ADDRESS_LIST.action="adressList.html";
    	document.FORM_ADDRESS_LIST.submit();
	}
	else alert (ERROR_ALIAS_SETDEFAULT);
}

function manageSignatures(act) {
	var TMP_OBJ;

		if (CURRENT_OBJ != null || act == "add") {
		switch (act) {
			case "add" :

							if (isTextFieldEmpty(document.composeform.name_sign)) {
								alert (INFO_GET_VALID_NAME_SIGNATURE);
								highlightError (document.composeform.name_sign);
								break;
							}

							var exist=false;
							var myAccount = document.composeform.name_sign.value;
							if(document.composeform.name_sign.value!=modified_Account){
								for(var i=0; i<count; i++) {
									if(myAccount==tab[i]){
   										exist=true;
   									}
 		 						}
 		 					}
							if(exist){
   									alert (INFO_EXIST_ADDRESS);
   									break;
   							}else{
   								maj_corps();
								if (document.composeform.msg_text.value==TXT_TEXTAREA_CHG_DSP) {
									document.composeform.signature.value="";
									document.composeform.signatureHtml.value="";
								} else {
									document.composeform.signature.value=document.composeform.msg_text.value;
									document.composeform.signatureHtml.value=document.composeform.msg_text.value;
									if(document.composeform.compose!=null && document.composeform.compose.value=="true"){
										document.composeform.signatureHtml.value=document.composeform.msg_body.value;
									}
								}
									if (document.composeform.signature.value==""){
										alert (ERROR_MESSAGE_SIGNATURE);
										highlightError (document.composeform.signature);
										return;
									}
	   								document.composeform.defaut.value=""+SET_DEFAULT;
									document.composeform.action="signature_submit.html";
									document.composeform.submit();
									break;
   							}
			case "del" :
							document.composeform.signId.value = CURRENT_OBJ;
							CURRENT_OBJ = null;
					if ( window.confirm(CONFIRM_DELETE_REMOTE) )
					{
						document.composeform.action="signature_submit_delete.html";
						document.composeform.submit();
					}
							break;
			case "upd" :
						if(!vEdition){
							Edit(CURRENT_OBJ);
						}
							break;

		}

		if (CURRENT_OBJ != null) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
	}
	else
	if(!vEdition){
		alert (INFO_VALIDATION_SELECT_ADDRESS_BEFORE);

	}
}


/* Ajout de nouvelles fonctions pour la gestion des listes */
// ------------------------------------------------
// Function initSelectListBis :
// Initialize a select list
//
// Params :
//	- valuesArr : 2 dimension array containing id and value
//	- idList : the id of the list
//  - nbLines : number of lines
//  - idItem : the id of the item (not always "List_" ...)
// ------------------------------------------------
function initSelectListBis(valuesArr,idList,nbLines, idItem) {
	var ch = "";
//	<a href='javascript:setItemBis(1,id1)' id="List_1"><span class='theItem' id='id1'>aazeezae@eazezea.fr</span></a>

	if (idItem == null || idItem == "") idItem = "List_";

	for (i=0; i < valuesArr.length; i++) {
		if(valuesArr[i][2]!=null){
			ch += "<a onClick='javascript:setItemBis(" + i + ", \"" + escape(valuesArr[i][0]) + "\", \"" + idItem + "\" )' id='" + idItem + i + "'><div class='theItem' id='" + escape(valuesArr[i][0]) + "'>" + valuesArr[i][1] + "</div><div>" + valuesArr[i][2]+"</div></a>";
		}else{
			ch += "<a onClick='javascript:setItemBis(" + i + ", \"" + escape(valuesArr[i][0]) + "\", \"" + idItem + "\" )' id='" + idItem + i + "'><div class='theItem' id='" + escape(valuesArr[i][0]) + "'>" + valuesArr[i][1] + "</div></a>";
		}
	}

	document.getElementById(idList).innerHTML = ch ;
	document.getElementById(idList).style.height = nbLines * 26;
}

function initSelectListNotification(valuesArr,idList,nbLines) {
	var ch = "";

	for (i=0; i < valuesArr.length; i++) {

		ch += "<a href='javascript:setItemNotification(" + i + ", \"" + valuesArr[i][0] + "\")' id='List_" + i + "'><span class='theItemNotification' id='" + valuesArr[i][0] + "'>" + valuesArr[i][1] + "</span></a>";

	}
	document.getElementById(idList).innerHTML = ch ;
	document.getElementById(idList).style.height = nbLines * 26;
}

var old_n = 9999999999;
var list_select = "";
// ------------------------------------------------
// Function setItemBis :
// Change the style of the selected item of a list
// and save the current id of the item selected
// Params :
//	- n : index of the current line selected
//  - idItem : id of the item selected
//
// ------------------------------------------------
function setItemBis (n, idItem, nameList) {
  var borderBottomColor = "#F60";
	if (nameList == null || nameList == "") idItem = "List_";

	if ( (list_select == "") || (list_select == nameList) )
	{
		if (parseInt(old_n) != 9999999999) {
			if (parseInt(old_n) != 0) {

				document.getElementById(nameList + old_n).className = "";
				document.getElementById(nameList + old_n).style.borderBottomColor = "#CCC";
				document.getElementById(nameList + (old_n-1)).style.borderBottomColor = "#CCC";
			}
			else  {
				document.getElementById(nameList + old_n).className = "";
				document.getElementById(nameList + old_n).style.borderBottomColor = "#ccc";
			}
		}
	}
	else
	{
		if (parseInt(old_n) != 9999999999) {
			if (parseInt(old_n) != 0) {

				document.getElementById(list_select + old_n).className = "";
				document.getElementById(list_select + old_n).style.borderBottomColor = "#CCC";
				document.getElementById(list_select + (old_n-1)).style.borderBottomColor = "#CCC";
			}
			else  {
				document.getElementById(list_select + old_n).className = "";
				document.getElementById(list_select + old_n).style.borderBottomColor = "#ccc";
			}
		}
	}

	if (parseInt(n) != 0) {
		document.getElementById(nameList + n).className = "current";
		document.getElementById(nameList + n).style.borderBottomColor = borderBottomColor;
		document.getElementById(nameList + (n-1)).style.borderBottomColor = borderBottomColor;
	}
  else  {
    document.getElementById(nameList + n).className = "current";
		document.getElementById(nameList + n).style.borderBottomColor = borderBottomColor;
	}

	// Correction de la disparition de la toolbar tinyMCE
	if (document.all)
	{
         if (typeof(window['tinyMCE'])!="undefined")
         {
          tinyMCE.execInstanceCommand('mce_editor_0','Bold',false);
          tinyMCE.execInstanceCommand('mce_editor_0','Bold',false);
         }
	}

	list_select = nameList;
	old_n = n;
	CURRENT_OBJ = idItem;

}

//Ajout d un controle pr la longueur de la liste suite a une suppresion
// d un element supprime

function setItemNotification (n,idItem) {
  var borderBottomColor = "#F60";
	if (parseInt(old_n) != 9999999999 && parseInt(old_n)<= (tab_notif.length-1)) {
		if (parseInt(old_n) != 0) {
			document.getElementById("List_"+old_n).className = "";
			document.getElementById("List_"+old_n).style.borderBottomColor = "#CCC";
			document.getElementById("List_"+ (old_n-1)).style.borderBottomColor = "#CCC";
		}
		else  {
			document.getElementById("List_"+old_n).className = "";
			document.getElementById("List_"+old_n).style.borderBottomColor = "#ccc";
		}
	}
	if (parseInt(n) != 0) {
			document.getElementById("List_"+n).className = "current";
			document.getElementById("List_"+n).style.borderBottomColor = borderBottomColor;
			document.getElementById("List_"+(n-1)).style.borderBottomColor = borderBottomColor;
	}
    else  {
  	   document.getElementById("List_"+n).className = "current";
	   document.getElementById("List_"+n).style.borderBottomColor = borderBottomColor;
	}

	old_n = n;
	CURRENT_OBJ = idItem;
}

/* Ajout de nouvelles fonctions pour la page de parametrage SMS */

    // Retourne une condition simple sous forme de string
    // Exemple : "Si expediteur est egal a xxx"
    function SMSConditionToString(infos)
		{
		  oneCondition="[";
      if (infos[1]==criteriaFrom)
        oneCondition = oneCondition + IF_SENDER	;
      else if (infos[1]==criteriaSubject)
        oneCondition = oneCondition + IF_SUBJECT;
      else if (infos[1]==criteriaRecipient)
        oneCondition = oneCondition + IF_RECIPIENT;
      if (infos[2]==operatorContains)
        oneCondition = oneCondition + CONTAIN;
      else if (infos[2]==operatorDoesNotContain)
        oneCondition = oneCondition + NOTCONTAIN;
      else if (infos[2]==operatorEquals)
        oneCondition = oneCondition + EQUAL;
      else if (infos[2]==operatorStartWith)
        oneCondition = oneCondition + STARTWITH;
      else if (infos[2]==operatorEndWith)
        oneCondition = oneCondition + ENDWITH;

      oneCondition = oneCondition + infos[4];
      oneCondition = oneCondition + "]";
      return oneCondition;

    }

	function SMSConditionToEncodedString(infos)
	{
		 oneCondition="$";
      if (infos[1]==criteriaFrom)
        oneCondition = oneCondition + "FROM|";
      else if (infos[1]==criteriaSubject)
        oneCondition = oneCondition + "SUBJECT|";
      else if (infos[1]==criteriaRecipient)
        oneCondition = oneCondition + "TO|";
      if (infos[2]==operatorContains)
        oneCondition = oneCondition + "CONTAINS|";
      else if (infos[2]==operatorDoesNotContain)
        oneCondition = oneCondition + "DOESNOTCONTAIN|";
      else if (infos[2]==operatorEquals)
        oneCondition = oneCondition + "EQUAL|";
       else if (infos[2]==operatorStartWith)
        oneCondition = oneCondition + "STARTWITH|";
       else if (infos[2]==operatorEndWith)
        oneCondition = oneCondition + "ENDWITH|";

      oneCondition = oneCondition + escape(infos[4]);
      return oneCondition;
    }

    // Retourne une condition complexe (triple de conditions) sous forme de string
    // Exemple : "Si expediteur est egal a xxx et si sujet contient xxx et si destinataire contient xxx"
    function SMSTripleConditionToString(triple)
		{
		  tripleString = "";
		  string1 = "";
		  string2 = "";
		  string3 = "";
      for (j=0;j<triple.length;j++){
        if (triple[j][1]==criteriaFrom)
          string1 = SMSConditionToString(triple[j]);
        else if (triple[j][1]==criteriaSubject)
          string2 = SMSConditionToString(triple[j]);
        else if (triple[j][1]==criteriaRecipient)
          string3 = SMSConditionToString(triple[j]);
      }
      if (string1!="")
        tripleString = tripleString+string1;
      if (string2!="")
        if (tripleString!="")
          tripleString = tripleString+" et ";
        tripleString = tripleString+string2;
      if (string3!="")
        if (tripleString!="")
          tripleString = tripleString+" et ";
        tripleString = tripleString+string3;
      return tripleString;
		}

// Retourne une condition complexe (triple de conditions) sous forme de string encod?e
    // Exemple : "Si expediteur est egal a xxx et si sujet contient xxx et si destinataire contient xxx"
    function SMSTripleConditionToEncodedString(triple)
	{
	  tripleString = "";
	  string1 = "";
	  string2 = "";
	  string3 = "";
      for (j=0;j<triple.length;j++){
        if (triple[j][1]==criteriaFrom)
          string1 = SMSConditionToEncodedString(triple[j]);
        else if (triple[j][1]==criteriaSubject)
          string2 = SMSConditionToEncodedString(triple[j]);
        else if (triple[j][1]==criteriaRecipient)
          string3 = SMSConditionToEncodedString(triple[j]);
      }
      if (string1!="")
        tripleString = tripleString+string1;
      if (string2!="")
        if (tripleString!="")
          tripleString = tripleString;
        tripleString = tripleString+string2;
      if (string3!="")
        if (tripleString!="")
          tripleString = tripleString;
        tripleString = tripleString+string3;
      return tripleString;
	}

		// Ajoute une condition complexe (triple) a la liste deja existante
    function addSMSTripleCondition(lg_notif)
    {
    	lg=lg_notif;
      subject = document.FORM_SMSPARAM.subject_to_add.value;
      from = document.FORM_SMSPARAM.from_to_add.value;
      recipient = document.FORM_SMSPARAM.recipient_to_add.value;
      operatorSubject = criteria_subject;
      operatorFrom = criteria_from;
      operatorRecipient = criteria_recipient;
      triple = new Array();
      ind=0;
      if ((from=="")&&(subject==="")&&(recipient==""))
          alert("Vous devez saisir au moins une condition !");
      if (from!=""){
        fromInfos = new Array();
        fromInfos[0]=""+lg+1;
        fromInfos[1]=criteriaFrom;
        fromInfos[2]=operatorFrom;
        fromInfos[3]="";
        fromInfos[4]=from;
        triple[ind] = fromInfos;
        ind ++;
      }
      if (subject!=""){
        subjectInfos = new Array();
        subjectInfos[0]=""+lg+1+"_0";
        subjectInfos[1]=criteriaSubject;
        subjectInfos[2]=operatorSubject;
        subjectInfos[3]=""+lg+1;
        subjectInfos[4]=subject;
        triple[ind] = subjectInfos;
        ind ++;
      }
      if (recipient!=""){
        recipientInfos = new Array();
        recipientInfos[0]=""+lg+1+"_1";
        recipientInfos[1]=criteriaRecipient;
        recipientInfos[2]=operatorRecipient;
        recipientInfos[3]=""+lg+1;
        recipientInfos[4]=recipient;
        triple[ind] = recipientInfos;
        ind ++;
      }
     document.FORM_SMSPARAM.allTripleDisplay.options[lg]=new Option(SMSTripleConditionToString(triple),""+lg);
    }

    // Initialise toutes les conditions complexes (triples)
    function initAllSMSTripleConditions(conditions)
    {
      triple = new Array();
      allTriple = new Array();
      alreadyTreated = new Array();
      j=0;
      h=0;
      z=0;
      for (i=0;i<conditions.length;i++){
        dejaTraite=0;
        triple = new Array();
        j=0;
        for (z=0;z<alreadyTreated.length;z++){
          if (alreadyTreated[z][0]==conditions[i][0]){
            dejaTraite=1;
          }
        }
        if (dejaTraite==0){
          infos=conditions[i];
          alreadyTreated[z]=infos;
    		  triple[j] = infos;
          j=j+1;
    		  for (k=i+1;k<conditions.length;k++){
            infos2 = conditions[k];
            t1=infos2[3];
            t2=infos[0];
            if (t1==t2){
              triple[j]=infos2;
              alreadyTreated[z]=infos2;
              z=z+1;
              j=j+1;
            }
          }
          allTriple[h] = triple;
          h=h+1;
        }
  		}
  		return allTriple;
    }


    function resetForm()
    {
    	document.FORM_ADDRESS_LIST.modifyAlias.value = "0";
        document.getElementById("nomAffiche").style.display = "none";
    	document.getElementById("aliasEmail").style.display = "";
    	document.getElementById("displayName").value = "";
    	document.getElementById("aliasEmailText").value = "";
    }


var ALL_DAY_MSG = "allday";
var NO_EVENT_MSG = "no events";
var NO_TASK_MSG = "no tasks";
var LINK_PIM_MSG = "see more";


/* pour la gestion des templates */

/* Fonction utilisee pour afficher seulement les n premiers
caracteres d'un element dans la liste */
function decoup(mot, taille)
{
 	mot_sub= mot.substring(0,taille);
 	mot_final = mot_sub;
	if(mot.length > mot_sub.length){
		mot_final = mot_final+"...";
	}
	return mot_final;
}

/* Var pour gestion des templates*/
	var INFO_GET_VALID_TITLE_TPL = "You need to fill the template before saving";
  	var INFO_VALIDATION_SELECT_TEMPLATE_BEFORE = "You first have to select an element";
	var TXT_TEXTAREA_CHG_TPL	= "Vous devez d\u0027abord selectionner un element";
	var CONFIRM_DELETE_TEMPLATE  = "Etes vous s\u00fbr de vouloir supprimer ce template?";
	var MAX_TEMPLATES_UP = "Nombre maximum de templates atteint";

	/* Scripts pour gestion des templates */
	function setTemplates (id) {
	if (CURRENT_OBJ != null) {
		document.getElementById(CURRENT_OBJ).style.backgroundColor="transparent";
		document.getElementById(CURRENT_OBJ).style.color="black";
	}
	CURRENT_OBJ = id;
	if(CURRENT_OBJ != tempOBJ){
  	  activebutton("majbttn");
	  vEdition=false;
	}else{
	  desactivebutton("majbttn");
	  vEdition=true;
	}

}

/* fonction pour la gestion des templates */
function manageTemplates(act) {
	var TMP_OBJ;
	if (CURRENT_OBJ != null || act == "add" || act =="raz") {
		switch (act) {
			case "add" :

						if (((count+1) > maxTemplates) && document.FORM_WRITE_MAIL.tplId.value==0)
						{
							alert(MAX_TEMPLATES_UP) ;
							break;
						}

							document.FORM_WRITE_MAIL.texte.value = document.FORM_WRITE_MAIL.ADDTEMPL.value;
							if (isTextFieldEmpty(document.FORM_WRITE_MAIL.texte)) {
								alert (INFO_GET_VALID_TITLE_TPL);
								highlightError (document.FORM_WRITE_MAIL.text);
								break;

   							}else{
   								maj_corps();
								if (document.FORM_WRITE_MAIL.ADDTEMPL.value==TXT_TEXTAREA_CHG_TPL) {
									document.FORM_WRITE_MAIL.texte.value="";
									document.FORM_WRITE_MAIL.type.value="";
								} else {
									document.FORM_WRITE_MAIL.texte.value=document.FORM_WRITE_MAIL.ADDTEMPL.value;
									document.FORM_WRITE_MAIL.type.value="";

								}

									if (document.FORM_WRITE_MAIL.texte.value==""){
										alert (INFO_GET_VALID_TITLE_TPL);
										highlightError (document.FORM_WRITE_MAIL.texte);
										return;
									}

									document.FORM_WRITE_MAIL.action="my_Settings_Template_submit.html";
									document.FORM_WRITE_MAIL.submit();
									break;
   							}
			case "del" :
							document.FORM_WRITE_MAIL.tplId.value = CURRENT_OBJ;
							CURRENT_OBJ = null;
					if ( window.confirm(CONFIRM_DELETE_TEMPLATE))
					{
						document.FORM_WRITE_MAIL.action="my_Settings_Template_submit_delete.html";
						document.FORM_WRITE_MAIL.submit();
					}
					else document.FORM_WRITE_MAIL.tplId.value=0 ;

							break;
			case "upd" :
						if(!vEdition){
							Edit(CURRENT_OBJ);
						}
							break;
			case "raz" :
				self.location="my_Settings_Template.html";
				break;

		}

		if (CURRENT_OBJ != null) {
			document.getElementById(CURRENT_OBJ).style.backgroundColor="#93AAD3";
			document.getElementById(CURRENT_OBJ).style.color="black";
		}
	}
	else
	if(!vEdition){
		alert (INFO_VALIDATION_SELECT_TEMPLATE_BEFORE);
	}
}

function ajaxProcessExpandAttachment(thisXMLObject,expandViewId){
	try {
		if (thisXMLObject.readyState == 4) {
			if (thisXMLObject.status == 200) {
				if (thisXMLObject.responseText) {
					var links = thisXMLObject.responseText.split("\n");
					var index = 0;
					for(var i=0; i< links.length; i++){
						if(links[i].search(/[\S]+/) != -1){
							document.getElementById("expandImg"+index).src = links[i];
							index++;
						}

					}
				}
			}
		}
	}catch(e){
		// rien
		ajaxExpandCalled = false;
	}
}

function openAttachmentExpandView(expandViewId, collapseViewId) {
	if(!ajaxExpandCalled){
		ajaxExpandCalled = true;
		try{
			// on appelle les thumbnails en ajax
			var url = "ajaxExpandAttachments.html";
			var params ="";
			if(document.location.search.indexOf("TYPE=edit") != -1){ // cas du brouillon
				params = "FOLDER="+document.getElementsByName("folderFunctionnalName")[0].value+"&UID="+document.getElementsByName("msg_id")[0].value+"&MODE=WRITE";
			}else if(ajaxFromWrite){ // write pur
				params = "MODE=WRITE";
			}else{ // read
				params = "FOLDER="+currentUserFolderFunctionnalName+"&UID="+MAIL_UID;
			}
			var xmlObject = newXMLObject();
			XMLRequestCaller(xmlObject, url,params, "GET", function() {ajaxProcessExpandAttachment(xmlObject,expandViewId)});
		}catch(e){
			//rien
			ajaxExpandCalled = false;
		}
	}
	document.getElementById (collapseViewId).style.display = "none";
	document.getElementById(expandViewId).style.display = "block";

	if (document.getElementById(expandViewId).clientHeight < document.getElementById(expandViewId).scrollHeight)
		document.getElementById('attachFiles').style.padding = "0 0 0 0";
}

function closeAttachmentExpandView(expandViewId, collapseViewId) {
	document.getElementById (expandViewId).style.display = "none";
	document.getElementById(collapseViewId).style.display = "block";
	document.getElementById('attachFiles').style.padding = "";
}

var OPEN_EXPAND = "open";
var CLOSE_EXPAND = "close";
var DOWNLOAD_LINK = "download";
var FILES = "Files";
var SLIDESHOW = "Image slideshow";
/* DDM 946: Mail - Photo services interconnection fonctionnalite 3 */
var TITLE_UPLOAD_PHOTO		= "Upload des photos";
var	UPLOAD_PHOTO_ACTIV		="pictures upload in progress<BR><BR><BR>";

/* S?paration Webmail/WebMU - Fonctionnalit?s R?pondre et transf?rer message Vocal */
var TITLE_UPLOAD_VOICEMESSAGE		= "[i18n:text.title.uploadvoicemessage]";
var	UPLOAD_VOICEMESSAGE		="[i18n:text.text.uploadvoicemessage]";

function encodeToHTML(string){
  var string = string.replace(/\r\n/g,"\n");
  var temp = "";

  for (var n = 0; n < string.length; n++) {
    var c = string.charCodeAt(n);
    if (c < 128) {
      switch(c){
			case 38 :
				temp +="&amp;";
				break;
			case 60 :
				temp +="&lt;";
				break;
			case 62 :
				temp +="&gt;";
				break;
			case 34 :
				temp +="&quot;";
				break; // '"'
      default: temp += String.fromCharCode(c);      
      }
    } else {
      switch(c){
        case 8364 :
				temp +="&euro;";
				break;
			case 161 :
				temp +="&iexcl;";
				break; // '?'
			case 162 :
				temp +="&cent;";
				break; // '?'
			case 163 :
				temp +="&pound;";
				break; // '?'
			case 164 :
				temp +="&curren;";
				break; // '?'
			case 165 :
				temp +="&yen;";
				break; // '?'
			case 170 :
				temp +="&ordf;";
				break; // '?'
			case 176 :
				temp +="&deg;";
				break; // '?'
			case 190 :
				temp +="&frac34;";
				break; // '?'
			case 189 :
				temp +="&frac12;";
				break; // '?'
			case 188 :
				temp +="&frac14;";
				break; // '?'
				// ??? case '?': temp +="&;";          break;
			case 171 :
				temp +="&laquo;";
				break; // '?'
			case 187 :
				temp +="&raquo;";
				break; // '?'
			case 34 :
				temp +="&quot;";
				break; // '"'
			case 193 :
				temp +="&Aacute;";
				break; // '?'
			case 225 :
				temp +="&aacute;";
				break; // '?'
			case 194 :
				temp +="&Acirc;";
				break; // '?'
			case 226 :
				temp +="&acirc;";
				break; // '?'
			case 192 :
				temp +="&Agrave;";
				break; // '?'
			case 224 :
				temp +="&agrave;";
				break; // '?'
			case 197 :
				temp +="&Aring;";
				break; // '?'
			case 229 :
				temp +="&aring;";
				break; // '?'
			case 195 :
				temp +="&Atilde;";
				break; // '?'
			case 227 :
				temp +="&atilde;";
				break; // '?'
			case 196 :
				temp +="&Auml;";
				break; // '?'
			case 228 :
				temp +="&auml;";
				break; // '?'
				// case '?': temp +="&ordf;";      break;
			case 198 :
				temp +="&AElig;";
				break; // '?'
			case 230 :
				temp +="&aelig;";
				break; // '?'
			case 199 :
				temp +="&Ccedil;";
				break; // '?'
			case 231 :
				temp +="&ccedil;";
				break; // '?'
			case 240 :
				temp +="&eth;";
				break; // '?'
			case 208 :
				temp +="&ETH;";
				break; // '?'
			case 201 :
				temp +="&Eacute;";
				break; // '?'
			case 233:
        temp +="&eacute;";
        break;
			case 202 :
				temp +="&Ecirc;";
				break; // '?'
			case 234 :
				temp +="&ecirc;";
				break; // '?'
			case 200 :
				temp +="&Egrave;";
				break; // '?'
			case 232 :
				temp +="&egrave;";
				break; // '?'
			case 203 :
				temp +="&Euml;";
				break; // '?'
			case 235 :
				temp +="&euml;";
				break; // '?'

			case 205 :
				temp +="&Iacute;";
				break; // '?'
			case 237 :
				temp +="&iacute;";
				break; // '?'
			case 206 :
				temp +="&Icirc;";
				break; // '?'
			case 238 :
				temp +="&icirc;";
				break; // '?'
			case 204 :
				temp +="&Igrave;";
				break; // '?'
			case 236 :
				temp +="&igrave;";
				break; // '?'
			case 207 :
				temp +="&Iuml;";
				break; // '?'
			case 239 :
				temp +="&iuml;";
				break; // '?'
			case 209 :
				temp +="&Ntilde;";
				break; // '?'
			case 211 :
				temp +="&Oacute;";
				break; // '?'
			case 243 :
				temp +="&oacute;";
				break; // '?'
			case 212 :
				temp +="&Ocirc;";
				break; // '?'
			case 244 :
				temp +="&ocirc;";
				break; // '?'
			case 210 :
				temp +="&Ograve;";
				break; // '?'
			case 242 :
				temp +="&ograve;";
				break; // '?'
			case 216 :
				temp +="&Oslash;";
				break; // '?'
			case 248 :
				temp +="&oslash;";
				break; // '?'
			case 213 :
				temp +="&Otilde;";
				break; // '?'
			case 245 :
				temp +="&otilde;";
				break; // '?'
			case 214 :
				temp +="&Ouml;";
				break; // '?'
			case 246 :
				temp +="&ouml;";
				break; // '?'

			case 223 :
				temp +="&szlig;";
				break; // '?'
			case 222 :
				temp +="&THORN;";
				break; // '?'
			case 254 :
				temp +="&thorn;";
				break; // '?'
			case 218 :
				temp +="&Uacute;";
				break; // '?'
			case 250 :
				temp +="&uacute;";
				break; // '?'
			case 219 :
				temp +="&Ucirc;";
				break; // '?'
			case 251 :
				temp +="&ucirc;";
				break; // '?'
			case 217 :
				temp +="&Ugrave;";
				break; // '?'
			case 249 :
				temp +="&ugrave;";
				break; // '?'
			case 220 :
				temp +="&Uuml;";
				break; // '?'
			case 252 :
				temp +="&uuml;";
				break; // '?'
			case 221 :
				temp +="&Yacute;";
				break; // '?'
			case 253 :
				temp +="&yacute;";
				break; // '?'
			case 255 :
				temp +="&yuml;";
				break; // '?'

        default: temp += String.fromCharCode(c);
      }
    }
  }
  return temp;
}

/* DDM 961: previsualisation des pieces jointes en html */
var TITLE_CONVERT		= "We are converting your file to be previewed";
var	TEXT_CONVERT		="";
var PREVIEW_LINK = "preview";
var TITLE_PREVIEW_ERROR		= "error opening attachment";
var	TEXT_PREVIEW_ERROR		="<b>We are sorry but there has been a<BR>problem opening this attachment.<BR><BR>Please close this window and try again</b>";
var	TEXT_FILE_PREVIEW_ERROR		="<b>We are sorry but there has been a problem opening this attachment.</b>";
var PREVIEW_LABEL_CLOSE = "Close";
var PREVIEW_ERROR_TECH = "Technical error";
var PREVIEW_ERROR_NOT_VIEWABLE = "Not viewable image?";
var PREVIEW_ERROR_TITLE = "Error";
var PREVIEW_ERROR_NONE = "&nbsp;";
var PREVIEW_DIV_IMG;
var PREVIEW_DIV_ERR;
var PREVIEW_OBJ_ERR_LABEL;

/**
 * Initialisation de la page "preview" lorsqu'il s'agit d'une image
 * idDivImg : id de l'objet div pour l'image a afficher 
 * idDivErr : id du div pour le message d'erreur  
 * idLabelError : id de l'objet label pour le message d'erreur 
 */ 
function preview_init(idDivImg,idDivErr,idLabelError)
{  
  PREVIEW_DIV_IMG = eval(document.getElementById(idDivImg));
  PREVIEW_DIV_ERR = eval(document.getElementById(idDivErr));
  PREVIEW_OBJ_ERR_LABEL = eval(document.getElementById(idLabelError));
}

/**
 * Affichage du div d'erreur et du message d'erreur
 * errorType : Type de l'erreur
 */
function preview_error(errorType)
{
  // On masque le div image et on affiche le div erreur
  PREVIEW_DIV_IMG.style.display="none";
  PREVIEW_DIV_ERR.style.display="block";  
  if (errorType == PREVIEW_ERROR_NOT_VIEWABLE){
		// On affiche le message d'erreur
    preview_setLabel(PREVIEW_OBJ_ERR_LABEL, errorType);
  } else {  
		// On affiche le message d'erreur 'PREVIEW_ERROR_TECH'
    preview_setLabel(PREVIEW_OBJ_ERR_LABEL, PREVIEW_ERROR_TECH);
  }
}

/**
 * Mise a jour du label
 * anObj : objet concerne par le label a afficher
 * aLabel : nouveau label a afficher
 */
function preview_setLabel(anObj,aLabel)
{
  if (anObj.innerHTML) {
	   anObj.innerHTML = aLabel;
	} else {
	   anObj.open();
	   anObj.writeln(aLabel);
	   anObj.close();
	}
}
/* DDM 975 : Mobilite */
/* Textes et liens param?trables par FT dans le menu  de gauche */
	var MENU_INBOX_ITEM		= "astuces";
	var MENU_WELCOME_ITEM		= "astuces";
	var MENU_OPTIONS_LABEL = "Other options & services";

/**
 * retourne l'object en fonction de l'id
 * anId : id de l'objet concerne
 */
function getObjLabel(idObj)
{
  if (document.getElementById&&!document.all) {
      MY_OBJ = document.getElementById(idObj);
  }else if (document.all) {
      MY_OBJ = document.all[idObj];
	}else if (document.layers) {
	    MY_OBJ = document.layers[idObj];
	}
	return MY_OBJ;
}
