var URLBlog = 'http://'+window.location.hostname+'/';
function open_popup2( url ){
	var h=200;
	var l=400;
	var hauteur=Math.round((screen.availHeight-h)/2);
	var largeur=Math.round((screen.availWidth-l)/2);
	window.open( url , null, "width=400,height=200,top="+hauteur+", left="+largeur+", status=no, resizable=no, toolbar=no, menubar=no, scrollbars=no")
}
//Bannière callback
function open_popup(ip){
	var h=410;
	var l=490;
	var hauteur=Math.round((screen.availHeight-h)/2);
	var largeur=Math.round((screen.availWidth-l)/2);
	window.open("http://webcallback.axialys.net/popup.php?ip="+ip, null, "width="+l+", height="+h+", top="+hauteur+", left="+largeur+", status=no, resizable=no, toolbar=no, menubar=no, scrollbars=no")
}
function affTab( tab ) {
	$('letterFermer').show();

	$$('.tabsContents').each( function( ele ) {
		ele.hide();
		$('letter'+ele.id).className = 'white';
	});

	if( "close" != tab )
	{
		$(tab).show();
		$('letter'+tab).className = 'gray';
	}
	else
		$('letterFermer').hide();
}


//Flash info
function flashInfo(){
		var m4 = new Marquee({
			element: "agenda",
			life: 7,
			change: function(){
				//$("agendalst").down("li.active").removeClassName("active");
				//$("agendalst").down(m4.current).addClassName("active");
			}
		});
		var t = new Template('<div>&nbsp;#{indiceTitre} #{indiceCour}#{img}#{indiceDef}</div>');
		var opt = {
	    method: 'post',
	    postBody: 'action=getIndice',
	    onSuccess: function(r) {
				var infos = r.responseXML.getElementsByTagName("info");
				var data = [];
				$A(infos).each(function(q, i){

					var titre 			= q.childNodes[0].firstChild.nodeValue;
					var definition 	= q.childNodes[1].firstChild.nodeValue;
					try{
						var progression = q.childNodes[2].firstChild.nodeValue;
					}catch(err){
						var progression = '';
					}
					var URLLien 		= q.childNodes[3].firstChild.nodeValue;
					var img = "<img src='"+ q.childNodes[4].firstChild.nodeValue+"'/>";
					data.push({message: t.evaluate({indiceTitre:titre, indiceDef:definition, indiceCour:progression, img:img}),life: 5.5, link: URLLien } );
					if($("agendalst"))
						$("agendalst").insert(new Element("li", {idx: i}));
				});
				m4.load(data);
				if($("agendalst"))
					$("agendalst").down(0).addClassName("active");
			}
		};
		new Ajax.Request( URLBlog+"wp-content/plugins/SVPFlashInfo/php/dispatcher.php", opt);

		if($("agendalst"))
		{
			$("agendalst").observe("click", function(e){
				if(e.target.tagName=="LI"){
					$("agendalst").down("li.active").removeClassName("active");
					e.target.addClassName("active");
					m4.clear();
					m4.start(parseInt(e.target.getAttribute("idx")));
				}
			});
		}
}

function initEvent(e){
	Event.stop(e);
	//Protection des adresses emails
	$$('span.svpadd').each( function( ele ) {
		ele.innerHTML = ele.getAttribute('attr') + '@svp.com';
	});

	if( $('lesTags') )
	{
		var firstTab = '';
		$$('.tabsContents').each( function( ele ) {
			if( "" == firstTab )
				firstTab = ele.id;
			ele.hide();
		});
		$('letterFermer').hide();
	}

	if( $('agenda') )
		flashInfo();
}
Event.observe( window ,'load', initEvent );
