// affiche le nuage de tags
function displayTagCloud(){
	var so = new SWFObject("swf/tagcloud.swf", "tagcloud", "310", "135", "7", "#F2EBFD");
	so.addParam("wmode", "transparent");
	so.addVariable("tcolor", "0x333333");
	so.addVariable("hicolor", "0x000000");
	so.addVariable("tspeed", "300");
	so.addVariable("distr", "true");
	so.addVariable("xmlpath", "swf/tagcloud.xml");
	so.write("tagCloud");
}

// affiche la gmap
function loadMap(){
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.enableDoubleClickZoom();
	map.setCenter(new GLatLng(48.873721530844215, 2.3619210720062256), 14);
	var point = new GLatLng(48.873721530844215, 2.3619210720062256);
	var icon = new GIcon();
	icon.image = 'pics/relaxmap.png';
	icon.iconSize = new GSize(9, 9);
	icon.iconAnchor = new GPoint(0, 0);
	icon.infoWindowAnchor = new GPoint(8, 5);
	var marker = new GMarker(point, icon);
	var message = '<div style="height:75px;"><img src="pics/relaxmap.jpg" width=76"" height="30" alt="Relaxnews"/> <br/>39 rue Lucien Sampaix <br/>75010 Paris - France<br/>+33 1 53 19 89 50</div>';
	GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(message);
	});
	marker.openInfoWindowHtml(message);
	map.addOverlay(marker);
}

function hideOverlay(){
	new Effect.Fade($('overlay'), {duration: 0.3, from:0.6, to:0 });
	new Effect.Fade('bourse', {duration: 0.3, from:1, to:0 });
}

Event.observe(window, "load", function(){

	// popup
	if($('bourse') != null){
		Effect.Appear('overlay', { duration: 0.5});
		Effect.Appear('bourse', { duration: 0.5});
	}

	// home : click sur colonne 1
	if($('homeLeft')){
		Event.observe($('homeLeft'), "click", function(ev){
			window.location = 'relax-agence.php';
		});
	}

	// logos en boucle sur la home
	if($('homeLeft') && $('logos')){
		new Ajax.PeriodicalUpdater('logosContainer', 'includes/update_logosHome.inc.php',
		{
			method: 'get',
			frequency: 5,
			onSuccess: function() {
				Effect.Appear('logosContainer', { duration: 0.2});
				setTimeout("Effect.Fade('logosContainer', { duration: 0.1, from:1, to:0 });", 4875);
			}
		});
	}

	// communiqués de presse
	if($('morecoms') && $('comssuivants')){
		Event.observe($('morecoms'), "click", function(ev){
			if(typeof myEffect != "undefined") myEffect.cancel();
			if($('comssuivants').style.overflow == '' || $('comssuivants').style.display == 'none'){
				myEffect = Effect.BlindDown('comssuivants', { duration: 0.5 });
			}
			else if($('comssuivants').style.overflow == 'visible'){
				myEffect = Effect.BlindUp('comssuivants', { duration: 0.5 });
			}
			ev.stop();
		});
	}
	// liens presse
	if($('moreliens') && $('lienssuivants')){
		Event.observe($('moreliens'), "click", function(ev){
			if(typeof myEffect != "undefined") myEffect.cancel();
			if($('lienssuivants').style.overflow == '' || $('lienssuivants').style.display == 'none'){
				myEffect = Effect.BlindDown('lienssuivants', { duration: 0.5 });
			}
			else if($('lienssuivants').style.overflow == 'visible'){
				myEffect = Effect.BlindUp('lienssuivants', { duration: 0.5 });
			}
			ev.stop();
		});
	}

	// click sur le ticker
	if($('ticker')){
		Event.observe($('ticker'), "click", function(ev){
			window.location = 'relax-formulaire.php?souhait1';
		});
	}
	if($('tickernews')){
		Event.observe($('tickernews'), "click", function(ev){
			window.location = 'relax-formulaire.php?souhait1';
		});
	}
});

// ticker
function tick(){
	if(typeof(current) == "undefined") current = 0;
	Effect.Appear($$('#tickernews A')[current], { duration: 0.8 });
	setTimeout("Effect.Fade($$('#tickernews A')["+current+"], { duration: 0.2 });", 6500);
	if($$('#tickernews A')[current+1] != null) current++;
	else current = 0;
	setTimeout("tick();", 8000);
}

// accordéon relax contacts
include("accordion.js", function() {
	new accordion("content", {
		resizeSpeed : 6,
		classNames : {
			toggle: "accordion_toggle",
			toggleActive: "accordion_toggle_active",
			content: "accordion_contenu"
		},
		defaultSize : {
			height : null,
			width : null
		},
		direction : "vertical",
		onEvent : "click"
	});
});

