var newWin = null;

function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}

function popUp(strURL,strName,strWidth,strHeight)
{
	larg=screen.width/2;
	haut=screen.height/2;
	test=haut-(haut/2);
	closeWin();
	var strOptions="";
	strOptions="status,height="+strHeight+",width="+strWidth+",top="+test+",left="+(larg-larg/2)+",scrollbars=yes";
	newWin = window.open(strURL, strName, strOptions);
	newWin.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//## OUVRIR VIDEO ##

function ouvrirVideo(destination)
{
window.open(destination,'','location=yes, resizable=no, scrollbars=no, status=no,toolbar=no, location=no, directories=no, menubar=no, width=400, height=340');
}

function testform() {
	if(document.publier.pseudo_utilisateur.value == "") {
		alert("Veuillez entrer un nom d'utilisateur!");
		document.publier.pseudo_utilisateur.focus();
		return false;
	}  

	if(document.publier.mdp.value == "") {
		alert("Veuillez entrer un mot de passe!");
		document.publier.mdp.focus();
		return false;
	}
}

function popup(page) {
	window.open(page, "popup", "scrollbars=yes,toolbar=no,resizable=no,width=250,height=250");
}

// JS Brain pour Newsletter
function IsValidMail(mail) {
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(mail));
}

function testMail() {
	if(!IsValidMail(document.form_newsletter.mail.value)) {
		alert("Veuillez indiquer une adresse mail correcte.");
 		return false;
 	}
	if(document.form_newsletter.mail.value == "mon@email.com") {
		alert("Veuillez indiquer votre adresse mail.");
 		return false;
	}
 	else return true;
}
// Fin de JS Newsletter

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ajout_date()
{
	le_mois=document.change_mois.select_mois.value;
	annee=document.change_mois.annee.value;
	lejour=document.change_mois.lejour.value;
	tab_jour=lejour.split("-");
	
	
			
	document.change_mois.mois.value=annee+"/"+le_mois;
	document.change_mois.lejour.value=annee+"-"+le_mois+"-01";
	
	document.change_mois.submit();

}

