function zoom (){
		 var currentSRC2 = jQuery('#mainimg img').attr('src');
            var altSRC2 = jQuery('#mainimg img').attr('title');
			
		$('#zoomimg').html('<div onclick="dezoom()" id="fondzoom" style="z-index: 4999; top:0; left:0; position: fixed; height:100%; width:100%;"><img src='+currentSRC2+' id="centrage" onclick="dezoom()" title="'+altSRC2+'" style=""/></div>');
		align();	         
	}
function dezoom (){			
		$('#zoomimg').html('');	         
	}


/* galery */

jQuery("img", this)
jQuery(document).ready(function(){
        jQuery('.vignette img').click(function(){
            /* Get the sources */
            var currentSRC = jQuery(this).attr('src');

            var altSRC = jQuery(this).attr('title');


            /*Fade, Callback, swap the alt and src, fade in */

            jQuery('#mainimg').fadeOut('fast',function(){
                jQuery(this).html("<img src="+currentSRC+" onclick='zoom()' title='"+altSRC+"' />").fadeIn("fast");                    
            });
        });

    });


/*galery*/

/* maps*/

  /* Déclaration des variables  */

 
  /* Initialisation de la carte  */
  function initialize() {
    var geocoder;
  var map;
  var markers = new Array();
  var i = 0;
var j=0;
 var total =document.getElementById("nb").value;
 
  if(total==1){
  var infowindow = new google.maps.InfoWindow();
  lat1=document.getElementById("lat1").value;
   long1=document.getElementById("long1").value;
   geocoder = new google.maps.Geocoder();
    var ville = new google.maps.LatLng(lat1,long1);
   var myOptions = {
     zoom: 16,
    center: ville,
  mapTypeId: google.maps.MapTypeId.HYBRID
   };
   var map = new google.maps.Map(document.getElementById("EmplacementDeMaCarte"), myOptions);  
  var urlappart ='/var/ezwebin_site/scripts/images/appartmark.png';
    var urlmaison ='/var/ezwebin_site/scripts/images/maismark.png';
	var urlterrain ='/var/ezwebin_site/scripts/images/termark.png';
	 var urlmix ='/var/ezwebin_site/scripts/images/mixmark.png';
   n1=document.getElementById("n1").value;
   
  desc1=document.getElementById("desc1").value;
   lien1=document.getElementById("lien1").value;
     nom1=document.getElementById("nom1").value;
	 type1=document.getElementById("type1").value;
	 var pointLieu = new google.maps.LatLng(lat1, long1);
	if(type1=='a'){
      marker = new google.maps.Marker({	  
	    icon: urlappart,
        position: pointLieu,
        map: map,
		title: nom1
      });
	  }
	  if(type1=='m'){
      marker = new google.maps.Marker({
	 
	  icon: urlmaison,
        position: pointLieu,
        map: map,
		title: nom1
      });
	  }
	  if(type1=='t'){
      marker = new google.maps.Marker({
	   
	  icon: urlterrain,
        position: pointLieu,
        map: map,
		title: nom1
      });
	  }
	  if(type1=='mix'){
      marker = new google.maps.Marker({
	 
	  icon: urlmix,
        position: pointLieu,
        map: map,
		title: nom1
      });
	  }
	  google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent('<h4>'+nom1+'<h/4><h5>'+n1+'</h5><p>'+desc1+'</p><a href="'+lien1+'" target="_blank">Voir les détails');
          infowindow.open(map, marker);
        }
      })(marker, i));
  }else{
   /* Instanciation du geocoder  */
   geocoder = new google.maps.Geocoder();
    var nantes = new google.maps.LatLng(47.218635,-1.551132);
   var myOptions = {
     zoom: 10,
    center: nantes,
  mapTypeId: google.maps.MapTypeId.HYBRID
   };
   /* Chargement de la carte  */
   var map = new google.maps.Map(document.getElementById("EmplacementDeMaCarte"), myOptions);  
	var bounds = new google.maps.LatLngBounds();
   
   var locations = new Array(total);
    var urlappart ='/var/ezwebin_site/scripts/images/appartmark.png';
    var urlmaison ='/var/ezwebin_site/scripts/images/maismark.png';
	var urlterrain ='/var/ezwebin_site/scripts/images/termark.png';
	 var urlmix ='/var/ezwebin_site/scripts/images/mixmark.png';
	
    for (i=1; i<=total; i++) {
   locations[ i]=new Array(6);
   }
   for (i=1; i<=total; i++) {
	
   var nom="n";
   var num= i;
   var id= nom+num;
   var lati="lat";
	var longi= "long";
	var des = "desc";
	var desc =des+num;
	var lie = "lien";
	var lien= lie+num;
	var lat=lati+num;
	var longit =longi+num;
	var nomp="nom";
	var nomprog=nomp+num;
	var typ= "type"
	var type=typ+num
	locations[i][0]=document.getElementById(id).value;
   locations[i][1]=document.getElementById(lat).value;
   locations[i][2]=document.getElementById(longit).value;
  locations[i][3]=document.getElementById(desc).value;
   locations[i][4]=document.getElementById(lien).value;
     locations[i][5]=document.getElementById(nomprog).value;
	 locations[i][6]=document.getElementById(type).value;
	}
	var infowindow = new google.maps.InfoWindow();
	
	for (i = 1; i <=total; i++) {  
	var pointLieu = new google.maps.LatLng(locations[i][1], locations[i][2]);	
	bounds.extend(pointLieu);
	if(locations[i][6]=='a'){
      marker = new google.maps.Marker({	  
	    icon: urlappart,
        position: pointLieu,
        map: map,
		title: locations[i][5]
      });
	  }
	  if(locations[i][6]=='m'){
      marker = new google.maps.Marker({
	 
	  icon: urlmaison,
        position: pointLieu,
        map: map,
		title: locations[i][5]
      });
	  }
	  if(locations[i][6]=='t'){
      marker = new google.maps.Marker({
	   
	  icon: urlterrain,
        position: pointLieu,
        map: map,
		title: locations[i][5]
      });
	  }
	  if(locations[i][6]=='mix'){
      marker = new google.maps.Marker({
	 
	  icon: urlmix,
        position: pointLieu,
        map: map,
		title: locations[i][5]
      });
	  }
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent('<h4>'+locations[i][5]+'<h/4><h5>'+locations[i][0]+'</h5><p>'+locations[i][3]+'</p><a href="'+locations[i][4]+'" target="_blank">Voir les détails');
          infowindow.open(map, marker);
        }
      })(marker, i));
    }


	map.fitBounds(bounds);	
}	
  }
 google.maps.event.addDomListener(window, 'load', initialize); 
  
  

