/*POP UP*/
function popup(pop_url,pop_width,pop_height) {
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	window.open(pop_url,"","left=" + pop_left + ",top=" + pop_top + ",width=" + pop_width + ",height=" + pop_height + ",scrollbars=yes,noresize");
}

/*FERME/OUVRE UN BLOC*/
function display_block(nom){
	if(document.getElementById(nom).style.display == 'none') document.getElementById(nom).style.display = 'block';
	else document.getElementById(nom).style.display = 'none';
}

/*IMPRIME ET CACHE LES BOUTONS DU BAS*/
function imprimer(){
	display_block('bloc_boutons');
	window.print();
	setTimeout("display_block('bloc_boutons');",5000);
}

/*AFFICHE LES FLASH*/
function RunFoo(swf, hauteur, largeur) {
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+hauteur+"\" height=\""+largeur+"\">");
	document.write("<param name=\"movie\" value=\""+swf+"\" />");
	document.write("<param name=\"quality\" value=\"high\" />");
	document.write("<param name=\"menu\" value=\"false\" />");
	document.write("<param name=\"wmode\" value=\"transparent\" />");
	document.write("<embed src=\""+swf+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" width=\""+hauteur+"\" height=\""+largeur+"\" wmode=\"transparent\"></embed>");
	document.write("</object>");
}

/*GOOGLE MAP*/
var map = null;
var geocoder = null;

function load_gmap(lat, lng, ville){
	if (GBrowserIsCompatible()){
		map = new GMap2(document.getElementById("map_villa"), {mapTypes:[G_NORMAL_MAP,G_SATELLITE_MAP]});
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		geocoder = new GClientGeocoder();
		
		if(ville!='') showAddress(ville);
		else{
			map.clearOverlays();
			
			var base_icon = new GIcon();
			base_icon.iconSize=new GSize(32,32);
			base_icon.shadowSize=new GSize(0,0);
			base_icon.iconAnchor=new GPoint(16,16);
			base_icon.infoWindowAnchor=new GPoint(32,16);
			var icone_info = new GIcon(base_icon, "imgs/puce_gmap.png", null, null);
			
			var point = new GLatLng(parseFloat(lat), parseFloat(lng));
			map.setCenter(point, 11);
			var marker = new GMarker(point,icone_info);
			map.addOverlay(marker);
		}
	}
}

function showAddress(address){
	if(geocoder){
		geocoder.getLatLng(
			address, function(point){
				if(point){
					map.clearOverlays();
					map.setCenter(point, 11);
					
					var base_icon = new GIcon();
					base_icon.iconSize=new GSize(32,32);
					base_icon.shadowSize=new GSize(0,0);
					base_icon.iconAnchor=new GPoint(32,32);
					base_icon.infoWindowAnchor=new GPoint(32,16);
					var icone_info = new GIcon(base_icon, "imgs/puce_gmap.png", null, null);
					
					var marker = new GMarker(point,icone_info);
					map.addOverlay(marker);
				}
				else{
					map.clearOverlays();
					var point = new GLatLng(43.276, 6.687);
					map.setCenter(point, 11);
					
					var base_icon = new GIcon();
					base_icon.iconSize=new GSize(32,32);
					base_icon.shadowSize=new GSize(0,0);
					base_icon.iconAnchor=new GPoint(16,16);
					base_icon.infoWindowAnchor=new GPoint(32,16);
					var icone_info = new GIcon(base_icon, "imgs/puce_gmap.png", null, null);
					
					var marker = new GMarker(point,icone_info);
					map.addOverlay(marker);
				}
			}
		);
	}
}

