$(document).ready(function(){
	
	//Nyromodal YOUTUBE
	$.nyroModalSettings({
    processHandler: function(settings) {
      var from = settings.from;
      if (from && from.href && from.href.indexOf('http://www.youtube.com/watch?v=') == 0) {
        $.nyroModalSettings({
          type: 'swf',
          height: 340,
          width: 560,
          url: from.href.replace(new RegExp("watch\\?v=", "i"), 'v/')
        });
      }
    }
  });
	
	//$( 'form' ).live( 'click', controlDoubleSubmit );
	
	
	
	// Fonction qui retrieve le diese (sans le diese)
	function getHash(){
		var contentToShow;
		
		if(location.hash == "") {
			contentToShow = 1;
		} else {
			contentToShow = location.hash;
			contentToShow = parseInt(contentToShow.replace(/#/g,''));  
		}
		return contentToShow;
	}
	
	//ÉQUIPIERS
	if($('#allemploye').length > 0){
		$('#allemploye').lemFlow({
			prev:'.prev',
			next:'.next',
			/*height:335,*/
			width:220,
			numVisible:1,
			pos: 1,
			loop: true,
			linkset: '.demandemploye'
		});
	}
		

     // SERVICES 
	if($('#allservice').length > 0){
		$('#allservice').lemFlow({
			prev:'.prev',
			next:'.next',
			height:282,
			width:980,
			numVisible:1,
			pos: getHash(),
			linkset: '.demandservice'
		});
	}
		
		
	 // RÉALISATIONS
	if($('#flow').length > 0){
		$('#flow').lemFlow({
			prev:'.prev',
			next:'.next',
			height:260,
			width:240,
			numVisible:4,
			pos: 1,
			loop: true
		});
	}
     
     
     // PROJETS
	if($('#allprojetimage').length > 0){
		$('#allprojetimage').lemFlow({
			prev:'.prev-image-projet',
			next:'.next-image-projet',
			height:510,
			width:940,
			numVisible:1,
			pos: 1,
			loop: true,
			current: '.imageprojetnow',
			total: '.totalimagesprojet'
		});
	}		
	
	
	// RÉSEAUX SOCIAUX //
	$("#socialmedia p a").hover(
      function(){
         $("#sm-name").html($(this).children(0).html());
      }, 
      function () {
         $('#sm-name').html("&nbsp;");
      }
   );
	
	
	// LIENS VIDEO //
	$(".lienvideo").mouseover(function(){
		$(this).parent().css('top','-510px');
	});
	$(".lienvideo").mouseout(function(){
		$(this).parent().css('top','0px');
	});
	
	
});


function detect_iphone(){
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = 0;
	if(agent.indexOf('iphone')!=-1 || agent.indexOf('ipad')!=-1){
		is_iphone = 1;
	}
	return is_iphone;
}

//IPHONE
var is_iphone = detect_iphone();

$(function(){
	$('a[rel="external"]').attr('target','_blank');
});
