// Copyright 2005 Mirode.com

function lettre_minuscule() { return String.fromCharCode(97+Math.round(Math.random()*25)); }
function lettre_majuscule() { return String.fromCharCode(65+Math.round(Math.random()*25)); }
function nombre_hasard(init) { return Math.round(Math.random()*init); }
function tt_hasard() { return "#"+lettre_majuscule()+lettre_minuscule()+lettre_minuscule()+lettre_majuscule()+lettre_minuscule()+lettre_minuscule()+nombre_hasard(2)+lettre_majuscule()+"#"; }
function Verifemail(mail_val){  var place = mail_val.indexOf("@",1);var point = mail_val.indexOf(".",place+1);if ((place > -1)&&(mail_val.length >2)&&(point > 1))  return(true); else return(false); }
function VerifForm(form,ab)
{
var nom_val=form.nom.value;
var prenom_val=form.prenom.value;
var mail_val=form.mail.value;
var choix_val=form.final_choix.value;
var tel_val=form.tel.value;
var titre_val=form.titre.value;
var annonce_val=form.annonce.value;//alert("choix is "+choix_val);
var pho_val=form.file_photo.value;

if (nom_val=='') { alert("Entrez votre nom!"); goFocus(0,2); return false; }
else if (prenom_val=='') { alert("Entrez votre prénom!"); goFocus(0,3); return false; }
else if ((gr_renc(choix_val)) && (tel_val!='') && (mail_val=='')) { alert("Concernant les annonces de rencontre: \n "+ "\t\t - L'email est obligatoire \n "+ "\t\t - Le numéro de tél est inutile"); goFocus(0,4); return false; }
else if ((gr_renc(choix_val)) && (tel_val!='') && (!Verifemail(mail_val))) { alert("Entrez une adresse e-mail valide!!\n "+ "[ Le numéro de tél est inutile pour les annonces de rencontres ]"); goFocus(0,4); return false; }
//else if ((gr_renc(choix_val)) && (tel_val=='') && (!Verifemail(mail_val))) { alert("Entrez une adresse e-mail valide!!"); goFocus(0,4); return false; }
//else if ((mail_val=='' && tel_val=='') || ((tel_val=='')&&(!Verifemail(mail_val)))) { alert('Entrez une adresse e-mail valide et/ou votre numéro de téléphone (mobile de préférence)!!'); goFocus(0,3); return false; }
//else if (((mail_val!='')&&(!Verifemail(mail_val)))||(mail_val=='' && tel_val=='')||((tel_val=='')&&(!Verifemail(mail_val)))) { alert('Entrez une adresse e-mail valide et/ou votre numéro de téléphone (mobile de préférence)!!'); goFocus(0,2); return false; }
else if (mail_val=='' && tel_val=='') { alert('Entrez une adresse e-mail valide et votre numéro de téléphone (mobile de préférence)!!'); goFocus(0,4); return false; }
else if ((!gr_renc(choix_val)) && (tel_val=='')) { alert("Entrez votre numéro de téléphone!!"); goFocus(0,3); return false; }
else if ((mail_val=='')||(!Verifemail(mail_val))) { alert('Entrez une adresse e-mail valide!!'); goFocus(0,5); return false; }
else if (choix_val=='') { alert("Vous n'avez pas classé votre annonce correctement!"); document.location.href = '#classement_annonce'; return false; }
else if (titre_val=='') { alert("Entrez un titre pour votre annonce!"); document.form_pa.titre.focus(); return false; }
else if (annonce_val=='') { alert("Entrez votre annonce!"); document.form_pa.annonce.focus(); return false; }
if (!ab) {
if (choix_val=='40'||choix_val=='41'||choix_val=='42'||choix_val=='43'||choix_val=='44') { tel_val='';
if (pho_val!='') alert("Votre photo sera soumise à l'approbation du webmaster, \n avant d'être publiée. \n Merci de votre compréhension."); }
if (pho_val!='') { if (choix_val=='10'||choix_val=='11') { alert("il n'est pas possible de poster une photo pour les annonces d'emploi. \n Merci de lire la FAQ. \n Effacez le contenu du champ photo afin de pouvoir continuer."); pho_val=''; return false; } }
else if ((pho_val!='')&&(gr_renc(choix_val))&&(suspension_photo_ren=='oui')) { alert("L'envoi de photos pour les petites annonces de rencontres a été désactivé par le webmaster. \n Merci de votre compréhension. \n Effacez le contenu du champ photo afin de pouvoir continuer."); pho=""; return false; }

//passage de l'image
rendre_visible('envoiAnnonce'); rendre_visible('patienterEnvoi','on');
form.submit(); 
 
		} else return true;
	}
