/* 
Projet : Anatome
Auteur : Philippe Khill
Modifications : Xavier Nuel - Net-Concept
*/

$(document).ready(function() {

	// vidage des attributs ALT pour IE7 pour ne pas avoir d'étiquettes jaunes au survol
	$('body.ie7 img').attr('alt','');

	// transition index
	if(('#mask_intro').length) {
		var montimer = window.setTimeout("$('#mask_intro').remove()", 3500);
	}
	
	// changement de couleur des chiffres-clés (version 'cut', pas de fading)
	/* $('.bgt').delay(1000).animate({backgroundColor:'#000000', color:'#ffffff'}, 0); */

	// Modif Xavier Nuel - Net-Concept
	// modif chgt couleur chiffres-clés.. on change l'un après l'autre...

	{
		function animchiffre(ausuivant) {
			var lechiffre=$('.bgt').get(ausuivant);
			$(lechiffre).delay(1000).animate({backgroundColor:'#ff0099', color:'#000'}, 0, function() {
				if (ausuivant!=$('.bgt').size()) {
					ausuivant++;
					animchiffre(ausuivant);
				}
			});
		}
		ausuivant = 0;
		animchiffre(ausuivant);
	}
	
	// cacher les bios dans agence > management
	$('.bio').hide();
	
	// rollover/out des bios pour agence>management
	$('.portrait a.vweb').each(function(index) {
		var id = index+1;
		$(this).mouseover(function(){
			load_bio(id);
		});
		$(this).mouseout(function(){
			unload_bio();
		});
	});
	
	// rollover/out des bios pour equipe
	$('.vignette a').each(function(index) {
		var id = index+1;
		$(this).mouseover(function(){
			load_bio(id);
		});
		$(this).mouseout(function(){
			unload_bio();
		});
	});
	
	// cacher btn precedent dans equipe
	// $('#mosaique #btp').hide();
	
	// initialisation du caroussel d'actus
	caroussel.init($('#actus'));
	
	// affichage/masquage des roll dans la rubrique references > 12 cas
	$('.case .over').hide();
	
	$('.case').mouseover(function(){
		$(this).find('.out').hide();
		$(this).find('.over').show();
	});
	$('.case').mousedown(function(){
		$(this).find('.out').hide();
		$(this).find('.over').show();
	});
	$('.case').mouseout(function(){
		$(this).find('.out').show();
		$(this).find('.over').hide();
	});
	$('.case').mouseup(function(){
		$(this).find('.out').show();
		$(this).find('.over').hide();
	});
	
	$('.map').hide();
	
	
	/*jquery.select_skin.js */
	/*
	 * jQuery select element skinning
	 * version: 1.0.6 (26/06/2010)
	 * @requires: jQuery v1.2 or later
	 * adapted from Derek Harvey code
	 *   http://www.lotsofcode.com/javascript-and-ajax/jquery-select-box-skin.htm
	 * Licensed under the GPL license:
	 *   http://www.gnu.org/licenses/gpl.html
	 *
	 * Copyright 2010 Colin Verot
	 */
	(function ($) {
	    // skin the select
	    $.fn.select_skin = function (w) {
	        return $(this).each(function(i) {
	            s = $(this);
	            if (!s.attr('multiple')) {
	                // create the container
	                s.wrap('<div class="cmf-skinned-select"></div>');
	                c = s.parent();
	                c.children().before('<div class="cmf-skinned-text">&nbsp;</div>').each(function() {
	                    if (this.selectedIndex >= 0) $(this).prev().text(this.options[this.selectedIndex].innerHTML)
	                });
	                c.width(s.outerWidth()-2);
	                c.height(s.outerHeight()-2);

	                // skin the container
	                c.css('background-color', s.css('background-color'));
	                c.css('color', s.css('color'));
	                c.css('font-size', s.css('font-size'));
	                c.css('font-family', s.css('font-family'));
	                c.css('font-style', s.css('font-style'));
	                c.css('position', 'relative');
					c.css('width', '165px');

	                // hide the original select
	                s.css( { 'opacity': 0,  'position': 'relative', 'z-index': 100 } );

	                // get and skin the text label
	                var t = c.children().prev();
	                t.height(c.outerHeight()-s.css('padding-top').replace(/px,*\)*/g,"")-s.css('padding-bottom').replace(/px,*\)*/g,"")-t.css('padding-top').replace(/px,*\)*/g,"")-t.css('padding-bottom').replace(/px,*\)*/g,"")-2);
	                t.width(c.innerWidth()-s.css('padding-right').replace(/px,*\)*/g,"")-s.css('padding-left').replace(/px,*\)*/g,"")-t.css('padding-right').replace(/px,*\)*/g,"")-t.css('padding-left').replace(/px,*\)*/g,"")-c.innerHeight());
	                t.css( { 'opacity': 100, 'overflow': 'hidden', 'position': 'absolute', 'text-indent': '0px', 'z-index': 1, 'top': 0, 'left': 0 } );

	                // add events
	                c.children().click(function() {
	                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
	                });
	                c.children().change(function() {
	                    t.text( (this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : '') );
	                });
	             }
	        });
	    }

	    // un-skin the select
	    $.fn.select_unskin = function (w) {
	        return $(this).each(function(i) {
	            s = $(this);
	            if (!s.attr('multiple') && s.parent().hasClass('cmf-skinned-select')) {
	                s.siblings('.cmf-skinned-text').remove();
	                s.css( { 'opacity': 100, 'z-index': 0 } ).unwrap();
	             }
	        });
	    }
	})(jQuery);
	jQuery(".my-select").select_skin();
	
	
	/* ascenseur stylé de la page de mentions légales */
	if($('#ascenseur').width()>400) {
		$('#ascenseur').jScrollPane();
	}

	
});

