positionX = 0;
positionY = 0;
winWidth = getWindowWidth();
winHeight = getWindowHeight();
document.onmousemove = position;
previewCanMoved = true;
dragDropType = "";
dragDropId = "";
window.onerror = function (msg, url, line) 
{
	ajaxHttpRequest(null,'/ajaxJavascriptError.php','msg='+msg+'&url='+url+'&line='+line+'&browser='+navigator.userAgent,0);
}
function winopen(page,query,largeur,hauteur,lightbox)
{
	winopen1(page,query,"_blank",largeur,hauteur,lightbox,"no");
}
function winopen1(page,query,target,largeur,hauteur,lightbox,menubar)
{
	if (lightbox=='1')
	{
		showLightboxPage(page,query,largeur,hauteur);
	}
	else
	{
		var top = (screen.height-hauteur)/2;
		if (top>40)
			top = top-40;
		var left = (screen.width-largeur)/2;
		if (menubar!="no")
			menubar = "yes";
		if (query=="")
			open(page,target,"toolbar=no,location=no,directories=no,status=yes,menubar="+menubar+",scrollbars=yes,resizable=yes,width="+largeur+",height="+hauteur+",top="+top+",left="+left);
		else
			open(page+"?"+query,target,"toolbar=no,location=no,directories=no,status=yes,menubar="+menubar+",scrollbars=yes,resizable=yes,width="+largeur+",height="+hauteur+",top="+top+",left="+left);
	}
}
function URLEncode(text)
{
	text = encodeURI(text);
	text = text.replace(/\+/g, '%2B');
	text = text.replace(/%20/g, '+');
	text = text.replace(/\*/g, '%2A');
	text = text.replace(/\//g, '%2F');
	text = text.replace(/@/g, '%40');
	text = text.replace(/\?/g, '%3F');
	text = text.replace(/&/g, '%26');
	text = text.replace(/=/g, '%3D');
	text = text.replace(/#/g, '%23');
	return text;
}
function position(e) 
{
	if (e)
	{
		positionX = e.pageX;
		positionY = e.pageY;
	}
	else
	{
		var DocRef;

		positionX = event.clientX;
		positionY = event.clientY;

		if( document.documentElement && document.documentElement.clientWidth)
			DocRef = document.documentElement;
		else
			DocRef = document.body;

		positionX += DocRef.scrollLeft;
		positionY += DocRef.scrollTop;
	}

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	var elemDiv = 'ajaxPreviewID';
	var divID = document.getElementById(elemDiv);
	if (div && div.innerHTML!='' && divID && divID.innerHTML!='chooseEncode' && divID.innerHTML!='chooseLang' && divID.innerHTML!='repetition' && divID.innerHTML!='linkData' && divID.innerHTML!='contactPhotoAdd' && divID.innerHTML.substring(0,6)!='mobile' && divID.innerHTML.substring(0,10)!='showAction')
		movePreview('ajaxPreview',0,1);
}
function showImage(elemId, image, width, height, positionImageX, positionImageY) 
{
	if (document.getElementById(elemId))
	{
		document.getElementById(elemId).width = width;
		document.getElementById(elemId).height = height;
		if (positionImageX!=null && positionImageY!=null)
		{
			document.getElementById(elemId).style.display = "block";
			document.getElementById(elemId).style.left = (positionX+positionImageX)+"px";
			document.getElementById(elemId).style.top = (positionY+positionImageY)+"px";
		}
		document.getElementById(elemId).src = image;
	}
}
function hideImage(elemId) 
{
	if (document.getElementById(elemId))
	{
		document.getElementById(elemId).style.display = "none";
		document.getElementById(elemId).width = '120';
		document.getElementById(elemId).height = '90';
	}
}
function showThumb(url, nb, elem) 
{
	if (nb==null)
		var nb = 0;

	if (elem==null)
		var elem = 'thumbshot';

	var testImage = new Image();
	var adresseImage = 'http://open.thumbshots.org/image.aspx?url='+URLEncode(url);
	testImage.src = adresseImage;

	if (testImage.height>1)
		showImage(elem,adresseImage,'120','90',10,10);
	else if (nb==0)
		setTimeout('showThumb(\''+url+'\',1,\''+elem+'\');',800);
	else
		showImage(elem,'http://static.memotoo.com/img/158.gif','120','90',10,10);
}
function hideThumb() 
{
	hideImage('thumbshot');
	document.getElementById('thumbshot').src = "http://static.memotoo.com/img/109.gif";
}
function isThumb(imageId) 
{
	try
	{
		var idTmp = document.getElementById(imageId);
		if (idTmp && idTmp.height<=1)
			idTmp.src = "http://static.memotoo.com/img/158.gif";
	} 
	catch(e) {}
}
function getThumb(url, nb) 
{
	if (nb==null)
		var nb = 0;

	var elem = 'thumbshot1';

	var testImage = new Image();
	var adresseImage = 'http://open.thumbshots.org/image.aspx?url='+URLEncode(url);
	testImage.src = adresseImage;

	if (testImage.height>1)
		showImage(elem,adresseImage,'120','90',null,null);
	else if (nb==0)
		setTimeout('getThumb(\''+url+'\',1);',1200);
	else
		showImage(elem,'http://static.memotoo.com/img/158.gif','120','90',null,null);
}
function getReloadPage(query) 
{
	if (query!='' && query!='undefined')
		return query+'&reload='+URLEncode(getInfoPage(true));
	else 
		return 'reload='+URLEncode(getInfoPage(true));
}
function getInfoPage(addPage) 
{
	var formTmp = document.getElementById('infopage');
	var strTmp = '';

	if (formTmp && formTmp.page.value!='')
	{
		if (formTmp.rub.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'rub='+URLEncode(formTmp.rub.value);
		}
		if (formTmp.dir.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'dir='+URLEncode(formTmp.dir.value);
		}
		if (formTmp.id.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'id='+URLEncode(formTmp.id.value);
		}
		if (formTmp.selection.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'selection='+URLEncode(formTmp.selection.value);
		}
		if (formTmp.show.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'show='+URLEncode(formTmp.show.value);
		}
		if (formTmp.tag.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'tag='+URLEncode(formTmp.tag.value);
		}
		if (formTmp.sort.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'sort='+URLEncode(formTmp.sort.value);
		}
		if (formTmp.by.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'by='+URLEncode(formTmp.by.value);
		}
		if (formTmp.search.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'search='+URLEncode(formTmp.search.value);
		}
		if (formTmp.lettre.value!='')
		{
			if (strTmp!='')	strTmp += '&';
			strTmp += 'lettre='+URLEncode(formTmp.lettre.value);
		}

		if (strTmp!='')
		{
			if (addPage)
				strTmp = formTmp.page.value+'?'+strTmp;
			else
				strTmp = strTmp;
		}
		else if (addPage)
			strTmp = formTmp.page.value;
	}

	return strTmp;
}
function goweb(url) 
{
	if (url=="http://" || url=="") 
		url = "http://www.memotoo.com/my-bookmarks.php";
	else if (url.substring(0,1)==">") 
		url = "http://www.memotoo.com/my-bookmarks.php?action=changedir&dir="+url.substring(1,url.length);
	else if (url.substring(0,3)=="www") 
		url = "http://"+url;

	var div = document.getElementById("web");
	if (div) 
		div.src = url;

	majUrlBarre(url);
}
function puturl(url) 
{
	if (document.getElementById('formBarre') && document.getElementById('formBarre').url1)
		document.getElementById('formBarre').url1.value = url;
	else if (top && top.parent && top.parent.document && top.parent.document.getElementById("formBarre")) 
		top.parent.document.getElementById('formBarre').url1.value = url;
}
function majUrlBarre(url) 
{
	if (document.getElementById('formBarre') && document.getElementById('formBarre').url1) 
		document.getElementById('formBarre').url1.value = url;
	if (top && top.parent && top.parent.document && top.parent.document.getElementById("formBarre")) 
		top.parent.document.getElementById('formBarre').url1.value = url;
}
function getUrlBarre() 
{
	if (document.getElementById('formBarre') && document.getElementById('formBarre').url1)
		return document.getElementById('formBarre').url1.value;
	else if (top && top.parent && top.parent.document && top.parent.document.getElementById("formBarre")) 
		return top.parent.document.getElementById('formBarre').url1.value;
	else
		return "";
}
function help(lightbox) 
{
	winopen('/aide.php','simpleHeader=1','740','600',lightbox);
}
function showBookmark(id,lightbox)
{
	winopen('/infofavori.php',getReloadPage('id='+id),'550','486',lightbox);
}
function modifyBookmark(id,lightbox)
{
	winopen('/modifierfavori.php',getReloadPage('id='+id),'550','486',lightbox);
}
function modifyBookmarkFolder(id,lightbox)
{
	winopen('/modifierdfav.php',getReloadPage('id='+id),'510','226',lightbox);
}
function validityBookmark(dossier,lightbox)
{
	winopen('/validitefavori.php','dir='+dossier,'550','600',lightbox);
}
function addBookmark(barre,url,lightbox)
{
	winopen('/ajouterfavori.php','barre='+barre+'&url='+url,'550','486',lightbox);
}
function searchBookmark(query,lightbox)
{
	winopen('/rechercherfavori.php',query,'550','600',lightbox);
}
function moveBookmark(query,lightbox)
{
	winopen('/deplacerFavori.php',getReloadPage(query),'510','320',lightbox);
}
function goUrl(url) 
{
	if (url!="" && url!="file://" && url!="ftp://" && url!="http://" && url!="https://") 
		window.open("/go.php?url="+URLEncode(url),"_blank");
	else
		alert("Enter an address ...");
}
function showContact(id,lightbox)
{
	winopen('/infocontact.php',getReloadPage('id='+id),'720','1020',lightbox);
}
function modifyContact(id,lightbox)
{
	winopen('/modifiercontact.php',getReloadPage('id='+id),'720','1020',lightbox);
}
function modifyContacts(query,lightbox)
{
	winopen('/modifierContacts.php',getReloadPage(query),'510','400',lightbox);
}
function modifyContactFolder(id,lightbox) 
{
	winopen('/modifierContactGroupe.php',getReloadPage('id='+id),'510','226',lightbox);
}
function moveContact(query,lightbox)
{
	winopen('/deplacerContact.php',getReloadPage(query),'510','320',lightbox);
}
function modifyNote(id,lightbox)
{
	winopen('/modifierPostIt.php',getReloadPage('id='+id),'620','546',lightbox);
}
function modifyTask(id,lightbox)
{
	winopen('/modifierTask.php',getReloadPage('id='+id),'620','536',lightbox);
}
function addCategory(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierCategorie.php','noreload=1','510','236',lightbox);
	else
		winopen('/modifierCategorie.php',getReloadPage(''),'510','236',lightbox);
}
function addCategoryFeed(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierCategorie.php','noreload=1&type=feed','510','276',lightbox);
	else
		winopen('/modifierCategorie.php',getReloadPage('type=feed'),'510','276',lightbox);
}
function modifyCategory(id,lightbox)
{
	winopen('/modifierCategorie.php',getReloadPage('id='+id),'510','236',lightbox);
}
function modifyCategoryFeed(id,lightbox)
{
	winopen('/modifierCategorie.php',getReloadPage('id='+id),'510','286',lightbox);
}
function addEventWithContact(mktime,guests,lightbox,reload)
{
	if (reload==0)
		winopen('/modifieragenda.php','noreload=1&mktime='+mktime+'&guests='+guests,'620','556',lightbox);
	else
		winopen('/modifieragenda.php',getReloadPage('mktime='+mktime+'&guests='+guests),'620','556',lightbox);
}
function addTask(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierTask.php','noreload=1','620','536',lightbox);
	else
		winopen('/modifierTask.php',getReloadPage(''),'620','536',lightbox);
}
function addNote(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierPostIt.php','noreload=1','620','546',lightbox);
	else
		winopen('/modifierPostIt.php',getReloadPage(''),'620','546',lightbox);
}
function showEvent(id,lightbox)
{
	winopen('/infoagenda.php',getReloadPage('id='+id),'620','556',lightbox);
}
function showSms(id,lightbox)
{
	winopen('/infoSms.php',getReloadPage('id='+id),'510','350',lightbox);
}
function showMail(id,type,lightbox)
{
	winopen('/infoMail.php',getReloadPage('id='+id+'&type='+type),'700','460',lightbox);
}
function showMailInAccount(id,account,lightbox,changeMailbox)
{
	winopen('/infoMail.php',getReloadPage('id='+id+'&type=mailHistory&account='+account+'&changeMailbox='+changeMailbox),'700','460',lightbox);
}
function inviteFriends(id,lightbox)
{
	winopen('/inviteFriends.php','id='+id,'600','400',lightbox);
}
function showProfile(id,lightbox)
{
	winopen('/profile/'+id,'','980','560',lightbox);
}
function askProfileShare(query,lightbox) 
{
	winopen('/transferDataMail.php',query,'700','440',lightbox);
}
function transferDataFile(query,lightbox)
{
	winopen('/transferDataMail.php',query,'700','500',lightbox);
}
function transferDataAskContact(query,lightbox) 
{
	winopen('/transferDataMail.php',query,'700','440',lightbox);
}
function transferData(query,lightbox) 
{
	winopen('/transferDataMail.php',query,'700','500',lightbox);
}
function shareData(query,lightbox)
{
	winopen('/shareData.php',query,'740','420',lightbox);
}
function modifySharedData(query,lightbox)
{
	winopen('/shareData.php',query,'560','340',lightbox);
}
function linkData(query) 
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML=='linkData')
		closePreview();

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = "350px";
	div.style.left = (positionX-320)+"px";
	div.style.top = (positionY+4)+"px";
	ajaxHttpRequest(elemDiv,'ajaxLinkData.php',query,0);
	div.style.display = 'block';

	divID.innerHTML = 'linkData';
}
function publicProfile(query) 
{
	ajaxHttpRequest('publicProfile','ajaxLinkProfile.php',query,1,'document.formLinkProfile.url.focus()');
}
function showMailing(id,lightbox)
{
	winopen('/infomailing.php',getReloadPage('id='+id),'550','486',lightbox);
}
function modifyMailing(id,lightbox)
{
	winopen('/modifiermailing.php',getReloadPage('id='+id),'550','486',lightbox);
}
function sendEmail(to,lightbox)
{
	winopen('/sendMail.php','contact='+to,'700','460',lightbox);
}
function sendEmailAccount(to,from,subject,msg,lightbox)
{
	winopen('/sendMail.php','contact='+to+'&from='+from+'&subject64='+URLEncode(subject)+'&msg64='+URLEncode(msg),'700','460',lightbox);
}
function sendSms(to,lightbox)
{
	winopen('/sendSms.php','contact='+to,'700','340',lightbox);
}
function sendSmsPhone(phone,lightbox)
{
	winopen('/sendSms.php','phone='+URLEncode(phone),'700','340',lightbox);
}
function startDrag(ev,typeTmp,idTmp) 
{
	dragDropType = typeTmp;
	dragDropId = idTmp;

	ev.dataTransfer.effectAllowed='move';
	showPreviewInfos("MoveData","PGRpdiBhbGlnbj0iY2VudGVyIj5Nb3ZlIGludG8gYSBmb2xkZXI/PC9kaXY+",180);

	return true;
}
function enterDrag(ev) 
{
	return true;
}
function endDrag(ev) 
{
	closePreview();
	dragDropType = "";
	dragDropId = "";
	return true;
}
function overDrag(ev) 
{
	return false;
}
function drop(ev,newDossier) 
{
	if (dragDropId!="" && dragDropType!="")
	{
		if (dragDropType=="bookmarkFolder")
			location.href = location.pathname+"?action=moveBookmarkFolder&id="+URLEncode(dragDropId)+"&newdos="+URLEncode(newDossier);	
		else if (dragDropType=="bookmark")
			location.href = location.pathname+"?action=moveBookmarks&id="+URLEncode(dragDropId)+"&newdos="+URLEncode(newDossier);
		else if (dragDropType=="contact")
			location.href = location.pathname+"?action=moveContacts&id="+URLEncode(dragDropId)+"&newdos="+URLEncode(newDossier);
		else if (dragDropType=="fileFolder")
			location.href = location.pathname+"?action=moveFileFolder&id64="+URLEncode(dragDropId)+"&newdos64="+URLEncode(newDossier);	
		else if (dragDropType=="file")
			location.href = location.pathname+"?action=moveFile&id64="+URLEncode(dragDropId)+"&newdos64="+URLEncode(newDossier);
		else if (dragDropType=="email")
			moveMsg(dragDropId,newDossier);
	}
	return false;
}
function couleurMouseOver(elem) 
{
	elem.id = elem.id+"Hover";
}
function couleurMouseOut(elem) 
{
	elem.id = elem.id.replace("Hover", "");
}
function addSearchEngine()
{
	if (window.external && ("AddSearchProvider" in window.external))
		window.external.AddSearchProvider("http://www.memotoo.com/searchEngine/memotooOpenSearch.src");
	else if (window.sidebar && ("addSearchEngine" in window.sidebar))
		window.sidebar.addSearchEngine("http://www.memotoo.com/searchEngine/memotooSearch.src","http://www.memotoo.com/searchEngine/memotooSearch.png", "Memotoo.com search", "Web Tools");
	else
		alert("No search engine support");
}
function showSearchMemotooBookmarks() 
{
	document.getElementById("menuSearchMemotooBookmarks").className = 'menu';
	document.getElementById("menuSearchGoogle").className = 'menuHidden';
	document.getElementById("menuSearchYahoo").className = 'menuHidden';
	document.getElementById("menuSearchWikipedia").className = 'menuHidden';
	document.getElementById("searchMemotooBookmarks").style.display = 'block';
 	document.getElementById("searchGoogle").style.display = 'none';
 	document.getElementById("searchYahoo").style.display = 'none';
	document.getElementById("searchWikipedia").style.display = 'none';
}
function showSearchGoogle() 
{
	document.getElementById("menuSearchMemotooBookmarks").className = 'menuHidden';
	document.getElementById("menuSearchGoogle").className = 'menu';
	document.getElementById("menuSearchYahoo").className = 'menuHidden';
	document.getElementById("menuSearchWikipedia").className = 'menuHidden';
	document.getElementById("searchMemotooBookmarks").style.display = 'none';
 	document.getElementById("searchGoogle").style.display = 'block';
 	document.getElementById("searchYahoo").style.display = 'none';
	document.getElementById("searchWikipedia").style.display = 'none';
}
function showSearchYahoo() 
{
	document.getElementById("menuSearchMemotooBookmarks").className = 'menuHidden';
	document.getElementById("menuSearchGoogle").className = 'menuHidden';
	document.getElementById("menuSearchYahoo").className = 'menu';
	document.getElementById("menuSearchWikipedia").className = 'menuHidden';
	document.getElementById("searchMemotooBookmarks").style.display = 'none';
 	document.getElementById("searchGoogle").style.display = 'none';
 	document.getElementById("searchYahoo").style.display = 'block';
	document.getElementById("searchWikipedia").style.display = 'none';
}
function showSearchWikipedia() 
{
	document.getElementById("menuSearchMemotooBookmarks").className = 'menuHidden';
	document.getElementById("menuSearchGoogle").className = 'menuHidden';
	document.getElementById("menuSearchYahoo").className = 'menuHidden';
	document.getElementById("menuSearchWikipedia").className = 'menu';
	document.getElementById("searchMemotooBookmarks").style.display = 'none';
 	document.getElementById("searchGoogle").style.display = 'none';
 	document.getElementById("searchYahoo").style.display = 'none';
	document.getElementById("searchWikipedia").style.display = 'block';	
}
function formCheckBoxSelectAll(form) 
{
	for(var i=0;i<eval("document."+form+".nbbox.value");i++) 
	{
		eval("document."+form+".chkbox"+i+".checked = true;");
	}
}
function formCheckBoxUnselectAll(form) 
{
	for(var i=0;i<eval("document."+form+".nbbox.value");i++) 
	{
		eval("document."+form+".chkbox"+i+".checked = false;");
	}
}
function formCheckBoxInvert(form) 
{
	for(var i=0;i<eval("document."+form+".nbbox.value");i++) 
	{
		if (eval("document."+form+".chkbox"+i+".checked"))
			eval("document."+form+".chkbox"+i+".checked = false;");
		else
			eval("document."+form+".chkbox"+i+".checked = true;");
	}
}
function formCheckBoxSelection(form) 
{
	var strTmp = "";
	for(var i=0;i<eval("document."+form+".nbbox.value");i++) 
	{
		if(eval("document."+form+".chkbox"+i+".checked")) 
		{
			if (strTmp!="") 
			{
				strTmp = strTmp+",";
			}
			eval("strTmp = strTmp+document."+form+".chkbox"+i+".value");
		}
	}
	return strTmp;
}
function formCheckBoxDeleteSelection(form,action,idAjax,pageAjax,functionAfterLoad) 
{
	var strTmp = formCheckBoxSelection(form);
	eval("document."+form+".selection.value = '"+strTmp+"'");
	if (idAjax!=null && pageAjax!=null)
		eval("document."+form+".action = 'javascript:ajaxHttpRequest(\"'+idAjax+'\",\"'+pageAjax+'\",\"'+action+'&selection='+strTmp+'\",1,\"'+functionAfterLoad+'\")'");
	else
		eval("document."+form+".action = '"+action+"'");
	if (strTmp!="")
	{
		if (confirm ("Do you really want to delete this selection?"))
			eval("document."+form+".submit()");
	}
	else
		confirm ("No data selected ...");
}
function formCheckBoxModifySelection(form,type,lightbox) 
{
	var strTmp = formCheckBoxSelection(form);
	if (type=="contacts")
	{
		if (strTmp!="" && strTmp.length>1000)
		{
			eval("document."+form+".action = '/modifierContacts.php'");
			eval("document."+form+".target = '_blank'");
			eval("document."+form+".selection.value = '"+strTmp+"'");
			eval("document."+form+".submit()");
			eval("document."+form+".target = '_self'");
		}
		else if (strTmp!="")
		{
			eval("document."+form+".action = 'javascript:modifyContacts(\"selection="+strTmp+"\","+lightbox+")'");
			eval("document."+form+".submit()");
		}
		else
			confirm ("No data selected ...");
	}
}
function formCheckBoxMoveSelection(form,type,lightbox) 
{
	var strTmp = formCheckBoxSelection(form);
	if (type=="bookmarks")
	{
		if (strTmp!="" && strTmp.length>1000)
		{
			eval("document."+form+".action = '/deplacerFavori.php'");
			eval("document."+form+".target = '_blank'");
			eval("document."+form+".selection.value = '"+strTmp+"'");
			eval("document."+form+".submit()");
			eval("document."+form+".target = '_self'");
		}
		else if (strTmp!="")
		{
			eval("document."+form+".action = 'javascript:moveBookmark(\"selection="+strTmp+"\","+lightbox+")'");
			eval("document."+form+".submit()");
		}
		else
			confirm ("No data selected ...");
	}
	else if (type=="contacts")
	{
		if (strTmp!="" && strTmp.length>1000)
		{
			eval("document."+form+".action = '/deplacerContact.php'");
			eval("document."+form+".target = '_blank'");
			eval("document."+form+".selection.value = '"+strTmp+"'");
			eval("document."+form+".submit()");
			eval("document."+form+".target = '_self'");
		}
		else if (strTmp!="")
		{
			eval("document."+form+".action = 'javascript:moveContact(\"selection="+strTmp+"\","+lightbox+")'");
			eval("document."+form+".submit()");
		}
		else
			confirm ("No data selected ...");
	}
}
function formCheckBoxPrivateSelection(form,action,idAjax,pageAjax) 
{
	var strTmp = formCheckBoxSelection(form);
	eval("document."+form+".selection.value = '"+strTmp+"'");
	if (idAjax!=null && pageAjax!=null)
		eval("document."+form+".action = 'javascript:ajaxHttpRequest(\"'+idAjax+'\",\"'+pageAjax+'\",\"'+action+'&selection='+strTmp+'\",1)'");
	else
		eval("document."+form+".action = '"+action+"'");
	if (strTmp!="")
	{
		if (confirm ("Do you really want to mark these events private?"))
			eval("document."+form+".submit()");
	}
	else
		confirm ("No data selected ...");
}
function formCheckBoxPublicSelection(form, action, idAjax, pageAjax) 
{
	var strTmp = formCheckBoxSelection(form);
	eval("document."+form+".selection.value = '"+strTmp+"'");
	if (idAjax!=null && pageAjax!=null)
		eval("document."+form+".action = 'javascript:ajaxHttpRequest(\"'+idAjax+'\",\"'+pageAjax+'\",\"'+action+'&selection='+strTmp+'\",1)'");
	else
		eval("document."+form+".action = '"+action+"'");
	if (strTmp!="")
	{
		if (confirm ("Do you really want to mark these events public?"))
			eval("document."+form+".submit()");
	}
	else
		confirm ("No data selected ...");
}
function formCheckBoxChangeSelection(form, action, idAjax, pageAjax, functionAfterLoad) 
{
	var strTmp = formCheckBoxSelection(form);
	eval("document."+form+".selection.value = '"+strTmp+"'");
	if (idAjax!=null && pageAjax!=null)
		eval("document."+form+".action = 'javascript:ajaxHttpRequest(\"'+idAjax+'\",\"'+pageAjax+'\",\"'+action+'&selection='+strTmp+'\",1,\"'+functionAfterLoad+'\")'");
	else
		eval("document."+form+".action = '"+action+"'");
	if (strTmp!="")
	{
		if (confirm ("Do you really want to change this data?"))
			eval("document."+form+".submit()");
	}
	else
		confirm ("No data selected ...");
}
function formCheckBoxTransferSelection(form,action,lightbox) 
{
	var strTmp = formCheckBoxSelection(form);
	eval("document."+form+".selection.value = '"+strTmp+"'");
	eval("document."+form+".action = 'javascript:transferData(\"action=transfer"+action+"&selection="+strTmp+"\","+lightbox+")'");
	if (strTmp!="")
		eval("document."+form+".submit()");
	else
		confirm ("No data selected ...");
}
function formCheckBoxPurgeSyncMLSelection(form, sync)
{
	var strTmp = formCheckBoxSelection(form);
	if (strTmp!="")
		confirmPurgeSyncML(sync, '2', strTmp);
	else
		confirm ("No data selected ...");
}
function formCheckBoxMergeContactsSelection(form,action) 
{
	var strTmp = formCheckBoxSelection(form);
	if (strTmp!="")
	{
		if (confirm ("Do you really want to merge these contacts into only 1 contact ?"))
		{
 			document.getElementById("memotoocontacts").style.display = 'none';
			document.getElementById("memotooiframe").style.display = 'block';
			document.getElementById("memotooiframe").src="/mescontactsMerge.php?"+action+"&selection="+strTmp;
		}
	}
	else
		confirm ("No data selected ...");
}
function formCheckBoxMergeContactsSelection1(form,action) 
{
	var strTmp = formCheckBoxSelection(form);
	if (strTmp!="")
	{
		if (confirm ("Do you really want to merge these contacts into only 1 contact ?"))
		{
 			location.href="/mescontactsMerge.php?"+action+"&selection="+strTmp;
		}
	}
	else
		confirm ("No data selected ...");
}
function showId(id) 
{
 	var styleTmp = document.getElementById(id).style.display;
 	if (styleTmp=='none' || styleTmp=='')
 	 	document.getElementById(id).style.display = 'block';
 	else
 	 	document.getElementById(id).style.display = 'none';
}
function displayId(id) 
{
 	document.getElementById(id).style.display = 'block';
}
function displayId1(id) 
{
 	document.getElementById(id).style.display = 'table-row';
}
function displayId2(id) 
{
 	document.getElementById(id).style.display = 'inline';
}
function hideId(id) 
{
 	document.getElementById(id).style.display = 'none';
}
function ajaxHttpRequest(elemDiv, page, data, loading, functionAfterLoad)
{
	var XhrObj = false;
	var div = null;
	if (elemDiv)
	{
		if (document.getElementById(elemDiv))
			div = document.getElementById(elemDiv);
		else if (top && top.opener && top.opener.parent && top.opener.parent.document && top.opener.parent.document.getElementById(elemDiv))
			div = top.opener.parent.document.getElementById(elemDiv);
		else if (top && top.parent && top.parent.document && top.parent.document.getElementById(elemDiv))
			div = top.parent.document.getElementById(elemDiv);

		if (div && loading=="1")
			div.innerHTML = "<div align=\"center\"><br /><br /><font class=\"texteDiscret\">Loading...</font><br /><br /><img src=\"http://static.memotoo.com/img/loading2.gif\" width=\"32\" height=\"32\" border=\"0\" alt=\"Loading\" title=\"Loading\" /><br /><br /></div>";
		else if (div && loading=="2")
			div.innerHTML = "<div align=\"center\"><img src=\"http://static.memotoo.com/img/loading.gif\" width=\"20\" height=\"20\" vspace=\"6\" border=\"0\" alt=\"Loading\" title=\"Loading\" /></div>";
		else if (div && loading=="2big")
			div.innerHTML = "<div align=\"center\"><img src=\"http://static.memotoo.com/img/loading2.gif\" width=\"32\" height=\"32\" vspace=\"6\" border=\"0\" alt=\"Loading\" title=\"Loading\" /></div>";
		else if (div && loading=="3")
			div.innerHTML = "<div align=\"center\" style=\"background-color:#ffffff;padding:6px\"><img src=\"http://static.memotoo.com/img/loading2.gif\" width=\"32\" height=\"32\" vspace=\"6\" border=\"0\" alt=\"Loading\" title=\"Loading\" /></div>";
	}

	if (page!='')
	{
		if(window.XMLHttpRequest)
		{
	   XhrObj = new XMLHttpRequest(); 
		}
		else if(window.ActiveXObject)
		{
			try
			{
				XhrObj = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
			{
				XhrObj = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		else 
		{
			XhrObj = false; 
		}		

		if (XhrObj)
		{
			XhrObj.open("POST", page, true);
			XhrObj.onreadystatechange = function()
			{
				if (XhrObj.readyState==4 && XhrObj.status==200)
				{
					if (div)
						div.innerHTML = XhrObj.responseText;
					else
						eval(XhrObj.responseText); 

					if (functionAfterLoad && functionAfterLoad!="")
						eval(""+functionAfterLoad+";");
				}
			}
			XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			XhrObj.send(data);
		}
		else 
		{
			alert("Your browser doesn't support the XMLHTTPRequest objects...");
		}
	}
}
function browseFolder(id, image) 
{
	var objMemotooArbre = document.getElementById("memotooarbre");

	objMemotooArbre.style.display = "none";

	var objFolder = document.getElementById(id);
	var objImage = document.getElementById(image);

	if (objImage.name=="plus") 
	{
		objImage.name = "moins";
		objImage.src = image1.src;
		objFolder.style.display = "block";
	}
	else
	{
		objImage.name = "plus";
		objImage.src = image2.src;
		objFolder.style.display = "none";
	}

	objMemotooArbre.style.display = "block";
}
function browseFolderAjax(page,pere,espace,id,image,query) 
{
	if (query!="") 
		ajaxHttpRequest(id,page,'colorMouseOver=ffcc66&pere='+pere+'&espace='+espace+'&'+query,2);
	else
		ajaxHttpRequest(id,page,'colorMouseOver=ffcc66&pere='+pere+'&espace='+espace,2);
	browseFolder(id,image);
}
function showDevise(devise) 
{
	var tabDevise = new Array("AUD", "CAD", "EUR","GBP", "JPY", "USD");
	for(var i=0;i<tabDevise.length;i=i+1)
	{
		eval("document.getElementById('"+tabDevise[i]+"1_1').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"1_2').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"12_1').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"12_2').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"18_1').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"18_2').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"24_1').style.display = 'none';");
		eval("document.getElementById('"+tabDevise[i]+"24_2').style.display = 'none';");
	}
	eval("document.getElementById('"+devise+"1_1').style.display = 'inline';");
	eval("document.getElementById('"+devise+"1_2').style.display = 'inline';");
	eval("document.getElementById('"+devise+"12_1').style.display = 'inline';");
	eval("document.getElementById('"+devise+"12_2').style.display = 'inline';");
	eval("document.getElementById('"+devise+"18_1').style.display = 'inline';");
	eval("document.getElementById('"+devise+"18_2').style.display = 'inline';");
	eval("document.getElementById('"+devise+"24_1').style.display = 'inline';");
	eval("document.getElementById('"+devise+"24_2').style.display = 'inline';");
}
function showPriceStorage(storage, devise) 
{
	ajaxHttpRequest("infoPriceStorage","ajaxPriceStorage.php","storage="+storage+"&devise="+devise,2);
}
function showSmsCredit(idgateway) 
{
	ajaxHttpRequest("smsCredit","ajaxSmsCredit.php","show=select&idgateway="+idgateway,2);
}
function showSmsCredit1(idgateway) 
{
	ajaxHttpRequest("smsCredit"+idgateway,"ajaxSmsCredit.php","idgateway="+idgateway,0);
}
function moveSelectedOptions(from, to)
{
	var fromSelect = document.getElementById(from);
	var selOptions = getSelectedOptions(fromSelect);
	if(selOptions.length>0)
	{
		var toSelect=document.getElementById(to);
		for(i=0;i<selOptions.length;i++)
		{
			option = selOptions[i];
			fromSelect.removeChild(option);	
			toSelect.appendChild(option);
		}
	}
}
function getSelectedValues(select)
{
	var selValues = new Array();
	if (select && select.options)
	{
		for (var i=0;i<select.options.length;i++)
		{
			if (select.options[i].selected)
			{
				selValues[selValues.length] = select.options[i].value;
			}
		}
	}
	return selValues;
}
function getSelectedOptions(select) 
{
	var selOptions  = new Array();
	if (select && select.options)
	{
		for (var i=0;i<select.options.length;i++)
		{
			if (select.options[i].selected)
			{
				selOptions[selOptions.length] = select.options[i];
			}
		}
	}
	return selOptions;
}
function selectAllAndSubmit(form, select) 
{
	var select = document.getElementById(select);
	for (var i=0;i<select.options.length;i++)
	{
		if (select.options[i].value!="")
		{
			select.options[i].selected = true;
		}
	}
	eval("document."+form+".submit();");
}
function selectAllAndSubmit1(form, select) 
{
	var select = document.getElementById(select);
	for (var i=0;i<select.options.length;i++)
	{
		if (select.options[i].value!="")
		{
			select.options[i].selected = true;
		}
	}
	eval("document.getElementById('"+form+"').submit();");
}
function updateSyncSettingsDb(elemId, db, to, settings2)
{
	var settings1 = db;
	if (document.getElementById(elemId))
	{
		var selValues = getSelectedValues(document.getElementById(elemId));
		if(selValues.length>0)
		{
			for(i=0;i<selValues.length;i++)
			{
				if (selValues[i]!="")
					settings1 += '.'+selValues[i];
			}
		}
	}
	document.getElementById(to).innerHTML = settings1+settings2;
}
function searchAddressOk(adresse, cp, ville, state, pays) 
{
	if (adresse!="" && (cp!="" || ville!="" || state!="" || (pays!="0" && pays!="")))
	{
        	return true;
	}
	else if (ville!="")
	{
		return true;
	}
	else if ((cp!="" || ville!="" || state!="") && (pays!="0" && pays!=""))
	{
		return true;
	}
	else if (adresse!="" && (adresse.indexOf("\n")>0 || adresse.indexOf(",")>0))
	{
		return true;
	}
	else
	{
		return false;
	}
}
function changeClass(elemDiv,classNew) 
{
	var div = document.getElementById(elemDiv);
	if (div)
		div.className = classNew;
}
function changeClass1(elem,classNew) 
{
	elem.className = classNew;
}
function loadSearchAjax(elemDiv,page,elemSearch,elemDest,sizeSearch,loading)
{
	var div = document.getElementById(elemDiv);
	var search = document.getElementById(elemSearch).value;

	if (search.length>=sizeSearch)
	{
		div.style.display = 'block';
		ajaxHttpRequest(elemDiv,page,"search="+URLEncode(search)+"&div="+URLEncode(elemDiv)+"&from="+URLEncode(elemSearch)+"&to="+URLEncode(elemDest),loading);
	}
	else
	{
		closeSearchAjax(elemDiv);
	}
}
function loadSearchAjaxSelect(search,event,elemDiv,page,elemSearch,elemDest,sizeSearch,loading,functionAfterLoad)
{
	var div = document.getElementById(elemDiv);
	var listIdSelected = 0;
	var listNb = 0;
	var listIdSelectedNew = 0;
	var divTmp = null;
	var loaded = 0;
	
	if (document.getElementById('formInfo'+elemDiv+'idSelected'))
	{
		listIdSelected = parseInt(document.getElementById('formInfo'+elemDiv+'idSelected').innerHTML);
		listNb = parseInt(document.getElementById('formInfo'+elemDiv+'nb').innerHTML);
		loaded = 1;
	}

	switch (event.keyCode)
	{
		case 40 :
			if (loaded==1 && listIdSelected>=0 && listIdSelected<listNb)
			{
				listIdSelectedNew = listIdSelected+1;
				changeFocusSearchAjaxSelect(elemDiv,listIdSelectedNew,listIdSelected);
			}
			break;
		case 39 :
			break;
		case 38 :
			if (loaded==1 && listIdSelected>0 && listIdSelected<=listNb)
			{
				listIdSelectedNew = listIdSelected-1;
				changeFocusSearchAjaxSelect(elemDiv,listIdSelectedNew,listIdSelected);
			}
			break;
		case 37 :
			break;
		case 27 :
			closeSearchAjax(elemDiv);
			break;
		case 13 :
			submitSearchAjaxSelect(elemDiv,elemSearch,elemDest,parseInt(listIdSelected));
			break;
		default :
			div.innerHTML = '';
			if (search.length>=sizeSearch)
			{
				div.style.display = 'block';
				ajaxHttpRequest(elemDiv,page,"search="+URLEncode(search)+"&div="+URLEncode(elemDiv)+"&from="+URLEncode(elemSearch)+"&to="+URLEncode(elemDest),loading,functionAfterLoad);
			}
			else
			{
				closeSearchAjax(elemDiv);
			}
			break;
	}
}
function changeFocusSearchAjaxSelect(elemDiv,idNew,idOld)
{
	if (idOld==null)
		idOld = parseInt(document.getElementById('formInfo'+elemDiv+'idSelected').innerHTML);

	eval("divNewTmp = document.getElementById('list"+elemDiv+idNew+"');");
	if (divNewTmp!=null)
	{
		if (idOld>0)
		{
			eval("divOldTmp = document.getElementById('list"+elemDiv+idOld+"');");
			divOldTmp.className = document.getElementById('formInfo'+elemDiv+'classSelected').innerHTML;
		}
		document.getElementById('formInfo'+elemDiv+'idSelected').innerHTML = idNew;
		document.getElementById('formInfo'+elemDiv+'classSelected').innerHTML = divNewTmp.className;
		divNewTmp.className = "resultAjaxOptionHover";
	}
}
function submitSearchAjaxSelect(elemDiv,elemFrom,elemTo,id)
{
	if (document.getElementById('formInfo'+elemDiv+'idSelected'))
	{
		var fonction = document.getElementById('formInfo'+elemDiv+'fonction').innerHTML;
		var valeur = document.getElementById('formInfo'+elemDiv+'valeur'+id).innerHTML;
		valeur = valeur.replace("'", " ");
		var texte = document.getElementById('formInfo'+elemDiv+'texte'+id).innerHTML;
		eval(""+fonction+"(elemDiv,elemFrom,elemTo,'"+valeur+"',texte);");
	}
}
function closeSearchAjax(elemDiv)
{
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.display = 'none';
}
function loadSearchAjaxSelectEventLieu(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectEventLieu.php?showNotFound=0",elemSearch,elemDest,1,1,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectSociete(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectSociete.php?showNotFound=0",elemSearch,elemDest,1,1,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectJustContact(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchContact&showNotFound=0",elemSearch,elemDest,3,1,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectJustContact1(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchContactList&showNotFound=0",elemSearch,elemDest,3,1,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectContactEmail(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchEmail",elemSearch,elemDest,3,1);
}
function loadSearchAjaxSelectContactEmail1(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchEmail&showNotFound=0&searchInGroup=1",elemSearch,elemDest,3,0,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectContactAndEmail(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchContactEmail",elemSearch,elemDest,3,1);
}
function loadSearchAjaxSelectContactAndEmail1(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchContactEmailList&showNotFound=0",elemSearch,elemDest,1,0,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectContactAndMobile(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectContact.php?type=searchContactMobileList&showNotFound=0",elemSearch,elemDest,1,0,"hideDivIfEmpty('"+elemDiv+"')");
}
function loadSearchAjaxSelectMobile(value,event,elemDiv,elemSearch,elemDest)
{
	loadSearchAjaxSelect(value,event,elemDiv,"ajaxSelectMobile.php",elemSearch,elemDest,3,1);
}
function showPreview(elemDiv,page,query,size,moveHeight)
{
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = size+"px";
	div.style.display = 'block';
	if (moveHeight==0)
		ajaxHttpRequest(elemDiv,page,query,0,"movePreview('"+elemDiv+"',0,0)");
	else
		ajaxHttpRequest(elemDiv,page,query,0,"movePreview('"+elemDiv+"',0,1)");
}
function movePreview(elemDiv,block,moveHeight)
{
	if (previewCanMoved)
	{
		previewCanMoved = false;

		var div = document.getElementById(elemDiv);
		var divWidth = parseInt(div.style.width.replace('px', ''));
		if (winWidth>0 && positionX+202>winWidth)
			div.style.left = (positionX-divWidth-2)+"px";
		else
			div.style.left = (positionX+2)+"px";

		if (block==1)
			div.style.display = 'block';

		if (moveHeight==1)
		{
			var divHeight = div.offsetHeight;

			if (winHeight>0 && positionY+divHeight+8>winHeight)
				div.style.top = (positionY-divHeight-2)+"px";
//				div.style.top = (winHeight-divHeight)+"px";
			else
				div.style.top = (positionY+8)+"px";
		}
		else
			div.style.top = (positionY+8)+"px";

		previewCanMoved = true;
	}
}
function showPreviewContact(id,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='contact'+id)
	{
		var queryTmp = 'id='+URLEncode(id);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewContact.php',queryTmp,200,1);

		divID.innerHTML = 'contact'+id;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewContactMap(id,type,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='contactMap'+id+type)
	{
		var queryTmp = 'id='+URLEncode(id)+'&type='+URLEncode(type);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewContactMap.php',queryTmp,200,1);
		divID.innerHTML = 'contactMap'+id+type;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewEvent(id,uid)
{
	if (id!='0')
	{
		var divID = document.getElementById('ajaxPreviewID');

		if (divID.innerHTML!='event'+id)
		{
			var queryTmp = 'id='+URLEncode(id);
			if (uid!=undefined && uid!='')
				queryTmp += '&uid='+uid;
			showPreview('ajaxPreview','/previewEvent.php',queryTmp,200,1);
			divID.innerHTML = 'event'+id;
		}
		else
		{
			movePreview('ajaxPreview',1,1);
		}
	}
}
function showPreviewEventListDay(date,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='eventListDay'+date)
	{
		var queryTmp = 'date='+URLEncode(date);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewEventListDay.php',queryTmp,200,1);
		divID.innerHTML = 'eventListDay'+date;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewNote(id,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='note'+id)
	{
		var queryTmp = 'id='+URLEncode(id);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewNote.php',queryTmp,200,1);
		divID.innerHTML = 'note'+id;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewTask(id,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='task'+id)
	{
		var queryTmp = 'id='+URLEncode(id);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewTask.php',queryTmp,200,1);
		divID.innerHTML = 'task'+id;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewPagerank(url,uid)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='pagerank'+url)
	{
		var queryTmp = 'url='+URLEncode(url);
		if (uid!=undefined && uid!='')
			queryTmp += '&uid='+uid;
		showPreview('ajaxPreview','/previewPagerank.php',queryTmp,88,1);
		divID.innerHTML = 'pagerank'+url;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewThumbshot(url)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='thumbshot'+url)
	{
		showPreview('ajaxPreview','/previewThumbshot.php','url='+URLEncode(url),90,1);
		divID.innerHTML = 'thumbshot'+url;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewInfos(id,infos,size)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML!='infos'+id)
	{
		showPreview('ajaxPreview','/previewInfos.php','infos64='+URLEncode(infos),size,1);
		divID.innerHTML = 'infos'+id;
	}
	else
	{
		movePreview('ajaxPreview',1,1);
	}
}
function showPreviewMobile(id)
{
	var divID = document.getElementById('ajaxPreviewID');

	showPreview('ajaxPreview','/previewMobile.php','id='+URLEncode(id),220,0);
	divID.innerHTML = 'mobile'+id;
}
function showPreviewSync(id)
{
	var divID = document.getElementById('ajaxPreviewID');

	showPreview('ajaxPreview','/previewMobile.php','id=sync-'+URLEncode(id),460,0);
	divID.innerHTML = 'mobile'+id;
}
function showChooseEncode(page64,charset)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML=='chooseEncode')
		closePreview();

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = "300px";
	div.style.left = (positionX-240)+"px";
	div.style.top = (positionY+4)+"px";
	ajaxHttpRequest(elemDiv,'ajaxChooseEncode.php','page64='+URLEncode(page64)+'&charset='+URLEncode(charset),3);
	div.style.display = 'block';

	divID.innerHTML = 'chooseEncode';
}
function showChooseLang(page64, colorSelect, colorTexte)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divChoose = document.getElementById('chooseLang');

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='chooseLang' && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "280px";
		if (divChoose && divChoose.offsetLeft)
			div.style.left = (getPositionLeft(divChoose)-241)+"px";
		else
			div.style.left = (positionX-267)+"px";
		if (divChoose && divChoose.offsetTop)
			div.style.top = (getPositionTop(divChoose)+divChoose.offsetHeight-1)+"px";
		else
			div.style.top = (positionY+4)+"px";
		ajaxHttpRequest(elemDiv,'/ajaxChooseLang.php','colorMouseOver=ffcc66&page64='+URLEncode(page64)+'&colorSelect='+colorSelect+'&colorTexte='+colorTexte,3);
		div.style.display = 'block';
		divID.innerHTML = 'chooseLang';
	}
}
function showContactPhoto(div, id, width, height, noresize, action, name)
{
	ajaxHttpRequest(div,"/ajaxContactPhoto.php",'div='+div+'&id='+id+'&width='+width+'&height='+height+'&noresize='+noresize+'&action='+action+'&name='+URLEncode(name),2);
}
function showContactPhotoPublic(div, id, width, height, noresize, action, uid, key)
{
	ajaxHttpRequest(div,"/ajaxContactPhoto.php",'div='+div+'&id='+id+'&width='+width+'&height='+height+'&noresize='+noresize+'&action='+action+'&uid='+uid+'&key='+key,2);
}
function showContactPhotoAdd(id, name)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML=='contactPhotoAdd')
		closePreview();

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = "360px";
	div.style.left = positionX+"px";
	div.style.top = (positionY+4)+"px";
	ajaxHttpRequest(elemDiv,'/ajaxContactPhotoAdd.php','id='+id+'&name='+URLEncode(name),3);
	div.style.display = 'block';

	divID.innerHTML = 'contactPhotoAdd';
}
function showContactPhotoAdd1(id, name)
{
	var divID = document.getElementById('ajaxPreviewID');

	if (divID.innerHTML=='contactPhotoAdd')
		closePreview();

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = "360px";
	div.style.left = (positionX-360)+"px";
	div.style.top = (positionY+4)+"px";
	ajaxHttpRequest(elemDiv,'/ajaxContactPhotoAdd.php','id='+id+'&name='+URLEncode(name),3);
	div.style.display = 'block';

	divID.innerHTML = 'contactPhotoAdd';
}
function showActionBookmarkFolder(share, id, name64, type, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionBookmarkFolder'+id);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionBookmarkFolder'+id && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "160px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX;
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=bookmarkFolder&id='+id+'&name64='+URLEncode(name64)+'&type='+type+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionBookmarkFolder'+id;
	}
}
function showActionContactGroup(share, id, name64, type, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionContactGroup'+id);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionContactGroup'+id && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "160px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=contactGroup&id='+id+'&name64='+URLEncode(name64)+'&type='+type+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionContactGroup'+id;
	}
}
function showActionCalendarCategory(share, id, name64, type, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionCalendarCategory'+id);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionCalendarCategory'+id && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "160px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=calendarCategory&id='+id+'&name64='+URLEncode(name64)+'&type='+type+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionCalendarCategory'+id;
	}
}
function showActionDocsFolder(share, chemin64, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionDocsFolder'+chemin64);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionDocsFolder'+chemin64 && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "220px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=docsFolder&chemin64='+URLEncode(chemin64)+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionDocsFolder'+chemin64;
	}
}
function showActionDocsFolder1(share, chemin64, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionDocsFolder1'+chemin64);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionDocsFolder1'+chemin64 && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "220px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=docsFolder&chemin64='+URLEncode(chemin64)+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionDocsFolder1'+chemin64;
	}
}
function showActionDocsFile(share, chemin64, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionDocsFile'+chemin64);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionDocsFile'+chemin64 && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "220px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=docsFile&chemin64='+URLEncode(chemin64)+'&lightbox='+lightbox,2);
		div.style.display = 'block';
		divID.innerHTML = 'showActionDocsFile'+chemin64;
	}
}
function showActionMailAccountFolder(share, id, account, mailboxHexa, lightbox)
{
	var divID = document.getElementById('ajaxPreviewID');
	var divAction = document.getElementById('showActionMailAccountFolder'+mailboxHexa);

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	if (divID.innerHTML=='showActionMailAccountFolder'+mailboxHexa && div.style.display=='block')
	{
		closePreview();
	}
	else
	{
		div.style.width = "100px";
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp+"px";
			else
				div.style.left = positionX+"px";
		}
		else
			div.style.left = positionX+"px";
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp+"px";
			else
				div.style.top = (positionY+4)+"px";
		}
		else
			div.style.top = (positionY+4)+"px";
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';

		ajaxHttpRequest(elemDiv,page,'colorMouseOver=ffcc66&typeAction=mailAccountFolder&id='+id+'&account='+account+'&mailboxHexa='+URLEncode(mailboxHexa)+'&lightbox='+lightbox,3);
		div.style.display = 'block';
		divID.innerHTML = 'showActionMailAccountFolder'+mailboxHexa;
	}
}
function closeChooseEncode()
{
	closePreview();
	document.formChooseEncode.submit();
}
function closePreview(except)
{
	if (document.getElementById('ajaxPreviewID').innerHTML!=except)
		document.getElementById('ajaxPreview').style.display = 'none';
}
function dataAddToElem(elemDiv,elemFrom,elemTo,value,text)
{
	var to = document.getElementById(elemTo);
	
	if (to.getAttribute('type')=='text')
	{
		text = text.replace(/&amp;/g, "&");
		to.value = text;
	}
	else if (to.getAttribute('type')=='textarea')
	{
		value = value.replace(/&lt;/g, "<");
		value = value.replace(/&gt;/g, ">");
		to.value = value;
		to.focus();
	}
	else
	{
		var option = document.createElement('option');
		option.value = value;
		option.innerHTML = text;
	
		var from = document.getElementById(elemFrom);
		from.value = '';
		
		to.appendChild(option);
	}

	closeSearchAjax(elemDiv);
}
function dataAddToElem1(elemDiv,elemFrom,elemTo,value,text)
{
	var to = document.getElementById(elemTo);
	
	if (to.getAttribute('type')=='text')
	{
		text = text.replace(/&amp;/g, "&");
		to.value = value;
		to.focus();

		closeSearchAjax(elemDiv);
	}
	else
	{
		dataAddToElem(elemDiv,elemFrom,elemTo,value,text);
	}
}
function changePattern(elemId, pattern, errormsg)
{
	var elem = document.getElementById(elemId);
	elem.setAttribute('pattern',pattern);
	elem.setAttribute('errormsg',errormsg);
}
function checkPattern(elemId)
{
	var elem = document.getElementById(elemId);
	if (elem)
	{
		var value = elem.value;
		if (value!="" && elem.getAttribute('pattern')!="" && elem.getAttribute('errormsg')!="")
		{
			var pattern = elem.getAttribute('pattern');
			var errormsg = elem.getAttribute('errormsg');

			var num = eval("/"+pattern+"/");

			if(!num.test(value.toLowerCase()))
			{
				alert(errormsg);
				return false;
			}
		}
	}
	
	return true;
}
function bg(elem,bgcolor,addBackground) 
{
	if (bgcolor!="")
		elem.style.backgroundColor = "#"+bgcolor;
	if (addBackground=='fond1' || addBackground=='fond5' || addBackground=='fond8' || addBackground=='fond9' || addBackground=='fond10')
	{
		elem.style.backgroundImage = "url(http://static.memotoo.com/img/"+addBackground+".png)";
		elem.style.backgroundPosition = "top";
		elem.style.backgroundRepeat = "repeat-x";
	}
	else if (addBackground=='fond6')
	{
		elem.style.backgroundImage = "url(http://static.memotoo.com/img/fond6.png)";
		elem.style.backgroundPosition = "center center";
		elem.style.backgroundRepeat = "repeat-x";
	}
	else if (bgcolor=='ffcc66' || addBackground=='1')
	{
		elem.style.backgroundImage = "url(http://static.memotoo.com/img/fond1.png)";
		elem.style.backgroundPosition = "center center";
		elem.style.backgroundRepeat = "repeat-x";
	}
	else
	{
		elem.style.backgroundImage = "";
		elem.style.backgroundPosition = "center center";
		elem.style.backgroundRepeat = "repeat-x";
	}
}
function bg1(elem,bgcolor,fontcolor,addBackground) 
{
	if (fontcolor!="")
		elem.style.color = "#"+fontcolor;
	bg(elem,bgcolor,addBackground);
}
function bgTipsOut(elem,bgcolor) 
{
	elem.style.backgroundColor = "#"+bgcolor;
//	elem.style.backgroundImage = "url(http://static.memotoo.com/img/fond3.gif)";
//	elem.style.backgroundPosition = "top center";
//	elem.style.backgroundRepeat = "repeat-x";
}
function border(elem,color) 
{
	if (color!="")
		elem.style.borderColor = "#"+color;
}
function copyData(input) 
{
	copy = input.createTextRange();
	copy.execCommand("Copy");
	alert("Address copied");
}
function getWindowHeight()
{
	var win = -1;
	if (window.innerHeight)
		win = parseInt(window.innerHeight);
	else if (document.documentElement && document.documentElement.clientHeight)
		win = parseInt(document.documentElement.clientHeight);
	else if (document.body && document.body.clientHeight)
		win = parseInt(document.body.clientHeight);
	return win;
}
function getWindowWidth()
{
	var win = -1;
	if (window.innerWidth)
		win = parseInt(window.innerWidth);
	else if (document.documentElement && document.documentElement.clientWidth)
		win = parseInt(document.documentElement.clientWidth);
	else if (document.body && document.body.clientWidth)
		win = parseInt(document.body.clientWidth);
	return win;
}
function loading(bool) 
{
	if (bool=="1")
		document.write("<div id=\"loading\" align=\"center\"><br /><br /><br /><font class=\"texteDiscret\">Loading ...</font><br /><br /><img src=\"http://static.memotoo.com/img/loading.gif\" width=\"20\" height=\"20\" alt=\"Loading\" title=\"Loading\" /></div>");
	else
		document.getElementById("loading").style.display = 'none';
}
function loadingDiv(elemId) 
{
	document.getElementById(elemId).innerHTML = "<br /><br /><br /><font class=\"texteDiscret\">Loading ...</font><br /><br /><img src=\"http://static.memotoo.com/img/loading.gif\" width=\"20\" height=\"20\" alt=\"Loading\" title=\"Loading\" />";
}
function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowHeight = getWindowHeight();
	var windowWidth = getWindowWidth();
	
	if(yScroll<windowHeight)
		pageHeight = windowHeight;
	else
		pageHeight = yScroll;

	if(xScroll<windowWidth)	
		pageWidth = windowWidth;
	else
		pageWidth = xScroll;

	return new Array(pageWidth,pageHeight,windowWidth,windowHeight);
}
function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset)
		yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop)
		yScroll = document.documentElement.scrollTop;
	else if (document.body)
		yScroll = document.body.scrollTop;

	return new Array('',yScroll);
}
function lightboxResize(elem)
{
	var id = '';

	if (document.getElementById('lightboxalert'))
		id = 'alert';
	else if (document.getElementById('lightboxerror'))
		id = 'error';
	else if (document.getElementById('lightboxinfo'))
		id = 'info';
	else if (document.getElementById('lightboxpage'))
		id = 'page';
	else if (document.getElementById('lightboxloading'))
		id = 'loading';

	if (id!='')
	{
		var objOverlay = document.getElementById('overlay'+id);
		var objLightbox = document.getElementById('lightbox'+id);
		var objDiv = document.getElementById(elem);

		if (objDiv)
		{
			var height = objDiv.style.height;
			var width = objDiv.style.width;
			height = parseInt(height.replace('px', ''));
			width = parseInt(width.replace('px', ''));

			var arrayPageSize = getPageSize();
			var arrayPageScroll = getPageScroll();

			objOverlay.style.height = arrayPageSize[1]+"px";

			if (arrayPageSize[3]-20<height)
				height = arrayPageSize[3]-20;
			if (arrayPageSize[2]-60<width)
				width = arrayPageSize[2]-60;

			var lightboxTop = (arrayPageScroll[1]+(arrayPageSize[3]-height)/2);
			var lightboxLeft = ((arrayPageSize[2]-width)/2);
			objLightbox.style.top = (lightboxTop<0 ? 4 : lightboxTop)+"px";
			objLightbox.style.left = (lightboxLeft<0 ? 4 : lightboxLeft)+"px";
			objDiv.style.height = height+"px";
			objDiv.style.width = width+"px";
		}
	}
}
function showLightbox(id,width,height)
{
	var objBody = document.getElementsByTagName("body").item(0);

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	if (arrayPageSize[3]-20<height)
		height = arrayPageSize[3]-20;
	if (arrayPageSize[2]-60<width)
		width = arrayPageSize[2]-60;

	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay'+id);
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	objOverlay.style.height = arrayPageSize[1]+"px";
	objOverlay.style.display = 'block';

	var objLightbox = document.createElement("div");
	objLightbox.style.display = 'none';
	objLightbox.setAttribute('id','lightbox'+id);
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	var lightboxTop = (arrayPageScroll[1]+(arrayPageSize[3]-height)/2);
	var lightboxLeft = ((arrayPageSize[2]-width)/2);
	objLightbox.style.top = (lightboxTop<0 ? 4 : lightboxTop)+"px";
	objLightbox.style.left = (lightboxLeft<0 ? 4 : lightboxLeft)+"px";
	objLightbox.style.display = 'block';
	if (id=='page')
		objLightbox.style.height = height+'px';

	if (window.attachEvent)
		window.attachEvent('onresize',lightboxResize);
	else if (window.addEventListener)
		window.addEventListener('resize',lightboxResize,false);
	else
		window.onresize = lightboxResize;
}
function showLightboxPage(page,query,width,height)
{
	var idLightbox = 'page';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	if (parseInt(height)+50>winHeight && winHeight>150)
		height = winHeight-50;

	showLightbox(idLightbox,width,height);

	if (query=="")
		var link = page+"?lightbox=1";
	else
		var link = page+"?lightbox=1&"+query;

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.style.color = '#ffffff';
	objLink.onclick = function () {hideLightbox(idLightbox);return false;}
	objLightbox.appendChild(objLink);

	var objCloseButton = document.createElement("img");
	objCloseButton.src = 'http://static.memotoo.com/img/close2.png';
	objCloseButton.border = "0px";
	objCloseButton.setAttribute('id','closeButton');
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.top = "-12px";
	objCloseButton.style.right = "-12px";
	objCloseButton.style.zIndex = 200;
	objLink.appendChild(objCloseButton);

	var objImgLoading = document.createElement("img");
	objImgLoading.src = 'http://static.memotoo.com/img/loading2.gif';
	objImgLoading.border = "0px";
	objImgLoading.setAttribute('id','lightboxLoading');
	objImgLoading.style.position = 'absolute';
	objImgLoading.style.top = "4px";
	objImgLoading.style.left = "4px";
	objImgLoading.style.zIndex = 200;
	objLightbox.appendChild(objImgLoading);

	var objDiv = document.createElement("iframe");
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.setAttribute('frameborder','0px');
	objDiv.setAttribute('border','0px');
	var extension = page.substring(page.length-3,page.length);
	if (extension=="gif" || extension=="png" || extension=="jpg")
		objDiv.setAttribute('scrolling','yes');
	else
		objDiv.setAttribute('scrolling','no');
	objDiv.onload = function () {document.getElementById('lightboxLoading').style.display='none'}
	objDiv.src = link;
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.style.padding = "0px";
	objDiv.style.margin = "0px";
	objLightbox.appendChild(objDiv);

	lightboxResize('lightboxDiv');
}
function showLightboxHtml(html,width,height)
{
	var idLightbox = 'page';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	if (parseInt(height)+50>winHeight && winHeight>150)
		height = winHeight-50;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.onclick = function () {hideLightbox(idLightbox);return false;}
	objLightbox.appendChild(objLink);

	var objCloseButton = document.createElement("img");
	objCloseButton.src = 'http://static.memotoo.com/img/close2.png';
	objCloseButton.border = "0px";
	objCloseButton.setAttribute('id','closeButton');
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.top = "-12px";
	objCloseButton.style.right = "-12px";
	objCloseButton.style.zIndex = 200;
	objLink.appendChild(objCloseButton);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv1');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = html;
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';

	lightboxResize('lightboxDiv1');
}
function showLightboxError(message,width,height)
{
	var idLightbox = 'error';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	if (height-4>60)
		var heightTmp = height-4;
	else
		var heightTmp = 60;

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = '<form name="formErrorTmp" action="" method="post"><table width="100%" height="'+heightTmp+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="http://static.memotoo.com/img/z063s4.png" width="48" height="48" alt="" title="" align="absmiddle" /></td><td width="99%" align="center" class="td3"><b>'+message+'</b></td></tr><tr><td colspan="2" align="center"><input type="button" name="ok" value="Ok" class="submit1_1" onclick="hideLightbox(\''+idLightbox+'\')" style="width:100px" /></td></tr></table></form>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function showLightboxInfo(message,width,height)
{
	var idLightbox = 'info';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	if (height-4>60)
		var heightTmp = height-4;
	else
		var heightTmp = 60;

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = '<form name="formInfoTmp" action="" method="post"><table width="100%" height="'+heightTmp+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="http://static.memotoo.com/img/z067p4.png" width="48" height="48" alt="" title="" align="absmiddle" /></td><td width="99%" align="center" class="td3"><b>'+message+'</b></td></tr><tr><td colspan="2" align="center"><input type="button" name="ok" value="Ok" class="submit1_1" onclick="hideLightbox(\''+idLightbox+'\')" style="width:100px" /></td></tr></table></form>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function showLightboxAlert(message,width,height)
{
	var idLightbox = 'alert';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	if (height-4>60)
		var heightTmp = height-4;
	else
		var heightTmp = 60;

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = '<form name="formAlertTmp" action="" method="post"><table width="100%" height="'+heightTmp+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="http://static.memotoo.com/img/z063s4.png" width="48" height="48" alt="" title="" align="absmiddle" /></td><td width="99%" align="center" class="td3"><b>'+message+'</b></td></tr><tr><td colspan="2" align="center"><input type="button" name="ok" value="Ok" class="submit1_1" onclick="hideLightbox(\''+idLightbox+'\')" style="width:100px" /></td></tr></table></form>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function showLightboxLoading()
{
	var idLightbox = 'loading';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	var width = 200;
	var height = 80;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = '<br /><div align=\"center\" onclick=\"hideLightbox(\'loading\')\">Loading ...<br /><img src="http://static.memotoo.com/img/loading2.gif" width="32" height="32" vspace="10" alt="Loading" title="Loading" align="absmiddle" /></div>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function showLightboxAskContactUpdateFiche(idContact,nameContact,width,height)
{
	var idLightbox = 'info';

	if (document.getElementById('lightbox'+idLightbox))
		return false;

	showLightbox(idLightbox,width,height);

	var objLightbox = document.getElementById('lightbox'+idLightbox);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height+"px";
	objDiv.style.width = width+"px";
	objDiv.innerHTML = '<form name="formInfoTmp" action="" method="post"><table width="100%" height="'+(height-4)+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="http://static.memotoo.com/img/z067p4.png" width="48" height="48" alt="" title="" align="absmiddle" /></td><td width="99%" align="center" class="td3"><b>Contact has been added successfully</b><br /><br />Ask <b>'+nameContact+'</b> to update his/her information?<br /><br /><input type="button" name="yes" value="Yes" class="submit1_1" onclick="hideLightbox(\''+idLightbox+'\');transferDataAskContact(\'action=transferUrlContactShare&selection='+idContact+'&contact='+idContact+';'+idContact+'pro;'+idContact+'other\',1)" style="width:100px" />&nbsp;&nbsp;<input type="button" name="no" value="No" class="submit1_1" onclick="hideLightbox(\''+idLightbox+'\')" style="width:100px" /></td></tr></table></form>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function hideLightbox(id)
{
	if (document.getElementById('overlay'+id))
		document.getElementById('overlay'+id).style.display = 'none';
	if (document.getElementById('lightbox'+id))
	{
		document.getElementById('lightbox'+id).style.display = 'none';
		document.getElementById('lightbox'+id).parentNode.removeChild(document.getElementById('lightbox'+id));
	}

	if (window.detachEvent)
		window.detachEvent('onresize',lightboxResize);
	else if (window.removeEventListener)
		window.removeEventListener('resize',lightboxResize,false);
	else
		window.onresize = '';
}
function setCalendarSetup(id,format,day) 
{
	Calendar.setup({
		inputField:id,
		ifFormat:format,
		button:id+"Button",
		align:"Br",
		singleClick:true,
		firstDay:parseInt(day)
	});
}
function hideDivIfEmpty(elemDiv)
{
	var div = document.getElementById(elemDiv);
	if (div.innerHTML=='')
		div.style.display = 'none';
}
function setOpacity(elemId,value)
{
	var elem = document.getElementById(elemId);
	elem.style.opacity = value/10;
	elem.style.filter = 'alpha(opacity='+value*10+')';
}
function fade(eid,TimeToFade)
{
	var element = document.getElementById(eid);
	if (element == null)
		return;

	if (element.style.display=='none')
	{
		element.style.opacity = '0';
		element.style.filter = 'alpha(opacity=0)';
		element.FadeState = -2;
		element.style.display = 'block';
	}

	if (element.FadeState==null)
	{
		if(element.style.opacity==null || element.style.opacity=='' || element.style.opacity=='1')
			element.FadeState = 2;
		else
			element.FadeState = -2;
	}

	if (element.FadeState==1 || element.FadeState==-1)
	{
		element.FadeState = (element.FadeState == 1 ? -1 : 1);
		element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
	}
	else
	{
		element.FadeState = (element.FadeState == 2 ? -1 : 1);
		element.FadeTimeLeft = TimeToFade;
		setTimeout("animateFade("+new Date().getTime()+",'"+eid+"',"+TimeToFade+")", 33);
	}
}
function animateFade(lastTick,eid,TimeToFade)
{
	var curTick = new Date().getTime();
	var elapsedTicks = curTick-lastTick;
	
	var element = document.getElementById(eid);
 
	if (element.FadeTimeLeft<=elapsedTicks)
	{
		element.style.display = (element.FadeState == 1 ? 'block' : 'none');
		element.style.opacity = (element.FadeState == 1 ? '1' : '0');
		element.style.filter = 'alpha(opacity='+(element.FadeState == 1 ? '100' : '0')+')';
		element.FadeState = (element.FadeState == 1 ? 2 : -2);
		return;
	}

	element.FadeTimeLeft -= elapsedTicks;
	var newOpVal = element.FadeTimeLeft/TimeToFade;
	if (element.FadeState==1)
	{
		newOpVal = 1-newOpVal;
		newOpVal = parseInt(newOpVal*100)/100;
	}

	element.style.opacity = newOpVal;
	element.style.filter = 'alpha(opacity='+(newOpVal*100)+')';

	setTimeout("animateFade("+curTick+",'"+eid+"',"+TimeToFade+")", 33);
}
function getPositionLeft(This)
{
	var elem = This;
	var pos = 0;
	while(elem)
	{
		pos += elem.offsetLeft;
		elem = elem.offsetParent;
	}
	return pos;
}
function getPositionTop(This)
{
	var elem = This;
	var pos = 0;
	while(elem)
	{
		pos += elem.offsetTop;
		elem = elem.offsetParent;
	}
	return pos;
}
function showHideId(elemId)
{
	var elemDiv = document.getElementById(elemId);
	var elemImg = document.getElementById(elemId+'Img');

	if (elemDiv && (elemDiv.style.display=='none' || elemDiv.style.display==''))
	{
		elemDiv.style.display = 'block';
		if (elemImg)
			elemImg.src = 'http://static.memotoo.com/img/19_1.gif';
	}
	else if (elemDiv && elemDiv.style.display=='block')
	{
		elemDiv.style.display = 'none';
		if (elemImg)
			elemImg.src = 'http://static.memotoo.com/img/250.gif';
	}
}
function selectMenuShare(id,showInfos) 
{
	var elem = document.getElementById(id);
	changeClass(id,'menuShare');
	if (showInfos==1)
		displayId(id+"Infos");
}
function unselectMenuShare(id,hideInfos) 
{
	var elem = document.getElementById(id);
	changeClass(id,'menuShare1');
	if (hideInfos==1)
		hideId(id+"Infos");
}
function showEmbedCodeHtml()
{
	ajaxHttpRequest('embedCodeHtml','/ajaxEmbed.php',getEmbedQuery(''),0);
}
function showEmbedCodePreview(checkEmpty)
{
	if (checkEmpty==1)
	{
		if (document.getElementById("embedPreview").innerHTML=="")
			ajaxHttpRequest('embedPreview','/ajaxEmbed.php',getEmbedQuery('action=preview'),1);
	}
	else
	{
		showEmbedCodeHtml();
		ajaxHttpRequest('embedPreview','/ajaxEmbed.php',getEmbedQuery('action=preview'),1);
	}
}
function decryptBookmarkPasswordForm(elemForm,id)
{
	var password = prompt('Password Memotoo.com:','');
	if (password!="")
		ajaxHttpRequest(null,'/ajaxBookmarkDecryptPassword.php','password='+hex_md5(password)+'&id='+id+'&elemForm='+elemForm,0);
}
function decryptBookmarkPassword(elemDiv,id)
{
	var password = prompt('Password Memotoo.com:','');
	if (password!="")
		ajaxHttpRequest(elemDiv,'/ajaxBookmarkDecryptPassword.php','password='+hex_md5(password)+'&id='+id,0);
}
var hexcase = 0;
var b64pad  = "";
var chrsz   = 8;
function hex_md5(s){ if (s.length=="32") return s; else return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function core_md5(x, len)
{
	x[len >> 5] |= 0x80 << ((len) % 32);
	x[(((len + 64) >>> 9) << 4) + 14] = len;
	
	var a =  1732584193;
	var b = -271733879;
	var c = -1732584194;
	var d =  271733878;
	
	for(var i = 0; i < x.length; i += 16)
	{
		var olda = a;
		var oldb = b;
		var oldc = c;
		var oldd = d;
		
		a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
		d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
		c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
		b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
		a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
		d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
		c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
		b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
		a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
		d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
		c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
		b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
		a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
		d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
		c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
		b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
		
		a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
		d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
		c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
		b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
		a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
		d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
		c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
		b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
		a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
		d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
		c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
		b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
		a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
		d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
		c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
		b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
		
		a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
		d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
		c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
		b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
		a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
		d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
		c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
		b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
		a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
		d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
		c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
		b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
		a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
		d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
		c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
		b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
		
		a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
		d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
		c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
		b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
		a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
		d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
		c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
		b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
		a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
		d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
		c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
		b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
		a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
		d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
		c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
		b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
		
		a = safe_add(a, olda);
		b = safe_add(b, oldb);
		c = safe_add(c, oldc);
		d = safe_add(d, oldd);
	}
	return Array(a, b, c, d);
}
function md5_cmn(q, a, b, x, s, t)
{
	return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
	return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
	return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
	return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
	return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function core_hmac_md5(key, data)
{
	var bkey = str2binl(key);
	if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
	
	var ipad = Array(16), opad = Array(16);
	for(var i = 0; i < 16; i++)
	{
		ipad[i] = bkey[i] ^ 0x36363636;
		opad[i] = bkey[i] ^ 0x5C5C5C5C;
	}
	
	var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
	return core_md5(opad.concat(hash), 512 + 128);
}
function safe_add(x, y)
{
	var lsw = (x & 0xFFFF) + (y & 0xFFFF);
	var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
	return (msw << 16) | (lsw & 0xFFFF);
}
function bit_rol(num, cnt)
{
	return (num << cnt) | (num >>> (32 - cnt));
}
function str2binl(str)
{
	var bin = Array();
	var mask = (1 << chrsz) - 1;
	for(var i = 0; i < str.length * chrsz; i += chrsz)
		bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
	return bin;
}
function binl2hex(binarray)
{
	var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
	var str = "";
	for(var i = 0; i < binarray.length * 4; i++)
	{
		str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
			hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
	}
	return str;
}
function submitAuth(form,fieldPassword)
{
	eval("var f = document."+form+";");
	eval("var password = f."+fieldPassword+".value;");
	if (password!="" && password!="souvenir")
	{
		eval("f."+fieldPassword+".value = hex_md5(password);");
	}
}
function showSettingsSync(syncBookmark,syncContact,syncCalendar,syncTask,syncNote,syncBriefcase,syncMail,syncSms,syncPicture,syncTaskIntoCalendar,syncNoteTextPlain,name,id,changeMobile)
{
	ajaxHttpRequest("settingsMobile"+id,"/infoSyncml.php","action=showSettingsSync&name="+name+"&syncBookmark="+syncBookmark+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncBriefcase="+syncBriefcase+"&syncMail="+syncMail+"&syncSms="+syncSms+"&syncPicture="+syncPicture+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain+"&id="+id+"&changeMobile="+changeMobile,1);
}
function showSettingsSyncML(syncBookmark,syncContact,syncCalendar,syncTask,syncNote,syncBriefcase,syncMail,syncSms,syncPicture,syncTaskIntoCalendar,syncNoteTextPlain,name,id,changeMobile)
{
	ajaxHttpRequest("settingsMobile"+id,"/infoSyncml.php","action=showSettings&name="+name+"&syncBookmark="+syncBookmark+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncBriefcase="+syncBriefcase+"&syncMail="+syncMail+"&syncSms="+syncSms+"&syncPicture="+syncPicture+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain+"&id="+id+"&changeMobile="+changeMobile,1);
}
function showSettingsSendSyncML(syncBookmark,syncContact,syncCalendar,syncTask,syncNote,syncBriefcase,syncMail,syncSms,syncPicture,syncTaskIntoCalendar,syncNoteTextPlain,id,changeMobile)
{
	ajaxHttpRequest("settingsSend"+id,"/infoSyncml.php","action=showSettingsSend&syncBookmark="+syncBookmark+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncBriefcase="+syncBriefcase+"&syncMail="+syncMail+"&syncSms="+syncSms+"&syncPicture="+syncPicture+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain+"&id="+id+"&changeMobile="+changeMobile,"2big");
}
function showSettingsLinkSendSyncML(id,link)
{
	ajaxHttpRequest("settingsLinkSend"+id,"/infoSyncml.php","action=showSettingsLinkSend&id="+id+"&link="+URLEncode(link),"2big");
}
function sendSettingsSyncML(id) 
{
	eval("var form = document.sendSettings"+id+";");
	var syncContact = form.syncContact.value;
	var syncCalendar = form.syncCalendar.value;
	var syncTask = form.syncContact.value;
	var syncNote = form.syncNote.value;
	var syncTaskIntoCalendar = form.syncTaskIntoCalendar.value;
	var syncNoteTextPlain = form.syncNoteTextPlain.value;
	var codeCountry = form.codeCountry.value;
	var mobile = form.mobile.value;
	if (codeCountry=='')
		alert('Country code cannot be empty');
	else if (mobile=='')
		alert('Phone number cannot be empty');
	else
		ajaxHttpRequest("settingsSend"+id,"/infoSyncml.php","action=sendSettings&id="+id+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain+"&codeCountry="+codeCountry+"&mobile="+mobile,2);
}
function sendSettingsLinkSyncML(id) 
{
	eval("var form = document.sendSettingsLink"+id+";");
	var link = form.link.value;
	var codeCountry = form.codeCountry.value;
	var mobile = form.mobile.value;
	if (codeCountry=='')
		alert('Country code cannot be empty');
	else if (mobile=='')
		alert('Phone number cannot be empty');
	else
		ajaxHttpRequest("settingsLinkSend"+id,"/infoSyncml.php","action=sendSettingsLink&id="+id+"&link="+URLEncode(link)+"&codeCountry="+codeCountry+"&mobile="+mobile,2);
}
function changeDomainGoogle(type)
{
	if (document.syncGoogle.domain.value!="" && document.syncGoogle.domain.value.indexOf("@",0)<0)
	{
		document.syncGoogle.hd.value = document.syncGoogle.domain.value;
		if (type=="tasks")
		{}
		else
			document.syncGoogle.next.value += "&domain="+document.syncGoogle.domain.value;
		if (type=="calendar" && confirm("Did you enable SSL in your Google account for "+document.syncGoogle.domain.value+"?\n-> https://www.google.com/a/cpanel/"+document.syncGoogle.domain.value+"/DomainSettings"))
			document.syncGoogle.scope.value = "https://www.google.com/calendar/feeds/";
	}
	return true;
}
function submitMemotooSyncMLother(action,device)
{
	var form = document.getElementById('formMemotooSyncMLother');
	var query = "&action="+action;

	if (device!="")
		query += "&device="+device;

	query += "&urlServer="+URLEncode(form.urlServer.value);
	query += "&nameServer="+URLEncode(form.nameServer.value);
	query += "&loginServer="+URLEncode(form.loginServer.value);
	query += "&passwordServer="+URLEncode(form.passwordServer.value);
	if (form.syncContactServer.checked)
	{
		query += "&chkSyncContactServer=1";
		query += "&uriSyncContactServer="+URLEncode(form.uriSyncContactServer.value);
		query += "&sensSyncContactServer="+URLEncode(form.sensSyncContactServer.value);
		query += "&formatSyncContactServer="+URLEncode(form.formatSyncContactServer.value);
	}
	if (form.syncCalendarServer.checked)
	{
		query += "&chkSyncCalendarServer=1";
		query += "&uriSyncCalendarServer="+URLEncode(form.uriSyncCalendarServer.value);
		query += "&sensSyncCalendarServer="+URLEncode(form.sensSyncCalendarServer.value);
		query += "&formatSyncCalendarServer="+URLEncode(form.formatSyncCalendarServer.value);
	}
	if (form.syncTaskServer.checked)
	{
		query += "&chkSyncTaskServer=1";
		query += "&uriSyncTaskServer="+URLEncode(form.uriSyncTaskServer.value);
		query += "&sensSyncTaskServer="+URLEncode(form.sensSyncTaskServer.value);
		query += "&formatSyncTaskServer="+URLEncode(form.formatSyncTaskServer.value);
	}
	if (form.syncNoteServer.checked)
	{
		query += "&chkSyncNoteServer=1";
		query += "&uriSyncNoteServer="+URLEncode(form.uriSyncNoteServer.value);
		query += "&sensSyncNoteServer="+URLEncode(form.sensSyncNoteServer.value);
		query += "&formatSyncNoteServer="+URLEncode(form.formatSyncNoteServer.value);
	}
	if (form.schedule.value!="")
	{
		query += "&schedule="+URLEncode(form.schedule.value);
	}

	ajaxHttpRequest("syncSettings","/previewMobile.php","colorMouseOver=ffcc66&type=sync&id=sync-32&isPreview=0&canBeClose=0"+query,1,"");
}
function submitMemotooZimbraother(action,device)
{
	var form = document.getElementById('formMemotooZimbraother');
	var query = "&action="+action;

	if (device!="")
		query += "&device="+device;

	query += "&urlServer="+URLEncode(form.urlServer.value);
	query += "&nameServer="+URLEncode(form.nameServer.value);
	query += "&loginServer="+URLEncode(form.loginServer.value);
	query += "&passwordServer="+URLEncode(form.passwordServer.value);
	if (form.syncContactServer.checked)
	{
		query += "&chkSyncContactServer=1";
		query += "&sensSyncContactServer="+URLEncode(form.sensSyncContactServer.value);
	}
	if (form.syncCalendarServer.checked)
	{
		query += "&chkSyncCalendarServer=1";
		query += "&sensSyncCalendarServer="+URLEncode(form.sensSyncCalendarServer.value);
	}
	if (form.syncTaskServer.checked)
	{
		query += "&chkSyncTaskServer=1";
		query += "&sensSyncTaskServer="+URLEncode(form.sensSyncTaskServer.value);
	}
	if (form.schedule.value!="")
	{
		query += "&schedule="+URLEncode(form.schedule.value);
	}

	ajaxHttpRequest("syncSettings","/previewMobile.php","colorMouseOver=ffcc66&type=sync&id=sync-44&isPreview=0&canBeClose=0"+query,1,"");
}
function showLdapMozillaThunderbird() 
{
 	document.getElementById("menuMozillaThunderbird").className = 'menu';
	document.getElementById("menuOutlook").className = 'menuHidden';
 	document.getElementById("menuMacOS").className = 'menuHidden';
 	document.getElementById("infoMozillaThunderbird").style.display = 'block';
	document.getElementById("infoOutlook").style.display = 'none';
 	document.getElementById("infoMacOS").style.display = 'none';
}
function showLdapOutlook() 
{
 	document.getElementById("menuMozillaThunderbird").className = 'menuHidden';
	document.getElementById("menuOutlook").className = 'menu';
 	document.getElementById("menuMacOS").className = 'menuHidden';
 	document.getElementById("infoMozillaThunderbird").style.display = 'none';
	document.getElementById("infoOutlook").style.display = 'block';
 	document.getElementById("infoMacOS").style.display = 'none';
}
function showLdapMacOS() 
{
 	document.getElementById("menuMozillaThunderbird").className = 'menuHidden';
	document.getElementById("menuOutlook").className = 'menuHidden';
 	document.getElementById("menuMacOS").className = 'menu';
 	document.getElementById("infoMozillaThunderbird").style.display = 'none';
	document.getElementById("infoOutlook").style.display = 'none';
 	document.getElementById("infoMacOS").style.display = 'block';
}
function selectButton(id) 
{
	document.getElementById(id).className = 'buttonSelected';
}
function unselectButton(id) 
{
	document.getElementById(id).className = 'buttonNotSelected';
}
function showSelectCategories(idcategory,newCategoryName) 
{
	if (document.getElementById("selectCategories").style.display=='none' || newCategoryName!='')
	{
		document.getElementById("selectCategories").style.display = 'block';
		ajaxHttpRequest("selectCategories","/ajaxSelectCategories.php","idcategory="+idcategory+"&newCategoryName="+newCategoryName,2);
	}
	else
	{
		document.getElementById("selectCategories").style.display = 'none';
	}
}
function updateCategories() 
{
	idcategory = formCheckBoxSelection("form").replace(/,/g, "|");
	document.getElementById('formIdCategory').value = idcategory;
	ajaxHttpRequest("selectIdCategories","/ajaxSelectCategories.php","action=getListNameCategories&idcategory="+idcategory,0);
}

