﻿	
	var myPano;   
	var panoClient;
	
	function initCoordsStep(lat, long, yaw) {
		var coords = new GLatLng(Number(lat), Number(long));
		var coordsPov = {yaw:Number(yaw),pitch:0};
	
		var h = (document.documentElement) ? document.documentElement.clientHeight : window.innerHeight;
		document.getElementById("centerSW").style.top = Math.round((h - 400)/2) + "px";
		document.getElementById("centerSW").style.display = "block";
		  
		panoClient = new GStreetviewClient();
		  
		myPano = new GStreetviewPanorama(document.getElementById("pano"));
		myPano.setLocationAndPOV(coords , coordsPov);
		GEvent.addListener(myPano, "error", handleNoFlash);  
		GEvent.addListener(myPano, "pitchchanged", pitchHandler);
		GEvent.addListener(myPano, "yawchanged", yawHandler);
		GEvent.addListener(myPano, "initialized", initHandler);
		GEvent.addListener(myPano, "zoomchanged", zoomHandler);
    }
   			
	function doResize()
	{
		var h = (document.documentElement) ? document.documentElement.clientHeight : window.innerHeight;
		document.getElementById("centerSW").style.top = Math.round((h - 400)/2) + "px";
	}
	
	function zoomHandler(zoom)
	{
		//console.info("zoom", zoom);
	}
	
	function initHandler(location)
	{
		document.getElementById("EauDeToillette").checkGPS(location.lat, location.lng);
	}
		
	function yawHandler(yaw)
	{
		//console.info("yaw", yaw);
	}
	
	function pitchHandler(pitch)
	{
		//console.info("pitch ", pitch);
	}
	    
    function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }
    }
	
	// cacher street view
	function removeStreeView()
	{
		setTimeout(clearSV, 200);
	}
	function clearSV() 
	{
		document.getElementById("pano").innerHTML = "";
		document.getElementById("centerSW").style.display = "none";
	}
	
	window.onresize = doResize;
