var _cachesite = null;
var MaxFonction = 3;
var MySelectedItems =''; //Contient les fonctions souhaité d'un candidat
var OffreAddedtems = new Array();
var CvAddedtems = new Array();
var DoAddOffre = '';
var DoAddCV = '';
var ListViewed = '';
var _etatCompte = 1;
var _currentAncre = '';
var ErreurAjax = "Votre requ&ecirc;te n'a pas pu &ecirc;tre executer";
IS_IE6 = document.all && window.print && !window.opera && ( !document.compatMode || /MSIE 6/.test(navigator.userAgent) || (document.compatMode && document.compatMode=="BackCompat"));
is_ie = (window.navigator.userAgent.indexOf("MSIE") != -1);
//------------------ scrollTop
function getScrollTop(){
	if( document.body && ( document.body.scrollLeft || document.body.scrollTop ))
		return document.body.scrollTop;
	else
		return document.documentElement.scrollTop;
}
function setScrollTop(nb){
	if( document.body && ( document.body.scrollLeft || document.body.scrollTop ))
		 document.body.scrollTop = nb;
	else
		 document.documentElement.scrollTop = nb;
}
function SetMenuWeight(menu){
	DivBold = $('submenu').getElementsByClassName('setBold');
	for (i=0;i<DivBold.length;i++){
		DivBold[i].addClassName('setNormal');
	}
	if(menu){
		menu.addClassName('setBold');
		menu.removeClassName('setNormal');
	}
}

function SetWeightNormal(menu){
	if(menu) menu.addClassName('weightNormal');
}

function SetWeightBold(menu){
	if(menu) menu.addClassName('bold');
}

//loading icon ByClass/ID
function showloading(type){
	if(type == 'Byclass'){
		myLoading = $('main').getElementsByClassName('loading');
		for(i=0;i<myLoading.length;i++){
			myLoading[i].removeClassName('hidden');
		}
	}else{
		if($('loading')) $('loading').removeClassName('hidden');
	}
}

function hideloading(type){
		myLoading = $('main').getElementsByClassName('loading');
		for(i=0;i<myLoading.length;i++){
			myLoading[i].addClassName('hidden');
		}		
		if($('loading')) $('loading').addClassName('hidden');
}
////////////////////////////////

//Mots de passe oublier
function EnvoiEmail()
{
	if(isEmail($('forgotemail'))){
		params ='';
		params += '?forgotemail='+encodeURIComponent($('forgotemail').value);
		new Ajax.Request('/compte/EnvoiEmail'+params, {asynchronous:false, evalScripts:false, onComplete:function(request, json){
			alert(request.responseText);
			$('ForgotPass').addClassName('hidden');
			$('password_forget').addClassName('hidden');
		}});				
	}else{
		alert('Email invalide!!');
	}	
}
//////////


