// modules.change.lib.js.login-fr-fr 
$(document).ready(function(){
	$("input#memoryfield:not(.noqtip)").qtip({
   	tip: true,
	 	style: {
    	name: 'cream',
    	tip: 'bottomMiddle',
    	border: {
    		radius: 4
    	}
   	},
   	position: {
   		corner: {
   			tooltip: 'bottomMiddle',
   			target: 'topMiddle'
   		}
   	},
   	show: {
     		delay: 0,
     		effect: {
     			length: 0
     		}
     	}
	});

	if($("#pictologinerror").length)
	{
		$("#pictologinerror").qtip({
	   	tip: true,
		 	style: {
	    	name: 'cream',
	    	tip: 'bottomMiddle',
	    	border: {
	    		radius: 4
	    	}
	   	},
	   	position: {
	   		corner: {
	   			tooltip: 'bottomMiddle',
	   			target: 'topMiddle'
	   		}
	   	},
	   	show: {
	     		delay: 0,
	     		effect: {
	     			length: 0
	     		}
	     	}
		});
	}
});

// modules.change.lib.js.bigtarget-fr-fr 
// bigTarget.js - A jQuery Plugin
// Version 1.0.1
// Written by Leevi Graham - Technical Director - Newism Web Design & Development
// http://newism.com.au
// Notes: Tooltip code from fitted.js - http://www.trovster.com/lab/plugins/fitted/

// create closure
(function($) {
	// plugin definition
	$.fn.bigTarget = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.bigTarget.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			// set the anchor attributes
			var $a = $(this);
			var href = $a.attr('href');
			var title = $a.attr('title');
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $a.data()) : opts;
			// update element styles
			$a.parents(o.clickZone)
				.hover(function() {
					$h = $(this);
					$h.addClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.attr('title',title);
					}
				}, function() {
					
					$h.removeClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.removeAttr('title');
					}
				})
				// click
				.click(function() {
					if(getSelectedText() == "")
					{
						if($a.is('[rel*=external]')){
							window.open(href);
							return false;
						}
						else {
							//$a.click(); $a.trigger('click');
							window.location = href;
						}
					}
				});
		});
	};
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log)
		window.console.log('bigTarget selection count: ' + $obj.size());
	};
	// get selected text
	function getSelectedText(){
		if(window.getSelection){
			return window.getSelection().toString();
		}
		else if(document.getSelection){
			return document.getSelection();
		}
		else if(document.selection){
			return document.selection.createRange().text;
		}
	};
	// plugin defaults
	$.fn.bigTarget.defaults = {
		hoverClass	: 'hover',
		clickZone	: 'li:eq(0)',
		title		: true
	};
// end of closure
})(jQuery);

// modules.change.lib.js.home-fr-fr 
$(document).ready(function(){
  	$("div.home-download h2 a").bigTarget({
    		hoverClass: 'download-hover',
    		clickZone : 'div:eq(0)'
  	});
  	$("div.home-demo h2 a").bigTarget({
    		hoverClass: 'demo-hover',
    		clickZone : 'div:eq(0)'
  	});
});