/*maps*/

/* checkboxi */

		function Envoie(url)
		{
		if (document.getElementById("checkcarte").checked){
		document.searchrea.action=url+"Carte-des-operations";
		document.searchrea.submit();
		}else{
		document.searchrea.action=url+"Resultats";
		document.searchrea.submit();
		}
		}
		
/*checkbox */

function align()
{

	var lmt = document.getElementById('centrage');
	var container = document.documentElement;

	if(lmt && container)
	{
	    var containerHeight;
	    if (container.innerWidth)
	    {
            containerHeight = container.innerHeight;
		}
		else
		{
            containerHeight = container.clientHeight;
		}
	    var lmtHeight;
	    if (lmt.innerWidth)
	    {
            lmtHeight = lmt.innerHeight;
		}
		else
		{
            lmtHeight = lmt.offsetHeight;
		}
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y < 0)
		{
			y = 0;
		}
		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}
	if (document.getElementById)
	{
		document.body.style.visibility = 'visible';
	}

}

function addevent(obj,evt,fn,capt){
	if(obj.addEventListener)
	{
		obj.addEventListener(evt, fn, capt);
		return true;
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+evt, fn);
		return true;
	}
	else return false;
}

if (document.getElementById && document.getElementsByTagName)
{
	addevent(window, 'load', align, false);
	addevent(window, 'resize', align, false);
}
