var img01=new Image();img01.src = "themes/amba/images/charte/btn/btnD-blanc.png";
var img02=new Image();img02.src = "themes/amba/images/charte/btn/btnG-blanc.png";
var img03=new Image();img03.src = "themes/amba/images/charte/btn/btnS-blanc.png";

var img04=new Image();img04.src = "themes/amba/images/charte/btn/btnD-h.png";
var img05=new Image();img05.src = "themes/amba/images/charte/btn/btnG-h.png";
var img06=new Image();img06.src = "themes/amba/images/charte/btn/btnS-h.png";

var img07=new Image();img07.src = "themes/amba/images/charte/btn/orangebtnD-blanc.png";
var img08=new Image();img08.src = "themes/amba/images/charte/btn/orangebtnG-blanc.png";
var img09=new Image();img09.src = "themes/amba/images/charte/btn/orangebtnS-blanc.png";

var img10=new Image();img10.src = "themes/amba/images/charte/btn/orangebtnD-h.png";
var img11=new Image();img11.src = "themes/amba/images/charte/btn/orangebtnG-h.png";
var img12=new Image();img12.src = "themes/amba/images/charte/btn/orangebtnS-h.png";

var img13=new Image();img13.src = "themes/amba/images/charte/btn/rougebtnD-blanc.png";
var img14=new Image();img14.src = "themes/amba/images/charte/btn/rougebtnG-blanc.png";
var img15=new Image();img15.src = "themes/amba/images/charte/btn/rougebtnS-blanc.png";

var img16=new Image();img16.src = "themes/amba/images/charte/btn/rougebtnD-h.png";
var img17=new Image();img17.src = "themes/amba/images/charte/btn/rougebtnG-h.png";
var img18=new Image();img18.src = "themes/amba/images/charte/btn/rougebtnS-h.png";

var img50=new Image();img50.src = "themes/amba/images/charte/onglet/d-blanc2.gif";
var img51=new Image();img51.src = "themes/amba/images/charte/onglet/d-blanc22.gif";
var img52=new Image();img52.src = "themes/amba/images/charte/onglet/d-bleu.gif";
var img53=new Image();img53.src = "themes/amba/images/charte/onglet/d-jaune.gif";
var img54=new Image();img54.src = "themes/amba/images/charte/onglet/d-vert.gif";
var img55=new Image();img55.src = "themes/amba/images/charte/onglet/g-blanc2.gif";
var img56=new Image();img56.src = "themes/amba/images/charte/onglet/g-blanc22.gif";
var img57=new Image();img57.src = "themes/amba/images/charte/onglet/g-bleu.gif";
var img58=new Image();img58.src = "themes/amba/images/charte/onglet/g-jaune.gif";
var img59=new Image();img59.src = "themes/amba/images/charte/onglet/g-vert.gif";
var img60=new Image();img60.src = "themes/amba/images/charte/onglet/m-blanc2.gif";
var img61=new Image();img61.src = "themes/amba/images/charte/onglet/m-bleu.gif";
var img62=new Image();img62.src = "themes/amba/images/charte/onglet/m-jaune.gif";
var img63=new Image();img63.src = "themes/amba/images/charte/onglet/m-rouge.gif";
var img64=new Image();img64.src = "themes/amba/images/charte/onglet/m-vert.gif";
var img65=new Image();img65.src = "themes/amba/images/charte/onglet/d-rouge.gif";
var img66=new Image();img66.src = "themes/amba/images/charte/onglet/g-rouge.gif";



jQuery(document).ready(function(){
setTimeout('resizeFooter()',1000);

    resizeFooter();
    $("#footer").slideDown('normal');
    
    $(window).resize(function(){
      resizeFooter();
    });
    
    blockG = 0;   
    $(".gauchecontblock").each(function(){
      blockGHeight = $(this).height();
      blockD = 0;
      $(".droitcontblock").each(function(){
        if(blockG == blockD) $(this).height(blockGHeight);
        blockD++;
      });
      blockG++;
    });
        
    blockGa = 0;   
    $(".gauchecontblock2").each(function(){
      blockGaHeight = $(this).height();
      blockDr = 0;
      $(".droitcontblock2").each(function(){
        if(blockGa == blockDr) $(this).height(blockGaHeight);
        blockDr++;
      });
      blockGa++;
    });
     
    //Design button
/*-----------------------------------------------------------------*/
    $(".btnAmbaLink").live("mouseover", function(){
      var elem = $(this); 
      changeStylebtnAmbaLink(elem,"hover","");
    });
    $(".btnAmbaLink").live("mouseout", function(){
      var elem = $(this); 
      changeStylebtnAmbaLink(elem,"","");
    });
    $(".btnAmbaLink").live("mousedown", function(){
      var elem = $(this); 
      changeStylebtnAmbaLink(elem,"down","h");
    });
    $(".btnAmbaLink").live("mouseup", function(){
      var elem = $(this); 
      changeStylebtnAmbaLink(elem,"","");
    });
    //-------------------------------------------------- Correction png
    $(document).pngFix();

});

