window.onload = function() {
	
	if($('entete')) Event.observe('entete', 'click', function(e){
		document.location = "Accueil.html";
	} , true);


	var dt = document.getElementsByClassName('descriptif_toggler');
	for(i=0; i<dt.length; i++)
	{
		var tid=dt[i].getAttribute('id')
		if($(tid)){
			Event.observe($(tid), 'click', function(e){
				var tid=Event.element(e).id.split('_');
				tid=tid[1];
				Effect.toggle('db_'+tid,'blind', {/*duration: 0.5,
					afterFinish:function(){
						if( Element.hasClassName('dt_1','descriptif_untoggler') ){
							Element.addClassName('dt_1','descriptif_toggler');				 
							Element.removeClassName('dt_1','descriptif_untoggler');				 
						}else{
							Element.addClassName('dt_1','descriptif_untoggler');				 
							Element.removeClassName('dt_1','descriptif_toggler');				 
						}
						return true;
					}*/
				});
			} , true);
		}
	}
	
	
	var se = document.getElementsByClassName('send_me');
	for(i=0; i<se.length; i++)
	{
		//var tid=se[i].getAttribute('id')
		Event.observe(se[i], 'click', function(e){
//			window.open("http://gema.mangaia.fr/Envoyer_a_un_ami.html","nom","width=475,height=500,status=no,toolbar=no,menubar=no,location=no");
			window.open("http://gema-fm.fr/index.php?page=alerte_ami&url="+window.location,"nom","width=475,height=600,status=no,toolbar=no,menubar=no,location=no");
		} , true);
	}
	
	if($('close_window')) Event.observe($('close_window'), 'click', function(e){
		window.close();
	} , true);
	
	
};

function pageprint(rub,art)
{
//window.open("http://gema.mangaia.fr/Imprimer.html?id_rubrique="+rub+"&id_article="+art,"nom","width=475,height=500,status=no,toolbar=no,menubar=no,location=no");
			window.open("http://gema-fm.fr/spip.php?page=print&id_rubrique="+rub+"&id_article="+art,"nom","width=580,height=500,status=no,toolbar=no,scrollbar=yes,menubar=no,location=no");
}

function searchprint(rub,art)
{
	
}


function deplie()
{
	var dt = document.getElementsByClassName('descriptif_box');
	for(i=0; i<dt.length; i++)
	{
		Effect.BlindDown( dt[i].getAttribute('id') );
	}
	return false;
}

function replie()
{
	var dt = document.getElementsByClassName('descriptif_box');
	for(i=0; i<dt.length; i++)
	{
		Effect.BlindUp( dt[i].getAttribute('id') );
	}
	return false;
}
/*
	var body_onload = window.setTimeout(function(){
		try{
			if(document.body){
					onload();
				window.clearTimeout(body_onload);
			}
		}catch(e){}
	},10);
*/
/*
function onload(){
	
	// Round Corner
	if(NiftyCheck()){
		Rounded("div.boite","all","#FFF","transparent");
	}

	
	if($('inscription')) new Effect.Highlight('inscription',{delay:1});
	if($('entete')) Event.observe('entete', 'click', function(e){
		document.location = "Accueil.html";
	} , true);

	try{
	Event.observe('12-32', 'click', function(e){
		switch_entete('entete_images.png');
		switch_article(12,32);
		return false;
	} , true);
	url = $('12-32').getAttribute("href");
	$('12-32').setAttribute("href","http://formation.mangaia.fr/#"+url);
	}catch(e){}
}
*/
/*
//	this will iterate with each element with the class 'ie-fix-opacity' and add an IE filter,
		//	replacing the background-image for the filter of that image
		var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
		if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
			document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
				// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
				var cBGImg = poElement.currentStyle.backgroundImage;
				var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
						
				poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
				poElement.style.backgroundImage = "none";
			});
		}
*/
/*
}

function switch_style(idrub){
	var css = document.getElementsByTagName("link");
	var balises_css = $A(css);
	balises_css.each(function(balise_css){
		if(balise_css.getAttribute("href").search(/theme\.php/)>0){
			balise_css.setAttribute("href","skel-mangaia/css/theme.php?secteur="+idrub);
		}
	});
}

function switch_entete(image){
	window.setTimeout(function(){
		$('entete').style.background = "url(skel-mangaia/images/"+image+") top center no-repeat";
		Effect.Fade('entete', {duration: 1,from: 0.0, to:1});
	},1000);
	Effect.Fade('entete', {duration: 1,from: 1.0, to:0.01});
}

function switch_article(idrub,idart){
	
//	Effect.Fade('contenu', {duration: 1,from: 1.0, to:0.01});
	var url = 'http://formation.mangaia.fr/spip.php';
	var pars = 'page=ajax.article&id_article='+idart;
	var myAjax = new Ajax.Updater('contenu', url, {method: 'get', parameters: pars, asynchronous:false, evalScripts:false});
	
	//switch_style(idrub);
	//Effect.Fade('contenu', {duration: 1,from: 0.0, to:1});
}

function getArticle(id)
{
	var url = 'http://formation.mangaia.fr/spip.php';
	var pars = 'page=ajax.article&id_article='+id;
		
	var myAjax = new Ajax.Updater('contenu', url, {method: 'get', parameters: pars});
}


function deplieMenu(id)
{
	al = document.getElementsByClassName('formations_actif' );
	for(i=0; i<al.length; i++)
	{
		tid=al[i].getAttribute('id');
		$(tid).className = 'formations_inactif';
	}
	ul = document.getElementsByClassName('theme_formation_ul' );
	for(i=0; i<ul.length; i++)
	{
		tid=ul[i].getAttribute('id');
		if(id!=tid){
			Effect.BlindUp(tid, {duration: 0.0});
		}
	}
	if($('theme_formation_'+id).style.display!='none'){
		$('deplie_'+id).className = 'formations_inactif';
	}else{
		$('deplie_'+id).className = 'formations_actif';
	}
	Effect.toggle('theme_formation_'+id,'blind', {duration: 0.2});
}

*/