//Test inclusion
var lib_included_commun = '1';

/*Cookies*/
function cookieWrite(nom, valeur, expires) {
  document.cookie=nom+"="+escape(valeur)+
  ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+"; path=/";
}

function cookieArgs(offset) {
  var endstr=document.cookie.indexOf (";", offset);
  if (endstr==-1) endstr=document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr)); 
}

function cookieRead(nom) {
  var arg=nom+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  while (i<clen){
    var j=i+alen;
    if (document.cookie.substring(i, j)==arg)
       return cookieArgs(j);
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
  }
  return null; 
}

/*
Error Log
*/
/*
window.onerror = function (msg, url, lno) {
	var ajax;
	if (window.XMLHttpRequest) {
		try {
			ajax = new window.XMLHttpRequest();
		} catch (e) {
			ajax = false;
		}
	} else {
		var msXML = new Array(
			"Msxml2.XMLHTTP.5.0",
			"Msxml2.XMLHTTP.4.0",
			"Msxml2.XMLHTTP.3.0",
			"Msxml2.XMLHTTP",
			"Microsoft.XMLHTTP"
		);
		for (var i = 0; i < msXML.length; i++) {
			try {
				ajax = new ActiveXObject(msXML[i]);
				window.status=i;
				break;
			} catch (e) {
				ajax = false;
			}
		}
	}
	if (ajax) {
		var data = "";
		data += ((data != "") ? "&" : "") + encodeURIComponent('message') + "=" + encodeURIComponent(msg);
		data += ((data != "") ? "&" : "") + encodeURIComponent('url') + "=" + encodeURIComponent(url);
		data += ((data != "") ? "&" : "") + encodeURIComponent('ligne') + "=" + encodeURIComponent(lno);
		data = '/interface/js/js_err_log.php?' + data;
		ajax.open('GET', data, true);
		ajax.send(null);
	}
	return false;
}
*/

/*
MAJ date/time local (v 9.91)
*/
function localTimeMaj()
{
		//var localTimestamp 	= Math.round(new Date().getTime() / 1000);
		
		var curDate = new Date();
		
		var curMonth= (curDate.getMonth()+1);
		if(curMonth < 10)
		{
			curMonth = '0'+curMonth;
		}
		
		var curDay= curDate.getDate();
		if(curDay < 10)
		{
			curDay = '0'+curDay;
		}	
		
		var curHours= curDate.getHours();
		if(curHours < 10)
		{
			curHours= '0'+curHours;
		}
		
		var curMinutes= curDate.getMinutes();
		if(curMinutes < 10)
		{
			curMinutes = '0'+curMinutes;
		}
		
		var curSeconds= curDate.getSeconds();
		if(curSeconds < 10)
		{
			curSeconds = '0'+curSeconds;
		}							
		
		sqlFormatDate = curDate.getFullYear()+'-'+curMonth+'-'+curDay+' '+curHours+':'+curMinutes+':'+curSeconds;
		
	    //Envoi du timestamp local a PHP
	  	new Ajax.Request('/securite/timestamp_local_update.php', {
	  	  	method: 'post',
	  	  	parameters: {sqldate: sqlFormatDate},
	  	  	onSuccess: function(transport) {
	  	  }
	  	});		
}

/*
notifications Messages
*/
function notificationsMsgLstShow(loaderImgPath)
{
	$('notificationsMsgConteneur').update('<img src="'+loaderImgPath+'" align="absmiddle"> Chargement...');

	if($('notificationsMsgConteneur').style.display == 'none')
	{		
		notificationsMsgLst(1);		
	}
	else
	{
		$('notificationsMsgConteneur').style.display = 'none';
	}
}

function notificationsMsgLst(pageNum)
{
	$('notificationsMsgConteneur').style.display = '';
	
  	new Ajax.Request('/interface/notifications_msg_lst.php', {
  	  	method: 'post',
  	  	parameters: {page:pageNum},
  	  	onSuccess: function(transport) 
  	  	{
  	  		$('notificationsMsgConteneur').update(transport.responseText);
  	  	}
  	});
}

/*
Partenaires
*/
/*
function partenaires()
{
		//div_modal_url('/sommaire/partenaires.php')  ;              
}
*/

/*
Contact
*/

//Contact support
function contactSupport()
{
		//div_modal_url('/bal/contact_support.php');                
		window.location = '/sommaire/contact.php';
}

function contactGetScreenSize(Form)
{
    	$('resolution').value = screen.width+"x"+screen.height ;
}

/*
Documents
*/

//Documents : album desactive	  
function docs_album_desactive()
{
	div_modal_url ('/annu/detail_album_desactive.php');                
}	

//Ajout de document
function docs_aff_addpopup(doc_type)
{
    window.open('../docs/docs_user_add.php?page='+doc_type,'docs_add','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=570,height=410,left='+(screen.width-570)/2+',top='+(screen.height-410)/2+'');
}

//Ouverture de la librairie de documents
function docs_aff_lst(an_key, id_doc_default)
{
 	window.open('/docs/docs_consult_lst.php?an_key='+an_key+'&ID_doc='+id_doc_default,'Consultation','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=953,height=607,left='+(screen.width-953)/2+',top='+(screen.height-607)/2);
}