// affichage des bios au survol des photos dans agence>management et equipe
function load_bio(e) {
	$('.bio').hide();
	$('#b' + e).show();
}

// masquage des bios dans agence>management et equipe
function unload_bio() {
	$('.bio').hide();
}

// Modif Xavier Nuel - Net-Concept

$('#mosaique_inner').scrollable({next: '.btn_sui', prev: '.btn_pre', circular: false});

// Modif Xavier Nuel - Net-Concept
// prise en compte versions mobiles...

function load_map(e)
{
	$('#adresses').addClass('modecarte');
	$('.adresse').hide()
	$('.map').hide();
	if (e == 1)
	{
		$('#m-paris').show(function(){vmob();});
		$('#paris').show();
	}
	if (e == 2)
	{
		$('#m-lyon').show(function(){vmob();});
	 	$('#lyon').show();
	}
	if (e == 3)
	{
 		$('#montpellier').show();
		$('#m-montpellier').show(function(){vmob();});
	}
	if (e == 4)
	{
		$('#marseille').show();
		$('#m-marseille').show(function(){vmob();});
	}

}
function vmob(){
	$('.separateur-vmob').css('height', $('#maps').height()+50);
}

function fake_trans(t)
{
	window.open(t,'_self');
	/*
	$('.actu').fadeOut(1000);
	$('.texte_actu').fadeOut(1000, function () {
	  window.open(t,'_self');
	});	
	*/
}

function fake_trans_cas(t)
{
	window.open(t,'_self');
	/*
	$('#actus').fadeOut(1000);
	$('.texte_cas').fadeOut(1000, function () {
	  window.open(t,'_self');
	});
	*/
}
$(document).ready(function() {
	function isValidEmail(mail){
		if(mail!=""){
			return ((mail.indexOf("@")>=0)&&(mail.lastIndexOf(".")>mail.indexOf("@")));
		}else{
			return false;
		} 
	}
	$('#frmNewsletter').submit(function() {
		if(isValidEmail($('#email').attr('value'))) {
			return true;
		} else {
			alert("Veuillez saisir une adresse Mail valide");
			return false
		}
	});
});

// Hack source iframe Youtube pour Chrome qui gere mal le z-index;
$(document).ready(function() {
	$("iframe").each(function(){
		  var ifr_source = $(this).attr('src');
		  if( /youtube/g.test(ifr_source)) {
			var wmode = "wmode=transparent";
			if(ifr_source.indexOf('?') != -1) $(this).attr('src',ifr_source+'&'+wmode);
			else $(this).attr('src',ifr_source+'?'+wmode);
		  }
	});
});