function popimg(url,w,h)
{
  window.open(url,"popimg","width="+w+",height="+h);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function verif_emploi()
{
	radio=document.form1.radio_recherche[0].checked;
	
	if(radio==true)
	{
		rubrique=document.form1.rub.value;
		adresse="visu_offre.php?rub="+rubrique;
		window.open(adresse,"_parent");
		
	
	}
	else
	{
		window.open("depose_cv.php","_parent");
	}
}

function verif_embauche()
{
	radio=document.form2.radio_embauche[0].checked;
	
	if(radio==true)
	{
			rubrique=document.form2.rub.value;
			adresse="visu_cv.php?rub="+rubrique;
			window.open(adresse,"_parent");
	
	}
	else
	{
		window.open("depose_offre.php","_parent");
	}
}

function VerificationEmail(elm)
{
if (elm.value.indexOf("@") != "-1" &&
    elm.value.indexOf(".") != "-1" &&
    elm.value != "")
    return true;

return false;
}

function VerificationFormulaire()
{

	if(document.form_annuaire.nom_form.value == "")
	{
		alert("Veuillez entrer un nom");
		document.form_annuaire.nom_form.focus();
	}
	else
	{
		if(document.form_annuaire.societe_form.value == "")
		{
			alert("Veuillez entrer un nom de société");
			document.form_annuaire.societe_form.focus();
		}
		else
		{
			if(document.form_annuaire.adresse_form.value == "")
			{
				alert("Veuillez entrer une adresse");
				document.form_annuaire.adresse_form.focus();
			}
			else
			{
				if(document.form_annuaire.cp_form.value == "")
				{
					alert("Veuillez entrer un code postal");
					document.form_annuaire.cp_form.focus();
				}
				else
				{
					if(document.form_annuaire.ville_form.value == "")
					{
						alert("Veuillez entrez une ville");
						document.form_annuaire.ville_form.focus();
					}
					else
					{
							if(document.form_annuaire.tel_form.value == "")
							{
								alert("Veuillez entrer un numéro de téléphone");
								document.form_annuaire.tel_form.focus();
							}
							else
							{
							
								if (VerificationEmail(document.form_annuaire.email_form) == false)
								{
									alert("Email non Valide.");
									document.form_annuaire.email_form.focus();
									return false;
								}
								else
								{
										if(document.form_annuaire.nomsite_form.value == "")
										{
											alert("Veuillez entrer le nom du site web");
											document.form_annuaire.nomsite_form.focus();
										}
										else
										{
											
											if(document.form_annuaire.url_form.value == "")
											{
												alert("Veuillez entrer l'url de votre site web");
												document.form_annuaire.url_form.focus();
											}
											else
											{
												if(document.form_annuaire.resume_form.value == "")
												{
													alert("Veuillez entrer le resume de votre site");
													document.form_annuaire.resume_form.focus();
												}
												else
												{
														document.form_annuaire.submit();
												}
											}
										}
								}	
							}
					}
				}
			}
		}	
	}
return true;
}

function ouvr_img(legende,pic,larg,haut)
{
if(pic=="images/pano_shop.jpg")
    param_plus="scrollbars";
else param_plus="";
txt='<html>\n<head><title>'+legende+'</title><style type="text/css">img {border-color: #000000}<\/style>\n<\/head>\n<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">\n<table height=100% width=100% cellspacing=5 cellpading=0>\n<tr><td>\n<p align=center>\n<img src="'+pic+'" border=2>\n<br>\n<b><font size=3 face="Arial, Courrier" color="#000000">'+legende+'<\/font><\/b>\n<\/p>\n<\/td><\/tr>\n<\/table>\n<\/body>\n<\/html>';
fen=window.open('about:blank','_blank',"status=no,menubar=yes,toolbar=no,left=100,width="+larg+",height="+haut);
//alert(num);
//num.txt=txt;
fen.document.open();
fen.document.write(txt);
fen.document.close();
fen.focus();
}


decal_x = 25;
decal_y = -15;


// document.onmousemove = suivre_souris0;
// var contenu
// function pop0(contenu)
// {
  // document.getElementById("bulle").innerHTML = "<table border='1'  style='background-color:#FFFFFF;' cellpadding='6' cellspacing='0'><tr><td><font class='td_contenu'>"+contenu+"</font></td></tr></table>";
// }

// function suivre_souris0(e)
// {
  // if (navigator.appName=="Microsoft Internet Explorer")
  // {
    // var x = event.x + document.body.scrollLeft;
    // var y = event.y + document.body.scrollTop;
  // }
  // else
  // {
    // var x =  e.pageX;var y =  e.pageY;
  // }
  // document.getElementById("bulle").style.left = x + decal_x; document.getElementById("bulle").style.top  = y + decal_y;
// }
// function disparaitre0()
// {
  // document.getElementById("bulle").innerHTML = '';
// }

function ajout_date()
{
	le_mois=document.change_mois.select_mois.value;
	annee=document.change_mois.annee.value;
	lejour=document.change_mois.lejour.value;
	tab_jour=lejour.split("-");
	
	
			
	document.change_mois.mois.value=annee+"/"+le_mois;
	document.change_mois.lejour.value=annee+"-"+le_mois+"-01";
	
	document.change_mois.submit();

}

var testfoc=0;
var testfoc1=0;
//efface les champs lors d'un focus une seule fois champ expediteur
function effexp()
{
	testfoc+=1;
	if(testfoc==1)
	{
		document.form1.expediteur.value="";
	}
}

//efface les champs lors d'un focus une seule fois champ destinataire
function effdest()
{
	testfoc1+=1;
	if(testfoc1==1)
	{
		document.form1.destinataire.value="";
	}
}

// function verif_embauche()
// {
	// radio=document.form2.radio_embauche[0].checked;
	
	// if(radio==true)
	// {
		// alert("ok");
	
	// }
	// else
	// {
		// window.open("depose_offre.php","_parent");
	// }
// }

	function verif_cv()
	{
		nom=document.form1.nom.value;
		prenom=document.form1.prenom.value;
		adresse=document.form1.adresse.value;
		code_postal=document.form1.code_postal.value;
		ville=document.form1.ville.value;
		date_naissance=document.form1.date_naissance.value;
		poste=document.form1.poste.value;
		formation=document.form1.formation.value;
		experience=document.form1.experience.value;
		competence=document.form1.competence.value;
		mail=document.form1.mail.value;
		telephone=document.form1.telephone.value;
		
		
		if(nom=="")
		{
			alert("Veuiller rentrer votre nom");
			return 0;
		}
		
		if(prenom=="")
		{
			alert("Veuiller rentrer votre prenom");
			return 0;
		}
//Date de naissance
		if(date_naissance=="" || date_naissance==" ")
		{
			alert("Veuiller remplir le champ date de naissance avant de valider");
			return 0;
		}
		tab_naissance=date_naissance.split("/");
		
		test_jour=tab_naissance[0]*0;
		test_mois=tab_naissance[1]*0;
		test_annee=tab_naissance[2]*0;
		if(test_jour*1!=0 || test_mois*1!=0 || test_annee*1!=0 || tab_naissance[0]*1>31 || tab_naissance[1]*1>12)
		{
			alert("Champ date de naissance invalide");
			return 0;
		}
//fin date de naissance
		if(adresse=="")
		{
			alert("Veuiller rentrer votre adresse");
			return 0;
		}
		if(code_postal=="")
		{
			alert("Veuillez rentrer un code postal");
			return 0;
		
		}
		if(code_postal!="")
		{
			test=code_postal*0;
			if(test!=0)
			{
				alert("Veuillez rentrer un code postal valide");
				return 0;
			}
		
		}
		if(ville=="")
		{
			alert("Veuillez rentrer une ville");
			return 0;
		
		}
		if(telephone=="")
		{
			alert("Veuillez rentrer un numéro de téléphone");
			return 0;
		
		}
		/*if(telephone!="")
		{
			test=telephone*0;
			
			if(test!=0 || telephone.length<10)
			{
				alert("Veuillez rentrer un telephone valide");
				return 0;
			}
		}*/
		if(poste=="")
		{
			alert("Veuillez rentrer Le poste que vous souhaitez occuper")
			return 0;
		}
		if(formation=="")
		{
			alert("Veuillez rentrer vos formations")
			return 0;
		}
		if(experience=="")
		{
			alert("Veuillez rentrer vos experiences professionnelles")
			return 0;
		}
		if(competence=="")
		{
			alert("Veuillez rentrer vos compétences")
			return 0;
		}
		document.form1.submit();
	
	}

function verif_compte(){
	alert("Veuillez vous identifier en haut de la page !");
	document.publier.pseudo_utilisateur.focus();
	return false;
}

function verif()
	{
		societe=document.form1.societe.value;
		adresse=document.form1.adresse.value;
		codepostal=document.form1.code_postal.value;
		ville=document.form1.ville.value;
		telephone=document.form1.telephone.value;
		fax=document.form1.fax.value;
		mail=document.form1.mail.value;
		site_web=document.form1.site_web.value;
		intitule=document.form1.intitule.value;
		description_off=document.form1.description_off.value;
		contact=document.form1.contact.value;
		contrat=document.form1.contrat.value;
		salaire=document.form1.salaire.value;
		date_embauche=document.form1.date_embauche.value;
		
		if(societe=="")
		{
			alert("Veuillez rentrer le nom de votre socièté");
			return 0;
		
		}
		
		if(adresse=="")
		{
			alert("Veuillez rentrer une adresse");
			return 0;
		}
	
		if(codepostal=="")
		{
			alert("Veuillez rentrer un code postal");
			return 0;
		
		}
		if(ville=="")
		{
			alert("Veuillez rentrer une ville");
			return 0;
		
		}
		
		if(intitule=="")
		{
			alert("Veuillez rentrer un intitulé");
			return 0;
		
		}
		if(description_off=="")
		{
			alert("Veuillez rentrer une description");
			return 0;
		
		}
//date embauche		
		if(date_embauche!="")
		{
			tab_embauche=date_embauche.split("/");
			
			for(i=0;i<3;i++)
			{
				test=tab_embauche[i]*0;
				if(test!=0)
				{
					alert("Veuillez rentrer une date valide");
					return 0;
				}
			
			}
			if(tab_embauche[0]>31 || tab_embauche[1]>12 || tab_embauche[2]<2005)
			{
				alert("Veuillez rentrer un date valide. ex: 12/12/2005");
				return 0;
			}

		}
//fin date embauche
		if(contrat=="")
		{
			alert("Veuillez rentrer le type de contrat");
			return 0;
		}
		document.form1.submit();
	
	}