function executeRep(rep){
	if(rep !=""){
		if(rep.toLowerCase() == "false")
			msgbox(ErreurAjax);
		else
			eval(rep);
	}
}
/*----------------------------------------------------------*/
function removeCachebody(event,func){
		var e = Event.findElement(event, 'div');
		//if(IS_IE6){
			if(e.className == "cachesite" ){
				func();
				Event.stopObserving(document, 'click', myFunc.removeCachebody)
				restoreSelect();
			}
		//}
}
/*-------------------chargement box-------------------------*/
function chargementbox(msg,width){
	if(!msg) msg="Veuillez patienter quelques instants...";
	cacheBody();
	if(!width) width = 180;
		myLeft = ((document.documentElement.clientWidth - width)/2);
		myTop = ((document.documentElement.clientHeight - 180)/2)+getScrollTop();
		contentDiv = "<div class='floatL clear rMargin' style='width:"+width+"px;color:#B1B1B1'><div class='floatR loading rPaddingSm'></div><div class='floatL txtC tMargin' style='width:"+(width-55)+"px;'>"+msg+"</div></div>";
		myDiv  = "<table><tr><td class='voteTL'></td><td class='voteTT'></td><td class='voteTR'></td></tr><tr><td class='voteLL'></td><td class='voteMM'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px";
		bigPhoto.innerHTML = myDiv;
		$('top_part_one').appendChild(bigPhoto);
}
function removeChargementbox(){
	_cachesite.remove();
	if($('bigPhoto')) $('bigPhoto').remove();
	restoreSelect();
}
/*-------------------msg box-------------------------*/
onClose ="";
function msgbox(msg,scriptOnClose,type,width){
	cacheBody();
	onClose = scriptOnClose;
	if(!width) width = 180;
	if(type = "ok"){
		typeMsg = "";
	}else
		typeMsg = "<div class='floatR interogation rPaddingSm'></div>"
		myLeft = ((document.documentElement.clientWidth - width)/2);
		myTop = ((document.documentElement.clientHeight - 180)/2)+getScrollTop();
		contentDiv = "<div class='floatR clear btnClose'></div><div class='floatL clear rMargin' style='width:"+width+"px;color:#B1B1B1'>"+typeMsg+"<div class='floatL txtC' style='width:"+(width-55)+"px;'>"+msg+"</div></div>";
		myDiv  = "<table><tr><td class='voteTL'></td><td class='voteTT'></td><td class='voteTR'></td></tr><tr><td class='voteLL'></td><td class='voteMM'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px";
		bigPhoto.innerHTML = myDiv;
		$('top_part_one').appendChild(bigPhoto);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
		myFunc = {
			removeCachebody : function(event){
				removeCachebody(event,closeMsgbox)
			}
		}
		setTimeout("Event.observe(document, 'click', myFunc.removeCachebody)",100);
}
function closeMsgbox(){
	if($('ne_plus_afficher')){
		if($('ne_plus_afficher').checked){
			new Ajax.Request('/compte/nePlusAfficherMsgAddMesContacts',{asynchronous:true, evalScripts:false,onComplete:function(request, json){}});
		}
		new Ajax.Request('/compte/nePlusAfficherMsgAddMesContactsKillSession',{asynchronous:true, evalScripts:false,onComplete:function(request, json){}});
	}
	_cachesite.remove();
	$('bigPhoto').remove();
	if(onClose != "") eval(onClose);
	onClose ="";
	restoreSelect()
}
/*--------------------get mes contacts--------------*/
//getMesContacts('');
Event.observe(window, 'resize', function(){
	Scrolling();
	Scrolling();
});
function getLogoMessenger(){
	if($('logo_messenger'))	$('logo_messenger').src = "/images/"+$('type_messenger').value+".gif"
}
function submitAddMesContact(){
	var erreur = "";
	if(!$('type_messenger').value)
		erreur += "- Type de messagerie\n";
	if(!isEmail($('email')))
		erreur += "- Email\n";
	if(!$('pass').value)
		erreur += "- Mot de passe\n";
	if(erreur == ""){
		if($('loading1')) $('loading1').removeClassName('hidden');
		params = "messagerie="+$('type_messenger').value+"&email="+$('email').value+"&pass="+$('pass').value
		new Ajax.Request('/compte/addMesContacts?'+params,{asynchronous:true, evalScripts:false,onComplete:function(request, json){closeMsgbox();}});
	}else
		alert('Veuillez verifier les champs suivants : \n'+erreur);
}
function getMesContacts(){
		cacheBody();
		width = 500;
		height = 190;
		myLeft = ((document.documentElement.clientWidth - width)/2);
		myTop = ((document.documentElement.clientHeight - height)/2)+getScrollTop();
		select = "<select style='width:123px;' id='type_messenger' name='type_messenger' onchange='getLogoMessenger()'><option value='gmail' >Gmail</option><option value='hotmail' >Hotmail</option><option value='yahoo' >Yahoo</option><option value='aol' >AOL</option></select>";
		button = '<div class="floaR clear tPadding" style="height: 20px"><div class="btBackground font11 rMargin floatR setNormal"><a onclick="submitAddMesContact();return false;" href="#" id="btnAddFrm">Envoyer</a></div><div id="loading1" class="floatR hidden"></div></div>';
		bottom = "<div class='floatL grisFonce clear font11'  style='height: 20px;width:480px;'><a class='floatR mauveLink' onclick='closeMsgbox();return false;' href='#'>Plus tard</a><input class='checkbox' type='checkbox' name='ne_plus_afficher' id='ne_plus_afficher' style='margin-top:0px;' /><label>Ne plus afficher</label></div>";
		form ="<div class='floatL grisFonce hMargin vPadding weightNormal' style='width:280px'><div  class='bPadding'>En un geste simple, vous pouvez aider <u>votre famille</u> et <u>vos amis</u> &agrave; <b>trouver un emploi</b>.</div><div class='bPaddingSm'><label>Type de messagerie &nbsp;&nbsp;</label>"+select+"</div><div class='bPaddingSm'><label class='tMargin' for='email'>Email</label><input name='email' id='email' type='text' style='margin-left:90px;width:120px' /></div><div class='bPaddingSm'><label>Mot de passe</label><input  name='pass' id='pass' type='password' style='margin-left: 48px;width:120px;'></input></div></div><img id='logo_messenger' src='/images/gmail.gif' alt='' style='margin-top:30px' />"+button+bottom;
		contentDiv = "<div id='luiEcrireMsg' class='font12 bold' style='height:"+height+"px;width:"+width+"px;'><div style='padding-left:7px;padding-right:7px;color:#3d3d3d;height:25px;background-color:#e0f1ce;'><div class='floatR clear btnClose'></div><div class=''>Invitez votre entourage</div></div>"+form+"</div>";
		myDiv  = "<table><tr><td class='voteTL1'></td><td class='voteTT1'></td><td class='voteTR1'></td></tr><tr><td class='voteLL'></td><td class='voteMM padding0'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.className = 'luiEcrireMsg';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px";
		bigPhoto.innerHTML = myDiv;
		$('top_part_one').appendChild(bigPhoto);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
		myFunc = {
			removeCachebody : function(event){
				removeCachebody(event,closePopupPhoto)
			}
		}
		setTimeout("Event.observe(document, 'click', myFunc.removeCachebody)",100);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
}
/*--------------------vote photo -------------------*/
fixe = false;
id_user = "";
id_photo = "";
function setClassNote(event){
	if(!fixe){
		var node = $$('#note div')[0].childNodes;
		for(i=0;i<node.length;i++){
			if(this == node[i]) j = i+1;
		}
		for(i=0;i<j;i++){
			node[i].className = 'noteOn';
		}
		for(i=j;i<node.length;i++){
			node[i].className = 'noteOff';
		}
	}
}
var noteChoisi = 0;
function setClassNote1(j){
	if(!fixe){
		noteChoisi = j;
		var node = $$('#note div')[0].childNodes;
		for(i=0;i<j;i++){
			node[i].className = 'noteOn';
		}
		for(i=j;i<node.length;i++){
			node[i].className = 'noteOff';
		}
	}
}
function setClassNoteOff(event){
	if(!fixe && $$('#note div')[0]){
		var node = $$('#note div')[0].childNodes;
		//alert(event);
		var e = Event.findElement(event, 'div');
		if(e.className != 'noteOn' && e.className != 'noteOff' ){
			for(i=0;i<node.length;i++){
				node[i].className = 'noteOff';
			}
		}
	}
}
function fixeClassNote(event){
	var node = $$('#note div')[0].childNodes;
	if($('noteOff1')) $('noteOff1').addClassName('curDefault');
	for(i=0;i<node.length;i++){
		node[i].addClassName('curDefault');
		Event.stopObserving(node[i], 'mouseover', setClassNote);
		Event.stopObserving(node[i], 'click', fixeClassNote);
	}
	var laNote = (((parseFloat($('noteVote').innerHTML)* parseFloat($('nbrVotant').innerHTML))+noteChoisi)/(parseFloat($('nbrVotant').innerHTML)+1));
	try{
		laNote += '';
		laNote = laNote.substring(0,laNote.indexOf('.')+3);
	}catch(e){}

	$('noteVote').innerHTML = laNote;
	$('nbrVotant').innerHTML = parseFloat($('nbrVotant').innerHTML)+ 1;
	fixe = true;
	params = 'note='+noteChoisi;
	params += '&id_user='+id_user;
	params += '&id_photo='+id_photo;
	if(imgClicked){
		var donnees = imgClicked.readAttribute('onclick').replace('getPopupPhoto(','').replace(')','').replace(';','').split(',');
		donnees[1] =  "'"+$('nbrVotant').innerHTML+"'";
		donnees[2] =  "'"+$('noteVote').innerHTML+"'";
		donnees[3] =  "''";
		donnees[4] =  "''";
		var params1 ="";
		for(i=0;i<donnees.length;i++){
			params1 += donnees[i]+","; 
		}
		
		params1 = params1.substring(0,params1.length-1);
		params1 = "getPopupPhoto("+params1+")";
		//imgClicked.writeAttribute('class1',params);
		for(i=0;i<imgClicked.attributes.length;i++){
			if(imgClicked.attributes[i].nodeName == "onclick"){
				imgClicked.attributes[i].nodeValue = params1;
				break;
			}
		}
		if(imgClicked.parentNode.parentNode.id == "album")imgClicked.next().innerHTML = "Note : "+$('noteVote').innerHTML;
	}
	new Ajax.Request('/rencontres/votePhoto?'+params,{asynchronous:true, evalScripts:false,onComplete:function(request, json){$('alert').innerHTML = request.responseText;stopEvents();}});
}

