// JavaScript

// Navigateur
function Navigateur() {
	
	// Firefox
	if(window.XMLHttpRequest) 
		return new XMLHttpRequest();
	// Internet Explorer
	else if(window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP");
	// XMLHttpRequest non suporté par le navigateur
	else return null;
	
}


// Ajout de produit
function modifPanier(id, action) {
	
	var method = "GET"; 
	
	xhr_object = Navigateur();
	// Objet
	xhr_object.open(method, "../global/includes/modifpanier.php?id=" + id + "&action=" + action, true); 
	xhr_object.onreadystatechange = 
		function() 
		{ 
			if(xhr_object.readyState == 4) { 	
			
				var retour = xhr_object.responseText;
				
				if(action == "ajout") alert(retour);
				else document.getElementById("panier").innerHTML = retour;
				
			}
		}
	
	// Header 
	if(method == "POST")
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	xhr_object.send(null);
	
}


// Google Map
function load() {
	if (GBrowserIsCompatible()) {
	
		var map = new GMap2(document.getElementById("plan"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		map.setCenter(new GLatLng(48.821290165837816, 8.026671409606934), 13);
		
		function createMarker(point, number) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml("<span style=\"color:#000000\"><strong>Fast Détection</strong><br>10 parc Activité Uffried Nord<br>67480 Roeschwoog<br>Tél. : 03 88 63 03 12</span><br><br><br>");
		});
		return marker;
		}
	
		// Add marker
		var point = new GLatLng(48.821290165837816, 8.026671409606934);
		map.addOverlay(createMarker(point, 1));
	}
}