/*
Login / Identification
*/

/*Perte mot de passe*/
function login_pwd_lost()
{
   window.open('/securite/demande_mdp.php?<?echo strip_tags(SID)?>','demande_mdp','resizable=yes,location=no,toolbar=no,scrollbars=no,width=430,height=240,left='+(screen.width-430)/2+',top='+(screen.height-240)/2)
}

/*Fonction de mise à jour des fenetres suite au login*/
function login_update_win( type,page,SID ) 
{
	if(IContact_frameset == 1)
    {
    	top.liste.liste_dials.checkDialLst('');
	}
	if (page == "crea_fiche_renvoi")
	{
    			window.location = "/inscription2/crea_fiche_renvoi.php?"+SID;
    }
    else
    {
    			window.location = '/sommaire/somgen.php?onL=1&'+SID;	    
    }
}

//Blocage nbconn max
function login_maxcnx_bloque (type)
{

		if ( type == "acc")
		{
 				window.location = '../interface/index.php?pageint=licmax&';
		} 
		else 
		{
        		
				if (opener) 
				{
					if(IContact_frameset == 1)
					{
						 top.opener.top.centre.location = '/sommaire/somgen.phpo?onL=11&';
					}
					else
					{
						top.opener.location = '/sommaire/somgen.phpo?onL=11&';
					}				
        			window.self.close();
        		} 
				else 
				{			 
					if(IContact_frameset == 1)
					{
						 top.centre.location = '/sommaire/somgen.phpo?onL=11&';
					}
					else
					{
						top.location = '/sommaire/somgen.phpo?onL=11&';
					}				
        			
        		}
								
		}
}

/*
Chartes
*/
function charte_deontologique()
{
      //div_modal_url('/inscription2/charte_deontologie.php');
      window.location = '/sommaire/charte-deontologique.php';
}

function charte_utilisation()
{
     //div_modal_url('/inscription2/charte_utilisation.php');
      window.location = '/sommaire/charte-utilisation.php';
     
}

function charte_infosediteur()
{
    //div_modal_url('/sommaire/som_infos_editeur.php');
      window.location = '/sommaire/informations-legales.php';
}

/*
Annuaire / Fiches
*/