function closePopupPhoto(){
	_cachesite.remove();
	$('bigPhoto').remove();
	fixe = false;
	restoreSelect()
}
var imgClicked = null;
function getHeightAndWidth(hi,wi){
	var wNormal = 800;
	var hNormal = 500;
	var myHi1 = 0;
	myWi = parseInt(wi)+140;
	myHi = parseInt(hi);
	if(wNormal >= document.documentElement.clientWidth)
		wNormal = document.documentElement.clientWidth -90;
	if(hNormal >= document.documentElement.clientHeight)
		hNormal = document.documentElement.clientHeight-90;
		
	if(parseInt(wi)>wNormal && parseInt(wi)>parseInt(hi)){
		myHi = (wNormal*parseInt(hi)/parseInt(wi))-90;
		myWi = wNormal;
	}else if(myHi>hNormal){
		myWi = (parseInt(wi)*hNormal/parseInt(hi))+140 ;
		myHi = hNormal;
	}
	else if(myHi<120){
		myHi1 = 60;
	}
	return [myHi,myWi,myHi1];
}
function getPopupPhoto(img,nbr,note,user,photo,wi,hi,obj){
	if(img){
		if(obj){
			imgClicked = $(obj);
		}
		myImg =  document.createElement('img');
		id_user = user;
		id_photo = photo;
		myHi1 = 0;
		var taille = getHeightAndWidth(hi,wi);
		myHi = taille[0];
		myWi = taille[1];
		myHi1 = taille[2];
		myLeft = ((document.documentElement.clientWidth - myWi)/2);
		if(myLeft<0) myLeft = 0;
		myTop = ((document.documentElement.clientHeight - myHi)/2)-25+getScrollTop();
		if(myTop<0) myTop = 0;
		cacheBody();
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px"
		var divVote ="";
		if(user == '-1') divVote ="<u>Vous avez d&eacute;ja vot&eacute;</u>";
		else if(id_user && id_photo)divVote = "<div style='width:110px;' id='noteOff1' class='noteOff' onmousemove='getMousePos(event)'><div id='noteOff' class='noteOff'  onmouseover='setClassNote1(1)'></div><div class='noteOff'  onmouseover='setClassNote1(2)'></div><div class='noteOff'  onmouseover='setClassNote1(3)'></div><div class='noteOff' onmouseover='setClassNote1(4)' ></div><div class='noteOff' onmouseover='setClassNote1(5)'></div></div>";
		contentDiv ="<div id='interne' style='width:"+(myWi)+"px;height:"+(myHi+myHi1)+"px;'><img alt='' src='/"+img+"' style='width:"+(myWi-140)+"px;height:"+myHi+"px;' /><div id='tabR'><div class='btnClose'></div><br/><div id='note'>"+divVote+"</div><div class='floatL clear grisFonce tMarginSm' style='width:100%'><span id='nbrVotant'>"+nbr+"</span> votes</div><div class='tMarginSm floatL clear' style='color:#932FB8;width:100%'>Note moyenne : <span id='noteVote'>"+note+"</span></div><div id='alert' class='tMargin floatL' style='color:red'></div></div>";
		myDiv  = "<table><tr><td class='voteTL'></td><td class='voteTT'></td><td class='voteTR'></td></tr><tr><td class='voteLL'></td><td class='voteMM'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto.innerHTML = myDiv ;
		$('top_part_one').appendChild(bigPhoto);
		if(id_user && id_photo){
			var node = [];
			if($$('#note div')[0]) node = $$('#note div')[0].childNodes;
			for(i=0;i<node.length;i++){
				//Event.observe(node[i], 'mouseover', setClassNote);
				Event.observe(node[i], 'click', fixeClassNote);
			}
			Event.observe(document, 'mousemove', setClassNoteOff);
		}
		Event.observe(document, 'mousemove', setClassNoteOff);
		myFunc = {
			removeCachebody : function(event){
				removeCachebody(event,closePopupPhoto)
			}
		}
		setTimeout("Event.observe(document, 'click', myFunc.removeCachebody)",100);
		Event.observe($$('.btnClose')[0], 'click', closePopupPhoto);
	}
}
function getMousePos(e) {
  if (document.all) {
	  posX=event.x+document.body.scrollLeft; 
	  posY=event.y+document.body.scrollTop;
  }
  else {
	  posX=e.pageX;
	  posY=e.pageY;
  }
  return [posX,posY]
}
//---------------------------------------------------------
function restoreSelect(){
	if($('website') && IS_IE6){
		Lang = $('website').getElementsByClassName('select');
		for(i=0;i<Lang.length;i++){
			Lang[i].removeClassName('hidden');
		}
	}
	if($('website')){
		Lang = $('website').getElementsByClassName('selectFlash');
		for(i=0;i<Lang.length;i++){
			Lang[i].removeClassName('hidden');
		}
	}	
}
function removeSelect(){
	if($('website') && IS_IE6){
		Lang = $('website').getElementsByClassName('select');
		for(i=0;i<Lang.length;i++){
			Lang[i].addClassName('hidden');
		}
	}
	if($('website')){
		Lang = $('website').getElementsByClassName('selectFlash');
		for(i=0;i<Lang.length;i++){
			Lang[i].addClassName('hidden');
		}
	}	
}

