/**** script slideshow par devblog.fr ******/

function slideshow(id,transition,pause)
{
	var total=jQuery('#'+id+' .slideshow-item').length;
	jQuery('#'+id+' .slideshow-item').each(
		function(i){
			jQuery(this).css('z-index',(total-i));
		}
	);
	jQuery('.slideshow-item').fadeIn('slow');
	setTimeout(function() {slide(id,total,transition,pause)},transition+pause);
}

function slide(id,total,transition,pause)
{
	jQuery('#'+id+' .slideshow-item').each(
		function(i){
			if(jQuery(this).css('z-index')==total)
			{
					jQuery(this).fadeOut(transition, function(){
					
						jQuery('#'+id+' .slideshow-item').each(
							function(){
								if(jQuery(this).css('z-index')==total)
								{
									jQuery(this).css('z-index',1);
									jQuery(this).fadeIn();
								}
								else
									jQuery(this).css('z-index',parseInt(jQuery(this).css('z-index'))+1);
							}
						);
					});
			}
		}
	);
	setTimeout(function() {slide(id,total,transition,pause)},transition+pause);
}

jQuery(document).ready(function(){
	if(iPhoneDetect())
	{
		if(versionsSite()=='fr')
		{
			
			jQuery('#tdslide').html('<div class="slideshow" id="monslideshow">'+
								'<img src="images/image1_fr.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image2_fr.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image3_fr.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image4_fr.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image5_fr.jpg" class="slideshow-item" alt="">' +
							'</div>');
		}
		else
		{	
			jQuery('#tdslide').html('<div class="slideshow" id="monslideshow">'+
								'<img src="images/image1_en.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image2_en.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image3_en.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image4_en.jpg" class="slideshow-item" alt="">' +
								'<img src="images/image5_en.jpg" class="slideshow-item" alt="">' +
							'</div>');
			
		}
		
		jQuery('.slideshow-item').hide();
	}
});
jQuery(window).load(function(){
	if(iPhoneDetect())
	{
		//slideshow('monslideshow',2000,3000);
		jQuery('#tdslide').html('<iframe src="http://player.vimeo.com/video/33409954?title=0&amp;byline=0&amp;portrait=0" width="580" height="339" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe><br><br><span class="Style1">Le Monde confie &agrave; Square la r&eacute;alisation de la version iPad de son magazine M.</span><br><br><a href="http://itunes.apple.com/fr/app/m-magazine/id478671861?mt=8" target="_blank"><img src="dispoappstore.gif" alt="app store" width="100" height="36" border="0"></a>');
	}
});

function iPhoneDetect() {
 if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/iPad/i))){
  return true;
 }
 else
 {
 	return false;
 }
}

function versionsSite()
{	
	if((document.URL.match(/english/i))){
		return 'en';
	}
	else
	{
		return 'fr';
	}
}
