// JavaScript Document
var tvis = 0;
function init()
  {
	$(".scrollable").each(function(){
		if($(this).find(".items > div:not(.cloned)").length>1)
		  {$(this).scrollable({ circular: true }).navigator(".navi").autoscroll({ autoplay: true, interval:7000 });}
		});
	$(".scrollablev").each(function(){
		if($(this).find(".items > div:not(.cloned)").length>1)
		  {$(this).scrollable({vertical: true, circular: true}).navigator(".navi").autoscroll({ autoplay: true, interval:7000 });}
		});
	//$('.needRSS').append('<a href="#" class="rss"></a>');
	$('.navi').each(function() {$(this).css('margin-left',($(this).parent().width()-$(this).innerWidth())/2); $(this).addClass('dblock');});
	$('.titleToClick').click(function(){window.location.href = $(this).find(".clickToTitle").attr('href');});
	$('.zOverlay .contenu .z2 .zb li a').hover(function() {$(this).parent('li').addClass('over');},function() {$(this).parent('li').removeClass('over');});
	$('.zOverlay .contenu .z2 .zb li a').click(function() {ouvrirTem($(this).attr('href').replace('#tem_',''));});
	$('.zOverlay').overlay({top: 'center',mask: {color: '#000000',loadSpeed: 200,opacity: 0.5},onClose:function() {$('#zoneVideoOv').html('');}});
	$('.triggerTem').click(function(){$(".zOverlay").data("overlay").load();ouvrirTem($(this).attr('href').replace('#tem_',''));});
	$('.zoneCV').each(function()
		{
		  var nid = 'zcv'+$('.zoneCV').index(this);
		  $(this).attr('id',nid);
		  $('#'+nid).flash({swf: rootPath+'images/uploadFichiers.swf',height: 25, width:200,wmode:'transparent',flashvars: {fileTarget: rootPath+'library/ajax/upload.php', idField:'champcache', callBack: 'changerValeur'}});
		});
	$('.slideme').click(function() 
		{
			var tvis = $(this).attr('id');
			if(!$('#C'+tvis).hasClass('estactif'))
			  {
				$(this).parents('.estactif').removeClass('estactif');
				var posY = $('#C'+tvis).offset().top;
				var parPosY = $(this).parents('.listRubriques').offset().top;
				$('#C'+tvis).addClass('estactif').parent().animate({scrollTop: posY-parPosY+$('#C'+tvis).parent().scrollTop()}, 300);
			  }
			else
			  {$('#C'+tvis).removeClass('estactif').parent().animate({scrollTop: 0}, 300);}
		});
	$('.triggerNextActu').click(function() {chargerActu($(this).parents('.contenuBlockCote').find('td:last').attr('id').replace('act',''),$(this).attr('href').replace('#',''),$(this).find('span').attr('id').replace('x',''));});
	$('.triggerNextOffre').click(function() {chargerOffre($(this).parents('.contenuBlockCote').find('td:last').attr('id').replace('off',''),$(this).attr('href').replace('#',''),$(this).find('span').attr('id').replace('x',''));});
	if($('body').hasClass('majActu'))
	  {$.get(rootPath+"library/ajax/loadRSS.php");}
	$('.triggerFooter').click(function()
		{
		  $('#voletFooter').toggle('blind');
		  var ot=$('#voletFooter').offset().top;
		  $('html,body').animate({scrollTop: ot}, 1000);
		});
  }
function chargerActu(last,nb,type)
  {
	$.post(rootPath+"library/ajax/actu.php",{type:type, debut:last, nombre:nb},
	  function (data)
		{
		  $('#zAjoutActu').append(data);
		  if($('#zAjoutActu .islastentry').length>0)
			{$("#btChargeAct").remove();}
		  $('.depliezMoi').show('blind',700,function(){$(this).removeClass('depliezMoi')});
		}
	);
  }
function chargerOffre(last,nb,type)
  {
	$.post(rootPath+"library/ajax/offre.php",{debut:last, nombre:nb, type:type},
	  function (data)
		{
		  $('#zAjoutOffre').append(data);
		  if($('#zAjoutOffre .islastentry').length>0)
			{$("#btChargeOff").remove();}
		  $('.depliezMoi').show('blind',700,function(){$(this).removeClass('depliezMoi')});
		}
	);
  }
function goSlide(myId)
  {
	
	//$('#'+myId).parents('.visib').hide('drop',300,function(){$('#C'+myId).addClass('visib').show('drop',300);}).removeClass('visib');
  }
function ouvrirTem(n)
  {
	$('.zOverlay .contenu .z2 .zb li.actif').removeClass('actif');
	$('#ovt'+n).addClass('actif');
	$('#overTems .z1 .zh h2').html($('#ovt'+n+" a").html());
	$('#zoneVideoOv').flash({swf: rootPath+'images/flvplayer.swf',height: 300, width:479, allowFullScreen:true,flashvars: {file:rootFile+$('#ovt'+n+" .video").text(),autostart:true,image:rootFile+$('#ovt'+n+" .visuel").text()}});
  }
function envoyerCV(n)
  {
	if(n==null)
	  {n="";}
	if($('input#cvNom'+n).val()!="" && $('input#cvNom'+n).val()!="Nom, Prénom")
	  {
		if($('input#cvEmail'+n).val()!="" && $('input#cvEmail'+n).val()!="Email")
		  {
			if($('input#cvMetier'+n).val()!="" && $('input#cvMetier'+n).val()!="Métier recherché")
			  {
				if($('input#champcache').val()!="")
				  {$("#fCV"+n).load(rootPath+"library/ajax/cv.php",{ 'offre':n,'cvMetier':$('input#cvMetier'+n).val(), 'cvNom':$('input#cvNom'+n).val(), 'cvEmail':$('input#cvEmail'+n).val(), 'cvFichier':$('input#champcache').val()});}
				else
				  {alert("Veuillez joindre votre CV");}
			  }
			else
			  {alert("Veuillez saisir le métier que vous recherchez");}
		  }
		else
		  {alert("Veuillez saisir votre adresse email");}
	  }
	else
	  {alert("Veuillez saisir votre nom");}
  }
function chpFocus(chp,valeur)
  {
	if($('#'+chp).val()==valeur)
	  {$('#'+chp).val('');}
  }
function chpBlur(chp,valeur)
  {
	if($('#'+chp).val()=='')
	  {$('#'+chp).val(valeur);}
  }
function changerValeur(chp,valeur)
  {$('#'+chp).val(valeur);}
function envoyerContact(n)
  {
	if($('input#contactNom').val()!="" && $('input#contactNom').val()!="Nom, prénom")
	  {
		if($('input#contactEmail').val()!="" && $('input#contactEmail').val()!="Email")
		  {
			if($('textarea#contactMessage').val()!="" && $('textarea#contactMessage').val()!="Message")
			  {$("#contact"+n).load(rootPath+"library/ajax/contact.php",{ 'contactNom':$('input#contactNom').val(), 'contactEmail':$('input#contactEmail').val(), 'contactMessage':$('textarea#contactMessage').val()});}
			else
			  {alert("Veuillez saisir votre message");}
		  }
		else
		  {alert("Veuillez saisir votre adresse email");}
	  }
	else
	  {alert("Veuillez saisir votre nom");}
	//alert("envoyer contact");
  }
function rechercher()
  {
	if($('input#chpRech').val()!="Rechercher" && $('input#chpRech').val()!="")
	  {$('#fRech').submit();}
	else
	  {alert("Veuillez saisir le texte à rechercher.");}
  }


