/**
 * Librairie javascript commune a tout l'ecog
 *
 * @author			Julie Tetard <julie@2jstudio.com> 
 * @version		E-cog 3.0
 * @package			public
 * @subpackage		param
 * @category		js
 * @internal		last modified
 */



/**
 * Attache Evenements
 */
$(document).ready(function () {
	
	// Galleries
	var galleries = $('.ad-gallery').adGallery({
		  loader_image: 'param/pix/index/ad-gallery/loader.gif',
		  width: 535, // Width of the image, set to false and it will read the CSS width
		  height: 300, // Height of the image, set to false and it will read the CSS height
		  thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
		                      // Note that this effect combined with other effects might be resource intensive
		                      // and make animations lag
		  start_at_index: 0, // Which image should be displayed at first? 0 is the first image
		  animate_first_image: false, // Should first image just be displayed, or animated in?
		  animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
		  display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
		  display_back_and_forward: false, // Are you allowed to scroll the thumb list?
		  scroll_jump: 0, // If 0, it jumps the width of the container
		  slideshow: {
		    enable: true,
		    autostart: true,
		    speed: 5000,
		    start_label: 'Start',
		    stop_label: 'Stop',
		    stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
		    countdown_prefix: '(', // Wrap around the countdown
		    countdown_sufix: ')',
		    onStart: function() {
		      // Do something wild when the slideshow starts
		    },
		    onStop: function() {
		      // Do something wild when the slideshow stops
		    }
		  },
		  effect: 'fade', // or 'slide-vert', 'resize', 'fade', 'none' or false
		  enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?
		  cycle: true, // If set to false, you can't go from the last image to the first, and vice versa
		  // All callbacks has the AdGallery objects as 'this' reference
			callbacks: {
			
				// This gets fired right before old_image is about to go away, and new_image
				// is about to come in
				beforeImageVisible: function(new_image, old_image){
					if ($('.ad-image-description span').text().replace(' ', '') != '') {
						//alert("'"+$('.ad-image-description span').text()+"'");
						$('.ad-image-description span').replaceWith(' <a href="' + $('.ad-image-description span').text() + '">[' + ($('meta name=language').attr('content') == 'fr' ? 'En savoir plus' : 'Further information') + ']</a>');
					}
				}
			}

		});
		
		
	
	$("#menu-main li a").hover(function() {
		$(this).parent('li').find("em").animate({opacity: "show", top: "200"}, "slow");
		$(this).find('img').attr('title', '');
		$(this).find('img').attr('alt', '');
	}, function() {
		
		
		$(this).parent('li').find("em").animate({opacity: "hide", top: "210"}, "fast");
	});

		

});

function validation(email)
{
	var verif = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
 	 if (verif.exec(email) == null)	{
		return false;
	} else	{
		return true;
	}
} 