/*--------------------lui ecrire -------------------------*/
function luiEcrirebox(to,id_user){
		cacheBody();
		width = 725;
		height = 300;
		myLeft = ((document.documentElement.clientWidth - width)/2);
		myTop = ((document.documentElement.clientHeight - height)/2)+getScrollTop();
		button = '<div><div class="btBackground tMargin rMargin txtSize11 floatR setNormal"><a onclick="closeMsgbox();return false;" href="#">Annuler</a></div><div class="btBackground tMargin rMargin txtSize11 floatR setNormal"><a onclick="submitMsg('+id_user+');return false;" href="#" id="btnAddFrm">Envoyer</a></div><div class="loading floatR hidden"></div></div>';
		form ="<div class='hMargin vMargin'><span>A &nbsp;&nbsp;<span><span class='mauveLink'>"+to+"</span><div class='tMargin'>Objet</div><input name='objet' id='objet' type='text' /><br/><span>Message</span><br/><textarea name='msg' id='msg'></textarea></div>"+button;
		contentDiv = "<div id='luiEcrireMsg' class='font12 bold' style='height:"+height+"px;width:"+width+"px;'><div style='padding-left:7px;padding-right:7px;color:#3d3d3d;height:25px;background-color:#e0f1ce;'><div class='floatR clear btnClose'></div><div class=''>Envoyer un message</div></div>"+form+"</div>";
		myDiv  = "<table><tr><td class='voteTL1'></td><td class='voteTT1'></td><td class='voteTR1'></td></tr><tr><td class='voteLL'></td><td class='voteMM padding0'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.className = 'luiEcrireMsg';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px";
		bigPhoto.innerHTML = myDiv;
		$('top_part_one').appendChild(bigPhoto);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
		myFunc = {
			removeCachebody : function(event){
				removeCachebody(event,closePopupPhoto)
			}
		}
		setTimeout("Event.observe(document, 'click', myFunc.removeCachebody)",100);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
}
function luiRepondrebox(to,id_user,id_parent){
		cacheBody();
		width = 725;
		height = 270;
		myLeft = ((document.documentElement.clientWidth - width)/2);
		myTop = ((document.documentElement.clientHeight - height)/2)+getScrollTop();
		button = '<div><div class="btBackground tMargin rMargin txtSize11 floatR setNormal"><a onclick="closeMsgbox();return false;" href="#">Annuler</a></div><div class="btBackground tMargin rMargin txtSize11 floatR setNormal"><a onclick="submitMsg('+id_user+','+id_parent+');return false;" href="#" id="btnAddFrm">Envoyer</a></div><div class="loading floatR hidden"></div></div>';
		form ="<div class='hMargin vMargin'><span>A &nbsp;&nbsp;<span><span class='mauveLink'>"+to+"</span><br/><br/><span>Message</span><br/><br/><textarea name='msg' wrap='HARD' id='msg'></textarea></div>"+button;
		contentDiv = "<div id='luiEcrireMsg' class='font12 bold' style='height:"+height+"px;width:"+width+"px;'><div style='padding-left:7px;padding-right:7px;color:#3d3d3d;height:25px;background-color:#e0f1ce;'><div class='floatR clear btnClose'></div><div class=''>Envoyer un message</div></div>"+form+"</div>";
		myDiv  = "<table><tr><td class='voteTL1'></td><td class='voteTT1'></td><td class='voteTR1'></td></tr><tr><td class='voteLL'></td><td class='voteMM padding0'>"+contentDiv+"</td><td class='voteRR'></td></tr><tr><td class='voteBL'></td><td class='voteBB'></td><td class='voteBR'></td></tr></table>";
		bigPhoto =  document.createElement('div');
		bigPhoto.id = 'bigPhoto';
		bigPhoto.className = 'luiEcrireMsg';
		bigPhoto.style.left = myLeft+"px"
		bigPhoto.style.top = myTop+"px";
		bigPhoto.innerHTML = myDiv;
		$('top_part_one').appendChild(bigPhoto);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
		myFunc = {
			removeCachebody : function(event){
				removeCachebody(event,closePopupPhoto)
			}
		}
		setTimeout("Event.observe(document, 'click', myFunc.removeCachebody)",100);
		Event.observe($$('.btnClose')[0], 'click', closeMsgbox);
}
/*--------------------------------------------------------*/
function viewForgotPass(){
	if($('ForgotPass').hasClassName('hidden')){
		$('ForgotPass').removeClassName('hidden');
	}else{
		$('ForgotPass').addClassName('hidden');
	}
}
function addGroupeCategorie(txt){
	$('mesCategories').removeClassName('hidden');
	$('mesCategories').innerHTML += txt; 
}
function removeCategorie(id,obj){
	params ="?id="+id;
	new Ajax.Request('/contacts/RemoveCategorie'+params,{asynchronous:true, evalScripts:false});
	$('mesCategories').removeChild(obj.parentNode);
}
function verifLogin(e){	
	params ='';
	if(e){
		params += '?email='+encodeURIComponent($j('#loginform1 #email')[0].value);
		params += '&password='+encodeURIComponent($j('#loginform1 #password')[0].value);
	new Ajax.Request('/compte/VerifLogin'+params, {asynchronous:true, evalScripts:false, onComplete:function(request, json){if(request.responseText == '0'){$('LoginError1').show()}else{document.loginform1.submit();}}});
	}else{
		params += '?email='+encodeURIComponent($('email').value);
		params += '&password='+encodeURIComponent($('password').value);
		new Ajax.Request('/compte/VerifLogin'+params, {asynchronous:true, evalScripts:false, onComplete:function(request, json){if(request.responseText == '0'){$('LoginError').show()}else{document.loginform.submit();}}});
	}			
}


//--------------------Upload File FLASH
function loadingProgress(bytesLoaded, bytesTotal,act){
	$('loading').removeClassName('hidden');
	showloading('Byclass');
	if($('photo'))$('photo').addClassName('hidden');
	if($('titre'))$('titre').addClassName('hidden');

}

function uploadFile(id,id_photo,path,act){
	thisMovie("uploadImage").uploadFile(id,id_photo,path,act);
	
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
         return window[movieName];
    }
    else {
         return document[movieName];
    }
}
//------------------------------en attante (ajouter a mes amis+contact)-----------------------------------
myObj = "";
function enAttente(obj,style,arg){
	myObj = obj;
	if(arg)
		obj.innerHTML = "<div class='gris txtSize11 txtR rMarginSm' style='"+style+"'>En attente</div>";
	else
		obj.innerHTML = "<div class='gris txtSize11 txtR' style='"+style+"'>Attente d'acceptation</div>";
	obj.removeAttribute('onclick');
	return false;
}
function enAttenteErreur(rep){
	if(rep == "false") myObj.innerHTML = "<div class='gris txtSize11'>"+ErreurAjax+"</div>";
	return false;
}

