// appel des cadeaux

var flag_ajax_call=true;

 var flag_page_compte;

function Ajax_Call_Page(url,cible,variable,mode,pos_mvt1,nb_mvt,pos_mvt2)
{
		if(flag_ajax_call)
		{
			if(mode=='ajax-new-action' || mode=='ajax-new-action-timer')
			{
				flag_ajax_call=false;
			}
			
			if(flag_wait_ajax==1 && mode!="event-action" && mode!="comptage-chat" && mode!="event-chat" && mode!="chat-profil" && mode.indexOf("chat-")==-1)
			{
				Showtrail(24,24,'js/wait.gif','ajax');
			}
			//alert("Ajax_Call_Page");
	
			 var httpRequest = null;
	
			 httpRequest = false;
			
			if (window.XMLHttpRequest) { // Mozilla, Safari,...
				httpRequest = new XMLHttpRequest();
				if (httpRequest.overrideMimeType) {
					httpRequest.overrideMimeType('text/xml');
					// Voir la note ci-dessous à propos de cette ligne
				}
			}
			else if (window.ActiveXObject) { // IE
				try {
					httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e) {
					try {
						httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch (e) {}
				}
			}
	
			if (!httpRequest) 
			{
				alert('Abandon :( Impossible de créer une instance XMLHTTP');
				return false;
			}
			
			
			
			if(variable=='sync')
			{
			   httpRequest.open('POST', url, false);
			}
			else
			{
			   httpRequest.open('POST', url, true);
			}
		   httpRequest.onreadystatechange = function() { Ajax_Display_Page(httpRequest,cible,mode,pos_mvt1,nb_mvt,pos_mvt2); };
			
			httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			httpRequest.send(variable);
			
			return false;
		}
 }
	

// affichage des cadeaux
function Ajax_Display_Page(httpRequest,cible,mode,pos_mvt1,nb_mvt,pos_mvt2)
 {

     if (httpRequest.readyState == 4) 
	{
         if (httpRequest.status == 200)
		 {
		   
		   flag_ajax_call=true;
		   
			 if(httpRequest.responseText=="1" && mode!="no-redirect")
			 {
			 	window.location.href="index.php";
			 }
			 else
			 {
				
				 
				 //if ajax has a visible result 
				if(cible!="no-display" && mode!="add-display" && mode.indexOf("chat-")==-1)
				 {
					//alert(httpRequest.responseText);
					//document.getElementById(cible).style.visibility="hidden";

					document.getElementById(cible).innerHTML="<center style='padding:0px;margin:0px'>"+httpRequest.responseText+"</center>";
				 }		
				 
				 if(mode.indexOf("chat-")!=-1 && cible!="no-display")
				 {
					document.getElementById(cible).innerHTML=httpRequest.responseText;
				 }	
				 
				  if(cible=="affich_profil")
				 {
					 	if(document.getElementById('page-bas'))
						{
								var temp1=document.getElementById('page-bas-place').offsetWidth+2;
								 document.getElementById('page-bas').style.width=''+temp1+'px';
								 document.getElementById('page-bas').style.visibility="visible";
						}
						
						if(document.getElementById('page-bas2'))
						{
								var temp1=document.getElementById('page-bas-place2').offsetWidth+2;
								 document.getElementById('page-bas2').style.width=''+temp1+'px';
								 document.getElementById('page-bas2').style.visibility="visible";
						}
				 }
				 
				 
				 if(mode=="ecrire-fil")
				 {
					 	Ajax_Call_Page("module/onglet/fil.php","affich_profil","login="+document.getElementById('fil-login').value+"&start=0&start_page=0","affich_fil");
				 }
				 
				 if(mode=="ecrire-mur")
				 {
					 	Ajax_Call_Page("module/onglet/mur.php","affich_profil","login="+document.getElementById('mur-login').value+"&start=0&start_page=0","affich_fil");
				 }
				 
				 if(mode=="msn" && httpRequest.responseText=="erreur")
				 {
					 	//document.getElementById('div-msn-reponse').innerHTML='';
						document.getElementById('div-msn-reponse').innerHTML='Votre invitation n\'a pas pu &ecirc;tre envoy&eacute;e &agrave; vos contacts MSN. Veuillez v&eacute;rifier vos identifiants.						<div class="spacer" style="height:29px;">&nbsp;</div>						<center> <img alt="" src="images/faux.jpg" /> </center>						<div class="spacer" style="height:29px;">&nbsp;</div>						<center>						<div class="bouton-100" id="btn_parrainage"><a style="text-decoration: none;color:#000000;" onmouseOver="javascript:void(Roll_Div(\'btn_parrainage\',100));" onmouseOut="javascript:void(Over_Div(\'btn_parrainage\',100));" href="?parrainage" >Retour</a></div>						</center>'
				 }
				 
				  if(mode=="gmail" && httpRequest.responseText=="erreur")
				 {
						//document.getElementById('div-msn-reponse').innerHTML='';
						document.getElementById('div-msn-reponse').innerHTML='Votre invitation n\'a pas pu &ecirc;tre envoy&eacute;e &agrave; vos contacts GMAIL. Veuillez v&eacute;rifier vos identifiants.						<div class="spacer" style="height:29px;">&nbsp;</div>						<center> <img alt="" src="images/faux.jpg" /> </center>						<div class="spacer" style="height:29px;">&nbsp;</div>						'
				 }
				 
				 if( (mode=="gmail" || mode=="msn") && httpRequest.responseText!="erreur")
				 {

						document.getElementById('pass_msn').value="";
					  document.getElementById('user_msn').value="";

				 }
				
				
				 if(mode=="add-display")
				 {
					//alert(httpRequest.responseText);
					//document.getElementById(cible).style.visibility="hidden";

					document.getElementById(cible).innerHTML+=""+httpRequest.responseText;
				 }	
				 
				 // chat ajax
				 
				 if(mode=="open-chat")
				 {
					 	
					var str=httpRequest.responseText;
					
					var temp_pos=str.indexOf("#");
					
					//alert(str);
					
					//id of current chat 
					id_chat=str.substring(0,temp_pos);
					
					// id of current user selected
					// if new is add current user is new add
					user=str.substring(temp_pos+1);
					
					
					Load_Chat();
					
					
				 }
				 
				 if(mode=='close-chat')
				 {
					 flag_chat_online=0;
					 cible_scroll_position='';
					 Add_On_Scroll(null,1);
					 document.getElementById('div-absolute').innerHTML=''
				 }
				 
				 if(mode=="chat-ajax")
				 {
					
					var scrolltop;
						
						if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
						{
							scrolltop=document.body.scrollTop;
						}
						else
						{
							scrolltop=truebody().scrollTop;
						}
						
						y_test=(document.documentElement.clientHeight-480)/2;
						y_test=Math.floor(y_test);
		
						scrolltop+=y_test;
						
						x_test=(document.documentElement.clientWidth-700)/2;
						x_test=Math.floor(x_test);
						
						document.getElementById('content').style.top=''+scrolltop+'px';
						document.getElementById('content').style.left=''+x_test+'px';

						
						// height for outsitde toggle
						document.getElementById('action-outside').style.height=getTotalHeight()+'px';
						
						
						// to move toggle with scroll
						//cible_scroll_position="content";
	
						Add_On_Scroll(Scroll_Position,1);
					
					Chat_Conversation("timer");
					Chat_Profil(user);
					Chat_Liste("timer");
					
					
				 }
				 
				  if(mode=="chat-profil")
				 {
					 	img_chat_profil_temp=new Array();
						
						for(ichatprofil=0;ichatprofil<document.getElementById('get-nb-img-chat-profil').value;ichatprofil++)
						{
								if(document.getElementById('get-img-chat-profil'+ichatprofil))
								{
									img_chat_profil_temp[ichatprofil]=new Image();
									img_chat_profil_temp[ichatprofil].src=document.getElementById('get-img-chat-profil'+ichatprofil).src;
									//alert(img_chat_profil_temp[ichatprofil].src);
									document.getElementById('get-img-chat-profil'+ichatprofil).src=img_chat_profil_temp[ichatprofil].src;
								}
						}
						
						/*img_liste_action=new Array("cadeau","mail","coup-coeur","ami","note-etoile-chat","acces-photo","acces-stats","liste-noire","abus"); 
						img_chat_profil_temp1=new Array();
						
						for(ichatprofil=0;ichatprofil<img_liste_action.length;ichatprofil++)
						{
								
								//alert(img_liste_action[ichatprofil])
								
								img_chat_profil_temp1[ichatprofil]=new Image();
								img_chat_profil_temp1[ichatprofil].src=document.getElementById('img_'+img_liste_action[ichatprofil]).src;
								document.getElementById('img_'+img_liste_action[ichatprofil]).src=img_chat_profil_temp1[ichatprofil].src;
								
						}*/
						
						img_chat_profil_sexe=new Image();
						img_chat_profil_sexe.src="images/fond-photo-grd-"+document.getElementById('get-img-chat-profil-sexe').value+"-blanc.png";
						document.getElementById('get-img-chat-profil2').style.backgroundImage="url("+img_chat_profil_sexe.src+")";
						
						img_chat_profil_fond=new Array();
						
						//Debug();
						
						for(ichatprofil=0;ichatprofil<document.getElementById('get-nb-img-chat-profil').value-6;ichatprofil++)
						{
							temp=ichatprofil+4;
								
								if(document.getElementById('get-img-chat-profil'+temp))
								{
									if(temp!=7)
									{
										img_chat_profil_fond[ichatprofil]=new Image();
									img_chat_profil_fond[ichatprofil].src="images/fond-photo-"+document.getElementById('get-img-chat-profil-sexe').value+"-chat.png";
									document.getElementById('get-img-chat-profil'+temp).style.backgroundImage="url("+img_chat_profil_fond[ichatprofil].src+")";
									}
								}
						}
						//alert("ddd");

				 }
				 
				 
				  if(mode=="chat-check-online")
				 {
					 
					 //alert(httpRequest.responseText)
					 if(httpRequest.responseText!="")
					{
						flag_chat_check_online=0;
						Fond_Param();
				 	}
				 }
				 
				 if(mode=="chat-ecrire")
				 {
					Chat_Conversation("ajax");
					document.getElementById("msg").value="";
				 }
				 
				 if(mode=="chat-conversation")
				 {
					 
					 if(document.getElementById("first-msg"))
					 {
						img_temp_fond= new Image();
						img_temp_fond.src="images/chat/fond-bulle-"+document.getElementById("sex").value+".jpg"
						
						document.getElementById("first-msg").style.backgroundImage="url("+img_temp_fond.src+")"
						
						
					 }
					 
					 img_temp_smiley=new Array();
					 img_temp_smiley2=new Array();
					
					var ismiley=0;
					
					//user 1 smiley
					
					for(ismiley=0;ismiley<=document.getElementById('nb_smiley_a').value;ismiley++)
					{
							
							if(document.getElementById('asmy'+ismiley))
							{							
								img_temp_smiley[ismiley]=new Image;
								 img_temp_smiley[ismiley].src=document.getElementById('asmy'+ismiley).src;
								 document.getElementById('asmy'+ismiley).src=img_temp_smiley[ismiley].src; 
								
							}
					}
					
					ismiley=0;
					
					for(ismiley=0;ismiley<=document.getElementById('nb_smiley_b').value;ismiley++)
					{
							
							if(document.getElementById('bsmy'+ismiley))
							{							
								img_temp_smiley2[ismiley]=new Image;
								 img_temp_smiley2[ismiley].src=document.getElementById('bsmy'+ismiley).src;
								 document.getElementById('bsmy'+ismiley).src=img_temp_smiley2[ismiley].src; 
								
								
							}
					}
					
					 /*
					for(ismiley=0;ismiley<200;ismiley++)
					{
						//alert(ismiley);
						
						if(document.getElementById('smy'+ismiley))
						 {
							
							
							img_temp_smiley[ismiley]=new Image;
							 img_temp_smiley[ismiley].src=document.getElementById('smy'+ismiley).src;
							 document.getElementById('smy'+ismiley).src=img_temp_smiley[ismiley].src; 
							// ismiley++;
						 }
						 else
						 {
							 	//break;
						 }
					}*/
					 
					 // scroll must be on bottom ....
					//Debug(flag_bottom)
					
					//if(flag_init_scroll==1)
					  {
					  	
						Init_Scroll();
				 	}
					
					if(flag_bottom==1)
					 {
						 document.getElementById("conversation").scrollTop=document.getElementById("conversation").scrollHeight-220;
						 //Debug()
					 }
					 
					  //document.getElementById("msg").value="";
					 
				 }
				 
				 if(mode=="chat-liste" || mode=="chat-list-flag")
				 {
					 	img_temp=null;
						img_temp=new Array();
						
						/*img_del=new Image();
						img_del.src="images/chat/del.jpg";*/
						
						img_new=new Image();
						img_new.src="images/chat/new.jpg";
						
						img_sexe=new Array();

						img_sexe[0]=new Image();
						img_sexe[0].src="images/fond-photo-0-blanc.png";
						
						img_sexe[1]=new Image();
						img_sexe[1].src="images/fond-photo-1-blanc.png";
						
						img_nb_new=new Image();
						img_nb_new.src="images/chat/new.png";


						for(i=0;i<document.getElementById('total-liste-chat').value;i++)
						{
							if(document.getElementById("chat-nb-new-"+i))
							{
									document.getElementById("chat-nb-new-"+i).style.backgroundImage="url("+img_nb_new.src+")";
							}
							
							if(document.getElementById("get-img-chat-"+i))
							{
							
								img_temp[i]=new Image();
								img_temp[i].src=document.getElementById("get-img-chat-"+i).value;
								
								//alert(img_temp[i].src)
								
								document.getElementById("img-"+i).src=img_temp[i].src;
								
								document.getElementById("img-"+i).style.backgroundImage="url("+img_sexe[document.getElementById('sexe'+i).value].src+")";
								
								//document.getElementById("del"+i).src=img_del.src;
							
							}
							if(document.getElementById("new"+i))
							{
								document.getElementById("new"+i).src=img_new.src;
							}
						}
						
						if(document.getElementById("last-new"))
						{
							 id_chat=document.getElementById("last-chat").value;
							 user=document.getElementById("last-new").value;
							 
							 pos=document.getElementById('total-liste-chat-ok').value-1
							 
							 document.getElementById('msg').focus();
							
							Chat_Select(id_chat,user,pos);
						}
						
						var temp_larg=0;
					
					for(i=0;i<=99;i++)
					{
						if(document.getElementById('liste-chat'+i))
						{
							temp_larg+=getOff('liste-chat'+i);
						}
					}
											
						if(temp_larg>660)
						{
							var sexe=document.getElementById('sex').value
							
							fleche_top=new Image();
							fleche_top.src="images/chat/fleche-gch.jpg";
							document.getElementById('fleche-top').src=fleche_top.src;
														
							fleche_bottom=new Image();
							fleche_bottom.src="images/chat/fleche-dte.jpg";
							document.getElementById('fleche-bottom').src=fleche_bottom.src;
							
						}
						else
						{
							
							fleche_top=new Image();
							fleche_top.src="images/internal-new/fleche-gch-no.jpg";
							document.getElementById('fleche-top').src=fleche_top.src;
							
							
							fleche_bottom=new Image();
							fleche_bottom.src="images/internal-new/fleche-dte-no.jpg";
							document.getElementById('fleche-bottom').src=fleche_bottom.src;
							
						}
						
						
					
					//alert(temp_larg)
					
					document.getElementById('liste-chat').style.width=''+temp_larg+4+'px';
					
				 }
				 
				 if(mode=="chat-list-flag")
				 {
					 flag_refresh_list=1;
				 }
				 
				 
				 
				 if(mode=="del-chat")
				 {					 
					 // refresh list - no timer ...
					Chat_Liste("ajax");
					
				 }
				 
				 // eof chat ajax
				 
				
				 
				 
				/* if(mode=='remontage-ajax')
				 {
					 	ajax_update_url='module/best-membres.php';
						ajax_update='zone-0';
						ajax_update_hide='zone-0';
				 }*/
				 
				 if(mode=='register')
				 {
					 	Fond_Param();
				 }
				 
				 if(mode=='carte')
				 {
							
						var top_carte=0;
							
						switch(eval(document.getElementById('choix_pays').value))
					  {
						case 189:
						
						document.getElementById('carte_belgique').style.display="block";
						
				
						
						break;
						
						 case 190:
							document.getElementById('carte_france').style.display="block";
							
						break;
						
						  case 191:
						  document.getElementById('carte_suisse').style.display="block";
						  
						break;
					  }
					  
						var scrolltop;
								
								if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
								{
									scrolltop=document.body.scrollTop;
								}
								else
								{
									scrolltop=truebody().scrollTop;
								}
								
								
								top_carte=(document.documentElement.clientHeight-document.getElementById(id_carte).offsetHeight)/2;
						
						if(top_carte<0)
						{
							top_carte=0
						}
							


								document.getElementById(id_carte).style.top=scrolltop+top_carte+'px';
								
								Fond_Param_Only();
				 }
				 
				 if(mode=="del-chat-liste")
				 {
						position1=0;
						position2=0;
						nb_mvt=2;
						ajax_start=0;
						ajax_start_page=0;
						
												//alert(onglet+' '+ajax_start+' '+ajax_start_page);

						
						Ajax_Call_Page('module/onglet/display_onglet_contact.php','affich_profil','id_onglet='+onglet+'&start2='+ajax_start+'&start_page2='+ajax_start_page+'&new='+nouveau,'onglet_contact',position1,nb_mvt,position2);

						//alert(onglet);
				 }
				 
				 if(mode=="del-ami-liste")
				 {
						nb_mvt=0;
						glob_id='je';
						Ajax_Call_Page('module/onglet/display_onglet_contact.php','affich_profil','id_onglet=0&start1=0;start_page1=0;start2=0&start_page2=0&new=0','onglet_contact',position1,nb_mvt,position2);
				 }
				 
				 
				if(mode=='timer-top')
				{
						
						
						document.getElementById('onglet_mvt_best').style.left='0px';
			
						vitesse=0;
						
						document.getElementById('zone-0').style.visibility='visible';
						//document.getElementById('zone-0').style.display='none';
						
						
						
						//new Effect.toggle('zone-0','blind');
						
						blind_sens=-1;
						
						Custom_Blind();

						
						Ajax_Call_Page('module/ajax/personnalisation-lien-plus.php','perso-lien-plus','no-param','perso-lien-plus');
					
						
						setTimeout("Update_Top()",60000);
			 	}
				 
				 if(mode=='ajax-photo')
				{
					Fond_Param_Only();
					
					document.getElementById('liste-photo').style.width=document.documentElement.clientWidth+'px';
					document.getElementById('liste-photo').style.left=-document.documentElement.clientWidth/2+350+'px';
					
					var scrolltop;
						
						if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
						{
							scrolltop=document.body.scrollTop;
						}
						else
						{
							scrolltop=truebody().scrollTop;
						}
						
						//alert(truebody().scrollTop+"-"+document.body.scrollTop)
		
					
						y_test=(document.documentElement.clientHeight-530)/2;
						
						if(y_test>=0)
						{
							y_test=Math.floor(y_test);
							
							var y_top=scrolltop+y_test;
							y_param=y_top;
						}
						else
						{
							var y_top=0;
						}
						
						y_top=scrolltop;
						
						cible_scroll_position="container-div-param-photo";
					
					Scroll_Position();
	
					Add_On_Scroll(Scroll_Position,1);
					
					
					document.getElementById('wait-photo').style.visibility='visible';

					
					document.getElementById('container-div-param-photo').style.top=y_top+'px';
					
					document.getElementById('liste-photo').style.top=document.documentElement.clientHeight-130+'px';
					
					document.getElementById('liste-photo').style.display='block';
					
					//alert(document.getElementById('liste-photo').style.top+' '+getTotalHeight());
					
					
					
					temp=new Image();
					
					temp.onload=Photo_Place;
					
					
					temp.src=document.getElementById('ajax-photo-img').src;

					photo_largeur=temp.height;	

				}
				
				 if(mode=='ajax-photo-ref')
				{
					
					
					temp=new Image();
					
					
					temp.onload=function()
					{
							
							var larg=temp.width+10+46*2+40;
							//document.getElementById('container-div-param-photo').style.width=''+larg+'px';
							Fond_Param_Only();
							temp.src=document.getElementById('ajax-photo-img').style.visibility="visible";
					}
					
					temp.src=document.getElementById('ajax-photo-img').src;

					if(document.getElementById('tab_ajax_photo_pos'))
					{
							pos_tab_ajax_ref=eval(document.getElementById('tab_ajax_photo_pos').value);
					}
				}

				
				 if(mode=='select-anniversaire')
				{
						
						//start is updated in birth button file on list and checkbox click
						Ajax_Call_Page('module/onglet/bouton-anniversaire.php','affich_profil','filtre='+filtre+'&start='+start_liste,'anniversaire');
						
						//alert(12)
				}
				
				
				 if(mode=='anniversaire')
				{
					position=Defil_Page('gch',position,'mvt-page',0);
				}
				 
				 if(mode=='chat-close')
				 {
					 	if(var_close_clic==10)
						{
							var_close_clic=0;
						}
						
						if(var_close_clic==1)
						{
							var_close_clic=10;
						}
						
						
				 }
				
				 
				 if(mode=="chat-accept" || mode=='offline-chat')
				 {
					 //	alert("22")
					 	Ajax_Call_Page('chat-ajax/ajax/comptage-chat.php','no-display','no-param','comptage-chat');

				 }
				 
				 
				 // count new chat 
				 if(mode=="comptage-chat")
				 {
					 
					// alert("ceci est un test pour le chat "+httpRequest.responseText)
					if(httpRequest.responseText!="down")
					{
						
						
						event_chat_open=0;
						
						if(event_chat_page==0)
							{
									//event_chat_page=1;
							}
							
						 if(httpRequest.responseText=="no-move")
						{
							flag_no_move=1;
						}
						else
						{
						
						
							if(httpRequest.responseText=="sound")
							{
								
								
								//Sound.play("mp3/new-msg.mp3");
								//document.getElementById('chat-son').innerHTML='<embed style="height:0" id="sound_chat" src="mp3/new-msg.mp3" loop="1" autostart="true" hidden="true"/><object id="sound_chat" width="0" height="0" type="audio/mpeg" data="mp3/new-msg.mp3"/>';

								document.getElementById('chat-son').innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="sound" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="flash/sound.swf" /><param name="quality" value="low" /><param name="bgcolor" value="#ffffff" /><embed src="flash/sound.swf" quality="low" bgcolor="#ffffff" width="1" height="1" name="sound" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

								flag_sound=0;
								
								
							}
							
							
							
							flag_no_move=0;
						}
							//if new chat -> update
							Ajax_Call_Page('chat-ajax/ajax/event-chat.php','event-chat','page='+event_chat_page+'&open='+event_chat_open+'&reduce='+event_chat_reduce,'event-chat');
							
							flag_load_profil_chat=1;
							
							// test if container for profil is display
							// if ok => load profil else wait display with event-chat
							/*if(document.getElementById('event-chat-profil'))
							{
								flag_load_profil_chat=0;
								Ajax_Call_Page('chat-ajax/ajax/profil.php','event-chat-profil','page='+event_chat_page,'chat-profil')
							}*/
							
							
						
				 	}
					else
					{
							flag_no_move=0;
							// if no new chat -> hide
							if(var_close_clic==0)
							{
								//Mvt_Chat(0);
							}
				 	}
					
					//flag_logout_chat=0;
				 }
				 
				 
				
				
				if(mode=="chat-profil" || mode=="event-chat")
				{
						
						if(document.getElementById("event-chat-msg"))
						{
							// fix ie bug cache
							
							// background msg
							img_event_chat_msg=new Image();
							img_event_chat_msg.src="images/chat/event-chat-msg.jpg";
							
							document.getElementById("event-chat-msg").style.backgroundImage="url("+img_event_chat_msg.src+")"
							
							
							//background thumnail
							img_fond_profil_chat=new Image();
							img_fond_profil_chat.src="images/fond-photo-"+document.getElementById("get-img-fond-profil-chat").value+"-blanc.png";
							
							document.getElementById("img-profil-chat").style.backgroundImage="url("+img_fond_profil_chat.src+")"
							
							//thumbnail
							img_profil_chat=new Image();
							img_profil_chat.src=document.getElementById("get-img-profil-chat").value;
							
							document.getElementById("img-profil-chat").src=img_profil_chat.src;
							
							//potential smiley
							
							//tab_tag_img=new Array();
							tab_tag_img_temp=new Array();
							
							var cible_event_chat=document.getElementById('event-chat');
							
							var tab_tag_img=cible_event_chat.getElementsByTagName("img");
							
							//document.getElementById('div-absolute').innerHTML=tab_tag_img.item(0);
							
							if(tab_tag_img.length!=0)
							{
							
								for(ismiley=0;ismiley<tab_tag_img.length;ismiley++)
								{
									//document.getElementById('div-absolute').innerHTML+=tab_tag_img.item(ismiley).getAttribute("id")+"//";
									
										if(tab_tag_img.item(ismiley).getAttribute("id")!=null && tab_tag_img.item(ismiley).getAttribute("id").substr(1,3)=="smy")
										{
											
											tab_tag_img_temp[ismiley]=new Image();
											tab_tag_img_temp[ismiley].src=tab_tag_img.item(ismiley).getAttribute("src");
											tab_tag_img.item(ismiley).setAttribute("src",tab_tag_img_temp[ismiley].src);
										}
								}
							
							}
						}
				
				}
				
				if(mode=="onglet_profil")
				{
					// for onglet photo
					flag_onglet_photo=false;
				}
				
					
				 if(mode=='personnalisation' || mode=="perso-param")
				 {
					if(document.getElementById('perso_type').value==1 && (document.getElementById('perso_param_value4').value!="" || document.getElementById('perso_param_value3').value!=""))
					{
							Ajax_Call_Page('module/ajax/personnalisation-region.php','perso-region-liste','id_pays='+document.getElementById('perso_param_value3').value+'&id_pays_save='+document.getElementById('perso_param_value3').value+'&zone='+document.getElementById('perso_zone').value,'perso-region');
					}
					
					perso_info=document.getElementById('perso_type').value;
				 }
				 
				 
				  if(mode=='remontage' || mode=='personnalisation')
				 {
					// axis_param="vertical";
					//url_after_hide_param="?jetons";
					Fond_Param();
				 }

				 
				 if(mode=="update-ajax")
				 {
					Appear_Ajax_Update(); 
				 }
				 
				 if(mode=='save-perso-param')
				 {
					 Param_Window_Out();
				 }
				 
				 if(mode=='sauv-delete-stat')
				 {
					 	url_after_hide_param=window.location.href;
						Param_Window_Out();
				 }
				 
				  if(mode=='msg_payant' || mode=='delete-stat')
				 {
					// axis_param="vertical";
					//url_after_hide_param="?jetons";
					Fond_Param();
				 }
				 
				 if(mode=='event-action' && nb_event_action==0)
				 {
					 	//setTimeout("Event_Action()",5000);
						//Pulsate_Event();
						
						
						
						
						for(i=0;i<9;i++)
						{
							
						//img_event=new Image();
						//img_event.src="images/event-action/"+document.getElementById('event-action-img'+i).name+".jpg" ;
						
						document.getElementById('event-action-img'+i).src=tab_event_action_img[document.getElementById('event-action-img'+i).name.substr(1,1)][document.getElementById('event-action-img'+i).name.substr(2,1)].src;
						
						//alert(document.getElementById('event-action-img'+i).name.substr(0,1))
				 		}
						
						img_temp_event=new Array();
						
						for(i=0;i<document.getElementById('total-event').value;i++)
						{
					
							img_temp_event[i]=new Image();
							img_temp_event[i].src=document.getElementById("get-img-"+i).value;
							
							
							document.getElementById("nb-event-"+i).src=img_temp_event[i].src;
						
						}
						
						
						Pulsate_Event();
						
						
						
				 }
				 
				 if(mode=='event-action')
				 {
					 nb_event_action++;
					 
					 if(document.getElementById('sound-event'))
						{
							
							nb_sound_event=document.getElementById('sound-event').value;
							
							if(document.getElementById('sound-event').value>=1)
							{
								//Sound.play("mp3/new-msg.mp3");
								document.getElementById('chat-son').innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="sound" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="flash/sound.swf" /><param name="quality" value="low" /><param name="bgcolor" value="#ffffff" /><embed src="flash/sound.swf" quality="low" bgcolor="#ffffff" width="1" height="1" name="sound" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
								//document.getElementById('chat-son').innerHTML='';
								
							}
						}
				 }
				 
				 
				 
				if(nb_event_action==2)
				{
					nb_event_action=0;
				}
				 
				 
				 if(mode=='cadeau')
				 {
					 axis_param="vertical";
					 Fond_Param();
				 }
				 
				 
				  
				
				 
				if(mode=='ajax-new-action' || mode=='ajax-new-action-timer')
				{
						// set flag for clear custom admin msg 
						flag_clear_msg_admin=0;
						
						// put timer to initial value
						nb_decompte_ajax=3;
						flag_toggle=1;
						
						//set top position for toggle
						
						//patch for safari
						var scrolltop;
						
						if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
						{
							scrolltop=document.body.scrollTop;
						}
						else
						{
							scrolltop=truebody().scrollTop;
						}
						
						y_test=(document.documentElement.clientHeight-384)/2;
						y_test=Math.floor(y_test);
		
						scrolltop+=y_test;
						
						document.getElementById('action-container-div').style.top=''+scrolltop+'px';
						
						//alert(truebody().scrollTop+"--"+document.documentElement.scrollTop+"--"+document.body.scrollTop)
						
						
						// height for outsitde toggle
						document.getElementById('action-outside').style.height=getTotalHeight()+'px';
						
						// appear action
						if(document.getElementById('div-note-etoile'))
						{
								
							document.getElementById('action-div').style.display="block";

							
							//function Display_Note_Etoile()
							{
									document.getElementById('div-note-etoile').style.display="block";
							}
							
							
							//new Effect.toggle('action-div','appear',{duration:0,afterFinish:Display_Note_Etoile})
							
			
						}
						else
						{
								document.getElementById('action-div').style.display="block";
								//new Effect.toggle('action-div','appear',{duration:0});
						}
						

						if(block_action!="" && mode!="ajax-new-action-timer" && block_action1!="")
						{
							setTimeout("Timer_New_Action()",3000);
						}
						
						// to move toggle with scroll
						//cible_scroll_position="action-container-div";
	
						Add_On_Scroll(Scroll_Position,1);
	
	//window.onscroll=Scroll_Position;
	
				}
				
				if(mode=='ajax-action-timer' )
				{
					Decompte_Ajax();
				}
				
				if(mode=='ajax-new-action-timer' )
				{
					Decompte_New_Ajax();
				}
				
				
				
				if(mode=='ajax-action-result')
				{

					document.getElementById('action').style.display='none';
					document.getElementById('result-action').style.display='block';
					
					setTimeout("Timer_Action()",3000);
					
					Decompte_Ajax();
					
					Add_On_Scroll(Scroll_Position,1);
	
	//window.onscroll=Scroll_Position;
				}
				
				if(mode=='result-ajax-action')
				{
					setTimeout("Timer_Action()",3000);
				}
				
				if(mode=='ajax-new-action-result')
				{
					Decompte_New_Ajax();
					setTimeout("Timer_New_Action()",3000);
				}
				
				

				 if(mode=='affich-ville')
				 {
					    
						//alert(httpRequest.responseText);
						
						 if(httpRequest.responseText=="invalid")
					   {
						   document.getElementById('code_postal').style.color="#ff0000";
							document.getElementById('code_postal').value="code postal invalide";
							
								document.getElementById('ville_choix').style.display="none";
									document.getElementById('ville_label').style.display="none";
					   }
					   else if(httpRequest.responseText=="region" || httpRequest.responseText=="province" || httpRequest.responseText=="canton")
					   {
						    document.getElementById('code_postal').style.color="#ff0000";
							
							if(httpRequest.responseText=="region" )
							{
								document.getElementById('code_postal').value="R\351gion invalide";
							}
							
							if(httpRequest.responseText=="province" )
							{
								document.getElementById('code_postal').value="Province invalide";
							}
							
							if(httpRequest.responseText=="canton" )
							{
								document.getElementById('code_postal').value="Canton invalide";
							}
							
															document.getElementById('ville_choix').style.display="none";
									document.getElementById('ville_label').style.display="none";

							
					   }
					   else
					   {	
					 
					   	document.getElementById('ville_choix').style.display="block";
			 		  	document.getElementById('ville_label').style.display="block";
			   				
							if(no_cp==0 || no_reset==1)
							{
								Fixe_Info();
								
								//alert(flag_compte_submit)
								
								if(flag_compte_submit==1 && flag_ville==1)
								{
										document.getElementById('btn_update_gen').value=1;
										document.getElementById('form-compte').action+='&onglet='+onglet;
										document.getElementById('form-compte').submit();
								}
					   		}
					   }
				 }
				 
				
				 
				 if(mode=='affich-region')
				 {
					 	
						//alert(flag_page_compte);
						
						if(flag_page_compte=="compte")
						{
								flag_page_compte="";
								Display_Cp(0);
						}
						
						// document.getElementById('region_choix').innerHTML=(httpRequest.responseText);
					   document.getElementById('region_choix').style.display="block";
					  
					  
					  //alert(document.getElementById('region_label').innerHTML);
					  
					  switch(eval(document.getElementById('choix_pays').value))
					  {
						case 189:
						
							document.getElementById('region_label').innerHTML="<div style=\"float:left;\">"+tab_label[0];
							add="<a href=\"javascript:void(id_carte='carte_belgique');void(Carte_Region());\" style=\"position:relative;float:left;visibility:hidden;\"><img src=\"images/point-interogation.jpg\" style=\"padding-left:9px;position:absolute;top:-7px;width:22px;\" title=\"Cliquer pour ouvrir la carte g&eacute;ographique\" align=\"bottom\" border=\"0\"></a>";

						break;
						
						 case 190:
							document.getElementById('region_label').innerHTML="<div style=\"float:left;\">"+tab_label[1];
								add="<a href=\"javascript:void(id_carte='carte_france');void(Carte_Region());\" style=\"position:relative;float:left;visibility:hidden;\"><img src=\"images/point-interogation.jpg\" style=\"padding-left:9px;position:absolute;top:-7px;width:22px;\" title=\"Cliquer pour ouvrir la carte g&eacute;ographique\" align=\"bottom\" border=\"0\"></a>";

						break;
						
						  case 191:
							document.getElementById('region_label').innerHTML="<div style=\"float:left;\">"+tab_label[2];
								add="<a href=\"javascript:void(id_carte='carte_suisse');void(Carte_Region());\" style=\"position:relative;float:left;visibility:hidden;\"><img src=\"images/point-interogation.jpg\" style=\"padding-left:9px;position:absolute;top:-7px;width:22px;\" title=\"Cliquer pour ouvrir la carte g&eacute;ographique\" align=\"bottom\" border=\"0\"></a>";
		 
							 //add="<br><a href=\"javascript:void(id_carte='carte_suisse');void(Fond_Param_Only());void(Carte_Region());\">Cliquer pour ouvrir la carte g&eacuteographique</a>";

						break;
				
						default:
							document.getElementById('region_label').innerHTML="<div style=\"float:left;\">Ma r&eacute;gion : *";
							add="";
						break;
			 		 }
					 

					 document.getElementById('region_label').innerHTML+="<span id=\"modif_region\" style=\"display:none;float:left;\"><a href=\"javascript:Unlock_Info(1);\">&nbsp;modifier</a></span></div>"+add;
					 
					 document.getElementById('region_label').style.display="block";
					 
					 if(httpRequest.responseText.indexOf('no-cp')!=-1)
					 {
						 	document.getElementById('required-cp').style.display='none';
							no_cp=1;
							
							//alert(no_cp);
					 }
					 else
					 {
						 document.getElementById('required-cp').style.display='inline';
							no_cp=0
					 }
					 
					 if(document.getElementById('ville') && no_reset==1)
					 {
						 Ville(0);
					 }
					 
					 
				 }
				 
				 
				 //alert(document.getElementById('container-div-param').innerHTML);
				 if(mode=='lost-password')
				{
					
					
					Fond_Param();
					//alert("ll");
					
				}
				
				
				 
				/* 
				
				//obsolete
				
				 if(mode=="onglet_profil_photo")
				 {
					 Toggle('div-photo-publique');
					 flag_onglet_photo=true;
				
					 
					// Toggle('div-photo-publique'));
					 
				 }
				 
				  if(mode=="onglet_profil_photo_privee")
				 {
					 Toggle('div-photo-privee');
					 flag_onglet_photo=true;
				
				 }
				*/
				
				if(mode=="onglet_profil_photo_vu")
				{
						//Debug()
						Display_Onglet_Photo_Vu("onglet_profil_photo");
				}
					
				
					
				
				
				if(mode=="photo-publique" || mode=="photo-privee" || mode=="onglet_profil_photo" || mode=="onglet_profil_photo_privee" || mode=="onglet_vu")
				{
					
					 flag_onglet_photo=true;
					
					
					
					if(mode=="photo-publique" || mode=="onglet_profil_photo")
					{
						//Debug()
						Display_Onglet_Photo("onglet_profil_photo");
					}
					
					if(mode=="photo-privee" || mode=="onglet_profil_photo_privee")
					{
						Display_Onglet_Photo("onglet_profil_photo_privee");
					}										
										
										
				}
				
				if(mode=="liste-ville")
				{
					document.getElementById('liste-ville').style.display='block';
					document.getElementById('fond-ville').style.height=getTotalHeight()+'px';
					//alert(document.getElementById('fond-ville').style.height);
				}
				
				
				if(mode=="recadrage")
				{
					/*var pos;
					pos=document.body.clientWidth/2-320;
					//document.getElementById('ajax_recadr').style.left=''+pos+'px';
					*/
					//patch for safari
						var scrolltop;
						//
						
						if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
						{
							scrolltop=document.body.scrollTop;
						}
						else
						{
							scrolltop=truebody().scrollTop;
						}
						
						//alert(scrolltop)
						
						document.getElementById('ajax_recadr').style.top=''+scrolltop+'px';
						
						//alert(document.getElementById('ajax_recadr').style.top)
					
					var taille;
					taille=getTotalHeight();
					document.getElementById('display_ajax_footer').style.height=''+taille+'px';
					document.getElementById('display_ajax_footer1').style.height=''+taille+'px';

					//cible_scroll_position="ajax_recadr";
						
					//Add_On_Scroll(Scroll_Position,1);
						
						//alert(document.getElementById('ajax_recadr').style.top)
				}
				
				
				//alert(mode);
				if(mode=='onglet_msg')
				{
					if(document.getElementById('centrage-btn'))
					{
						document.getElementById('centrage-btn').style.width=''+getOff('offset-centrage-btn')+'px';
					}
					
					if(document.getElementById('msg_mail'))
					{
						document.getElementById('msg_mail').style.display="none";
					}
					
					
					Event_Action(0);	
					//alert(document.getElementById('centrage-btn').offsetWidth+"**"+getOff('centrage-btn')+"**"+document.getElementById('centrage-btn').style.width);
				}
				
				if(mode=="onglet_vu" || mode=="onglet_vu_1")
				{
					
				
				
					if(document.getElementById('map'))
				   {
					   
					  
					  var dist;
					  var startPoint;
					  var endPoint;
					  
					  var lat1;
					  var lat2;
					  var long1;
					  var long2;
					  
					  var str_start=document.getElementById('str_start').value;
					   var str_end=document.getElementById('str_end').value;

					  
					  if (GBrowserIsCompatible()) {
						var map = new GMap2(document.getElementById("map"));
						
						var geocoder = new GClientGeocoder();
						
						 geocoder.getLatLng(str_start,
						function(point) {
						
						//alert(point.lat());
						
						if (!point) {
							//alert(address + " not found");
						  } else {
							//map.setCenter(point, 13);
							var marker = new GMarker(point);
							map.addOverlay(marker);
							
							startPoint = new LatLong(point.lat(),point.lng());
							
							lat1=point.lat();
							long1=point.lng();


							//marker.openInfoWindowHtml(address);
							
							if(startPoint && endPoint)
							{
							 
							 	  dist = LatLong.distHaversine(startPoint, endPoint);
							  
							  var polyline = new GPolyline([
							  new GLatLng(lat1,long1),
							  new GLatLng(lat2,long2)
							], "#ff0000", 10);
							  
							map.addOverlay(polyline);
														document.getElementById('google-km').innerHTML='<strong>'+dist.toFixed(2)+" Km</strong>";


							}
						  }}
						  );
						 
						 
						 
						  geocoder.getLatLng(str_end,
						function(point) {
						  if (!point) {
							//alert(address + " not found");
						  } else {
							map.setCenter(point, 5);
							var marker = new GMarker(point);
							map.addOverlay(marker);
							map.openInfoWindowHtml(map.getCenter(),'<br>'+document.getElementById('str_hint').value);
							
							
  							endPoint = new LatLong(point.lat(),point.lng());
							
							lat2=point.lat();
							long2=point.lng();
							
							if(startPoint && endPoint)
							{
							    dist = LatLong.distHaversine(startPoint, endPoint);
							  
							  var polyline = new GPolyline([
							  new GLatLng(lat1,long1),
							  new GLatLng(lat2,long2)
							], "#ff0000", 10);
							  
							map.addOverlay(polyline);
							document.getElementById('google-km').innerHTML='<strong>'+dist.toFixed(2)+" Km</strong>";
							}
  
							//marker.openInfoWindowHtml(address);
							
						  }}
						  );


						map.addControl(new GSmallMapControl());
						//map.addControl(new GMapTypeControl());
					   }

				   }
					
					//document.getElementById("affich_profil").style.height=document.getElementById("affich_profil").offsetHeight+'px';
					//alert(document.getElementById("affich_profil").offsetHeight+"**"+document.getElementById("affich_profil").style.height)
				}
				
				
				if(mode=="photo-publique-vu")
				{
					Display_Onglet_Photo_Vu("onglet_profil_photo");
				}
				
				
				//
				//
				
				
				if(mode=='perso-region')
				{
						document.getElementById('perso_param_value4').value=-1;
						
						if(document.getElementById('perso_param_value3').value!=-1)
						{
								document.getElementById('perso-region').style.display='block';
						}
						else
						{
								document.getElementById('perso-region').style.display='none';
						}

				}
				
				if(mode=='perso-ville')
				{
						document.getElementById('perso-ville').style.display='block';
				}
				
				
				
				
				//
				//
				
				
				if(mode=='onglet_contact')
				{
					//
					
					
					if(nb_mvt==2)
					{
						offset1=document.getElementById('autre').style.height;
						document.getElementById('autre').style.height='0px';
						position1=0;
						
						//alert(document.getElementById('autre').style.height);
					}
					
					if(document.getElementById('je'))
					{
						position2=0;
						offset2=document.getElementById('je').style.height;
						document.getElementById('je').style.height='0px';
					}
					
					//document.getElementById(globid).style.overflow='auto';
					//document.getElementById(globid).style.overflowY='auto';

					
					if(globid=='je')
					{
						if(document.getElementById(globid))
						{
						document.getElementById(globid).style.height=offset2;
						}
					}
					else
					{
						if(document.getElementById(globid))
						{
						document.getElementById(globid).style.height=offset1;
						}
					}
					
					
					//alert(offset1+"--"+document.getElementById('autre').style.height);
					
					if(document.getElementById(globid))
					{
					document.getElementById(globid).style.visibility='visible';
					document.getElementById(globid).style.overflow="visible";
					}
					
					if(document.getElementById('nb-je'))
					{
					document.getElementById('nb-je').style.display='none';
					}
					
					if(document.getElementById('nb-autre'))
					{
						document.getElementById('nb-autre').style.display='none';
					}
					
					if(document.getElementById('nb-'+globid))
					{
					document.getElementById('nb-'+globid).style.display='block';
					}

					
					//alert(document.getElementById('liste_sens'));
					
					if(document.getElementById('liste_sens'))
					{
					
						if(globid=="je")
						{
							document.getElementById('liste_sens').selectedIndex=0;
						}
						else
						{
							document.getElementById('liste_sens').selectedIndex=1;
		
						}
					}
					
					nb_event_action=0
					Event_Action(0);	
				}
				
				
				
				if(pos_mvt1!=undefined)
				{
							
					if(nb_mvt==2)
					{
						if(document.getElementById('mvt-page-1'))
						{
							position1=Defil_Page('gch',-pos_mvt1,'mvt-page-1',position1);
						}

						if(document.getElementById('mvt-page-2'))
						{
							position2=Defil_Page('gch',-pos_mvt2,'mvt-page-2',position2);
						}

						//position2=Defil_Page('gch',-pos_mvt2,'mvt-page-2',position2);
					}
					else
					{
						if(document.getElementById("mvt-page"))
						{
							Defil_Page('gch',-pos_mvt1,'mvt-page',position);
							
							if(mode=='classement')
							{
									//alert(position)
							}
						}
						else
						{
							if(document.getElementById('mvt-page-2'))
							{
								position2=Defil_Page('gch',-pos_mvt2,'mvt-page-2',position2);
							}
							//position2=Defil_Page('gch',-pos_mvt2,'mvt-page-2',position2);
						}
					}
					
					//new Effect.Opacity('nb-'+globid,{duration:0, fps:25, from:1.0, to:1});
						
				}
				
				
				if(cible!="no-display"  && mode!="update-ajax"  && mode!="perso-ville"  && mode!="perso-region" && mode!="msn" && mode!="gmail")
				{
					document.getElementById(cible).style.visibility='visible';
				}
			 }
			 
			 
		if(flag_wait_ajax==1 && mode!="event-action" && mode!="comptage-chat" && mode!="event-chat" && mode!="chat-profil" && mode.indexOf("chat-")==-1)
		{
			
			Hidetrail('img');
		}
			   
         }
		else 
		{
             if(httpRequest.responseText=="1")
			 {
			 	window.location.href="index.php";
			 }
			 else
			 {
			  
			  	if(flag_alert_ajax==1)
				{
				  flag_alert_ajax=0;
				 // alert('Le script n a pas abouti, ce n est rien de grave, verifiez votre connexion ou veuillez retenter, merci');
				 	
			 	}
			 }
			 
			 return;
        }
	}
	else
	{
		//alert(httpRequest.readyState);
	}
	
	return false;

}
