Event.observe(window, 'load', function(){
		if($('pano')){
		  var myPano = new GStreetviewPanorama(document.getElementById("pano"));
	      fenwayPark = new GLatLng(48.621477,7.726681);
	      myPOV = {yaw:63.017031832715475,pitch:-5.9897251981999124,zoom:0};
	      myPano.setLocationAndPOV(fenwayPark, myPOV);
	 	}
	});

function loadmaps() {
		if (GBrowserIsCompatible() && $('map')) {
			var map;
			var marker;
			var puce = new GIcon();
				puce.image="img/puce_map.png";
				puce.iconSize=new GSize(50,50);
				puce.iconAnchor=new GPoint(19,38);
				puce.infoWindowAnchor=new GPoint(19, 0);
			var txt = ('<span style="font-size:11px; text-align:center"><strong>L\'Espace H Strasbourg</strong><br/>2 rue Emile Mathis<br/>67800 Strasbourg - Hoenheim<br/>Accés Autoroute A4, Sortie 49.1</span>');

			map = new GMap2(document.getElementById("map"));
			var point = new GLatLng( 48.6224424,  7.7283112);
			map.setCenter(point, 9);

				map.setMapType(G_NORMAL_MAP);		// Vue plan
			// 	map.setMapType(G_SATELLITE_MAP);	        // Vue satelite
			//	map.setMapType(G_HYBRID_MAP);	        // Vue mixte
			//	map.setMapType(G_PHYSICAL_MAP);	        // Vue relief

			//	map.addControl(new GSmallMapControl());
				map.addControl(new GLargeMapControl ());
			//	map.addControl(new GSmallZoomControl());
			//	map.addControl(new GHierarchicalMapTypeControl());
				map.addControl(new GMapTypeControl());
			//	map.removeMapType(G_NORMAL_MAP);
				map.removeMapType(G_SATELLITE_MAP);
				map.removeMapType(G_HYBRID_MAP);
				map.removeMapType(G_PHYSICAL_MAP);
			//	map.addMapType(G_PHYSICAL_MAP);
			//	map.addMapType(G_MOON_ELEVATION_MAP);
			//	map.addMapType(G_MOON_VISIBLE_MAP);
			//	map.addMapType(G_MARS_ELEVATION_MAP);
			//	map.addMapType(G_MARS_VISIBLE_MAP);
			//	map.addMapType(G_MARS_INFRARED_MAP);
			//	map.addMapType(G_SKY_VISIBLE_MAP);
			//	map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(100,20)));
			//	map.addControl(new GOverviewMapControl());

				map.enableScrollWheelZoom();
				map.enableDoubleClickZoom();
				map.enableContinuousZoom();
				new GKeyboardHandler(map);
			//	map.addOverlay(trafficInfo);

			var opts = new Object();
			opts.icon = puce;
			marker = new GMarker(point, opts);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(txt);

			GEvent.addListener(marker, "mouseover", function() {	marker.openInfoWindowHtml(txt);});
			GEvent.addListener(marker, "click", function() {		map.setCenter(point, 9);});
		}
	}
	Event.observe(window, 'load', loadmaps);








