
// Configure jQuery LightBox plugin





var version = 0;
if (navigator.appVersion.indexOf("MSIE") != -1)
{

   temp = navigator.appVersion.split("MSIE");
   version = parseFloat(temp[1]);
   

		   
		if(version  < 7) // Version inférieur ou égal à 7
		{ 
		
		
		}
		else
		{
			// Configure jQuery LightBox plugin
			$(function(){
				$.Lightbox.construct({
					show_linkback:	false,
					download_link:	false,
					opacity: 0.6,
					show_extended_info: true,
					text: {
						image: 'Photo',
						of: 'de',
						close: 'Fermer',
						closeInfo: 'Vous pouvez également cliquer n\'importe où en dehors de l\'image pour fermer.',
						download: 'Télécharger',
						help: {
							close:		'Cliquer pour fermer',
							interact:	'Survoler pour interagir'
						}
					}
				});
			});
		}

}else
{

	// Configure jQuery LightBox plugin
	$(function(){
		$.Lightbox.construct({
			show_linkback:	false,
			download_link:	false,
			opacity: 0.6,
			show_extended_info: true,
			text: {
				image: 'Photo',
				of: 'de',
				close: 'Fermer',
				closeInfo: 'Vous pouvez également cliquer n\'importe où en dehors de l\'image pour fermer.',
				download: 'Télécharger',
				help: {
					close:		'Cliquer pour fermer',
					interact:	'Survoler pour interagir'
				}
			}
		});
	});

}


$(document).ready(function () {
	
	// Iterates over all slide element
	$(".slide").each(function () {
		initSlideBox(this);
	});
	
	// Expand all link event
	$("li.slideexpandall").each(function () {
		$(this).bind("click", function(e) {
			expandAllSlideBox(this);
		});
	});
	
	// Collapse all link event
	$("li.slidecollapseall").each(function () {
		$(this).bind("click", function(e) {
			collapseAllSlideBox(this);
		});
	});
	
	// Page private space : events hover images
	$("#alias-espace-prive #content img").each(function () {
		var imgSrc = $(this).attr("src");
		$(this).bind("mouseover", function(e) {
			$(this).attr("src", imgSrc.replace(".png", "_hover.png"));
		});
		$(this).bind("mouseout", function(e) {
			$(this).attr("src", imgSrc);
		});
	});
	
	// Page press : expand first year
	$("#alias-presse .slide:first").each(function () {
		expandSlideBox(this);
	});
	
	// Basket - step number
	step = 1;
	$(".com-chkout-steps div").each(function () {
		$(this).addClass("com-chkout-step-" + step);
		step = step + 1;
	});
});

// Collapse a slide box
function initSlideBox(box) {
	
	// Extracted content title or resume
	var slideExtractElement = $(box).find("h3.resume,h1,h2,h3,h4,h5,h6,p,li");
	
	if ($(slideExtractElement).length > 0) {
		$(box).prepend("<h3 class=\"resume\">"+ slideExtractElement.eq(0).html().slice(0, 50) +"</h3>");
		$(slideExtractElement).eq(0).hide(); // Hide extract element in content
	} else {
		$(box).prepend("<h3 class=\"resume\">Contenu dÃ©pliant...</h3>");
	}
	collapseSlideBox(box);
}

// Collapse a slide box
function collapseSlideBox(box) {
	
	// Remove collapse link
	$(box).find(".collapse").remove();
	
	// Hide all content by using hide() or slideUp()
	if ($(box).hasClass("open")) {
		$(box).contents(".wrapper").slideUp("normal");
	} else {
		$(box).contents(".wrapper").hide();
	}
	
	// Change title style by adding/removing class
	$(box).removeClass("open");
	$(box).addClass("close");
	
	// Insert expand button
	$(box).prepend("<div class=\"expand pointer\" title=\"DÃ©plier\"><span>DÃ©pier</span></div>");
	
	// Add click event on expand button
	$(box).find(".expand").bind("click", function(e) {
	  expandSlideBox(box);
    });
}

// Expand a slide box
function expandSlideBox(box) {
	
	// Remove expand link
	$(box).find(".expand").remove();
	
	// Change title style by adding/removing class
	$(box).removeClass("close")
	$(box).addClass("open");
	
	// Insert collapse button
	$(box).prepend("<div class=\"collapse pointer\" title=\"Plier\"><span>Plier</span></div>");
	
	// Display content
	$(box).find(".wrapper").slideDown("normal");
	
	// Add click event on collapse button
	$(box).find(".collapse").bind("click", function(e) {
	  collapseSlideBox(box);
    });
}

function collapseAllSlideBox() {
	$(".slide.open").each(function () {
		//if ($(this).hasClass("open")) {
			collapseSlideBox(this);
		//}
	});
}

function expandAllSlideBox() {
	$(".slide.close").each(function () {
		//if ($(this).hasClass("close")) {
			//alert('test');
			expandSlideBox(this);
		//}
	});
}