function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}


function valider(email)
 {
var  adresse =email;
							place = adresse.indexOf("@",1);
							point = adresse.indexOf(".",place+1);
							if ((place > -1)&&(adresse.length >2)&&(point > 1))
									{ return true; }
							else 	
							{
								
							 return false;
							}
							alert("ok");
 }
 
 
$(document).ready(function(){
						   
			/*$("#slideshow_flash").live("click",function(){
									
										 window.open('formu_brunch.php','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=502, height=525'); 
										wopen('formu_brunch.php', 'popup', 502, 525);
												 });	*/	   
// page  actualités


initialiser_actualite();

function initialiser_actualite() {
	$("#lactualites a.lien_actu").click(function(){
								   $("#lactualites a.selected").removeClass("selected");
								   $("#scroll_actus").animate({scrollTop: $(this).attr("name")*($(".ligne_actus:first").height()+$("h5").height()+9) }, 500);
								   $(this).addClass("selected");
													
});
	
	//ajax
	$("#lactualites a.pagination").click(function(){
	var dt=new Date();											  
  $.ajax({
  type: "GET",
  url: "lib/pages/actualites.php",
  data: ""+$(this).attr('name')+"&time="+dt+"",
   success: function(msg){
	 $("#main").html(msg);
	 
	 initialiser_actualite();
	
   }
}); 

													
});}

// page nouvelle carrière
$("#conteneur_carriere .visible").fadeIn("fast");
$("#liste_carriere a").click(function(){ //alert("clic");
									var idtem=$(this).attr("name");
									$("#liste_carriere a.selected").removeClass("selected");
									$(this).addClass("selected");
									
						$('#conteneur_carriere .visible').fadeOut("fast", function(){$('#conteneur_carriere #'+idtem+'').fadeIn("fast");
																			$('#conteneur_carriere .visible').removeClass("visible");
																			$('#conteneur_carriere #'+idtem+'').addClass("visible");								
																														});				

});
						   
						   
 // debut  ajax implantations ------------------------------------------------------------------------
$("#regionc").css('visibility','hidden');
$("#pays").change(function(){
						  var p=$(this).val();
							if(p=='fr')
						   {$("#regionc").css('visibility','visible');
						   //recherche
						   
									$.ajax({
									   type: "POST",
									   url: "lib/pages/recherche_magasin.php",
									   data: "pays="+$("#pays").val()+"",
									   success: function(msg){
										  // alert("ajax: "+msg);
										$("#zone_recherche").html(msg);
								
										initialiserScroll();
										
									   }
									 });

						   
						   
						   }
						   else
						   {$("#regionc").css('visibility','hidden');
						    //recherche
						
									$.ajax({ 
									   type: "POST",
									   url: "lib/pages/recherche_magasin.php",
									   data: "pays="+$("#pays").val()+"",
									   success: function(msg){
										    //alert("ajax: "+msg);
										$("#zone_recherche").html(msg);
										initialiserScroll();
										
									   }
									 });
						   
						   }
						   });
$("#region").change(function(){
						   
						    //recherche
						   
									$.ajax({
									   type: "POST",
									   url: "lib/pages/recherche_magasin.php",
									   data: "pays="+$("#pays").val()+"&region="+$("#region").val()+"",
									   success: function(msg){
										  // alert("ajax: "+msg);
										$("#zone_recherche").html(msg);
										initialiserScroll();
										
									   }
									 });
									
									
									

						   
						   
						   });
$("area.fr").click(function(){
							 	
							
						   
						    //recherche
							var reg=$(this).attr("name");
						   
									$.ajax({
									   type: "POST",
									   url: "lib/pages/recherche_magasin.php",
									   data: "pays=fr&region="+reg+"",
									   success: function(msg){
										  // alert("ajax: "+msg);
										$("#zone_recherche").html(msg);
										initialiserScroll();
										
										//mise ajour des select
										$("#regionc").css('visibility','visible');
								
										
																		
										$('#pays').prev().text( $('#pays option[value=fr]').text());
										$('#region').prev().text( $('#region option[value='+reg+']').text());
										 
									    $('#pays option[value=fr]').attr("selected", "selected");
										$('#region option[value='+reg+']').attr("selected", "selected");
										
									   }
									 });

									
									
									

						   
						   
						   });

$("area.autres").click(function(){
							 	
							
						   
						    //recherche
							var pays=$(this).attr("name");
						   
									$.ajax({
									   type: "POST",
									   url: "lib/pages/recherche_magasin.php",
									   data: "pays="+pays+"",
									   success: function(msg){
										  // alert("ajax: "+msg);
										$("#zone_recherche").html(msg);
										initialiserScroll();
										
										//mise ajour des select
										$("#regionc").css('visibility','hidden');								  
										
										//$('#pays').val("chems");
										//alert($('#pays').prev().text());
									
										$('#pays').prev().text( $('#pays option[value='+pays+']').text());
										  $('#pays option[value='+pays+']').attr("selected", "selected");
										
										
										
									   }
									 });

									
									
									

						   
						   
						   });

 // Fin  ajax implantations ----------------------------------------------------------------------------
 
 // effacer les champs de formulaire
$("#fcandidature #annuler").click( function()
									 { $('#fcandidature').get(0).reset(); 
});
 
 //verificationdes formulaire

 $("#fcandidature").submit( function()
									 {var retour=true;
								
									
									 $("#fcandidature .obligatoire").each(function(){
																									 if($(this).val()=="") {$(this).css("background-color","#e6eea5"); retour=false;} else $(this).css("background-color","#fff"); }
																									 ); 
									 if(!retour) 
									 { $("#fcandidature .submit_alerte").css("display","none");
									 $("#fcandidature .submit_alerte").text("Veuillez saisir les champs obligatoires.");
										$("#fcandidature .submit_alerte").fadeIn("slow");
									 
									 }
									 
									 else
									  {
										  
										
									 if (valider(""+$("#fcandidature .obligatoire[name='email']").val()+"") )
									  return true;
									  else
									  {
									  $("#fcandidature .submit_alerte").css("display","none"); 
									  $("#fcandidature .submit_alerte").text("Veuillez saisir une adresse email valide.");
									  $("#fcandidature .submit_alerte").fadeIn("slow");
									
									  	  return false;
									  }
									  }
									 
									 return retour;})

 


//scroll bar magasin 
var etath=false;
var etatb=false;
function bougerb()
{
	if(etatb) {$(this).delay(100,function(){  $('#scroller').scrollTop($('#scroller').scrollTop()+10); bougerb(); }); }
	}
	function bougerh()
{
	if(etath) {$(this).delay(100,function(){  $('#scroller').scrollTop($('#scroller').scrollTop()-10); bougerh(); }); }
	}
function initialiserScroll()
{

$('#resultat a.bas').mouseenter(function (){ etatb=true; bougerb();});
$('#resultat a.bas').mouseout(function (){ etatb=false; });

$('#resultat a.haut').mouseenter(function (){ etath=true; bougerh();});
$('#resultat a.haut').mouseout(function (){ etath=false; });

$('#resultat a.haut').mouseover(function (){$('#scroller').scrollTop($('#scroller').scrollTop()-10);									
													});
$('#scroller')
        .bind('mousewheel', function(event, delta) {
            var dir = delta > 0 ? $('#scroller').scrollTop($('#scroller').scrollTop()-10) : $('#scroller').scrollTop($('#scroller').scrollTop()+10),
                vel = Math.abs(delta);
                       return false;
        });
}
initialiserScroll();


//page metiers 

$('#contenu_poste .visible').fadeIn("fast");
var clickposte=true;
$('#organigramme a').hover(function(){ 
									if(clickposte)
									{
									clickposte=false;
									var idposte=$(this).attr("class");
						$('#contenu_poste .visible').fadeOut("fast", function(){$('#contenu_poste #'+idposte+'').fadeIn("fast");
																			$('#contenu_poste .visible').removeClass("visible");
																			$('#contenu_poste #'+idposte+'').addClass("visible");										
																														clickposte=true;});					
									}
});

//page temoignage 

$('#temoignage_details .visible').fadeIn("fast");
if($("#temoignage_scroll").length>0)
$("#temoignage_scroll").animate({scrollTop:$("img.selects").position().top-90 }, 500);


$('#temoignage_scroll a').click(function(){ 
									
									var idtem=$(this).attr("class");
									
						$('#temoignage_details .visible').fadeOut("fast", function(){$('#temoignage_details #'+idtem+'').fadeIn("fast");
																			$('#temoignage_details .visible').removeClass("visible");
																			$('#temoignage_details #'+idtem+'').addClass("visible");									
																														});					

});



//style des select box
 if($("#pays").length>0)
$("#pays").select_skin();

 if($("#region").length>0)
$("#region").select_skin();	

 if($("#type_poste").length>0)
$("#type_poste").select_skin();

 if($("#pays_offre").length>0)
$("#pays_offre").select_skin();	

//style des input file

/*if($("input[type=file]").length>0)
$("input[type=file]").filestyle({image: "images/parcourir.jpg",imageheight : 21,imagewidth : 74,width : 120});*/



 // light box videos
if($("a[rel^='fancyboxvideo']").length>0)
$("a[rel^='fancyboxvideo']").fancybox({ 'hideOnContentClick': true,
		   					'frameWidth': 670,
		   					'frameHeight': 510 });
if($("a[rel^='fancyboxmentions']").length>0)
$("a[rel^='fancyboxmentions']").fancybox({ 'hideOnContentClick': true,
		   					'frameWidth': 600,
		   					'frameHeight': 400 });



// diapo
if($('#temdiapo').length>0)
$('#temdiapo').Horinaja({capture:'temdiapo',delai:0.8,duree:4,pagination:true});

if($('#style-diapo').length>0)
$('#style-diapo').Horinaja({capture:'style-diapo',delai:0.8,duree:4,pagination:true});







 
 

 });