//---------------------------------------------------------------------------------------------------------
function champObligatoire(id,sfor){
	if($(id).hasClassName('select')) $(id).addClassName('bgRed');
	else $(id).addClassName('brdRed');
	
	if(!sfor){
		var label = $('main').getElementsBySelector('[for="'+id+'"]')
		sfor = label[0];
	}else{
		var label = $('main').getElementsBySelector('[for="'+sfor+'"]')
		sfor = label[0];
	}
	if(sfor){
		if(sfor.innerHTML.indexOf(' *') == -1)
		sfor.innerHTML += " *";
	}
	if($(id).hasClassName('select'))
		Event.observe($(id),'change',function(){$(id).removeClassName('bgRed')});
	else
		Event.observe($(id),'keypress',function(){$(id).removeClassName('brdRed')});
}
//inscription
function DoRegister(){
	var erreur = false;
	if(!isEmail($('registeremail'))){
		champObligatoire('registeremail');
		erreur = true
	}
	if($('registerpassword').value.length < 5 || ($('registerpassword').value != $('registerpassword2').value)){
		champObligatoire('registerpassword');
		champObligatoire('registerpassword2');
		erreur = true
	}
	if($('nom').value == '' ){
		champObligatoire('nom');
		erreur = true
	}
	if($('prenom').value == ''){
		champObligatoire('prenom');
		erreur = true
	}
	if( $('annee').value == '0'){
		champObligatoire('annee','annee');
		erreur = true
	}
	if( $('mois').value == '0'){
		champObligatoire('mois','annee');
		erreur = true
	}
	if( $('jour').value == '0'){
		champObligatoire('jour','annee');
		erreur = true
	}
	if($('villes').value == 0){
		champObligatoire('villes');
		erreur = true
	}
	if($('pays').value == 0){
		champObligatoire('pays');
		erreur = true
	}
	if(!erreur)DoregisterEmail();
}

function DoregisterEmail()
{
	if(isEmail($('registeremail'))){
		params = '?registeremail='+encodeURIComponent($('registeremail').value);
		new Ajax.Request('/compte/VerifMail'+params, {asynchronous:true, evalScripts:false, onComplete:function(request, json){DoregisterEmailResult(request,json)}});
	}	
}

function DoregisterEmailResult(request,json)
{
	if(request.responseText == '1'){
		document.profileCompte.registeremail.focus();
		$('emailExiste').className = '';
	}else{
		document.profileCompte.submit();
	}
}

function validateComments()
{
	message = '';
   	if ($('commentsauteur').value == '') message += '. Pseudo' + '\n';   		
  	if (!isEmail($('commentsemail'))) message += '. Email' + '\n';      	
  	if ($('commentaire').value == '') message += '. Commentaire' + '\n';  
   
	if(message != ''){
		alert('Veuillez verifier les champs suivants :'+ '\n\n' + message);
	}else{
		document.commentsform.submit();
	}
   
}
/////////////////

//--------------------General fonctions --------------------------
function trim(str)
{
     s = str.replace(/^(\s)*/, '');
     s = s.replace(/(\s)*$/, '');
     return s;
}

function cacheBody()
{
	var Lang = '';
	_cachesite = document.createElement('div');
	Element.extend(_cachesite);
	_cachesite.addClassName("cachesite");
	//document.body.appendChild(_cachesite);
	$('website').appendChild(_cachesite);
	
	_cachesite.style.width = document.documentElement.clientWidth + "px";
	_cachesite.style.height = document.documentElement.clientHeight + "px";
	_cachesite.style.top = getScrollTop() + "px";

	if($('SF_Candidat')) $('SF_Candidat').addClassName('hidden');
	if($('ST_Candidat')) $('ST_Candidat').addClassName('hidden');
	if($('NiveauAtteint')) $('NiveauAtteint').addClassName('hidden');
	if($('ListSecteur')) $('ListSecteur').addClassName('hidden');
	
	removeSelect();
		
}

function Scrolling(){
	if(_cachesite){
		_cachesite.style.width = document.documentElement.clientWidth + "px";
		_cachesite.style.height = document.documentElement.clientHeight + "px";
	  	_cachesite.style.top = getScrollTop() + "px";
  	}	
  	
  	if($('editExperience')){
	  	if($('editExperience').className != 'hidden'){
	  		$('editExperience').style.marginLeft = ((document.documentElement.clientWidth - 725)/2) + "px";
			$('editExperience').style.marginTop = ((document.documentElement.clientHeight - 285)/2) + (getScrollTop()) + "px";	
	  	}
	}  	
  	
  	if($('editFormation')){
	  	if($('editFormation').className != 'hidden'){
	  		$('editFormation').style.marginLeft = ((document.documentElement.clientWidth - 725)/2) + "px";
			$('editFormation').style.marginTop = ((document.documentElement.clientHeight - 285)/2) + (getScrollTop()) + "px";	
	  	}  	
  	}
  	
  	if($('EnvoyeaAmi')){
	  	if($('EnvoyeaAmi').className != 'hidden'){
		  	$('EnvoyeaAmi').style.marginLeft = ((document.documentElement.clientWidth - 725)/2) + "px";
			$('EnvoyeaAmi').style.marginTop = ((document.documentElement.clientHeight - 265)/2) + (getScrollTop()) + "px";
	  	}
	}	 
	
	if($('PartagerCV')){
		if($('PartagerCV').className != 'hidden'){
			$('PartagerCV').style.marginLeft = ((document.documentElement.clientWidth - 503)/2) + "px";
			$('PartagerCV').style.marginTop = ((document.documentElement.clientHeight - 240)/2) + (getScrollTop()) + "px";			
		}
	} 
	
	if($('EnvoyeaAmi')){
		if($('EnvoyeaAmi').className != 'hidden'){
			$('EnvoyeaAmi').style.marginLeft = ((document.documentElement.clientWidth - 725)/2) + "px";
			$('EnvoyeaAmi').style.marginTop = ((document.documentElement.clientHeight - 265)/2) + (getScrollTop()) + "px";					
		}	
	}
	if($('bigPhoto')){
		if($('bigPhoto').className != 'hidden'){
			$('bigPhoto').style.top = ((document.documentElement.clientHeight - $('bigPhoto').offsetHeight)/2) + (getScrollTop()) + "px";
			scrollRight = 0;
			if($('website').clientWidth > document.documentElement.clientWidth)
				scrollRight = $('website').clientWidth-document.documentElement.clientWidth;
			$('bigPhoto').style.left = (((document.documentElement.clientWidth - $('bigPhoto').offsetWidth)/2)) + "px";
			if($('interne')){
				myLeft = ((document.documentElement.clientWidth - myWi)/2);
				if(myLeft<0) myLeft = 0;
				myTop = ((document.documentElement.clientHeight - myHi)/2)-25+getScrollTop();
				if(myTop<0) myTop = 0;
			
				var img = $$('#interne img')[0];
				var taille = getHeightAndWidth(img.naturalHeight,img.naturalWidth);
				myHi = taille[0];
				myWi = taille[1];
				myHi1 = taille[2];
				$('interne').style.width = (myWi)+"px";
				$('interne').style.height = (myHi+myHi1)+"px";
				img.style.width = (myWi-140)+"px";
				img.style.height = myHi+"px";
			}			
		}
	}	
}

