
// roll over classique
function roll(id){
	
	var tmp=document.getElementById(id)

	if(tmp.src.indexOf("_c.gif")==-1){

		if(tmp.src.indexOf("_a.gif")==-1){tmp.src=tmp.src.replace("_b.gif","_a.gif");}
			else{
				if(navigator.appName=="Microsoft Internet Explorer"){tmp.filters.blendTrans.apply()}
				tmp.src=tmp.src.replace("_a.gif","_b.gif");
				if(navigator.appName=="Microsoft Internet Explorer"){tmp.filters.blendTrans.play()}	
				}
		
		}

}


function check_login_form(){
	if(document.getElementById("login_id").value=="" || document.getElementById("login_password").value==""){ // champs incomplets
		alert("Veuillez saisir un identifiant et un mot de passe !");
		}else{ // champs saisis
			ajax("ajax_check_login.php?login_id="+document.getElementById("login_id").value+"&login_password="+document.getElementById("login_password").value);
			}
	}
	
	
function bad_login(){ // erreur de login
	document.getElementById("login_id").value=""
	document.getElementById("login_password").value=""
	alert("Bonjour,\n\nDésolé mais l’identifiant et/ou le mot de passe sont incorrects.\n\nAfin de définir votre mot de passe,\nil vous suffit de vous inscrire gratuitement\nen cliquant sur « Créer un compte ».\n\nL'équipe de Seniors à votre service.");
	document.getElementById("login_id").focus();
	}
	

function logout(){
	ajax("logout.htm?ok=1");
	}
	
	
// vérifie le formulaire de recherche d'annonces
function check_rechercher_annonce(){
	var error="";
	//if(document.getElementById("ra_categorie").value==""){error+="Veuillez choisir une catégorie dans la liste déroulante !";}
	
	if(error==""){
		document.form_rechercher_annonce.action="resultats.htm";
		document.form_rechercher_annonce.submit();
		}else{
			alert(error)
			}
	}
	
// vérifie le formulaire de recherche d'annonces
function check_deposer_annonce(id,type_annonce){
	var error="";
	if(document.getElementById(id).value==""){error+="Veuillez choisir une catégorie dans la liste déroulante !";}
	
	if(error==""){
		document.form_deposer_annonce.type_annonce.value=type_annonce
		document.form_deposer_annonce.action="ajouter-une-annonce.htm"
		document.form_deposer_annonce.submit();
		}else{
			alert(error)
			}
	}
	
	
	
	
// vérifie le formulaire de recommandation du site
function check_recommander(){
	var error="";
	if(document.getElementById("prenom").value==""){error+="Veuillez saisir votre prénom !\n";}
	if(document.getElementById("nom").value==""){error+="Veuillez saisir votre nom !\n";}
	if(document.getElementById("email_expediteur").value==""){error+="Veuillez saisir votre email !\n";}
	if(document.getElementById("email_destinataire").value==""){error+="Veuillez saisir l'adresse a-mail du destinataire !\n";}
	if(error==""){
		document.recommander.submit();
		}else{
			alert(error)
			}
	}
	
// vérifie le formulaire de mot de passe oublié
function check_oubli_motdepasse(){
	var error="";
	if(document.getElementById("email").value==""){error+="Veuillez saisir votre email !\n";}
	if(error==""){
		document.oubli.submit();
		}else{
			alert(error)
			}
	}
	
