function initializeMap(coord1, coord2, zoom) {
	if (GBrowserIsCompatible()) {
		
		var baseIcon = new GIcon();
		baseIcon.image = "http://www.thai-in-box.com/assets/img/mapicon.png";
		baseIcon.shadow = "http://www.thai-in-box.com/assets/img/mapicon-shadow.png";
		baseIcon.iconSize = new GSize(53, 50);
		baseIcon.shadowSize = new GSize(67, 53);
		baseIcon.iconAnchor = new GPoint(22, 25);
		baseIcon.infoWindowAnchor = new GPoint(0, 0);
		
		markerOptions = { icon:baseIcon };
		
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(coord1, coord2), zoom);
		map.setUIToDefault();
		var point = new GLatLng(48.879822394279315,2.240051329026755);
		var mainmarker = new GMarker(point,markerOptions);
		map.addOverlay(mainmarker);
		var point1 = new GLatLng(48.873381,2.342942);
		var marker1 = new GMarker(point1,markerOptions);
		map.addOverlay(marker1);
		var point2 = new GLatLng(48.875879, 2.347898);
		var marker2 = new GMarker(point2,markerOptions);
		map.addOverlay(marker2);
		var point3 = new GLatLng(48.855246,2.387752);
		var marker3 = new GMarker(point3,markerOptions);
		map.addOverlay(marker3);	
		var point4 = new GLatLng(45.763732,4.863988);
		var marker4 = new GMarker(point4,markerOptions);
		map.addOverlay(marker4);
		var point5 = new GLatLng(47.216027,-1.558921);
		var marker5 = new GMarker(point5,markerOptions);
		map.addOverlay(marker5);
		var point6 = new GLatLng(48.840737,2.239636);
		var marker6 = new GMarker(point6,markerOptions);
		map.addOverlay(marker6);
	}
}


function map01() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(48.873381, 2.342942, 11);
};

function map02() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(48.875877151579018, 2.348057627459638,11);
};

function map03() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(48.855275292739712, 2.387752, 11);
};

function map04() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(48.879822394279315, 2.240051329026755, 11);
};

function map05() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(45.763732, 4.863988, 16);
};

function map06() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(47.216027, -1.558921, 16);
};

function map07() {
	$.modal('<div id="map_canvas" style="width: 700px; height: 500px;"></div>', {overlayClose:true});
	initializeMap(48.840737, 2.239636, 16);
};

function defileAuto(){
  $("#caroussel_droite").trigger("click");
}

$(document).ready(function(){   
   // Gestion du caroussel
   if($('#mycarousel').length != 0 && $('#mycarousel li').length > 3){ 
     // Duplique li
     for(i=0 ; i<3 ; i++){
      $('#mycarousel li:eq('+($('#mycarousel li').length-1)+')').after("<li>"+$('#mycarousel li:eq('+i+')').html()+"</li>");
     } 
     for(i=4 ; i<7 ; i++){
      $('#mycarousel li:eq(0)').before("<li>"+$('#mycarousel li:eq('+($('#mycarousel li').length-i)+')').html()+"</li>");
     }  
        
     incVignette = 3;                                                                     
     derouleVignette = false;
     nbrVignettes = $('#mycarousel li').length;
     tailleVignette = $('#mycarousel li:eq(0)').width(); 
     $('#mycarousel').width(nbrVignettes*tailleVignette);
     temps = 500;
     $('#mycarousel').css('left',(-3*tailleVignette)+'px')
     
     // Gestion du click sur les fleche
     $('#caroussel_droite').click(function(){
      if (!derouleVignette && incVignette < nbrVignettes-3){
        if (typeof(automatique)!='undefined')
  	     clearTimeout(automatique);
        incVignette++;
        derouleVignette = true;
        $('#mycarousel').animate({"left":(incVignette*tailleVignette*-1)+"px"},temps ,function(){ derouleVignette = false; if(incVignette == nbrVignettes-3){ $('#mycarousel').css('left',(-3*tailleVignette)+'px'); incVignette = 3;} automatique = setTimeout('defileAuto()',3000); });   
      }
      return false;
     });
     $('#caroussel_gauche').click(function(){
      if (!derouleVignette && incVignette > 0){
        if (typeof(automatique)!='undefined')
  	     clearTimeout(automatique);
        incVignette--;
        derouleVignette = true;
        $('#mycarousel').animate({"left":(incVignette*tailleVignette*-1)+"px"},temps ,function(){ derouleVignette = false; if(incVignette == 0){ $('#mycarousel').css('left',(tailleVignette*(nbrVignettes-6)*-1)+'px'); incVignette = nbrVignettes-6 ;} automatique = setTimeout('defileAuto()',3000); });                  
      }
      return false;
     });
     
     // Lancement du defilement automatique
     automatique = setTimeout('defileAuto()',3000);
   }
   else{
    $('#caroussel_droite, #caroussel_gauche').css('cursor', 'default');
    $('#caroussel_droite, #caroussel_gauche').click(function(){ return false; });
   }

   $.Juitter.start({
		searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
		searchObject:"THAIINBOX", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.

		// The values below will overwrite the ones on the Juitter default configuration.
		// They are optional here.
		// I'm changing here as a example only
		lang:"fr", // restricts the search by the given language
		live:"live-15", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
		placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
		loadMSG: "Chargement messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on
		imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
		total: 1, // number of tweets to be show - max 100
		readMore: "Lire sur Twitter", // read more message to be show after the tweet content
		nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet
		openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
        filter:"sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
	});

	$('a').target();
    $("#commentForm").validate();
    $("#contactForm").validate();
});