function changeStylebtnAmbaLink(elem,even,color){
  var id = elem.attr("id").split("-")[1];
  if(color=="") color = elem.attr("class").replace("btnAmbaLink ","").replace(" btnAmbaLink",""); 
  $("#btnAmbaG-"+id).css("background","url(themes/amba/images/charte/btn/"+colorBTN+"btnG-"+color+".png) no-repeat left top");
  
  if (colorBTN=="orange"){
  if(even=="down"){ 
      elem.css("color","#fc8800");
  }else if(even=="hover"){ 
      elem.css("color","#fdf68d");
      
  }else{ 
      elem.css("color","#ffffff");
      }
      }else if(colorBTN=="rouge"){
  if(even=="down"){ 
      elem.css("color","#730000");
  }else if(even=="hover"){ 
      elem.css("color","#ec7676");
      
  }else{ 
      elem.css("color","#ffffff");
      }
      }
           
  $("#btnAmbaS-"+id).css("background","url(themes/amba/images/charte/btn/"+colorBTN+"btnS-"+color+".png) repeat-x left top");
  $("#btnAmbaD-"+id).css("background","url(themes/amba/images/charte/btn/"+colorBTN+"btnD-"+color+".png) no-repeat left top");
  $(".btnsAmba").pngFix();
}

function formulaire(emptyFields,errorName,errorMail,errorMessage){

    var re1= /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    var error = "";
    $("#nom").css("background","#fff");
    $("#email").css("background","#fff");
    $("#message").css("background","#fff");
    
    $("#nom").focus( function() { $("#nom").css("background","#fff"); } );
    $("#email").focus( function() { $("#email").css("background","#fff"); } );
    $("#message").focus( function() { $("#message").css("background","#fff"); } );
   
    var valeur = $("#nom").val(); 
      if(valeur=='') { /* si c'est vide c'est pas bon */
      $("#nom").css("background","#99ccff");  
      error += errorName+'\n <br/>';
    }
    
    valeur = $("#email").val(); 
    if((valeur=='')||(!valeur.match(re1))) { /* si c'est vide c'est pas bon */
      $("#email").css("background","#99ccff"); 
      error += errorMail+'\n <br/>';
    }
    
    valeur = $("#message").val(); 
      if(valeur=='') { /* si c'est vide c'est pas bon */
      $("#message").css("background","#99ccff");
      error += errorMessage+'\n <br/>';
    }
    if(error == ""){
    //  ambAlert("votre message a bien été envoyé","merci","info");
    
      $("form#formulairecontact").submit();
    }else{
      ambAlert(emptyFields,error,"error");
    }    
  }  

function resizeFooter(){
   var windowHeight = $(window).height();
   var headerHeight = $("#header").height();
   var contentHeight = $("#content").height();
   var footerHeight = $("#footer").height();
   if((headerHeight + contentHeight) >= (windowHeight-255)){
     $("#footer").css("position","relative");
   }else{
     $("#footer").css("position","fixed");
     var heightCentreFooter = (windowHeight - (headerHeight +  contentHeight + 45));
     $(".centrefooter").css("height",heightCentreFooter+"px");
     $(".grossebarrefooter .coing .gfooter").css("height",(heightCentreFooter - 40)+"px");
     $(".grossebarrefooter .coind .dfooter").css("height",(heightCentreFooter - 40)+"px");
   }

   $(".droitcont").height($(".gauchecont").height());
}

function ambAlert(message1,message2,image){
  $(".growlUI").remove();
  var growl = $("<div class='growlUI' style='display:none;background: url(js/blockUI/blockUI-" + image + ".png) no-repeat 10px 10px;'><h1>" + message1 + "</h1><h2>" + message2 + "</h2></div>");
  growl.appendTo($("body"));

  var growlH = $(".growlUI").height();
  var growlW = 400;
  var bgColor = "";
  if(image == "check") bgColor = "#003300";
  else if(image == "error") bgColor = "#990000";
  else if(image == "info") bgColor = "#000099";
  
    $.blockUI({ 
      message: $(".growlUI"),fadeIn: 700,fadeOut: 700,timeout: 3000,showOverlay: false,centerY: false,
      css: { 
        width: "" + growlW + "px", 
        top:  ($(window).height() - growlH) /2 + "px", 
        left: ($(window).width() - growlW) /2 + "px",  
        border: "none", 
        padding: "5px", 
        backgroundColor: bgColor, 
        "-webkit-border-radius": "10px", 
        "-moz-border-radius": "10px", 
        opacity: 0.8, 
        color: "#ccffcc" 
      } 
    }); 
}
function mapsLoaded(){
  var map = new google.maps.Map2(document.getElementById("Gmap"));

  map.setCenter(new GLatLng(43.3067156,5.3828040), 1);
  map.setMapType(G_HYBRID_MAP);
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  var icone = new GIcon();
  icone.image = "themes/amba/images/charte/map/logo-amba-alpha-map.png";
  icone.iconSize = new GSize(110,50);
  icone.iconAnchor = new GLatLng(43.3067156,5.3828040);
  icone.infoWindowAnchor = new GLatLng(43.3067156,5.3828040);
  
  var point = map.getCenter();
  var marker = new GMarker(point, icone);   
  map.addOverlay(marker);
  
  markerOptions = { icon:icone };
  var marqueur = new GMarker(new GLatLng(43.28233,5.41413),icone);
  map.addOverlay(marker);
  
  GEvent.addListener(marker, "click", function() {
    map.setCenter(new google.maps.LatLng(43.3067156,5.3828040), 13);
    map.setMapType(G_NORMAL_MAP);
  });
}
function loadMaps() {
  google.load("maps", "2", {"callback" : mapsLoaded});
}

function loadGmap() {
  var script = document.createElement("script");
  script.src = "http://www.google.com/jsapi?key=ABQIAAAAUZ3RGyohRhuk4baZDmCWPBTtX-N-c4En8OxqKjSYDn6bZO_6sRSUkBm1rN_eQoYZZ-FUxe_Mw58WNg&callback=loadMaps";
  script.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(script);
}