/*
 * Créer et programmer par Jean-François Duquette de Labo X Design 2011
 * 2011-04-07
 * 
 * */
	function isAlpha(str){
		  var re = /[^a-zA-Z- ]/g;
		  if (re.test(str)){
			   return false;
		  }
		  return true;
	}
	function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){		   
		    return false;
		 }

 		 return true;					
	}
	function loadPage(page,title)
 	{
		$("#container").empty();
		$("#container").css('display','none');
		
		$("#container").load(page, function() // Envoie au formulaire les donn�es n�c�ssaires pour la manipulation.
 		{					
					document.title = title;
					$("#container").slideToggle('slow');
 		});
 	}
	function scrollText(scrolling_content_id,action,top_move)
 	{
		if($('#'+scrolling_content_id))
		{
			var t_height = $('#'+scrolling_content_id).height()/top_move;						
			var t_position = $('#'+scrolling_content_id).position();
			var t_top = t_position.top;
			var max = $('#'+scrolling_content_id).height();
			
				if(action == "1")
				{
					if(t_top < 0)
					{
						$('#'+scrolling_content_id).animate({"top":"+="+top_move+"px"},1);
					}
				}
				else
				{		
					    var offset_top =  t_height - max;
					  
						if(t_top > offset_top)
						{
							$('#'+scrolling_content_id).animate({"top": "-="+top_move+"px"},1);
						}
				}
			
		}		
 	}
	function startGallerie()
 	{
		$('#gallerie_list').find('.main_image_item').each(function(e)
		{
			if(!$(this).hasClass('first'))
			{
				$(this).children().each(function(e)
				{
					$(this).css('opacity','0.2');
				});
				
			}			
		});
		$('#gallerie_scroll_list').find('.mini_image_item').each(function(e)
				{
					if(!$(this).hasClass('first'))
					{
						$(this).children().each(function(e)
						{
							$(this).css('opacity','0.2');
						});
					}			
				});
 	}
	function selectImage(id)
 	{
		$('#gallerie_list').find('.main_image_item').each(function(e)
				{
						if($(this).hasClass('selected'))
						{
							$(this).removeClass('selected');
							var int_id = $(this).attr('id').split('_')[2];
							if(int_id > id)
							{
								var scrolling = int_id - id;
								var mini_scrolling = scrolling * 104;
								scrolling = scrolling * 673;
								$('#gallerie_list').animate({
								    left: '+='+scrolling
								  }, 500, function() {
									
									  $('#m_img_'+int_id).children().animate({
										  opacity: '0.2'
									  }, 500, function() {});
									  $('#m_img_'+id).children().animate({
										  opacity: '1'
									  }, 500, function() {
										  
										  $('#m_img_'+id).addClass('selected');
										
									  });
								    // Animation complete.
								  });
								$('#gallerie_scroll_list').animate({
								    left: '+='+mini_scrolling
								  }, 500, function() {
									
									  $('#mini_img_'+int_id).children().animate({
										  opacity: '0.2'
									  }, 500, function() {});
									  $('#mini_img_'+id).children().animate({
										  opacity: '1'
									  }, 500, function() {
										  $('#mini_img_'+id).addClass('selected');
									  });
								    // Animation complete.
								  });
							
							}	
							else
							{
								
								var scrolling = id - int_id;
								var mini_scrolling = scrolling * 104;
								scrolling = scrolling * 673;
								$('#gallerie_list').animate({
								    left: '-='+scrolling
								  }, 500, function() {
									  $('#m_img_'+int_id).children().animate({
										  opacity: '0.2'
									  }, 500, function() {});
									  $('#m_img_'+id).children().animate({
										  opacity: '1'
									  }, 500, function() {
										  $('#m_img_'+id).addClass('selected');
									  });
								  });
								$('#gallerie_scroll_list').animate({
								    left: '-='+mini_scrolling
								  }, 500, function() {
									  $('#mini_img_'+int_id).children().animate({
										  opacity: '0.2'
									  }, 500, function() {});
									  $('#mini_img_'+id).children().animate({
										  opacity: '1'
									  }, 500, function() {
										  $('#mini_img_'+id).addClass('selected');
										  
									  });
								  });
								
							}
						}
				});
 	
 	}
 	