function removePopup(obj){
	_cachesite.remove();
	
	if($('editFormation')){
		$('editFormation').addClassName('hidden');
		$('edit_IdFormation').value= '';
		$('edit_DateDebFormation').value= '';
		$('edit_DateFinFormation').value= '';
		$('edit_NomFormation').value= '';
		$('edit_EcoleFormation').value= '';
		$('edit_EcoleFormationL').value= 0;
		$('edit_EcoleFormationL').removeClassName('hidden');			
		$('edit_EcoleFormation').addClassName('hidden');	
		$('edit_DescriptionFormation').value= '';
		$('lnk_AutreEcole').innerHTML = 'Autre';
	}
	
	if($('editExperience')){
		$('editExperience').addClassName('hidden');
		$('edit_IdExperience').value= '';
		$('edit_DateDebExperience').value= '';
		$('edit_DateFinExperience').value= '';
		$('edit_NomExperience').value= '';
		$('edit_PosteExperience').value= '';
		$('edit_EntrepriseExperience').value= '';
		$('edit_EntrepriseExperienceL').value= 0;
		$('edit_EntrepriseExperienceL').removeClassName('hidden');			
		$('edit_EntrepriseExperience').addClassName('hidden');	
		$('edit_DescriptionExperience').value= '';
		$('lnk_AutreEntse').innerHTML = 'Autre';
	}
	
	if($('EnvoyeaAmi')){
	  	$('friend_email').value='';
	  	$('subject_email').value='';
	  	$('comment_email').value='';
		$('Lien_Offre').value='';
		$('EnvoyeaAmi').addClassName('hidden');
	}
	
	if($('PartagerCV')){
		$('PartagerCV').addClassName('hidden');
		$('PopPartage_Nom').innHTML = '';
		$('PopPartage_Ville').innHTML = '';
		$('comment_partage').value = '';
	}
	
	if($('SF_Candidat')) $('SF_Candidat').removeClassName('hidden');
	if($('ST_Candidat')) $('ST_Candidat').removeClassName('hidden');
	if($('NiveauAtteint')) $('NiveauAtteint').removeClassName('hidden');
	if($('ListSecteur')) $('ListSecteur').removeClassName('hidden');
	
	if($('website') && IS_IE6){
		Lang = $('website').getElementsByClassName('select');
		for(i=0;i<Lang.length;i++){
			Lang[i].removeClassName('hidden');
		}
	}
}

function removeAllPopup()
{
	_cachesite.remove();
	_popup.remove();
}

function ValidateURL(url) {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    if (!v.test(url)) {

        if(($F('crkExtURL')!='')) {        
        		 if(($F('crkExtURL')!='http://'))alert(Translate['InvalidURL']);        	
        	}
        return false;
    }
    return true;
}

function isEmail (field){ 
	var val = field.value;
	
	if (!val.match (/^[a-z0-9\-\._]+@[a-z0-9\-_\.]+\.[a-z]{2,4}$/gi)){
	 	return false;
	}

	return true;
}

//vérifie si la chaine envoyée est de type numérique
function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
 	var IsNumber=true;
	var Char;

	 for (i = 0; i < sText.length && IsNumber == true; i++){
		 Char = sText.charAt(i);
		 if (ValidChars.indexOf(Char) == -1){
		 	IsNumber = false;
		 }
	 }
	 return IsNumber;
} 

//CONTROLE LA VALIDITE D UN CHAMP DATE
function isDateValid(chaineDate) {
	var isDate = true;
	if (chaineDate == "") isDate= false; 	
 	var ladate = (chaineDate).split("-"); 	
	if ((ladate.length != 3) || isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) isDate= false;
	if (ladate[0].length != 4 || ladate[1].length  > 2 || ladate[2].length  > 2) isDate= false;
	return isDate;
} 

