positionX = 0;
positionY = 0;
winWidth = getWindowWidth();
winHeight = getWindowHeight();
document.onmousemove = position;
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);
}
function winopen1(page,query,target,largeur,hauteur,lightbox) 
{
	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 (query=="")
			open(page,target,"toolbar=no,location=no,directories=no,status=yes,menubar=no,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=no,scrollbars=yes,resizable=yes,width="+largeur+",height="+hauteur+",top="+top+",left="+left);
	}
}
function puturl(url) 
{
	if (parent.barre) {
		parent.barre.document.form1.url1.value = url;	
	} else if (top.opener && top.opener.parent.barre) {

		top.opener.parent.barre.document.form1.url1.value = url;
	}
}
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) 
{
	positionX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : parseInt(event.x) + parseInt(document.body.scrollLeft);
	positionY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : parseInt(event.y) + parseInt(document.body.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);
}
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;
			document.getElementById(elemId).style.top = positionY + positionImageY;
		}
		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,'img/158.gif','120','90',10,10);
}
function hideThumb() 
{
	hideImage('thumbshot');
	document.getElementById('thumbshot').src = "/img/109.gif";
}
function isThumb(imageId) 
{
	try
	{
		var idTmp = document.getElementById(imageId);
		if (idTmp && idTmp.height<=1)
			idTmp.src = "/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,'img/158.gif','120','90',null,null);
}
function getReloadPage(query) 
{
	var formTmp = document.infopage;

	if (formTmp && formTmp.page.value!='')
	{
		var strTmp = '';

		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!='')
			strTmp = formTmp.page.value+'?'+strTmp;
		else
			strTmp = formTmp.page.value;

		if (query!='' && query!='undefined')
			return query+'&reload='+URLEncode(strTmp);
		else 
			return 'reload='+URLEncode(strTmp);
	}

	return query;
}
function goweb(url) 
{
	if (url=="http://" || url=="") 
		url = "http://www.memotoo.com/mesfavoris.php";
	else if (url.substring(0,1)==">") 
		url = "http://www.memotoo.com/mesfavoris.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 majUrlBarre(url) 
{
	if (document.formBarre && document.formBarre.url1) 
		document.formBarre.url1.value = url;
	if (top && top.parent && top.parent.document && top.parent.document.getElementById("barreHaut")) 
		top.parent.document.formBarre.url1.value = url;
}
function getUrlBarre() 
{
	if (document.formBarre && document.formBarre.url1)
		return document.formBarre.url1.value;
	else if (top && top.parent && top.parent.document && top.parent.document.getElementById("barreHaut")) 
		return top.parent.document.formBarre.url1.value;
}
function help(lightbox) 
{
	winopen('/aide.php','simpleHeader=1','740','600',lightbox);
}
function showBookmark(id,lightbox)
{
	winopen('/infofavori.php',getReloadPage('id='+id),'550','550',lightbox);
}
function modifyBookmark(id,lightbox)
{
	winopen('/modifierfavori.php',getReloadPage('id='+id),'550','550',lightbox);
}
function modifyBookmarkFolder(id,lightbox)
{
	winopen('/modifierdfav.php',getReloadPage('id='+id),'510','290',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','550',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','560',lightbox);
}
function modifyContact(id,lightbox)
{
	winopen('/modifiercontact.php',getReloadPage('id='+id),'720','560',lightbox);
}
function modifyContactFolder(id,lightbox) 
{
	winopen('/modifierContactGroupe.php',getReloadPage('id='+id),'510','290',lightbox);
}
function moveContact(query,lightbox)
{
	winopen('/deplacerContact.php',getReloadPage(query),'510','320',lightbox);
}
function modifyNote(id,lightbox)
{
	winopen('/modifierPostIt.php',getReloadPage('id='+id),'500','400',lightbox);
}
function modifyTask(id,lightbox)
{
	winopen('/modifierTask.php',getReloadPage('id='+id),'620','590',lightbox);
}
function addCategory(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierCategorie.php','noreload=1','510','326',lightbox);
	else
		winopen('/modifierCategorie.php',getReloadPage(''),'510','326',lightbox);
}
function modifyCategory(id,lightbox)
{
	winopen('/modifierCategorie.php',getReloadPage('id='+id),'510','326',lightbox);
}
function addEventWithContact(mktime,guests,lightbox,reload)
{
	if (reload==0)
		winopen('/modifieragenda.php','noreload=1&mktime='+mktime+'&guests='+guests,'620','590',lightbox);
	else
		winopen('/modifieragenda.php',getReloadPage('mktime='+mktime+'&guests='+guests),'620','590',lightbox);
}
function addTask(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierTask.php','noreload=1','620','590',lightbox);
	else
		winopen('/modifierTask.php',getReloadPage(''),'620','590',lightbox);
}
function addNote(lightbox,reload)
{
	if (reload==0)
		winopen('/modifierPostIt.php','noreload=1','500','400',lightbox);
	else
		winopen('/modifierPostIt.php',getReloadPage(''),'500','400',lightbox);
}
function showEvent(id,lightbox)
{
	winopen('/infoagenda.php',getReloadPage('id='+id),'620','590',lightbox);
}
function showSms(id,type,lightbox)
{
	winopen('/infoSms.php',getReloadPage('id='+id+'&type='+type),'510','350',lightbox);
}
function showMail(id,type,lightbox)
{
	winopen('/infoMail.php',getReloadPage('id='+id+'&type='+type),'740','500',lightbox);
}
function showMailInAccount(id,account,lightbox,changeMailbox)
{
	winopen('/infoMail.php',getReloadPage('id='+id+'&type=mailHistory&account='+account+'&changeMailbox='+changeMailbox),'740','500',lightbox);
}
function transferDataFile(query,lightbox)
{
	winopen('/transferDataMail.php',query,'680','500',lightbox);
}
function transferDataAskContact(query,lightbox) 
{
	winopen('/transferDataMail.php',query,'680','440',lightbox);
}
function transferData(query,lightbox) 
{
	winopen('/transferDataMail.php',query,'680','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 = 350;
	div.style.left = positionX-320;
	div.style.top = positionY+4;
	ajaxHttpRequest(elemDiv,'ajaxLinkData.php',query,0);
	div.style.display = 'block';

	divID.innerHTML = 'linkData';
}
function linkProfile(query) 
{
	var divID = document.getElementById('ajaxPreviewID');

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

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);

	div.style.width = 450;
	if (query=='')
	{
		div.innerHTML = '';
		div.style.left = positionX-420;
		div.style.top = positionY+4;
	}
	ajaxHttpRequest(elemDiv,'ajaxLinkProfile.php',query,0,'document.formLinkProfile.url.focus()');
	div.style.display = 'block';

	divID.innerHTML = 'linkData';
}
function showMailing(id,lightbox)
{
	winopen('/infomailing.php',getReloadPage('id='+id),'550','550',lightbox);
}
function modifyMailing(id,lightbox)
{
	winopen('/modifiermailing.php',getReloadPage('id='+id),'550','550',lightbox);
}
function sendEmail(to,lightbox)
{
	winopen('/sendMail.php','contact='+to,'700','450',lightbox);
}
function sendEmailAccount(to,from,subject,msg,lightbox)
{
	winopen('/sendMail.php','contact='+to+'&from='+from+'&subject64='+URLEncode(subject)+'&msg64='+URLEncode(msg),'700','450',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(typeTmp, idTmp) 
{
	dragDropType = typeTmp;
	dragDropId = idTmp;
	var dragData = window.event.dataTransfer;
	dragData.effectAllowed = 'linkMove';
	dragData.dropEffect = 'move';
}
function enterDrag() 
{
	window.event.dataTransfer.getData('Text');
}
function endDrag() 
{
	window.event.dataTransfer.clearData();

	dragDropType = "";
	dragDropId = "";
}
function overDrag() 
{
	window.event.returnValue = false;
}
function drop(newDossier) 
{
	if (dragDropId!="" && dragDropType!="")
	{
		if (dragDropType=="dossier")
			location.href = location.pathname+"?action=deplacerDossier&id="+URLEncode(dragDropId)+"&newdos="+URLEncode(newDossier);	
		else if (dragDropType=="fichier")
			location.href = location.pathname+"?action=deplacerFichier&id="+URLEncode(dragDropId)+"&newdos="+URLEncode(newDossier);
	}
}
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 formCheckBoxMoveSelection(form,type,lightbox) 
{
	var strTmp = formCheckBoxSelection(form);
	if (type=="bookmarks")
		eval("document."+form+".action = 'javascript:moveBookmark(\"selection="+strTmp+"\","+lightbox+")'");
	else if (type=="contacts")
		eval("document."+form+".action = 'javascript:moveContact(\"selection="+strTmp+"\","+lightbox+")'");
	if (strTmp!="")
		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 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 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 = "<center><br /><br /><font class=\"texteDiscret\">Loading ...</font><br /><br /><img src=\"/img/loading.gif\" width=\"20\" height=\"20\" border=\"0\" alt=\"Loading\" title=\"Loading\" /><br /><br /></center>";
		else if (div && loading==2)
			div.innerHTML = "<center><img src=\"/img/loading.gif\" width=\"20\" height=\"20\" vspace=\"6\" border=\"0\" alt=\"Loading\" title=\"Loading\" /></center>";
	}

	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,'pere='+pere+'&espace='+espace+'&'+query,2);
	else
		ajaxHttpRequest(id,page,'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() 
{
	ajaxHttpRequest("smsCredit","ajaxSmsCredit.php","",0);
}
function moveSelectedOptions(from, to)
{
	var fromSelect = document.getElementById(from);
	var selOpt = getSelectedOptions(fromSelect);
	var selValues = new Array();
	if(selOpt.length>0)
	{
		var selValues = getSelectedValues(fromSelect);
		var toSelect=document.getElementById(to);
		for(i=0;i<selOpt.length;i++)
		{
			option = selOpt[i];
			fromSelect.removeChild(option);	
			toSelect.appendChild(option);
		}
	}
	return selValues;
}
function getSelectedValues (select)
{
	var selValues = new Array();
	for (var i=0;i<select.options.length;i++)
	{
		selValues[selValues.length] = select.options[i].value;
	}
	return selValues;
}
function getSelectedOptions (select) 
{
	var selOptions  = new Array();
	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 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 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 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)
{
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = size;
	ajaxHttpRequest(elemDiv,page,query,0,"movePreview('"+elemDiv+"',0)");
	div.style.display = 'block';
}
function movePreview(elemDiv,block)
{
	var div = document.getElementById(elemDiv);
	var divWidth = parseInt(div.style.width.replace('px', ''));
	if (winWidth>0 && positionX+202>winWidth)
		div.style.left = positionX-divWidth+10;
	else
		div.style.left = positionX+2;
	div.style.top = positionY+8;
	if (block==1)
		div.style.display = 'block';
}
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);

		divID.innerHTML = 'contact'+id;
	}
	else
	{
		movePreview('ajaxPreview',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);
		divID.innerHTML = 'contactMap'+id+type;
	}
	else
	{
		movePreview('ajaxPreview',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);
			divID.innerHTML = 'event'+id;
		}
		else
		{
			movePreview('ajaxPreview',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);
		divID.innerHTML = 'eventListDay'+date;
	}
	else
	{
		movePreview('ajaxPreview',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);
		divID.innerHTML = 'note'+id;
	}
	else
	{
		movePreview('ajaxPreview',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);
		divID.innerHTML = 'task'+id;
	}
	else
	{
		movePreview('ajaxPreview',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);
		divID.innerHTML = 'pagerank'+url;
	}
	else
	{
		movePreview('ajaxPreview',1);
	}
}
function showPreviewThumbshot(url)
{
	var divID = document.getElementById('ajaxPreviewID');

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

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

	showPreview('ajaxPreview','/previewMobile.php','id='+URLEncode(id),220);
	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 = 300;
	div.style.left = positionX-240;
	div.style.top = positionY+4;
	ajaxHttpRequest(elemDiv,'ajaxChooseEncode.php','page64='+URLEncode(page64)+'&charset='+URLEncode(charset),2);
	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 = 280;
		if (divChoose && divChoose.offsetLeft)
			div.style.left = getPositionLeft(divChoose)-242;
		else
			div.style.left = positionX-270;
		if (divChoose && divChoose.offsetTop)
			div.style.top = getPositionTop(divChoose)+divChoose.offsetHeight-1;
		else
			div.style.top = positionY+4;
		ajaxHttpRequest(elemDiv,'/ajaxChooseLang.php','page64='+URLEncode(page64)+'&colorSelect='+colorSelect+'&colorTexte='+colorTexte,2);
		div.style.display = 'block';
		divID.innerHTML = 'chooseLang';
	}
}
function showContactPhoto(div, id, width, height, noresize, action)
{
	ajaxHttpRequest(div,"/ajaxContactPhoto.php",'div='+div+'&id='+id+'&width='+width+'&height='+height+'&noresize='+noresize+'&action='+action,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)
{
	var divID = document.getElementById('ajaxPreviewID');

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

	var elemDiv = 'ajaxPreview';
	var div = document.getElementById(elemDiv);
	div.innerHTML = '';
	div.style.width = 300;
	div.style.left = positionX;
	div.style.top = positionY+4;
	ajaxHttpRequest(elemDiv,'/ajaxContactPhotoAdd.php','id='+id,0);
	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 = 160;
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp;
			else
				div.style.left = positionX;
		}
		else
			div.style.left = positionX;
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp;
			else
				div.style.top = positionY+4;
		}
		else
			div.style.top = positionY+4;
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'typeAction=bookmarkFolder&id='+id+'&name64='+URLEncode(name64)+'&type='+type+'&lightbox='+lightbox,0);
		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 = 160;
		if (divAction && divAction.offsetLeft)
		{
			var leftTmp = getPositionLeft(divAction);
			if (leftTmp<positionX+16)
				div.style.left = leftTmp;
			else
				div.style.left = positionX;
		}
		else
			div.style.left = positionX;
		if (divAction && divAction.offsetTop)
		{
			var topTmp = getPositionTop(divAction)+divAction.offsetHeight;
			if (topTmp<positionY+16)
				div.style.top = topTmp;
			else
				div.style.top = positionY+4;
		}
		else
			div.style.top = positionY+4;
		if (share=='1')
			var page = '/share-ajaxShowAction.php';
		else
			var page = '/ajaxShowAction.php';
		ajaxHttpRequest(elemDiv,page,'typeAction=contactGroup&id='+id+'&name64='+URLEncode(name64)+'&type='+type+'&lightbox='+lightbox,0);
		div.style.display = 'block';
		divID.innerHTML = 'showActionContactGroup'+id;
	}
}
function closeChooseEncode()
{
	closePreview();
	document.formChooseEncode.submit();
}
function closePreview()
{
	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 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,color,addBackground) 
{
	elem.style.backgroundColor = "#"+color;
	if (color=='ffe16c' || addBackground==1)
	{
		elem.style.backgroundImage = "url(/img/fond6.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 bgTipsOut(elem) 
{
	elem.style.backgroundColor = "#eeeeee";
	elem.style.backgroundImage = "url(/img/fond3.gif)";
	elem.style.backgroundPosition = "top center";
	elem.style.backgroundRepeat = "repeat-x";
}
function border(elem,color) 
{
	elem.style.border = "1px solid #"+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=\"/img/loading.gif\" width=\"20\" height=\"20\" alt=\"Loading\" title=\"Loading\" /></div>");
	else
		document.getElementById("loading").style.display = 'none';
}
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';

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

		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];

		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;
		objLightbox.style.left = (lightboxLeft<0) ? 4 : lightboxLeft;
		objDiv.style.height = height;
		objDiv.style.width = width;
	}
}
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 = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	objOverlay.style.height = arrayPageSize[1];
	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;
	objLightbox.style.left = (lightboxLeft<0) ? 4 : lightboxLeft;
	objLightbox.style.display = 'block';

	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 = 'img/close2.png';
	objCloseButton.border = 0;
	objCloseButton.setAttribute('id','closeButton');
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.top = -12;
	objCloseButton.style.right = -12;
	objCloseButton.style.zIndex = 200;
	objLink.appendChild(objCloseButton);

	var objImgLoading = document.createElement("img");
	objImgLoading.src = 'img/loading.gif';
	objImgLoading.border = 0;
	objImgLoading.setAttribute('id','lightboxLoading');
	objImgLoading.style.position = 'absolute';
	objImgLoading.style.top = 4;
	objImgLoading.style.left = 4;
	objImgLoading.style.zIndex = 200;
	objLightbox.appendChild(objImgLoading);

	var objDiv = document.createElement("iframe");
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.setAttribute('frameborder','no');
	objDiv.setAttribute('border','0');
	objDiv.setAttribute('scrolling','no');
	objDiv.onload = function () {document.getElementById('lightboxLoading').style.display='none'}
	objDiv.src = link;
	objDiv.style.height = height;
	objDiv.style.width = width;
	objDiv.style.padding = 0;
	objDiv.style.margin = 0;
	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 = 'img/close2.png';
	objCloseButton.border = 0;
	objCloseButton.setAttribute('id','closeButton');
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.top = -12;
	objCloseButton.style.right = -12;
	objCloseButton.style.zIndex = 200;
	objLink.appendChild(objCloseButton);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv1');
	objDiv.style.height = height;
	objDiv.style.height = height;
	objDiv.style.width = width;
	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);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height;
	objDiv.style.width = width;
	objDiv.innerHTML='<form name="formErrorTmp" action="" method="post"><table width="100%" height="'+(height-4)+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="/img/z063s4.png" with="48" height="48" alt="" title="" /></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" 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);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height;
	objDiv.style.width = width;
	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="/img/z067p4.png" with="48" height="48" alt="" title="" /></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" 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);

	var objDiv = document.createElement("div");
	objDiv.style.display = 'none';
	objDiv.setAttribute('id','lightboxDiv');
	objDiv.style.height = height;
	objDiv.style.width = width;
	objDiv.innerHTML='<form name="formAlertTmp" action="" method="post"><table width="100%" height="'+(height-4)+'" border="0" cellspacing="2" cellpadding="2"><tr><td width="1%"><img src="/img/z063s4.png" with="48" height="48" alt="" title="" /></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" onClick="hideLightbox(\''+idLightbox+'\')" style="width:100px"></td></tr></table></form>';
	objLightbox.appendChild(objDiv);
	objDiv.style.display = 'block';
}
function showLightboxLoading()
{
	var idLightbox = 'info';

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

	var html = '<br /><center>Loading ...<br /><img src="/img/loading.gif" width="20" height="20" vspace="10" alt="Loading" title="Loading" /></center>';
	var width = 200;
	var height = 60;

	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;
	objDiv.style.width = width;
	objDiv.innerHTML=html;
	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 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 = '/img/19.gif';
	}
	else if (elemDiv && elemDiv.style.display=='block')
	{
		elemDiv.style.display = 'none';
		if (elemImg)
			elemImg.src = '/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 showSettingsSyncML(syncBookmark,syncContact,syncCalendar,syncTask,syncNote,syncBriefcase,syncMail,syncSms,syncTaskIntoCalendar,syncNoteTextPlain,name)
{
	ajaxHttpRequest("settingsMobile","/infoSyncML.php","action=showSettings&name="+name+"&syncBookmark="+syncBookmark+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncBriefcase="+syncBriefcase+"&syncMail="+syncMail+"&syncSms="+syncSms+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain,1);
}
function showSettingsSendSyncML(syncBookmark,syncContact,syncCalendar,syncTask,syncNote,syncBriefcase,syncMail,syncSms,syncTaskIntoCalendar,syncNoteTextPlain)
{
	ajaxHttpRequest("settingsSend","/infoSyncML.php","action=showSettingsSend&syncBookmark="+syncBookmark+"&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncBriefcase="+syncBriefcase+"&syncMail="+syncMail+"&syncSms="+syncSms+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain,1);
}
function sendSettingsSyncML() 
{
	var form = document.sendSettings;
	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","/infoSyncML.php","action=sendSettings&syncContact="+syncContact+"&syncCalendar="+syncCalendar+"&syncTask="+syncTask+"&syncNote="+syncNote+"&syncTaskIntoCalendar="+syncTaskIntoCalendar+"&syncNoteTextPlain="+syncNoteTextPlain+"&codeCountry="+codeCountry+"&mobile="+mobile,1);
}