function getPageSize(){
    var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body && document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	return [pageWidth,pageHeight];
}
function openWindow(url){
	$('iframeWindow').src = url;
	if(!$('iframeOverlay').visible()){

		var arrayPageSize = getPageSize();
		$('iframeOverlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1]+10 + 'px', top:'-10px'});
		Prototype.Browser.IE ? $('iframeOverlay').show() : $('iframeOverlay').appear({ duration: 1.0, from: 0.0, to: 1 });

		$('iframeWindow').setStyle({width:'1px', height:'1px'});
		$('iframeWindowLoading').show();
		$('iframeWindowContainer').setStyle({ width: document.viewport.getWidth()-30 + 'px', height: document.viewport.getHeight()-245 + 'px', top:'165px', left:'-1000px' });

		new Effect.Move('iframeWindowContainer', {
			x: 0,
			y: 165,
			mode: 'absolute',
			duration:2,
			afterFinish:function(){
				$('iframeWindowLoading').hide();
				$('iframeWindow').setStyle({width:'100%', height:'100%'});
			}
		});
	}
	//$('iframeOverlay').setStyle({ width: document.viewport.getWidth() + 'px', height: document.viewport.getHeight()+10 + 'px', top:'-10px' })
}
function resizeWindow(){
	var arrayPageSize = getPageSize();
	$('iframeOverlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1]+10 + 'px', top:'-10px'});
	$('iframeWindowContainer').setStyle({ width: document.viewport.getWidth()-30 + 'px', height: document.viewport.getHeight()-245 + 'px' });
}
function closeWindow(){
	$('iframeWindow').setStyle({width:'1px', height:'1px'});
	$('iframeWindowLoading').show();

	new Effect.Move('iframeWindowContainer', {
		x: -$('iframeWindowContainer').getWidth()-100,
		y: 165,
		mode: 'absolute',
		duration:2,
		afterFinish:function(){
			Prototype.Browser.IE ? $('iframeOverlay').hide() : $('iframeOverlay').fade({ duration: 1.0, from: 1, to: 0.0 });
		}
	});
}
Event.observe(window, "resize", resizeWindow);




Event.observe(window, 'load', function(){
	$$('div.mod_photos_diaporama').each(function(item){
		item.update('');
		item.setStyle({position:'relative'});
		this.img1 = Builder.node('img', { className:'modphotos_item', src:'', style:'display:none; position:absolute; top:0; left:0;' });
		this.img2 = Builder.node('img', { className:'modphotos_item', src:'', style:'display:none; position:absolute; top:0; left:0;' });
		item.appendChild(this.img1);
		item.appendChild(this.img2);
		new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
			method:'post',
			asynchronous:true,
			onSuccess: function(t) {
				if(t.responseText != ""){
					var img = t.responseText.evalJSON();
					img1.src = img.src;
					img1.title = img.title;
					new Effect.Appear(img1, {duration:2,afterFinish:function(){}});
				}
			},
			onComplete: function(){},
			evalScripts:true
		});

		new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
			method:'post',
			asynchronous:true,
			onSuccess: function(t) {
				if(t.responseText != ""){
					var img = t.responseText.evalJSON();
					img2.src = img.src;
				}
			},
			onComplete: function(){},
			evalScripts:true
		});
		new PeriodicalExecuter(function(pe) {
			new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
				method:'post',
				asynchronous:true,
				onSuccess: function(t) {
					if(t.responseText != ""){
						var toShow = img1.visible() ? img2 : img1;
						var toMask = img1.visible() ? img1 : img2;
						var img = t.responseText.evalJSON();
						new Effect.Fade(toMask, {duration:3,afterFinish:function(){toMask.src = img.src;toMask.title = img.title;}});
						new Effect.Appear(toShow, {duration:3,afterFinish:function(){}});
					}
				},
				onComplete: function(){},
				evalScripts:true
			});
		}, 7);

	});
});

Event.observe(window, 'load', function(){
	$$('div.mod_photos_diaporama_accueil').each(function(item){
		item.update('');
		item.setStyle({position:'relative'});
		this.img1 = Builder.node('img', { className:'modphotos_item', src:'', style:'display:none; position:absolute; top:0; left:0;' });
		this.img2 = Builder.node('img', { className:'modphotos_item', src:'', style:'display:none; position:absolute; top:0; left:0;' });
		item.appendChild(this.img1);
		item.appendChild(this.img2);
		new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
			method:'post',
			asynchronous:true,
			onSuccess: function(t) {
				if(t.responseText != ""){
					var img = t.responseText.evalJSON();
					img1.src = img.src;
					img1.title = img.title;
					new Effect.Appear(img1, {duration:2,afterFinish:function(){}});
				}
			},
			onComplete: function(){},
			evalScripts:true
		});

		new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
			method:'post',
			asynchronous:true,
			onSuccess: function(t) {
				if(t.responseText != ""){
					var img = t.responseText.evalJSON();
					img2.src = img.src;
				}
			},
			onComplete: function(){},
			evalScripts:true
		});
		new PeriodicalExecuter(function(pe) {
			new Ajax.Request('ajax.mod.photos.diaporama.php?id='+item.getAttribute('rel'), 	{
				method:'post',
				asynchronous:true,
				onSuccess: function(t) {
					if(t.responseText != ""){
						var toShow = img1.visible() ? img2 : img1;
						var toMask = img1.visible() ? img1 : img2;
						var img = t.responseText.evalJSON();
						new Effect.Fade(toMask, {duration:3,afterFinish:function(){toMask.src = img.src;toMask.title = img.title;}});
						new Effect.Appear(toShow, {duration:3,afterFinish:function(){}});
					}
				},
				onComplete: function(){},
				evalScripts:true
			});
		}, 7);

	});

	if($('nbr_vo') && $('nbr_vn'))
		new Ajax.Request('ajax.v.stats.php?u='+(new Date()).getTime(),{
				onSuccess: function(t) {
					if(t.responseText != ""){
						var stats = t.responseText.evalJSON();
						$('nbr_vn').update(stats.vn+" en stock");
						$('nbr_vo').update(stats.vo+" en stock");
					}
				}
			});
});

function number_format( number, decimals, dec_point, thousands_sep ) {
var n = number, prec = decimals;
var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
};

    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
   var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;

    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

    var abs = toFixedFix(Math.abs(n), prec);
   		var _, i;
   	if (abs >= 1000) {
        _ = abs.split(/D/);
        i = _[0].length % 3 || 3;
        _[0] = s.slice(0,i + (n < 0)) +
            _[0].slice(i).replace(/(d{3})/g, sep+'$1');
        s = _.join(dec);
	} else {
       s = s.replace('.', dec);
    }

    var decPos = s.indexOf(dec);
    if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) {
        s += new Array(prec-(s.length-decPos-1)).join(0)+'0';
    }
    else if (prec >= 1 && decPos === -1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    return s;
}