// JavaScript Document
$(document).ready(function() { 
			var flag = 1;			
			giveFocus(1);
			startGallery();	
			
			function startGallery(){
				var time = 4500;
				var thumb = 2;
				var count = $('ul.thumb li').length;
				$('.thumb').everyTime(time,function() {
					giveFocus(thumb);
					swapImage(thumb);
					if(thumb > 1){ removeFocus(thumb - 1); }
					if(thumb == 1){ removeFocus(count); }
					thumb++;
					if(thumb > count){ thumb = 1; }
				});
			}
			
			function swapImage(thumb){ 
				$("#main_view").fadeOut('fast', function() {
					if(thumb == 1){ 
						$("#div6").css("display", "none");
					}else{
						lastthumb = thumb - 1;
						$("#div"+lastthumb).css("display", "none");
					}
					$("#div"+thumb).css('display', 'block');
					$("#main_view").fadeIn('fast');
				});
				return false;
			}
			
			function giveFocus(thumb){
			
				if(thumb != 7){
					
					/*var src = $('#thumb'+thumb).find('img').attr('src');
					if(src.search('hover') != -1){
						$('#thumb'+thumb).find('img').attr('src', src.substring(0, src.length-10));	
					}*/
					
					$('#thumb'+thumb).css({'z-index' : '10'}); 
					
					$('#thumb'+thumb).find('img').addClass("hover").stop().animate({
							marginTop: '-20px', 
							marginLeft: '-20px',
							width: '78px', 
							height: '78px', 
							padding: '0px'
					}, 200);
				}else{
					/*var src = $('#'+thumb).find('img').attr('src');
					if(src.search('hover') != -1){
						$('#'+thumb).find('img').attr('src', src.substring(0, src.length-10));	
					}*/
					
					$('#'+thumb).css({'z-index' : '10'}); 
					$('#'+thumb).find('img').addClass("hover").stop().animate({
							marginTop: '-10px', 
							marginLeft: '-10px',
							width: '166px', 
							height: '78px', 
							padding: '0px'
					}, 200);
				}
			}
			
		
			
			function removeFocus(thumb){
				if(thumb != 7){
					
					$('#thumb'+thumb).css({'z-index' : '0'}); 
					$('#thumb'+thumb).find('img').removeClass("hover").stop() 
						.animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '50px', 
							height: '50px',
							padding: '0px'
					}, 400);
				}else{
					$('#'+thumb).css({'z-index' : '0'}); 
					$('#'+thumb).find('img').removeClass("hover").stop() 
						.animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '140px', 
							height: '66px',
							padding: '0px'
					}, 400);
				}
			}
			
			
			/*$("ul.thumb li").hover(function() {	
				
				if($(this).find('img').width() > 50){
					
				}else{
					var src = $(this).find('img').attr('src');
					$(this).find('img').attr('src', src+'.hover.png');	
				}
				
			} , function() {
				
				if($(this).find('img').width() > 50){
					
				}else{
					var src = $(this).find('img').attr('src');
					$(this).find('img').attr('src', src.substring(0, src.length-10));	
				}
				
			});*/
			
			
			/*$("ul.thumb li").hover(function() {	
				
				$(this).css({'z-index' : '10'});
				
				$(this).find('img').addClass("hover").stop().animate({
						marginTop: '-20px', 
						marginLeft: '-20px',
						width: '78px', 
						height: '78px', 
						padding: '0px'
					}, 200); 
			
				} , function() {
				$(this).css({'z-index' : '0'}); 
				
					$(this).find('img').removeClass("hover").stop().animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '50px', 
							height: '50px',
							padding: '0px'
					}, 400);
			});*/
			
			$("ul.thumb li a").click(function() {
				$('.thumb').stopTime();
				
				
				for(var i=1; i<8; i++){
					removeFocus(i);
				}
				
				giveFocus($(this).attr("id"));
							
				$(this).find('img').addClass('imgactive');
				
				var div = $(this).attr("href"); 
				$("#main_view").fadeOut('fast', function() {
					
					for(var i=0; i<8; i++){
						if($("#div"+i).css("display") == "block"){
							$("#div"+i).css("display", "none");
							break;
						}
					}
					$("#"+div).css('display', 'block');
					$("#main_view").fadeIn('fast');
					
				});
				flag++;
				return false;
			});
			
			
			//DATABASE ICON
			/*$("#database").hover(function() {
				$(this).css({'z-index' : '10'});
				
				$(this).find('img').addClass("hover").stop() 
					.animate({
						marginTop: '-10px', 
						marginLeft: '-10px',
						width: '166px', 
						height: '78px', 
						padding: '0px'
					}, 200); 
			
				} , function() {
				$(this).css({'z-index' : '0'}); 
				$(this).find('img').removeClass("hover").stop() 
					.animate({
						marginTop: '0', 
						marginLeft: '0',
						top: '0',
						left: '0',
						width: '140px', 
						height: '66px',
						padding: '0px'
					}, 400);
			});*/
			
			$("#database a").click(function() {
				$('.thumb').stopTime();
				
				
				for(var i=1; i<8; i++){
					removeFocus(i);
				}
							
				giveFocus($(this).attr("id"));
				
				var div = $(this).attr("href"); 
				$("#main_view").fadeOut('fast', function() {
					
					for(var i=0; i<8; i++){
						if($("#div"+i).css("display") == "block"){
							$("#div"+i).css("display", "none");
							break;
						}
					}
					$("#"+div).css('display', 'block');
					$("#main_view").fadeIn('fast');
				});
				flag++;
				return false;
			});
			
			/*$("#database a").hover(function() {	
				
				if($(this).find('img').width() > 140){
					
				}else{
					var src = $(this).find('img').attr('src');
					$(this).find('img').attr('src', src+'.hover.png');	
				}
				
			} , function() {
				
				if($(this).find('img').width() > 140){
					
				}else{
					var src = $(this).find('img').attr('src');
					$(this).find('img').attr('src', src.substring(0, src.length-10));	
				}
				
			});*/
			$('#div1').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div1').click(function(){
				window.location = 'services/courriel.php';
			});
			
			$('#div2').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div2').click(function(){
				window.location = 'services/sem.php';
			});
			$('#div3').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div3').click(function(){
				window.location = 'services/solutions-web.php';
			});
			$('#div4').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div4').click(function(){
				window.location = 'services/mobilite.php';
			});
						
			$('#div5').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div5').click(function(){
				window.location = 'services/reseaux-sociaux.php';
			});
			
			$('#div6').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div6').click(function(){
				window.location = 'services/solution-web.php';
			});
			
			$('#div7').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div7').click(function(){
				window.location = 'services/bases-de-donnees.php';
			});
			
			
			//$("#nosclients").tooltip({ effect: 'slide'});
			
			
		});




















