/*HAUTEUR EGAL*/

//var IE7_PNG_SUFFIX = ".png";

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

/*HAUTEUR EGAL*/

//Fonction pour ouvrir ou fermer les offres d'emploi
$("body:not(#home) #emploi tr:not(.bloc-offre)").click( function () {
	
	if($(this).hasClass("open")){
		$(this).removeClass("open");
		$(this).next("tr.bloc-offre").children().children().slideUp("normal");
		return false;
	}else{
		$("tr.bloc-offre").each(function (){ 
			$("tr.bloc-offre").children().children().slideUp("normal");		
		});
		$("#emploi tr:not(.bloc-offre)").each(function (){ 
			$(this).removeClass("open");	
		});
		$(this).addClass("open");
		$(this).next("tr.bloc-offre").children().children().slideDown("normal");
		return false;	
	}
	
});


$(document).ready(function() {
						   
		/*VALIDATION FORMULAIRE*/
	$.tools.validator.localize("fr", {
			':email'  		: 'Merci de mettre une adresse mail valide',
			'[max]'	 		: '$1 caractères maximum',
			'[min]'	 		: '$1 caractères minimum',
			'[required]' 	: 'Merci de remplir ce champ'
		});
		
		//$("#formulaire_contact").validator({lang: 'fr'});
		
		$("#formulaire_contact").validator({ 
			position: 'center right', 
			lang: 'fr'
		});
	/*VALIDATION FORMULAIRE*/
						   
	/*TABS*/
	$(function() {
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
	});
						   
	/*TABLEAU OFFRE D'EMPLOI*/
	//Cache toutes les offres d'emploi au chargement
	$("div.offre").hide();
	/*TABLEAU OFFRE D'EMPLOI*/
			
	/*HAUTEUR EGAL*/
	equalHeight($(".page"));
	
	  var lh = $('#page').height();
	   var rh = $('.page').height();
	   if (lh >= rh){
	  //alert('left : ' + lh);
	  $('.page').height(lh);
	  } else {
	  //alert('right : ' + rh);
	  $('#page').height(rh);
	  };
	  /*HAUTEUR EGAL*/
	
});

/**
 * Gestion des news dans la page d'accueil 
 */
function SpecialNews() {
    this.allNews   = $('.special_news');
    this.currentNews    = null;
}

SpecialNews.prototype.initDisplay = function() {
    $(this.allNews[0]).css({visibility: 'visible'});
    this.currentNews = 0;
    this.mouseOver = false;
    var that = this;
    $(this.allNews).mouseover(function() {that.mouseOver = true;});
    $(this.allNews).mouseout(function() {that.mouseOver = false;});
}

/* Affichage de la news suivante */
SpecialNews.prototype.displayNextNews = function() {

    if (!this.mouseOver) {

	    // On fait disparaitre la news en cours
	    this.fadeOutDiv = this.allNews[this.currentNews];
	    this.currentNews++;
	    if (this.currentNews >= this.allNews.length) {
		this.currentNews = 0;
	    }

	    // On fait apparaitre la nouvelle news
	    this.fadeInDiv = this.allNews[this.currentNews];
	    _this = this;
	    $(this.fadeOutDiv).fadeOut('slow', function() {_this.fadeInNext(); });
    }
}

SpecialNews.prototype.fadeInNext = function() {
    $(this.fadeOutDiv).css({visibility: 'hidden'});
    $(this.fadeInDiv).hide().css({visibility: 'visible'}).fadeIn('slow');
}

var gSpecialNews = new SpecialNews();

$(document).ready(function() {
    gSpecialNews.initDisplay();
    window.setInterval('gSpecialNews.displayNextNews()', 5000);
}
);