//Lecture d'une fichier club
function annu_view_detail(an_key, SID) 
{
	  window.open('../annu/detail.php?an_key='+an_key+'&'+SID,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=460,height=600,left='+(screen.width-460)/2+',top='+(screen.height-600)/2);
}

//Inscription
function annu_create_profil()
{
     div_modal_url ('/inscription2/crea_fiche.php');
}

//Inscription : check data
function annu_create_bg_check(typeQ, value, divId)
{
      //Loader
	  $(divId).update('<img src="'+IContact_imghost+'/DEFAULT/img/ajax-loader-small.gif" width=16 height=16  alt="">');
			
	  var urlCheck = '/inscription2/crea_fiche_bg_check.php?query_type='+typeQ+'&value='+encodeURIComponent(value);
      // notice the use of a proxy to circumvent the Same Origin Policy.
      
      new Ajax.Request(urlCheck, {
        method: 'post',
        onSuccess: function(transport) {
          $(divId).update(transport.responseText);
        }
      });
}

function annu_create_dtnaiss( genreVal )
{
      if( genreVal == 'COUPLE' )
		{
    	    $('dtnaiss_cpl_1').style.display = 'inline';
    	    $('dtnaiss_cpl_2').style.display = 'inline';
    	}
    	else
    	{
    	    $('dtnaiss_cpl_1').style.display = 'none';
    	    $('dtnaiss_cpl_2').style.display = 'none';
    	}
}

//Renvoi la ville en fonction du CP ou select si plusieurs
function annu_create_ville_from_cp_select (cpVal, divIdSelect, divIdDef, divIdErrVille, divIdErrCP)
{
      if(cpVal.length > 3)
			{
          //Loader
    			$(divIdErrVille).update('<img src="'+IContact_imghost+'/DEFAULT/img/ajax-loader-small.gif" width=16 height=16 alt="">');

      		//CM : v.prototype
          new Ajax.Request('/inscription2/crea_fiche_bg_get_ville.php?cp='+cpVal,
            {
              method:'post',
              onSuccess: function(transport) { annu_create_ville_from_cp_select_process(transport, divIdSelect, divIdDef, divIdErrVille, divIdErrCP, '-|', ';|') },
              onFailure: function(){ if(debug_status == 1) { alert('DBUG : Erreur xmlHttpRequest, appel echoue IContactAjaxSelectLoadContent...') } }
            });
			}
}
function annu_create_ville_from_cp_select_process(httpRequest, selectId, divIdDef, divIdErrVille, divIdErrCP, separatorOpts, separatorValues)
{
			var msgLst = httpRequest.responseText;
			var sel    = $(selectId);
			sel.length = 0;
			var msgArr = msgLst.split(separatorOpts);
			for( i=0; i <= msgArr.length; i++  )
			{
            if(msgArr[i] && msgArr[i] != '')
					{
  							sel.length ++;
  							var msgDatas = msgArr[i].split(separatorValues);//Format de chaine : VALUE;TEXTE;TRUE/FALSE(SELECTED)
                sel[sel.length-1].value    = msgDatas[0];//Value
                sel[sel.length-1].text     = msgDatas[1];//Texte
                sel[sel.length-1].selected = eval(msgDatas[2]);//Boolean (true/false)
					}
			}
			
			//Teste si tout a ete ok ? Affichage en consequence...
			if( sel.length > 0 )
			{
		     $(divIdDef).style.display   = 'none';
		     $(selectId).style.display    = 'inline';
				 var divIdErrContent = '<img src="'+IContact_imgpath+'/inscription2/crea_ok.gif" width=16 height=16 alt="" align="absmiddle">';
		     $(divIdErrCP).update(divIdErrContent);
		     $(divIdErrVille).update(divIdErrContent);
			}
			else
			{
		     $(divIdDef).style.display   = 'inline';
			   $(selectId).style.display    = 'none';
				 var divIdErrContent = '<img src="'+IContact_imgpath+'/inscription2/crea_err.gif" width=16 height=16 alt="" align="absmiddle">';
		     $(divIdErrCP).update(divIdErrContent+'&nbsp;<span style="color:red">Code postal incorrect</span>');
			}
}

function html_entities_decode( texte )
{
	texte = texte.replace(/&lt;/g,'<');
	texte = texte.replace(/&gt;/g,'>');
	texte = texte.replace(/&quot;/g,'"');
	
	return(texte);
}

function annu_create_pays_check (paysVal, deptVal)
{
	if(typeof('deptVal') == "undefined")
	{
		deptVal = '';
	}

	$('geoDatasCpost').style.display 		= 'none';
    $('geoDatasDept').style.display 		= 'none';
    $('geoDatasVilleTxt').style.display 	= 'none';    
     
    //Envoi du timestamp local a PHP
  	new Ajax.Request('/inscription2/crea_fiche_form_paysdatas.php', {
	  	  	method: 'post',
	  	  	parameters: {pays: paysVal, dept: deptVal},
	  	  	onSuccess: function(transport) { 
	  	  	
	  	  		var json_datas = transport.responseText.evalJSON(false);
	
			    if(json_datas['aff_cpost'] == 1)
				{
				     $('geoDatasDeptSelect').replace('<select name="dept" id="geoDatasDeptSelect"></select>');
	        		 $('geoDatasDept').style.display 		= 'none';
	        		 $('geoDatasVilleTxt').style.display 	= 'none';    		 
		    		 $('geoDatasCpost').style.display 		= '';
			    }
			    else if(json_datas['aff_dept'] == 1)
			    {
					 //Mise a jour de la liste des departements
					 var dept_lst = html_entities_decode(json_datas['dept_lst']);
					 
					 //$('geoDatasDeptSelect').replace('<select name="dept" id="geoDatasDeptSelect">'+dept_lst+'</select>');
					 $('geoDatasDeptSelect').update(dept_lst);
	        		 $('geoDatasCpost').style.display 		= 'none';
		    		 $('geoDatasDept').style.display 		= '';
	        		 $('geoDatasVilleTxt').style.display 	= '';
	  
			    }
			    else
			    {
				     $('geoDatasDeptSelect').replace('<select name="dept" id="geoDatasDeptSelect"></select>');
		    		 $('geoDatasDept').style.display 		= 'none';
	        		 $('geoDatasCpost').style.display 		= 'none';
	        		 $('geoDatasVilleTxt').style.display 	= '';
			    } 
				/*
			    if(paysVal != 'FRANCE')
				{
			    		 $('geoDatasCpost').style.visibility 		= 'hidden';
			    		 $('geoDatasDept').style.visibility 		= 'visible';
			    		 $('geoDatasVilleTxt').style.visibility 	= 'visible';    		 
			    }
			    else
			    {
			    		 $('geoDatasDept').style.visibility 		= 'hidden';
			    		 $('geoDatasVilleTxt').style.visibility 	= 'hidden';
			    		 $('geoDatasCpost').style.visibility 		= 'visible';
			    }  
			    */	  	     	    
	  	  }
  	});

}

function annu_create_rech_check (idBase, maxNb, divErr, divTxt)
{
     var err = 1;
	 var nb  = 0;
     for(i=1;i<=maxNb;i++)
	 {
     	   var curId = idBase+'_'+i;
    		 if( $(curId).checked == true)
    		 {
    		    err = 0;
    				nb ++;
    		 }		 
     }
     
     if(err == 1)
     {
    		 var divIdErrContent = '<img src="'+IContact_imgpath+'/inscription2/crea_err.gif" alt="" width=16 height=16 align="absmiddle">';
         	 $(divErr).update(divIdErrContent);
    		 //$(divTxt).update('Selectionner');
     
     }
     else
     {
    		 var divIdErrContent = '<img src="'+IContact_imgpath+'/inscription2/crea_ok.gif" alt="" width=16 height=16 align="absmiddle">';
         	 $(divErr).update(divIdErrContent);
    		 //$(divTxt).update(nb+' genre(s)');
     }
}

//Texte validation fin creation fiche
function annu_create_profil_valid_txt()
{
	div_modal_url('/inscription2/crea_fiche_process_fin_txt.php');

}

//Carte Google Map à partir du CPost
function annu_map_cpost (paysVal, cpostVal, villeVal)
{
	div_modal_url('/annu/detail_map.php?pays='+paysVal+'&cpost='+cpostVal+'&ville='+villeVal);

}

//Validation mail modif
function annu_validmail_modif()
{
	window.open('/inscription2/email_validate_ask_detail.php','emailValidateAskDetail','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=691,height=545,left='+(screen.width-691)/2+',top='+(screen.height-545)/2+'');
}


/*Lecture d'une espace perso interne*/
function annu_espaceperso_interne(an_key) 
{
 	div_open_centre('../annu/espace_perso_int.php?an_key='+an_key+'&'+IContact_session_id);
}

//Suppression profil
function annu_del_profil()
{
    div_modal_url ('/inscription2/del_fiche.php');

}

/*Bloc Notes*/
function annu_notepad(an_key_dest)
{
	window.open('../annu/blocnotes_detail.php?an_key='+an_key_dest+'&'+IContact_session_id,'notepad_edit','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=400,height=360,left='+(screen.width-400)/2+',top='+(screen.height-360)/2+'');
}

/*Envoi de SMS*/
function annu_sms_send(an_key_dest, session_id)
{
	if (IContact_idlicence == 3)
	{
	    //Newtech
		window.open('http://allopass.izipay.net/mvd.php?lic='+IContact_idlicence+'&an_key_dest='+an_key_dest+'&an_key='+IContact_curank+'&allopass_type=3&host='+IContact_host+'&ID_gserv='+IContact_idgserv+'&ID_serv='+IContact_idsite+'&sess_id='+session_id,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=320,height=350,left='+(screen.width-320)/2+',top='+(screen.height-350)/2);
	} else {
	    //Autres clients
		window.open('http://allopass.izipay.net/index.php?lic='+IContact_idlicence+'&an_key_dest='+an_key_dest+'&an_key='+IContact_curank+'&allopass_type=3&host='+IContact_host+'&ID_gserv='+IContact_idgserv+'&ID_serv='+IContact_idsite+'&sess_id='+session_id,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=395,height=230,left='+(screen.width-395)/2+',top='+(screen.height-230)/2);
	}
}

/*Plainte user*/
function annu_plainte(an_key)
{
 	window.open('../dial/dial_carton.php?an_key='+an_key+'&'+IContact_session_id,'popup','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=395,height=230,left='+(screen.width-395)/2+',top='+(screen.height-230)/2+'');												 
}

/*Flash*/
function annu_flash(an_key_dest)
{
    window.open('../annu/flash.php?an_key='+an_key_dest+'&'+IContact_session_id,'flash_'+an_key_dest,'toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=308,height=175,left='+(screen.width-308)/2+',top='+(screen.height-175)/2);
}



/*
Palier / Protection
*/

/*Messages gratuits*/
function palier_protect_msg_gratuit()
{
     div_modal_url ('/securite/palier_check_form.php?type=3');
}

/*Protection standard (DIV action payante)*/
function palier_protect_standard(err_type, id_action, an_key)
{
    div_modal_url ('/securite/palier_check_form.php?type='+err_type+'&id_action='+id_action+'&an_key='+an_key);
}

/*Abonnement vacances*/
function abo_vacances()
{
	window.open('/inscription2/vacances_form.php?&'+IContact_session_id,'vacances','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=400,height=300,left='+(screen.width-400)/2+',top='+(screen.height-300)/2+'');
}

/*Paiement duree*/
var curTelDurCheck = 0;
function protect_tel_duree_check()
{
	//CM : v.prototype
    new Ajax.Request('/securite/mvd_eaffiliation_tel_testok.php',
      {
        method:'post',
		asynchronous:'false',
        onSuccess: function(transport) { 
			curTelDurCheck = transport.responseText;
		},
        onFailure: function(){ if(debug_status == 1) { alert('DBUG : Erreur xmlHttpRequest, appel echoue IContactTelDurCheck...') } }
      });
	return(curTelDurCheck);
	
}

/*Limitation d'accès*/
function protect_acces_limit(SID, type) 
{

		if ( type == "acc")
		{
 				window.location = '../interface/index.php?pageint=acclimitX&';
		} 
		else 
		{
        		
				if (opener) 
				{
					if(IContact_frameset == 1)
					{
						top.opener.top.centre.location = '/sommaire/somgen.phpo?onL=15&';
					}
					else
					{
						top.opener.top.location = '/sommaire/somgen.phpo?onL=15&';
					}        			 
        			 
        			 window.self.close();
        		} 
				else 
				{		
					if(IContact_frameset == 1)
					{
						top.centre.location = '/sommaire/somgen.phpo?onL=15&';
					}
					else
					{
						top.location = '/sommaire/somgen.phpo?onL=15&';
					} 					 
        		}
								
		}

}

/*
Diverses
*/
function div_showhide(divId, effect)
{
		switch(effect)
		{
			case 'blind'://Inclusion scriptaculous / effects requise
				if($(divId).style.display == 'none')
				{
					$(divId).blindDown();
				}
				else
				{
					$(divId).blindUp();
				}		
			break;
			case 'inline':
		    	if($(divId).style.display == 'none')
				{
				 	$(divId).style.display = 'inline';
				}
				else
				{
				 	$(divId).style.display = 'none';
				}		
			break;			
			default:
		    	if($(divId).style.display == 'none')
				{
				 	$(divId).style.display = '';
				}
				else
				{
				 	$(divId).style.display = 'none';
				}		
			break;
		}

}

//Special select construits en checkboxes
function div_clickout_hide( clickFollowerId, divToHide, divToHide2 )
{
	    if($(clickFollowerId).value == 0)
		{
			    $(divToHide).style.display = 'none';
			    if(divToHide2 != '')
				{
					   $(divToHide2).style.display = 'none';
				}
		}
	    $(clickFollowerId).value   = 0;
}
function div_opener_exist()
{
	try { 
	    window.opener.document.title = window.opener.document.title; 
	    return (true);
	}
	catch(e) { 
	    return (false);
	 }
}

function div_opener_opener_exist()
{
	try { 
	    window.opener.opener.document.title = window.opener.document.title; 
	    return (true);
	}
	catch(e) { 
	    return (false);
	 }
}

/*Fonction qui ouvre toujours dans le cadre central*/
function div_open_centre(urlRedirect) 
{
	 if(div_opener_exist())
     {
			if (div_opener_opener_exist()) 
			{
					if(IContact_frameset == 1)
					{
						top.opener.top.opener.top.centre.location = urlRedirect;
					}
					else
					{
						top.opener.top.opener.top.location = urlRedirect;
					}    										
					
			}
    		else 
    		{
					if(IContact_frameset == 1)
					{
						top.opener.top.centre.location = urlRedirect;
					}
					else
					{
						top.opener.top.location = urlRedirect;
					}    										
    		}  
					
     }
     else
     {
			if(IContact_frameset == 1)
			{
				top.centre.location = urlRedirect;
			}
			else
			{
				top.location = urlRedirect;
			} 			    		
     }
}

function div_open_centre_noframes(url)
{
		 if(top.opener)
		 {
				if (top.opener.top.opener) 
				{
					top.opener.top.opener.top.location = url;
				}
				else 
				{
					top.opener.top.opener.top.location = url;
				}
		 }
		 else
		 {
			top.opener.top.opener.top.location = url;
		 }	
}

function div_loader_start()
{
 		$('div_attente').style.visibility = "visible";
}

function div_loader_stop()
{
 		$('div_attente').style.visibility = "hidden";
}	

//Recuperation de contenu AJAX dans un DIV
function div_load_content (divId, dataURL)
{
	new Ajax.Updater(divId, dataURL);
}


//Remplissage d'un select en Ajax
function div_select_load (selectId, dataURL, separatorOpts, separatorValues)
{
	//CM : v.prototype
    new Ajax.Request(dataURL,
      {
        method:'post',
        onSuccess: function(transport) { div_select_load_process(transport, selectId, separatorOpts, separatorValues) },
        onFailure: function(){ if(debug_status == 1) { alert('DBUG : Erreur xmlHttpRequest, appel echoue div_select_load_process...') } }
      });
}
function div_select_load_process(httpRequest, selectId, separatorOpts, separatorValues)
{
			var msgLst = httpRequest.responseText;
			var sel    = $(selectId);
			sel.length = 0;
			var msgArr = msgLst.split(separatorOpts);
			for( i=0; i <= msgArr.length; i++  )
			{
		            if(msgArr[i] && msgArr[i] != '')
					{
						sel.length ++;
						var msgDatas = msgArr[i].split(separatorValues);//Format de chaine : VALUE;TEXTE;TRUE/FALSE(SELECTED)
		                sel[sel.length-1].value    = msgDatas[0];//Value
		                sel[sel.length-1].text     = msgDatas[1];//Texte
		                sel[sel.length-1].selected = eval(msgDatas[2]);//Boolean (true/false)
					}
			}
}

/*Gestion des contacts*/
function contact_process (act_type, an_key)
{
 		switch(act_type)
		{
		 		case 'add':
				window.open('../contacts/contact_autoprocess.php?an_key='+an_key+'&action=1&'+IContact_session_id,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=298,height=150,left='+(screen.width-298)/2+',top='+(screen.height-150)/2+'');
				break;
		 		case 'del':
				window.open('../contacts/contact_autoprocess.php?an_key='+an_key+'&action=2&'+IContact_session_id,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=298,height=150,left='+(screen.width-298)/2+',top='+(screen.height-150)/2+'');
				break;
		}
}

function contact_liste ()
{
 		window.open('../contacts/contact_liste.php?'+IContact_session_id,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=300,height=390,left='+(screen.width-300)/2+',top='+(screen.height-390)/2+'');
}


/*BAL / Courrier*/

/*Envoi message BAL*/
function bal_send (pseudo) 
{
     window.open('../bal/ecrire_msg.php?pseu_dest='+pseudo+'&'+IContact_session_id,'','resizable=yes,toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=560,height=685,left='+(screen.width-560)/2+',top='+(screen.height-685)/2+'');
}

function bal_read(m_key)
{
	  window.open('../bal/lire_msg.php?m_key='+m_key+'&'+IContact_session_id,'','resizable=yes,toolbar=no,menubar=no,statusbar=no,scrollbars=auto,width=560,height=685,left='+(screen.width-560)/2+',top='+(screen.height-685)/2+'');

}

/*Dials*/


/*Envoi message dial*/
function dial_send (an_key, winName) 
{
     //Gestion de l'ascenceur ou non fonction de la resolution
     if(screen.width <= 900) 
  	 {
     			//800*600
     			var scrollbar_val = 'yes';
    			var win_width     = 656;
    			var win_height 		= 500;
     }  else {
     			//1024 et +
     			var scrollbar_val = 'no';
    			var win_width     = 656;
    			var win_height 		= 722;
     }
    
     window.open('../dial/c-naps_dial.php?dial_ref_dest='+an_key+'&'+IContact_session_id,'cnaps_dial_'+winName,'resizable=no,toolbar=no,menubar=no,statusbar=no,scrollbars='+scrollbar_val+',left='+(screen.width-win_width)/2+',top='+(screen.height-win_height)/2+',width='+win_width+',height='+win_height);	
}


/*Bloquer pseudo*/
function dial_ignore (s_ref, action, page) 
{
  	switch (action)
  	{
    		case '1':
    					 if (confirm("Cet utilisateur ne pourra plus vous contacter en dialogues. Etes vous sur de vouloir le bannir ?"))
    					 {
    					 	  window.location = '../dial/dial_ignore.php?s_ref='+s_ref+'&action='+action+'&page='+page+'&'+IContact_session_id;
    					 }
    		break;
    		default:
    					 if (confirm("Cet utilisateur pourra de nouveau vous contacter en dialogues, êtes vous sur de vouloir le débloquer ?"))
    					 {						
    		          window.location = '../dial/dial_ignore.php?s_ref='+s_ref+'&action='+action+'&page='+page+'&'+IContact_session_id;
    			     }
    		break;
  	}
}

function dial_liste_refresh()
{
	if(IContact_frameset == 1)
    {
    	top.liste.liste_dials.checkDialLst('');
	}
	else
	{
		liste_dials.checkDialLst('');
	}
}

/********************************
* Detection navigateurs mobiles *
********************************/

var deviceIphone = "iphone";
var deviceIpod = "ipod";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current device is an iPhone.
function detect_mobile_Iphone()
{
   if (uagent.search(deviceIphone) > -1)
      return true;
   else
      return false;
}

//**************************
// detect_mobile_s if the current device is an iPod Touch.
function detect_mobile_Ipod()
{
   if (uagent.search(deviceIpod) > -1)
      return true;
   else
      return false;
}

//**************************
// detect_mobile_s if the current device is an iPhone or iPod Touch.
function detect_mobile_IphoneOrIpod()
{
    if (detect_mobile_Iphone())
       return true;
    else if (detect_mobile_Ipod())
       return true;
    else
       return false;
}

var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function detect_mobile_S60OssBrowser()
{
   if (uagent.search(engineWebKit) > -1)
   {
     if ((uagent.search(deviceS60) > -1 || 
          uagent.search(deviceSymbian) > -1))
        return true;
     else
        return false;
   }
   else
      return false;
}

var deviceAndroid = "android";

//**************************
// detect_mobile_s if the current device is an Android OS-based device.
function detect_mobile_Android()
{
   if (uagent.search(deviceAndroid) > -1)
      return true;
   else
      return false;
}

var deviceWinMob = "windows ce";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is a Windows Mobile device.
function detect_mobile_WindowsMobile()
{
   if (uagent.search(deviceWinMob) > -1)
      return true;
   else
      return false;
}

var deviceBB = "blackberry";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is a BlackBerry of some sort.
function detect_mobile_BlackBerry()
{
   if (uagent.search(deviceBB) > -1)
      return true;
   else
      return false;
}

var devicePalm = "palm";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is on a PalmOS device.
function detect_mobile_PalmOS()
{
   if (uagent.search(devicePalm) > -1)
      return true;
   else
      return false;
}

//**************************
// detecte si c'est un navigateur mobile
function detect_mobile_nav()
{
	if(detect_mobile_IphoneOrIpod() || detect_mobile_S60OssBrowser() || detect_mobile_Android() || detect_mobile_WindowsMobile() || detect_mobile_BlackBerry() || detect_mobile_PalmOS())
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

//**************************
// rebascule vers version mobile si nav mobile
function detect_mobile_rerout(mobileUrl)
{
	if(detect_mobile_nav())
	{
		if(confirm("Ce site dispose d'une version optimisée pour les navigateurs mobiles. Souhaitez vous l'utiliser ?"))
		{
			top.window.location = mobileUrl;
		}
	}
}

/******************
* DIV transparent *
******************/

function div_modal(divId)
{
	var modal = new Control.Modal($(divId),{  
	    overlayOpacity: 0.50,  
	    className: 'modal',  
	    fade: true  
	});
}

function div_modal_from_div(divId)
{
		var modal = new Control.Modal.open($(divId),{  
		    overlayOpacity: 0.50,  
		    className: 'modal', 
		    fade: true,
		    iframeshim: true
		});
}

function div_modal_url(divUrl)
{
		var modal = new Control.Modal.open(divUrl,{  
		    overlayOpacity: 0.50,  
		    className: 'modal', 
		    fade: true,
		    iframeshim: true
		});
}

function div_modal_url_wh (divUrl, divW, divH)
{
  	var modal = new Control.Modal.open(divUrl,{  
	    overlayOpacity: 0.50,  
	    className: 'modal', 
	    width:divW,
	    height:divH,
	    fade: true
	});
}

function div_modal_url_noclose(divUrl)//Version modale sans possibilite de fermer
{
  	var modal = new Control.Modal.open(divUrl,{  
	    overlayOpacity: 0.50,  
	    closeOnClick: false,
	    className: 'modal', 
	    fade: true  
	});
}

function div_modal_close()
{
	Control.Modal.close();
}

function div_tooltip(divId, txt)
{
	var tooltip = new Control.ToolTip($(divId),txt,{  
	    className: 'tooltip'  
	});  
}

//DEPRECIE, POUR COMPATIBILITE
function docProtectWarnShow (messageURL, cssClass, palCheckWidth, palCheckHeight)
{
  /*
  	//docProtectMsgObj.setHtmlContent(messageContent);//Pas de message mais une recup d'URL
  	docProtectMsgObj.setSize(palCheckWidth,palCheckHeight);
  	docProtectMsgObj.setCssClassMessageBox(cssClass);
  	docProtectMsgObj.setSource(messageURL);
  	docProtectMsgObj.setShadowDivVisible(true);	// Ombre disponible
  	docProtectMsgObj.display();
  */
  div_modal_url(messageURL);
}

function docProtectWarnHide ()
{
 		//docProtectMsgObj.close();
 		div_modal_close();
}

/*
//Gestion du DIV masquant la popup (avertissement avant reroutage)
DHTML_modalMessage = function()
{
	var url;								// url of modal message
	var htmlOfModalMessage;					// html of modal message
	
	var divs_transparentDiv;				// Transparent div covering page content
	var divs_content;						// Modal message div.
	var iframe;								// Iframe used in ie
	//var layoutCss;							// Name of css file;
	var width;								// Width of message box
	var height;								// Height of message box
	
	var existingBodyOverFlowStyle;			// Existing body overflow css
	var dynContentObj;						// Reference to dynamic content object
	var cssClassOfMessageBox;				// Alternative css class of message box - in case you want a different appearance on one of them
	var shadowDivVisible;					// Shadow div visible ? 
	var shadowOffset; 						// X and Y offset of shadow(pixels from content box)
	var MSIE;
		
	this.url = '';							// Default url is blank
	this.htmlOfModalMessage = '';			// Default message is blank
	//this.layoutCss = 'modal-message.css';	// Default CSS file
	this.height = 200;						// Default height of modal message
	this.width = 400;						// Default width of modal message
	this.cssClassOfMessageBox = false;		// Default alternative css class for the message box
	this.shadowDivVisible = true;			// Shadow div is visible by default
	this.shadowOffset = 5;					// Default shadow offset.
	this.MSIE = false;
	if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	

}

DHTML_modalMessage.prototype = {	
	setSource : function(urlOfSource)
	{
		this.url 	   = urlOfSource;
	}		
	,	
	setHtmlContent : function(newHtmlContent)
	{
		this.htmlOfModalMessage = newHtmlContent;
	}	
	,		
	setSize : function(width,height)
	{
		if(width)this.width = width;
		if(height)this.height = height;		
	}		
	,				
	setCssClassMessageBox : function(newCssClass)
	{
		this.cssClassOfMessageBox = newCssClass;
		if(this.divs_content){
			if(this.cssClassOfMessageBox)
				this.divs_content.className=this.cssClassOfMessageBox;
			else
				this.divs_content.className='modalDialog_contentDiv';	
		}
					
	}		
	,			
	setShadowOffset : function(newShadowOffset)
	{
		this.shadowOffset = newShadowOffset
					
	}		
	,			
	display : function()
	{
		if(!this.divs_transparentDiv){
			this.__createDivs();
		}	
		// Redisplaying divs
		this.divs_transparentDiv.style.display='block';
		this.divs_content.style.display='block';
		this.divs_shadow.style.display='block';		
		if(this.MSIE)this.iframe.style.display='block';	
		this.__resizeDivs();
		window.refToThisModalBoxObj = this;		
		setTimeout('window.refToThisModalBoxObj.__resizeDivs()',150);
		this.__insertContent();	// Calling method which inserts content into the message div.
	}		
	,		
	setShadowDivVisible : function(visible)
	{
		this.shadowDivVisible = visible;
	}	
	,		
	close : function()
	{
		//document.documentElement.style.overflow = '';	// Setting the CSS overflow attribute of the <html> tag back to default.
		
		this.divs_transparentDiv.style.display='none';
		this.divs_content.style.display='none';
		this.divs_shadow.style.display='none';
		if(this.MSIE)this.iframe.style.display='none';
		
	}		
	,		
	addEvent : function(whichObject,eventType,functionName,suffix)
	{ 
	  if(!suffix)suffix = '';
	  if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else 
	    whichObject.addEventListener(eventType,functionName,false); 	    
	} 	
	,		
	__createDivs : function()
	{
		// Creating transparent div
		this.divs_transparentDiv = document.createElement('DIV');
		this.divs_transparentDiv.className='modalDialog_transparentDivs';
		this.divs_transparentDiv.style.left = '0px';
		this.divs_transparentDiv.style.top = '0px';
		
		document.body.appendChild(this.divs_transparentDiv);
		// Creating content div
		this.divs_content = document.createElement('DIV');
		this.divs_content.className = 'modalDialog_contentDiv';
		this.divs_content.id = 'DHTMLSuite_modalBox_contentDiv';
		this.divs_content.style.zIndex = 100000;
		
		if(this.MSIE){
			this.iframe = document.createElement('<IFRAME src="about:blank" frameborder=0>');
			this.iframe.style.zIndex = 90000;
			this.iframe.style.position = 'absolute';
			document.body.appendChild(this.iframe);	
		}
			
		document.body.appendChild(this.divs_content);
		// Creating shadow div
		this.divs_shadow = document.createElement('DIV');
		this.divs_shadow.className = 'modalDialog_contentDiv_shadow';
		this.divs_shadow.style.zIndex = 95000;
		document.body.appendChild(this.divs_shadow);
		window.refToModMessage = this;
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.__repositionTransparentDiv() });
		

	}
	,		
	__getBrowserSize : function()
	{
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];		
		
	}	
	,	
    __resizeDivs : function()
    {
    	
    	var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);

		if(this.cssClassOfMessageBox)
			this.divs_content.className=this.cssClassOfMessageBox;
		else
			this.divs_content.className='modalDialog_contentDiv';	
			    	
    	if(!this.divs_transparentDiv)return;
    	
    	// Preserve scroll position
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);

    	this.__repositionTransparentDiv();
    	

		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	
    	// Setting width and height of content div
      	this.divs_content.style.width = this.width + 'px';
    	this.divs_content.style.height= this.height + 'px';  	
    	
    	// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
    	var tmpWidth = this.divs_content.offsetWidth;	
    	var tmpHeight = this.divs_content.offsetHeight;
		
    	this.divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
    	
 		if(this.MSIE){
 			this.iframe.style.left = this.divs_content.style.left;
 			this.iframe.style.top = this.divs_content.style.top;
 			this.iframe.style.width = this.divs_content.style.width;
 			this.iframe.style.height = this.divs_content.style.height;
 		}
 		
    	this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px';
    	this.divs_shadow.style.height = tmpHeight + 'px';
    	this.divs_shadow.style.width = tmpWidth + 'px';
    	
    	if(!this.shadowDivVisible)this.divs_shadow.style.display='none';	// Hiding shadow if it has been disabled
    	
    	
    }	
    ,	    
    __repositionTransparentDiv : function()
    {
    	this.divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	this.divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var brSize = this.__getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	this.divs_transparentDiv.style.width = bodyWidth + 'px';
    	this.divs_transparentDiv.style.height = bodyHeight + 'px';		
		   	
    }	
	,	
    __insertContent : function()
    {
		if(this.url){	// url specified - load content dynamically
			div_load_content ('DHTMLSuite_modalBox_contentDiv', this.url);
		}else{	// no url set, put static content inside the message box
			this.divs_content.innerHTML = this.htmlOfModalMessage;	
		}
    }		
}

//Creation de la fenetre d'alerte
docProtectMsgObj = new DHTML_modalMessage();	// We only create one object of this class
docProtectMsgObj.setShadowOffset(4);					// Gere la disposition de l'ombre
*/

/*Fichier functions.js (old, deprecie ?)*/

//Ouverture de lien externe (mailing modal)
function mailing_interface_link ( linkType, lien ) 
{
	 switch ( linkType ) 
	 {
			case 1:
    		 	 window.open (lien);
    		break;
    		default:
    			if(IContact_frameset == 1)
    			{
    				top.centre.location = lien;
    			}
    			else
    			{
    				top.location = lien;
    			} 			    		
    			 
    		break;
	 }
}

/*Ouverture PA*/
function openAnn (IDAnn) 
{
	 window.open('/annonces/lire.php?ID_pa='+IDAnn,'','toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=395,height=500,left='+(screen.width-395)/2+',top='+(screen.height-500)/2+'');
}

/*Lecture d'un message BAL*/
function lire_msg_bal(m_key, SID) 
{
	 window.open('../bal/lire_msg.php?m_key='+m_key+'&'+SID,'','resizable=yes,toolbar=no,menubar=no,statusbar=no,scrollbars=auto,width=560,height=610,left='+(screen.width-560)/2+',top='+(screen.height-610)/2+'');
}

/*Lecture d'un message BAL*/
function ecrire_msg_bal(pseudo, SID) 
{
	 window.open('../bal/ecrire_msg.php?pseu_dest='+pseudo+'&'+SID,'','resizable=yes,toolbar=no,menubar=no,statusbar=no,scrollbars=no,width=560,height=610,left='+(screen.width-560)/2+',top='+(screen.height-610)/2+'');
}



/*FIN GENERIQUE*/