function addslashes(ch) {
	ch = ch.replace(/\\/g,"\\\\")
	ch = ch.replace(/\'/g,"\\'")
	ch = ch.replace(/\"/g,"\\\"")
return ch
}

function sortNumber(a,b)
{
	return a - b;
}

function submitEnter (event,e)
{
 
	 var keycode;
	 if (window.event)
	 	keycode = window.event.keyCode;
	 else if (event)
		keycode = event.which;

	 if (keycode == 13){
	 	if(e)
	 		verifLogin(1);
	 	else
	 		verifLogin();
	 }

}

function setEtat(obj, etat, id){
	Event.stopObserving(document.body,'mousedown',hideEtatList);
	$('etat_compte').innerHTML = obj.innerHTML
	$('list_etat_compte').addClassName("hidden");
	$('emailCompte').className = "bold lPaddingLg " + etat;
	$('etatonline').removeClassName("hidden");
	$('etatbusy').removeClassName("hidden")
	$('etataway').removeClassName("hidden")
	$('etatoffline').removeClassName("hidden")
	obj.addClassName("hidden")
	_etatCompte = id;
	updateEtat();
	
	 
}
//----------------------------------------------------------
objRemoveborderStatut = {
	removeBorderS : function(event){
		removeBorderStatut(event)
		}
	}
if($('etat_compte'))Event.observe(document, 'mousemove',objRemoveborderStatut.removeBorderS);
function removeBorderStatut(event){
	var e = Event.findElement(event, 'div');
	if(e.className != "item_etat_compte" && e.id != "etat_compte"){
		$('etat_compte').removeClassName('borderStatut');
		Event.stopObserving(document, 'mousemove',objRemoveborderStatut.removeBorderS);
		$('etat_compte').removeClassName('borderStatut');
	}else{
		Event.observe(document, 'mousemove',objRemoveborderStatut.removeBorderS);
		$('etat_compte').addClassName('borderStatut');
	}
}
//----------------------------------------------------------
function getEtatList(){
	if($('etat_compte'))Event.stopObserving(document, 'mousemove', objRemoveborderStatut.removeBorderS)
	if ($('list_etat_compte').hasClassName('hidden')){
		$('list_etat_compte').removeClassName('hidden')
		Event.observe(document.body, 'mousedown', hideEtatList);
		
	}
	else{
		$('list_etat_compte').addClassName('hidden')
		if($('etat_compte'))Event.stopObserving(document.body,'mousedown',hideEtatList);
	}
	
}

function hideEtatList(event) 
{
	var element = $(Event.element(event));
	if($('etat_compte'))$('etat_compte').removeClassName('borderStatut');
	if (!element.hasClassName('item_etat_compte') && !(element.id == 'etat_compte'))
	{
		$('list_etat_compte').addClassName("hidden");
		Event.stopObserving(document.body,'mousedown',hideEtatList);
	}
}

function addItemToMultiList(obj, word, wordPlurial, id)
{
	if(obj.checked)
	{
		obj.addClassName('itemOn');
		obj.removeClassName('itemOff');
	} else{
		obj.addClassName('itemOff');
		obj.removeClassName('itemOn');
	}
	this.refreshSelectedItem(obj, word, wordPlurial, id);
}

function refreshSelectedItem(obj, word, wordPlurial, id)
{
	var container = $(id + "_container");//obj.up().up();
	var selectedItem = container.getElementsByClassName('itemOn');
	var txt = "";
	var first = false;
	var listeId = "";
	for (var i = 0; i < selectedItem.length; i++)
	{
		if (first)
		{
			txt += ", ";
			listeId += ',';
		}
		txt += selectedItem[i].up().getElementsByTagName("label")[0].innerHTML;
		listeId += selectedItem[i].value;
		first = true;
	}
	
	var labelsDiv = container.up().getElementsByClassName("multiSelectLabels")[0]; 
	labelsDiv.update(txt);
	
	var idsDiv = container.up().getElementsByClassName("multiSelectIds")[0];
	idsDiv.value = listeId;
	
	var nb = selectedItem.length;
	if (nb > 1)
		nb += " " + wordPlurial;
	else
		nb += " " + word;
	var labelsDiv = container.up().getElementsByClassName("MyList")[0]; 
	labelsDiv.update('- ' + nb);
	
}

function showSubGroup(obj)
{
	var parent = obj.parentNode.parentNode;//obj.up().up();
	//alert($$('.subGroupList').length);
	var subGroup = parent.getElementsByClassName('subGroupList')[0];
	
	if (subGroup.hasClassName('hidden'))
		subGroup.removeClassName('hidden');
	else
		subGroup.addClassName('hidden');
	//alert(parent);
}

function ShowResult(id){

	var item =  $(id);	
	var items = $$('.select'); //document.getElementsByClassName('select');//
	if (item.className.indexOf("hidden") != -1){
		item.removeClassName('hidden');
		if(IS_IE6 && items!=undefined){					
			for(i=0;i<items.length;i++){
				items[i].addClassName('hidden');
			}
		}	
	}else{
		item.addClassName('hidden');
		if(IS_IE6 && items!=undefined){		
			for(i=0;i<items.length;i++){
				items[i].removeClassName('hidden');
			}
		}			
	}	

		
	Event.observe(document.body, 'mousedown', HideResult);
}

function HideResult(event){

		var e = Event.findElement(event, 'div');
		
		var element = $(Event.element(event));
		//alert(element.className);
		var items = document.getElementsByClassName('MultiSelectList');
		
		//alert(e.id + " -- " + e.className);
		//alert(item.hasClassName('hidden') + " -- " + element.hasClassName('MyList') + " -- " + element.hasClassName('multiListCheckBox') + " -- " +element.hasClassName('multiListItem'));  
		for (var i = 0; i < items.length; i++)
		{
			var item = items[i]
			//alert(element.className);
			if (!item.hasClassName('hidden') && !element.hasClassName('MyList') && !element.hasClassName('multiListCheckBox') && !e.hasClassName('multiListItem') 
			&& !e.hasClassName('MultiSelectList') && !e.hasClassName('multiListGroup'))
			{
				item.addClassName('hidden');
				Event.stopObserving(document.body,'mousedown',HideResult);
			}
		}
	var items = $$('.select');
	if(IS_IE6 && items!=undefined){
		for(i=0;i<items.length;i++){
			items[i].removeClassName('hidden');
		}
	}
			
		
}

/*************** gestion du status online ***********************/
function initEtat(etat)
{
	_etatCompte = etat;
	updateEtat();
	//setTimeout("updateEtat()",60000);
}

function updateEtat()
{
	new Ajax.Request("/compte/UpdateEtat?etat=" + _etatCompte, {
					 method: 'get', 
					 onSuccess: function(res) {
					 	setTimeout("updateEtat()",60000);
					 }
					 });	
}

/******************** gestion de l'ancre *******************/
function getCurrentId()
{
	var loc = window.location.toString();
	var i = loc.indexOf("#");
	var id = "";
	if (i > 0)
		id = loc.substring(i, loc.length);
	else if (id == _currentAncre) 
		return -1;
	_currentAncre = id;
}

function checkBack(func)
{
	var loc = window.location.toString();
	var i = loc.indexOf("#");
	var id = "";
	if (i > 0)
		id = loc.substring(i, loc.length);
	if (_currentAncre != id)
		eval(func)();
}

function ajoutNewsletter(){	
	message='';
	
	
	if($('Nom_News').value=='') message += '. Nom ' + '\n';
	if(!isEmail($('Mail_News')) || $('Mail_News').value=='')
	{
	message += ' . Email  ' + '\n';
	$('Mail_News').value='';
	}
	if($('ville_News').value=='0')  message += ' . Ville' + '\n';

	if (message!='')
	{
		alert ("Veuillez verifier les champs suivants:\n "+message) ;
		return false;
		}
	 else {	     
		 return true;
		 }			 
}

function ajoutNewsletterR(){
	message='';	
	
	if($('Nom_News').value=='') message += '. Nom ' + '\n';
	if(!isEmail($('Mail_News')) || $('Mail_News').value=='')
	{
	message += ' . Email  ' + '\n';
	$('Mail_News').value='';
	}
	if($('secteur_News').value=='0')  message += ' . Secteur' + '\n';

	if (message!='')
	{
		alert ("Veuillez verifier les champs suivants:\n "+message) ;
		return false;
		}
	 else {	     
		 return true;
		 }			 
}
function submitMsg(id,id_parent){
	var objt = ""
	if($('objet')){
		objt = $('objet').getValue()
		if(objt == "" || $('msg').getValue() == ""){
			alert('Tous les champs sont obligatoires à remplir.')
			return;
		}
	}else{
		if($('msg').getValue() == ""){
			alert('Tous les champs sont obligatoires à remplir.')
			return;
		}
	}
	var msg = $('msg').getValue()
	msg = msg.replace(/\n/gi, "<br>");
	msg = encodeURIComponent(msg);
	//msg = msg.replace(/\n/gi,"<br>");
	//msg = msg.replace(/&/gi,"%26");
	var params = "?id_user=" + id + "&objet=" + objt + "&msg=" + msg;
	if(id_parent) params += "&id_parent=" + id_parent
	new Ajax.Request('/messagerie/insertMessage'+params, {asynchronous:true, evalScripts:true, onSuccess:function(request, json){executeRep(request.responseText)},onFailure:function(request, json){msgbox(ErreurAjax)}});
	$('btnAddFrm').attributes[2].value = "";
	$$('#bigPhoto .loading')[0].removeClassName('hidden');
}
function deleteAmisContact(form){
	new Ajax.Request('/rencontres/deleteContacts/', {asynchronous:true, evalScripts:false, onFailure:function(request, json){msgbox(ErreurAjax)}, parameters:Form.serialize(form)});
	vars = Form.serialize(form);
	vars = vars.split('&');
	for(i=0;i<vars.length;i++){
		myVar = vars[i].split('=');
		if(myVar[0] != 'commit'){
			try{form.removeChild($(myVar[0]).parentNode.parentNode)}catch(e){}
		}
	}
	if($$('.contact').length == 0){
		if(form)form.remove();
	}
	return false;
}

function deleteContact(form){
	new Ajax.Request('/contacts/deleteContacts/', {asynchronous:true, evalScripts:false, onFailure:function(request, json){msgbox(ErreurAjax)}, parameters:Form.serialize(form)});
	vars = Form.serialize(form);
	vars = vars.split('&');
	for(i=0;i<vars.length;i++){
		myVar = vars[i].split('=');
		if(myVar[0] != 'commit'){
			try{form.removeChild($(myVar[0]).parentNode.parentNode)}catch(e){}
		}
	}
	if($$('.contact').length == 0){
		if(form)form.remove();
	}
	return false;
	
}
function deleteContactAndAmis(formContact,formAmis,formContact1,formAmis1){
	if(formContact) deleteContact(formContact);
	if(formAmis) deleteAmisContact(formAmis);
	if(formContact1) deleteContact(formContact1);
	if(formAmis1) deleteAmisContact(formAmis1);
	if($$('.contact').length == 0){
		/*try{if(formContact) formContact.remove();}catch(e){};
		try{if(formAmis) formAmis.remove();}catch(e){};
		try{if(formContact1) formContact1.remove();}catch(e){};
		try{if(formAmis1) formAmis1.remove();}catch(e){};
		try{if($('btnRemove'))$('btnRemove').remove();}catch(e){};*/
		try{if($('rencontres1')) $('rencontres1').innerHTML = ''}catch(e){};
		try{if($('demandeRecuesMenu')) $('demandeRecuesMenu').innerHTML = 'Demandes re&ccedil;ues (0)'}catch(e){};
	}
}
function goTo(to,page){
	if(page == 'sesAmis'){
		if(to == "")
			document.location = "/rencontres/recherche?back";
	}
	document.location = to+"?back";
}
function goToSearch(){
	var params = readCookie('params');
	if(params){
	new Ajax.Updater('main', '/contacts/recherche', {asynchronous:true, evalScripts:true, onLoading:function(){$('loading').className="centrer tMarginxLg";} ,onComplete:function(request, json){
		new Ajax.Updater('resultsQSContacts', '/contacts/recherche?act=result&submit=search'+params, {asynchronous:true, evalScripts:true, onLoading:function(){$('loading').className="centrer tMarginxLg";} ,onComplete:function(request, json){}});
		//eraseCookie('params');
	}});
	}else{
		history.back(0);
	}
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
if(!window.clipboardData) {
	window.clipboardData = {
		setData : function(mode,content) {
		var clipboard = document.body;
		var flashclipboard = clipboard.flashclipboard;
		if(flashclipboard == null) {
			flashclipboard = document.createElement('div');
			clipboard.flashclipboard = flashclipboard;
			clipboard.appendChild(flashclipboard);
		}
			flashclipboard.innerHTML = '<embed src="/images/clipboard.swf" FlashVars="clipboard='+encodeURIComponent(content)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		}
	}
}

function copierEnPressePapier(obj) {
	var code = $(obj).value;
	code = code.replace(/<.*?>/g,"");
	code = code.replace(/&lt;/g,"<");
	code = code.replace(/&gt;/g,">");
	return window.clipboardData.setData("text",code);
}
function getLinkToClipBoard(obj,event){
	$(obj).replace("<input id='codeACopier' readonly='true' onclick='getMessageClipBoard(event)' style='width:300px' value='"+$(obj).innerHTML+"'/>");
	copierEnPressePapier('codeACopier');
	$('codeACopier').select()
	getMessageClipBoard(event);
	return false;
}
function getMessageClipBoard(event){
	cord = initCoord(event);
	if($('clipboard_text')) $('clipboard_text').remove();
	$('codeACopier').up().insert('<span id="clipboard_text" style="left:'+(cord[0]+5)+'px;top:'+(cord[1]+getScrollTop()+10)+'px">Copi&eacute; dans le presse-papier</span>','after');
	setTimeout(function(){
		if($('clipboard_text')) $('clipboard_text').remove();
	},1500)
	$('codeACopier').select()
}
function initCoord(event) {
	return [event.clientX,event.clientY];
}
function getVilles(){
 $j.ajax({
   type: "POST",
   url: "/compte/getVilles",
   data: "pays="+$j('#pays').val(),
   success: function(data){
     	$('villes').replace(data);
   }
 });
}