// modules.imgslider.lib.js.carousel-fr-fr 
/* jQuery Carousel 0.9.1
   Copyright 2008-2009 Thomas Lanciaux and Pierre Bertet.
   This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/
;(function($){

	$.fn.carousel = function(params){

		var params = $.extend({
			direction: "horizontal",
			loop: false,
			dispItems: 1,
			pagination: false,
			paginationPosition: "inside",
			nextBtn: '<span role="button">Suivant</span>',
			prevBtn: '<span role="button">Précédent</span>',
			btnsPosition: "outside",
			nextBtnInsert: "appendTo",
			prevBtnInsert: "prependTo",
			nextBtnInsertFn: false,
			prevBtnInsertFn: false,
			autoSlide: false,
			autoSlideInterval: 3000,
			delayAutoSlide: false,
			combinedClasses: false,
			effect: "slide",
			slideEasing: "swing",
			animSpeed: "normal",
			equalWidths: "true",
			callback: function(){},
			useAddress: false,
			adressIdentifier: "carousel",
			useBtNav: true
		}, params);

		// Buttons position
		if (params.direction == "vertical"){
			params.prevBtnInsert = "insertBefore";
			params.nextBtnInsert = "insertAfter";
		}

		// Slide delay
		params.delayAutoSlide = params.delayAutoSlide || params.autoSlideInterval;

		return this.each(function(){

			// Env object
			var env = {
				$elts: {},
				params: params,
				launchOnLoad: []
			};

			// Carousel main container
			env.$elts.carousel = $(this).addClass("js");

			// Carousel content
			env.$elts.content = $(this).children().css({position: "absolute", "top": 0});

			// Content wrapper
			env.$elts.wrap = env.$elts.content.wrap('<div class="carousel-wrap"></div>').parent().css({overflow: "hidden", position: "relative"});

			// env.steps object
			env.steps = {
				first: 0, // First step
				count: env.$elts.content.children().length // Items count
			};

			// Last visible step
			env.steps.last = env.steps.count - 1;

			// Prev Button
			if ($.isFunction(env.params.prevBtnInsertFn)) {
				env.$elts.prevBtn = env.params.prevBtnInsertFn(env.$elts);

			} else {
				env.$elts.prevBtn = $(params.prevBtn)[params.prevBtnInsert](env.$elts.carousel);
			}

			// Next Button
			if ($.isFunction(env.params.nextBtnInsertFn)) {
				env.$elts.nextBtn = env.params.nextBtnInsertFn(env.$elts);

			} else {
				env.$elts.nextBtn = $(params.nextBtn)[params.nextBtnInsert](env.$elts.carousel);
			}

			// Add buttons classes / data
			env.$elts.nextBtn.addClass("carousel-control next carousel-next" + " " + env.params.direction);
			env.$elts.prevBtn.addClass("carousel-control previous carousel-previous" + " " + env.params.direction);

			if(!env.params.useBtNav)
			{
				env.$elts.nextBtn.addClass("hidden");
				env.$elts.prevBtn.addClass("hidden");
			}


			// Bind events on next / prev buttons
			initButtonsEvents(env);

			// Pagination
			if (env.params.pagination) {
				initPagination(env);
			}

			// Address plugin
			initAddress(env);

			// On document load...
			$(function(){

				// First item
				var $firstItem = env.$elts.content.children(":first");

				// Width 1/3 : Get default item width
				maxW = 0;
				env.$elts.content.children().each(function(){
					if($(this).outerWidth()>maxW)
					{
						maxW = $(this).outerWidth();
					}
				});
				env.itemWidth = maxW;
				maxH = 0;
				env.$elts.content.children().each(function(){
					if($(this).outerHeight()>maxH)
					{
						maxH = $(this).outerHeight();
					}
				});
				env.itemHeight = maxH;

				// Width 2/3 : Define content width

						env.$elts.content.children().each(function(){
								$(this).width(maxW);
								$(this).height(maxH);
							});

						if (params.direction == "vertical"){
							env.$elts.nextBtn.css('width', maxW);
							env.$elts.prevBtn.css('width', maxW);
							env.contentWidth = env.itemWidth;
							env.$elts.content.parent().css('width', maxW).css('height', maxH * env.params.dispItems);

						} else {
							env.$elts.nextBtn.css('height', maxH);
							env.$elts.prevBtn.css('height', maxH);
							env.contentWidth = env.itemWidth * env.steps.count;
							env.$elts.content.parent().css('width', maxW * env.params.dispItems).css('height', maxH);
						}


				// Width 3/3 : Set content width to container
				env.$elts.content.width( env.contentWidth );

				// Height 1/2 : Get default item height
				env.itemHeight = $firstItem.outerHeight();

				// Height 2/2 : Set content height to container
				if (params.direction == "vertical"){
					env.$elts.content.css({height:env.itemHeight * env.steps.count + "px"});
					env.$elts.content.parent().css({height:env.itemHeight * env.params.dispItems + "px"});

				} else {
					env.$elts.content.parent().css({height:env.itemHeight + "px"});
				}

				// Update Next / Prev buttons state
				updateButtonsState(env);

				// Launch function added to "document ready" event
				$.each(env.launchOnLoad, function(i,fn){
					fn();
				});

				// Launch autoslide
				if (env.params.autoSlide){
					window.setTimeout(function(){
						env.autoSlideInterval = window.setInterval(function(){
							goToStep( env, getRelativeStep(env, "next") );
						}, env.params.autoSlideInterval);
					}, env.params.delayAutoSlide);
				}

			});

		});

	};

	// Next / Prev buttons events only
	function initButtonsEvents(env){

		env.$elts.nextBtn.add(env.$elts.prevBtn)

			.bind("enable", function(){

				var $this = $(this)
					.unbind("click")
					.bind("click", function(){
						goToStep( env, getRelativeStep(env, ($this.is(".next")? "next" : "prev" )) );
						stopAutoSlide(env);
					})
					.removeClass("disabled");

				// Combined classes (IE6 compatibility)
				if (env.params.combinedClasses) {
					$this.removeClass("next-disabled previous-disabled");
				}
			})
			.bind("disable", function(){

				var $this = $(this).unbind("click").addClass("disabled");

				// Combined classes (IE6 compatibility)
				if (env.params.combinedClasses) {

					if ($this.is(".next")) {
						$this.addClass("next-disabled");

					} else if ($this.is(".previous")) {
						$this.addClass("previous-disabled");

					}
				}
			})
			.hover(function(){
				$(this).toggleClass("hover");
			});
	};

	// Pagination
	function initPagination(env){
		env.$elts.pagination = $('<div class="center-wrap"><div class="carousel-pagination"><p></p></div></div>')[((env.params.paginationPosition == "outside")? "insertAfter" : "appendTo")](env.$elts.carousel).find("p");

		env.$elts.paginationBtns = $([]);

		env.$elts.content.find("li").each(function(i){
			if (i % env.params.dispItems == 0) {
				env.$elts.paginationBtns = env.$elts.paginationBtns.add( $('<a role="button"><span>'+( env.$elts.paginationBtns.length + 1 )+'</span></a>').data("firstStep", i) );
			}
		});

		env.$elts.paginationBtns.appendTo(env.$elts.pagination);

		env.$elts.paginationBtns.slice(0,1).addClass("active");

		// Events
		env.launchOnLoad.push(function(){
			env.$elts.paginationBtns.click(function(e){
				goToStep( env, $(this).data("firstStep") );
				stopAutoSlide(env);
			});
		});
	};

	// Address plugin
	function initAddress(env) {

		if (env.params.useAddress && $.isFunction($.fn.address)) {

			$.address
				.init(function(e) {
					var pathNames = $.address.pathNames();
					if (pathNames[0] === env.params.adressIdentifier && !!pathNames[1]) {
						goToStep(env, pathNames[1]-1);
					} else {
						$.address.value('/'+ env.params.adressIdentifier +'/1');
					}
				})
				.change(function(e) {
					var pathNames = $.address.pathNames();
					if (pathNames[0] === env.params.adressIdentifier && !!pathNames[1]) {
						goToStep(env, pathNames[1]-1);
					}
				});
		} else {
			env.params.useAddress = false;
		}
	};

	function goToStep(env, step) {

		// Callback
		env.params.callback(step);

		// Launch animation
		transition(env, step);

		// Update first step
		env.steps.first = step;

		// Update buttons status
		updateButtonsState(env);

		// Update address (jQuery Address plugin)
		if ( env.params.useAddress ) {
			$.address.value('/'+ env.params.adressIdentifier +'/' + (step + 1));
		}

	};

	// Get next/prev step, useful for autoSlide
	function getRelativeStep(env, position) {
		if (position == "prev") {
			if ( (env.steps.first - env.params.dispItems) >= 0 ) {
				return env.steps.first - env.params.dispItems;

			} else {
				return ( (env.params.loop)? (env.steps.count - env.params.dispItems) : false );
			}

		} else if (position == "next") {

			if ( (env.steps.first - -env.params.dispItems) < env.steps.count ) {
				return env.steps.first - -env.params.dispItems;

			} else {
				return ( (env.params.loop)? 0 : false );
			}
		}
	};

	// Animation
	function transition(env, step) {

		// Effect
		switch (env.params.effect){

			// No effect
			case "no":
				if (env.params.direction == "vertical"){
					env.$elts.content.css("top", -(env.itemHeight * step) + "px");
				} else {
					env.$elts.content.css("left", -(env.itemWidth * step) + "px");
				}
				break;

			// Fade effect
			case "fade":
				if (env.params.direction == "vertical"){
					env.$elts.content.hide().css("top", -(env.itemHeight * step) + "px").fadeIn(env.params.animSpeed);
				} else {
					env.$elts.content.hide().css("left", -(env.itemWidth * step) + "px").fadeIn(env.params.animSpeed);
				}
				break;

			// Slide effect
			default:
				if (env.params.direction == "vertical"){
					env.$elts.content.stop().animate({
						top : -(env.itemHeight * step) + "px"
					}, env.params.animSpeed, env.params.slideEasing);
				} else {
					env.$elts.content.stop().animate({
						left : -(env.itemWidth * step) + "px"
					}, env.params.animSpeed, env.params.slideEasing);
				}
				break;
		}

	};

	// Update all buttons state : disabled or not
	function updateButtonsState(env){

		if (getRelativeStep(env, "prev") !== false) {
			env.$elts.prevBtn.trigger("enable");

		} else {
			env.$elts.prevBtn.trigger("disable");
		}

		if (getRelativeStep(env, "next") !== false) {
			env.$elts.nextBtn.trigger("enable");

		} else {
			env.$elts.nextBtn.trigger("disable");
		}

		if (env.params.pagination){
			env.$elts.paginationBtns.removeClass("active")
			.filter(function(){ return ($(this).data("firstStep") == env.steps.first) }).addClass("active");
		}
	};

	// Stop autoslide
	function stopAutoSlide(env) {
		if (!!env.autoSlideInterval){
			window.clearInterval(env.autoSlideInterval);
		}
	};

})(jQuery);