/*$(document).ready(function() { 
			var flag = 1;			
			giveFocus(1);
			startGallery();	
			
			function startGallery(){
				var time = 4500;
				var thumb = 2;
				var count = $('ul.thumb li').length;
				$('.thumb').everyTime(time,function() {
					giveFocus(thumb);
					swapImage(thumb);
					if(thumb > 1){ removeFocus(thumb - 1); }
					if(thumb == 1){ removeFocus(count); }
					thumb++;
					if(thumb > count){ thumb = 1; }
				});
			}
			
			function swapImage(thumb){ 
				$("#main_view").fadeOut('fast', function() {
					if(thumb == 1){ 
						$("#div6").css("display", "none");
					}else{
						lastthumb = thumb - 1;
						$("#div"+lastthumb).css("display", "none");
					}
					$("#div"+thumb).css('display', 'block');
					$("#main_view").fadeIn('fast');
				});
				return false;
			}
			
			function giveFocus(thumb){
				if(thumb != 7){
					$('#thumb'+thumb).css({'z-index' : '10'}); 
					$('#thumb'+thumb).find('img').addClass("hover").stop().animate({
							marginTop: '-20px', 
							marginLeft: '-20px',
							width: '78px', 
							height: '78px', 
							padding: '0px'
					}, 200);
				}else{
					$('#thumb'+thumb).css({'z-index' : '10'}); 
					$('#thumb'+thumb).find('img').addClass("hover").stop().animate({
							marginTop: '-20px', 
							marginLeft: '-20px',
							width: '166px', 
							height: '78px', 
							padding: '0px'
					}, 200);
				}
				
			}
			
		
			
			function removeFocus(thumb){
				if(thumb != 7){
					$('#thumb'+thumb).css({'z-index' : '0'}); 
					$('#thumb'+thumb).find('img').removeClass("hover").stop() 
						.animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '50px', 
							height: '50px',
							padding: '0px'
					}, 400);
				}else{
					$('#thumb'+thumb).css({'z-index' : '0'}); 
					$('#thumb'+thumb).find('img').removeClass("hover").stop() 
						.animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '140px', 
							height: '66px',
							padding: '0px'
					}, 400);
				}
			}
			
			$("ul.thumb li").hover(function() {	
				
				$(this).css({'z-index' : '10'});
				
				$(this).find('img').addClass("hover").stop().animate({
						marginTop: '-20px', 
						marginLeft: '-20px',
						width: '78px', 
						height: '78px', 
						padding: '0px'
					}, 200); 
			
				} , function() {
				$(this).css({'z-index' : '0'}); 
				
					$(this).find('img').removeClass("hover").stop().animate({
							marginTop: '0', 
							marginLeft: '0',
							top: '0',
							left: '0',
							width: '50px', 
							height: '50px',
							padding: '0px'
					}, 400);
			});
			
			$("ul.thumb li a").click(function() {
				$('.thumb').stopTime();
				
				if(flag == 1){
					for(var i=1; i<8; i++){
						removeFocus(i);
					}
				}
				
				
				
				var div = $(this).attr("href"); 
				$("#main_view").fadeOut('fast', function() {
					
					for(var i=0; i<8; i++){
						if($("#div"+i).css("display") == "block"){
							$("#div"+i).css("display", "none");
							break;
						}
					}
					$("#"+div).css('display', 'block');
					$("#main_view").fadeIn('fast');
					
				});
				flag++;
				return false;
			});
			
			
			//DATABASE ICON
			$("#database").hover(function() {
				$(this).css({'z-index' : '10'});
				
				$(this).find('img').addClass("hover").stop() 
					.animate({
						marginTop: '-10px', 
						marginLeft: '-10px',
						width: '166px', 
						height: '78px', 
						padding: '0px'
					}, 200); 
			
				} , function() {
				$(this).css({'z-index' : '0'}); 
				$(this).find('img').removeClass("hover").stop() 
					.animate({
						marginTop: '0', 
						marginLeft: '0',
						top: '0',
						left: '0',
						width: '140px', 
						height: '66px',
						padding: '0px'
					}, 400);
			});
			
			$("#database a").click(function() {
				$('.thumb').stopTime();
				
				if(flag == 1){
					for(var i=1; i<8; i++){
						removeFocus(i);
					}
				}
				
				
				var div = $(this).attr("href"); 
				$("#main_view").fadeOut('fast', function() {
					
					for(var i=0; i<8; i++){
						if($("#div"+i).css("display") == "block"){
							$("#div"+i).css("display", "none");
							break;
						}
					}
					$("#"+div).css('display', 'block');
					$("#main_view").fadeIn('fast');
				});
				flag++;
				return false;
			});
			
			
			$('#div2').mouseover(function(){
				$(this).css('cursor', 'pointer');
			});
			$('#div2').click(function(){
				window.location = 'services/sem.php';
			});
			
			$("#nosclients").tooltip({ effect: 'slide'});
			
		});*/
