function initializeMap() {
	//Fonction de pour afficher la map Google
	
	var citCoord = new google.maps.LatLng(46.817683, -71.218228);
	var latlng = new google.maps.LatLng(46.8180, -71.2150);
	var myOptions = {
	zoom: 15,
	center: citCoord,
	mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var mapCIT = new google.maps.Map(document.getElementById("map_canvas"),
	myOptions);
			
	var myMarker = new google.maps.Marker({
	// Coordonnées de cybertech
	position: citCoord,
	animation: google.maps.Animation.DROP,
	map: mapCIT,
	//icon: logos/logoCITAlone_xsmall.png,
	title: "Cybertech"
	});
}

function initializeSlides() 
{
    //Fonction de diaporama
	var tempsAttente = 17500;
	var currentPosition = 0;
	
	interval = setInterval(slides, tempsAttente);
	function slides() 
	{
		var currentPosition = $('.dock img.active').index();
		currentPosition++;
		var nombreDeSlides = $('.slide').length;
		var slideNumber = currentPosition % nombreDeSlides;
		goToSlide(slideNumber); 
		
	}
	
}


$(document).ready(function() {
    ////Pop-up de contact avec map
	///////////////////////////////////////////////////
	$("#contact").dialog({width: 550, 
                height: 650, 
		resizable: true,
		modal: true,
		draggable: true});
    $("#contact").dialog( "option", "position", ['center','top'] );
    $("#contact").dialog('close');
    initializeMap();
	///////////////////////////////////////////////////
		
	////Lancer le diaporama de photos sauf sur la page 'references' ou on lance le slideshow
	///////////////////////////////////////////////////
	if($('.slide:first').length != 0)
	{
		////Rendre le dock clicable 
		$(".dock img.clickable").click(function() {
		goToSlide($('.dock img.clickable').index(this));
		});	
	
		////Grossir la premiere image du dock
		$('.dock img.clickable:first').animate({ height: '110px' }, 500);
		
		////Lancer le diaporama de slides
		initializeSlides();
	}
	else
	{
		//Si il y a plusieurs images dans illustration
		if($('#illustration div:first').next().length > 0) 
		{
			//On lance le fondu d'images
			interval = setInterval(slideSwitch, 6500);
		}
	}
	
	$('.dock img:first').animate({ height: '110px' }, 500);
	//afficher la premiere image en fondu, sauf sur IE
	if ( !($.browser.msie) ){
  	$('#illustration div.active').fadeIn(1200);
	}
	///////////////////////////////////////////////////
	
});

function openContact() 
{
    $("#contact").dialog('open');
}

function slideSwitch() 
{
//Fonction de fondu d'images

	var $active = $('#illustration div.active');
	if($active.next().length == 0) 	//si l'image active est la derniere
	{
	$next=$('#illustration div:first');//alors la prochaine est la premiere
	}
	else
	{
	var $next = $active.next();//sinon, la prochaine est la suivante
	}

	//fondu
	if ( $.browser.msie )//si IE, on ne fait pas de fondu car il est mal gere
	{
	$active.css( "display","none" );
	$next.css( "display","block" );
	} 
	else
	{
	$active.fadeOut(1200);
	$next.fadeIn(1200);
	}
	
	//passer l'image suivante en active
	$next.addClass('active');
	$active.removeClass('active');
	
}

function goToSlide(slideNumber) 
{
  var tempsTransition = 500;  

	$('.old').removeClass('old');
	
	////Defilement du texte
	///////////////////////////////////////////////////
	$('#slidecontain').animate(
	{  
	'marginTop' : -295*(slideNumber)  //295 = hauteur de la div "slide"
	},tempsTransition);
	///////////////////////////////////////////////////

	////Defilement des images
	///////////////////////////////////////////////////
	$('#illustration div.active').addClass('old');
	$('#illustration div.active').removeClass('active');
	$('#illustration div').eq(slideNumber).addClass('active');

	
	//fondu d'images
	if ( $.browser.msie )
	{
	$('#illustration div.old').css( "display","none" );
	$('#illustration div.active').css( "display","block" );
	} 
	else 
	{
	$('#illustration div.old').fadeOut(500);
	$('#illustration div.active').fadeIn(500);
	}
	///////////////////////////////////////////////////
	
	////Changement de zoom sur le dock
	///////////////////////////////////////////////////
	$('.dock img.active').addClass('old');
	$('.dock img.active').removeClass('active');
	$('.dock img').eq(slideNumber).addClass('active');
				
	//Zoom et dezoom
	$('.dock img.old').animate({ height: '70px' }, 500);
	$('.dock img.active').animate({ height: '110px' }, 500);
	///////////////////////////////////////////////////

	
}																																	