/**************************************************************************************/
function wop() {
/*nom_val=document.form_pa.nom.value;
prenom_val=document.form_pa.prenom.value;*/
mail_val=document.form_pa.mail.value;
tel_val=document.form_pa.tel.value;
titre_val=document.form_pa.titre.value;
annonce_val=document.form_pa.annonce.value;
choix_val=document.form_pa.final_choix.value;
control_val=[mail_val, tel_val, titre_val, annonce_val];
var pass1_hasard_val=tt_hasard();//pour les &
var pass2_hasard_val=tt_hasard();//pour les =
var pass3_hasard_val=tt_hasard(); //pour les sauts de lignes dans l'annonce
var win = null;
var reg1 = new RegExp("&","gi");
var reg2 = new RegExp("=","gi");

for(i=0;i<control_val.length;i++) control_val[i]=(control_val[i].replace(reg1,pass1_hasard_val)).replace(reg2,pass2_hasard_val);
mail_val=control_val[0];tel_val=control_val[1];titre_val=control_val[2];annonce_val=control_val[3];
annonce_val_tab=annonce_val.split("\n");
annonce_val='';
for(i=0;i<annonce_val_tab.length;i++) annonce_val+=annonce_val_tab[i]+pass3_hasard_val;
pho=''; pho_val='';
pho=document.form_pa.file_photo.value;
//pho=document.post_photo.file_photo.value;
//alert("ok pho"+pho);
if ((pho!='')&&(choix_val=='10'||choix_val=='11')) { alert("il n'est pas possible de poster une photo pour les annonces d'emploi. \n Merci de lire la FAQ. \n Effacez le contenu du champ photo afin de pouvoir continuer."); pho="";  return false;}
else if ((pho!='')&&(gr_renc(choix_val))&&(suspension_photo_ren=='oui')) { alert("L'envoi de photos pour les petites annonces de rencontres a été désactivé par le webmaster. \n Merci de votre compréhension. \n Effacez le contenu du champ photo afin de pouvoir continuer."); pho="";  return false;}
if (pho!='') pho_val=(pho.replace(reg1,pass1_hasard_val)).replace(reg2,pass2_hasard_val);
if (choix_val=='10'||choix_val=='11') pho_val='';
if (choix_val=='40'||choix_val=='41'||choix_val=='42'||choix_val=='43'||choix_val=='44') tel_val='';
var rq="pass1="+pass1_hasard_val+"&pass2="+pass2_hasard_val+"&pass3="+pass3_hasard_val+"&mail_val="+mail_val+"&tel_val="+tel_val+"&titre_val="+titre_val+"&annonce_val="+annonce_val+"&pho_val="+pho_val;
rq=escape(rq);
LeftPosition = (screen.width) ? (screen.width-400)/2 : 0;
TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
settings ='height=400,width=420,top='+TopPosition+',left='+LeftPosition+',resizable=no, toolbar=false, scrollbars=yes, status=yes'
ut=location.hostname; if (!ut) ut='www.mirode.com';
win=window.open('http://'+ut+'/petites_annonces/previsualiser_ma_petite_annonce.html?'+rq,'previsualisation_petites_annonces',settings);
//if(win.window.focus){win.window.focus();}


}