function show_photo(id_annonce){
		window.open("show_photo.php?id_annonce="+id_annonce,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,height=400")
		}

function show_photo_loisirs(id_annonce){
		window.open("show_photo_loisirs.php?id_annonce="+id_annonce,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,height=400")
		}
		
function show_details(boucle){ // affiche ou masque le détail d'une annonce
	tmp=document.getElementById("annonce_details_"+boucle)
	if(tmp.style.display=="none"){tmp.style.display="";}else{tmp.style.display="none";}
	}


function search_keyword(){
	tmp=document.getElementById('ra_keyword');
	if(tmp.value!=""){
		location.href="resultats.htm?ra_keyword="+tmp.value;
		}else{
		alert("Veuillez saisir un mot-clé !");
		}
	}
	
// vérifie le formulaire de recherche d'annonces
function check_rechercher_annonce_loisirs(){
	var error="";
	//if(document.getElementById("ra_categorie_loisirs").value==""){error+="Veuillez choisir une catégorie dans la liste déroulante !";}
	
	if(error==""){
		document.form_rechercher_annonce_loisirs.action="resultats_loisirs.htm";
		document.form_rechercher_annonce_loisirs.submit();
		}else{
			alert(error)
			}
	}
	
	
// vérifie le formulaire de recherche d'annonces
function check_deposer_annonce_loisirs(id,type_annonce){
	var error="";
	if(document.getElementById(id).value==""){error+="Veuillez choisir une catégorie dans la liste déroulante !";}
	
	if(error==""){
		document.form_deposer_annonce.type_annonce.value=type_annonce
		document.form_deposer_annonce.action="ajouter-une-annonce-loisirs.htm";
		document.form_deposer_annonce.submit();
		}else{
			alert(error)
			}
	}


function popup (adresse,largeur,hauteur,scrollb,resize)
	{
	w = screen.availWidth;
	h = screen.availHeight;
	leftpos = w/2 - largeur/2;
	toppos = h/2 - hauteur/2;
		window.open(adresse,'_blank','toolbar=no,location=no,directories=no,menubar=no, scrollbars=' + scrollb + ',status=no,resizable=' + resize + ',width=' + largeur + ',height=' + hauteur + ',top=' + toppos + ',left=' + leftpos);
	}
	
	
function set_accueil(){
	document.getElementById('accueil_zone').innerHTML="<img src='img/comment-ca-marche2.gif' width='343' height='218' border='0' style='cursor:pointer;' usemap='#choix'><map name='choix'><area shape='rect' coords='59,102,276,132' href='emplois-senior-services-domicile-personnes-rechercher.htm'><area shape='rect' coords='111,152,223,183' href='emplois-senior-services-domicile-personnes-recruter.htm'></map>";
	}
	
function popup(titre,HTML_content,top,left,width){ // affiche une popup (top, left, width sans les "px" !
	
	HTML="<table cellpadding='0' cellspacing='0' border='0' class='popup_1' style='width:"+width+"px'><tr><td class='popup_3' width='100%' align='center'>"+titre+"</td><td align='right'><a href='javascript:hide_popup();'><img src='img/close.gif' border='0'></a></td></tr></table>";
	HTML+="<table cellpadding='0' cellspacing='0' border='0'><tr><td class='popup_2' style='width:"+width+"px'>"+HTML_content+"</td></tr></table>"
	
	mask_height=findPosY("footer")+68;
	
	document.getElementById("popup").innerHTML=HTML;
	document.getElementById("popup").style.top=top+"px";
	document.getElementById("popup").style.left=left+"px";
	document.getElementById("popup").style.width=width+"px";
	document.getElementById("mask").style.height=mask_height+"px";
	document.getElementById("mask").style.display="inline";
	document.getElementById("popup").style.display="inline";
	
	}
	
	
function hide_popup(){ // masque la popup
	document.getElementById("mask").style.display="none";
	document.getElementById("popup").style.display="none";
	document.getElementById("popup").innerHTML="";
	}
	
function mise_en_relation(id_annonce,type_annonce){
	HTML="<input type='hidden' name='id_annonce' id='id_annonce' value='"+id_annonce+"'><input type='hidden' name='type_annonce' id='type_annonce' value='"+type_annonce+"'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><b class='color4'>Saisissez le message qui sera transmis à l'annonceur.</b><br>L'annonceur sera libre de vous contacter par la suite s'il le souhaite.</td></tr><tr><td style='padding-top:8px;'><textarea name='relation_message' id='relation_message' style='font-family:arial;font-size:12px;width:98%;height:200px;background-color:#F0F0F0;border:1px solid #E0e0e0'></textarea></td></tr><tr><td align='center' height='50'><a href=\"javascript:send_relation()\"><img src='img/bt_valider_a.gif' name='bt_valider_tarif_1' width='92' height='21' border='0' id='bt_valider_tarif_1' onMouseOver='roll(this.id)' onMouseOut='roll(this.id)'></a></td></tr><tr><td align='center' style='font-size:10px;'>La mise en relation avec l'auteur de cette annonce vous décomptera 1 crédit.</td></tr></table>";
	popup("Mise en relation",HTML,ypos-300,xpos-150,400)
	}
	

function send_relation(id_annonce,type_annonce){
	tmp=document.getElementById("relation_message")
	if(tmp.value!=""){
		if(tmp.value.length<2000){
		ajax("send_relation.php?id_annonce="+document.getElementById("id_annonce").value+"&type_annonce="+document.getElementById("type_annonce").value+"&message="+encodeURIComponent(tmp.value));
		}else{
			tmp2=tmp.value
			tmp2=tmp2.substr(0,2000);
			tmp.value=tmp2;
			alert("Votre message est trop long, il ne doit pas comporter plus de 2000 caractères.\nIl a donc été tronqué sur la fin.\nMerci de rectifier");
			}
		}else{alert("Vous devez saisir un message !")}
	}
	
// *** KEY CHECK WEB-RELOAD
function keys(myfield, e, chars) {
 if(!e) var e = window.event
 if(e.keyCode) code = e.keyCode;
 else if (e.which) code = e.which;
 var char=String.fromCharCode(code);
 if(code==27) { this.blur(); return false; }
 if(!e.ctrlKey && code!=9 && code!=8 && code!=36 && code!=37 && code!=38 && (code!=39 || (code==39 && char=="'")) && code!=40) {
  if(chars.indexOf(char)!=-1) {return true;}else{return false;}
 }
}

function clist(c){
	alpha="abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	alpha_low="abcdefghijklmnopqurstuvwxyz";
	alpha_acc="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿRr";
	numeric="0123456789";
	special=" -,.=!@()$£%_+':;*&?";
	switch(c){
		case 1:t=numeric;break; // numeric
		case 2:t=numeric+".";break; // decimal
		case 3:t=alpha;break; // alpha
		case 4:t=alpha+numeric+"@._-";break; // email
		case 5:t=numeric+". ";break; // phone
		case 6:t=numeric+alpha+alpha_acc+special;break; // alpha tolerant
		case 7:t=alpha+numeric+"@._-";break; // login
		case 8:t=alpha+alpha_acc+numeric+" @._-";break; // pseudo
		case 9:t=alpha+numeric+"_-";break; // folder name or url
		case 10:t=alpha+numeric;break; // alpha numeric (captcha)
		case 11:t=alpha_low+numeric+"_-";break; // filename
		}
	return t;
	}
	
function check_codes(id){
	tmp=document.getElementById(id).value
	if(tmp.indexOf("-")!=-1 || tmp.indexOf("_")!=-1 || tmp.indexOf("$")!=-1 || tmp.indexOf("-")!=-1 || tmp.indexOf("&")!=-1 || tmp.indexOf("@")!=-1  || tmp.indexOf("+")!=-1 || tmp.indexOf(",")!=-1 || tmp.indexOf(";")!=-1 || tmp.indexOf(" ")!=-1){
		alert("Les caracères spéciaux, espaces... ne sont pas autorisés !")
		document.getElementById(id).value=document.getElementById(id).defaultValue
		}
	}
		
// *** END KEY CHECK