$(document).ready(function(){
  
  /**Gestion des onglets**/
  $(function(){ 
    $("#tabs .tab").hide(); 
    $("#tabs .tab:eq(0)").show(); 
  });
  
  $(function(){ 
      $("#tabs a.tab_onglet").click(function(){ 
          $("#tabs .tab").hide(); 
          $(this.hash).show(); 
          this.blur(); 
          return false; 
      }); 
  }); 
  
  /**Comportement dans le cas de l'entrée sur le site**/
  if($("#comportement").attr("comportement")=='home'){
    $("#home").show();
    $("#language").hide();
    $("#content").hide();
    $("#footer").hide();
    $("#container").css("margin-top","200px");
    
    $(".lang").click(function(){
      var lang = $(this).attr("lang");
      
      //Fonction ajax définition du langage
      $.ajax({
        type: "POST",
        url: "inc/scripts/language.php",
        data: "lang="+lang,
        success: function(){
          
          $.ajax({
            type: "POST",
            url: "inc/scripts/home.php",
            data: "",
            success: function(html){
              $("#content").empty();
              $("#content").append(html);
            }
          });
          
          $.ajax({
            type: "POST",
            url: "inc/scripts/footer.php",
            data: "",
            success: function(html){
              $("#footer").empty();
              $("#footer").append(html);
            }
          });
          
          $("#home").hide();
          $("#language").show();
          $("#container").animate({height: "645px",marginTop: "5px"},500,function(){
            $("#content").fadeIn(1500);
            $("#footer").fadeIn(1500,function(){
              $(location).attr('href','');
            });
          });
          
          /**Animation des onglets sociétés**/
          $(".societe").hover(function(){
            $(this).children(".logo-societe").stop().animate({marginTop: "170px"},500,function(){});
            $(this).children(".logo-societe").children(".liens-logo-societe").show();
          },function(){
            $(this).children(".logo-societe").stop().animate({marginTop: "2px"},500);
            $(this).children(".logo-societe").children(".liens-logo-societe").hide();
          }); 
          
        }
      });
  
    });
  }
  
  /**Animation des onglets sociétés**/
  $(".societe").hover(function(){
    $(this).children(".logo-societe").stop().animate({marginTop: "170px"},500,function(){});
    $(this).children(".logo-societe").children(".liens-logo-societe").show();
  },function(){
    $(this).children(".logo-societe").stop().animate({marginTop: "2px"},500);
    $(this).children(".logo-societe").children(".liens-logo-societe").hide();
  });
  
  $(".societe").click(function(){
    $(location).attr('href',$(this).children(".logo-societe").attr("href"));
  });
  
  /**Gestion affichage pages**/
  $(".page").hide();
  $("#page1").show();
  
});

/**Fonctions pour google map**/
function initialize(point,itineraire){
  
  if (point=="laval") {
    var point = new google.maps.LatLng(48.10099032177255, -0.733487606048584);
    var myHtml = "<div style=\"text-align: left;\"><strong>Groupe PRONUPTIA, Ko&iuml; Centre d'affaires</strong><br />ZA Autorouti&egrave;re<br />Bd de la Communication<br />F 53950 Louvern&eacute;<br />France<br /><br /><span class=\"icon telephone\">&nbsp;</span>00 33 (0)2 43 53 76 67<br /><span class=\"icon printer\">&nbsp;</span>00 33 (0)2 43 53 76 82<br /><span class=\"icon email\">&nbsp;</span><a href=\"mailto:contact@groupepronuptia.com\">contact@groupepronuptia.com</a><br /><a href=\"http://maps.google.fr/maps?daddr=bd+de+la+communication+53950+Louvern%C3%A9\" target=\"_blank\" class=\"icon car\">"+itineraire+"</a></div>";
  }
  if (point=="paris") {
    var point = new google.maps.LatLng(48.8708046,2.3292595);
    var myHtml = "<div style=\"text-align: left;\"><strong>Groupe PRONUPTIA</strong><br />15, square Edouard VII<br />F 75009 Paris<br />France<br /><br /><span class=\"icon telephone\">&nbsp;</span>00 33 (0)2 43 49 77 75<br /><span class=\"icon email\">&nbsp;</span><a href=\"mailto:contact@groupepronuptia.com\">contact@groupepronuptia.com</a><br /><a href=\"http://maps.google.fr/maps?daddr=rue+edouard+VII+paris\" target=\"_blank\" class=\"icon car\">"+itineraire+"</a></div>";
  }
  if (point=="shenzhen") {
    var point = new google.maps.LatLng(22.647526749702873,113.82210373878479);
    var myHtml = "<div style=\"text-align: left;\"><strong>Groupe PRONUPTIA</strong><br />Office 237-238, 2F<br />Information Building<br />Airport, Bao'an District<br />CN 518128 SHENZHEN<br />Chine<br /><br /><span class=\"icon telephone\">&nbsp;</span>+86 755 2345 3105<br /><span class=\"icon printer\">&nbsp;</span>+86 755 2345 3104<br /><span class=\"icon email\">&nbsp;</span><a href=\"mailto:contact@groupepronuptia.com\">contact@groupepronuptia.com</a><br /><a href=\"http://maps.google.fr/maps?daddr=airport+si+road+shenzhen\" target=\"_blank\" class=\"icon car\">"+itineraire+"</a></div>";
  }
  
  if (GBrowserIsCompatible()) {
    var myOptions = {
      zoom: 15,
      center: point,
      mapTypeControl: true,
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DEFAULT},
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
      scaleControl: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var marker = new google.maps.Marker({
      position: point,
      map: map
    });
    var infowindow = new google.maps.InfoWindow({
      content: myHtml
    });
    
    google.maps.event.addListener(marker, 'click', function(){
      infowindow.open(map, marker);
    });
  }
  
}

