var dir_http = "http://www.batiactu.com/";

function pop_commande(){
	openpopup('http://capinfo3.ecritel.net/emploi.batiactu.com/commander.php','commander',360,400,'no','no');
}
function pop_tarif(){
	pop=window.open("http://www.batiactuemploi.com/ordre_insertion_emploi_site.pdf","tarif","width=800, height=600, scrollbars=yes, menubar=yes, resizable=yes");
	pop.focus();
}
function openpopup(url,windowname,sizex,sizey,sizable,scrollable)
{
	var pop= window.open(url, windowname, "height="+sizey+",width="+sizex+",resizable="+sizable+",scrollbars="+scrollable+",menubar=yes");
	pop.focus();
}
function show_zoom(url,id_photo,id_edito){
	url_zoom = dir_http+"zoom.php?photo="+url+"&zone=EMPLOI";
	if(id_photo!=null){
		url_zoom+="&id_photo="+id_photo+"&id_edito="+id_edito;
	}
	openpopup(url_zoom, 'zoom_photo',800,600,'yes','yes');
}
function launch_search(formname){
	
	var CAT="";
	
	for (counter = 0; counter < document.forms[formname].elements['CAT'].length; counter++)
	{
			if (document.forms[formname].elements['CAT'][counter].checked){
				CAT=document.forms[formname].elements['CAT'][counter].value; 
			}
	}
	
	if(CAT=="WEB-ANNUAIRE"){
		document.forms[formname].action="http://produits.batiactu.com/recherche-libre.php";
	}
	else{
		document.forms[formname].action="http://www.batiacturecherche.com/include.php";
	}
	
}
function imprime_annonce(id_annonce,url_annonce){
	
	pop=window.open("../imprime-annonce.php?id_annonce="+id_annonce+"&url="+url_annonce,"pop_imprime","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
	
}
function imprime_article(){
	
	pop=window.open("../imprime-article.php","pop_imprime","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
	
}
function imprime_entreprise(url){
	
	pop=window.open("../imprime-entreprise.php?url_annonce="+url,"pop_imprime","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
	
}
function imprime_article_emploi(url){

	openpopup("http://www.batiactu.com/imprimer-emploi.php?url="+url,'imprime',800,600,'yes','yes');

}
function transmet_article_emploi(e,url){
	
	openpopup("http://www.batiactu.com/transmettre-emploi.php?e="+e+"&url="+url,'imprime',800,600,'yes','yes');
	
}

function mot_passe_perdu(){
	pop=window.open("http://dev3.batiactu.com/cap_emploi/dlg/mot-de-passe-perdu.php","pop_mdpperdu","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function mot_passe_perdu_recruteur(){
	pop=window.open("http://dev3.batiactu.com/cap_emploi/dlg/mot-de-passe-perdu-recruteur.php","pop_mdpperdu","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function repondre_annonce(id_annonce,url_annonce,lib_annonce,email_to){
	pop=window.open("../envoi-mail-cpt.php?id_annonce="+id_annonce+"&email_to="+email_to+"&lib_annonce="+lib_annonce,"pop_cpt","width=50, height=50, scrollbars=no, menubar=no");
	pop.blur();
	//document.location.href="mailto:"+email_to+"?subject=Suite à votre annonce ''"+lib_annonce+"'' parue sur Batiactu Emploi, un candidat vous contacte";
	
	//url = 'mailto:'+email_to+'?subject=Suite à votre annonce %22%22 parue sur Batiactu Emploi, un candidat vous contacte&body=';
	//alert(url);//'+lib_annonce+'
	//document.location.href=url;
}
function repondre_annonce_url(id_annonce,url){
	pop=window.open("../envoi-url-cpt.php?id_annonce="+id_annonce+"&url="+Remplacer_dans_chaine(url,"&","[SEP]"),"pop_cpt","width=800, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function transmettre_annonce(id_annonce,url_annonce){
	pop=window.open("../transfert-annonce.php?id_annonce="+id_annonce+"&url="+url_annonce,"pop_transfert","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
	
}
function transfert_article(url){
	pop=window.open("../transfert-article.php?url="+url,"pop_transfert","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function transfert_entreprise(url){
	pop=window.open("../transfert-entreprise.php?url="+url,"pop_transfert","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function getYdecal(){
	y=0;
	if (window.pageYOffset > -1)y = window.pageYOffset;else if (document.body)y = document.body.scrollTop;
	return y;
}
function add_formation(form){
	document.forms[form].elements['action'].value='ADD_FORMATION';
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function add_experience(form){
	document.forms[form].elements['action'].value='ADD_EXPERIENCE';
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function suppr_formation(form,i){
	document.forms[form].elements['action'].value='DEL_FORMATION';
	document.forms[form].elements['p1'].value=i;
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function suppr_experience(form,i){
	document.forms[form].elements['action'].value='DEL_EXPERIENCE';
	document.forms[form].elements['p1'].value=i;
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function charger_fichier_doc(form){
	document.forms[form].elements['action'].value='LOAD_FICHIER';
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function suppr_fichier_doc(form){
	document.forms[form].elements['action'].value='DEL_FICHIER';
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}
function suppr_fichier_img(form){
	document.forms[form].elements['action'].value='DEL_IMAGE';
	document.forms[form].elements['decal'].value=getYdecal();
	document.forms[form].submit();
}

function checkStringLen (string, min, max, msg) {
  var sValue = true;
  if ((min > 0) && (string.length < min)) sValue = false;
  if ((max > 0) && (string.length > max)) sValue = false;
  if (!sValue) alert(msg);
  return sValue;
}
function checkFilter (string, filter) {
  if (filter.test(string)) sValue = true;
  else {
    sValue = false;
  }
  return sValue;
}
function validite_mail(string, msg){
  var valid = true;
  valid = checkMail(string);
  
  if (valid == false) alert(msg);
  return valid;
}
function checkMail(string){
	if (!checkFilter(string, /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z]){2,6}$/)){
		return false	
	}
	else {
		return true;
	}
}
function write_div(msg,div){
	document.getElementById(div).innerHTML = msg;
}
function choix_div(x){
	if(x==0){
		document.getElementById('choix_afaire').className="job_divvisible";
		document.getElementById('choix_fichier').className="job_divinvisible";
		document.getElementById('choix_formulaire').className="job_divinvisible";
		document.getElementById('choix_retour').className="job_divinvisible";
		
	}
	else if(x==1){
		document.getElementById('choix_afaire').className="job_divinvisible";
		document.getElementById('choix_fichier').className="job_divvisible";
		document.getElementById('choix_formulaire').className="job_divinvisible";
		document.getElementById('choix_retour').className="job_divvisible";
	}
	else if(x==2){
		document.getElementById('choix_afaire').className="job_divinvisible";
		document.getElementById('choix_fichier').className="job_divinvisible";
		document.getElementById('choix_formulaire').className="job_divvisible";
		document.getElementById('choix_retour').className="job_divvisible";
	}
}
function choix_arbre_cv(form,x){
	document.forms[form].elements['action'].value='BROWSE_ARBRE';
	document.forms[form].elements['decal'].value=getYdecal();

	if(x==0){
		document.forms[form].elements['p1'].value='CHOIX';
	}
	else if (x==1){
		document.forms[form].elements['p1'].value='FICHIER';
	}
	else if (x==2){
		document.forms[form].elements['p1'].value='FORMULAIRE';
	}
	
	
	document.forms[form].submit();
}
function reponse_avec_cv(id_candidat,id_annonce,url_dlg){
/* ouvre un pop pour envoyer une réponse avec CV */
	
	id_cv = document.forms['form_annonce'].elements['my_cv'].options[document.forms['form_annonce'].elements['my_cv'].selectedIndex].value;
	
	pop=window.open(url_dlg+"send-reponse-annonce.php?id_annonce="+id_annonce+"&id_candidat="+id_candidat+"&id_cv="+id_cv,"pop_repcv","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();

}
function repondre_reponse_annonce( id_reponse , id_recruteur, url_dlg){
/* ouvre un pop pour envoyer une réponse à une réponse CV */
	pop=window.open(url_dlg+"send-reponse-reponse.php?id_reponse="+id_reponse+"&id_recruteur="+id_recruteur,"pop_reprep","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function repondre_cv( id_cv , id_recruteur, url_dlg){
/* ouvre un pop pour envoyer une réponse à une réponse CV */
	pop=window.open(url_dlg+"send-reponse-cv.php?id_cv="+id_cv+"&id_recruteur="+id_recruteur,"pop_repcv","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function visu_cv(url_cv){
	pop=window.open("imprime-visu-cv.php?url_cv="+url_cv,"pop_cv","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function imprime_cv(url_cv){
	pop=window.open("../imprime-visu-cv.php?PRINT=1&url_cv="+url_cv,"pop_cv","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function visu_annonce(url_annonce, id_annonce){

	url="imprime-annonce.php?NO_PRINT=1&url_annonce="+url_annonce;
	if(id_annonce!=undefined){
		url+="&id_annonce="+id_annonce;
	}

	pop=window.open(url,"pop_cv","width=600, height=600, scrollbars=yes, menubar=yes");
	pop.focus();
}
function Remplacer_dans_chaine(chaine,car_from, car_to){
	var reg=new RegExp(car_from, "g");
	tmp = chaine;
	tmp = tmp.replace(reg,car_to);

 	return tmp;
} 