function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
	}
}

$.accordian = function(items, first, options) {
	var active = first;
	var running = 0;
	var titles = options && options.titles || '.title';
	var contents = options && options.contents || '.content';
	var onClick = options && options.onClick || function(){};
	var onShow = options && options.onShow || function(){};
	var onHide = options && options.onHide || function(){};
	var showSpeed = options && options.showSpeed || 'slow';
	var hideSpeed = options && options.hideSpeed || 'fast';
	$(items).not(active).children(contents).hide();
	$(items).not(active).each(onHide);
	$(active).each(onShow);
	$(items).children(titles).click(function(e){
		var p = $(contents, this.parentNode);
		$(this.parentNode).each(onClick);
		if (running || !p.is(":hidden")) return false;
		running = 2;
		$(active).children(contents).not(':hidden').slideUp(hideSpeed, function(){--running;});
		p.slideDown(showSpeed, function(){--running;});
		$(active).each(onHide);
		active = '#' + $(this.parentNode)[0].id;
		$(active).each(onShow);
		return false;
	});
};

function raw_popup(url) {
var width =  600;
var height = 550;
var S_url = url;
startIndex=S_url.indexOf("?");
query=S_url.substr(startIndex+1);
var params = query.split("&");
var variables = new Array();
for (i in params) {
var segments_var = params[i].split("=");
variables.push(unescape(segments_var[1]));}
if(variables[0]) width = variables[0];
if(variables[1]) height = variables[1];
var PosX = ( screen.availWidth - width ) / 2; 
var PosY = ( screen.availHeight - height ) / 2;	
var option = "location=0,statusbar=0,menubar=0,resizable=yes,width="+width+",height="+height+",top="+PosY+",left="+PosX; 
var theWindow = window.open(url, "_blank", option);
theWindow.focus();
return theWindow;
}

$(document).ready(function() {
if($('body').attr("id")=="accueil"){
var diapos = new SWFObject("../swf/slideshow_as2.swf", "Le diaporama", "520", "250", "6.0", "#FFFFFF");
}else{
var diapos = new SWFObject("../swf/slideshow_as2.swf", "Le diaporama", "800", "250", "6.0", "#FFFFFF");
}
diapos.addVariable("links","../data/diapos/diapos.xml");
diapos.addParam("wmode","transparent");
diapos.write("diaporama");
externalLinks();
$.accordian('#list1 > dl', '#item11');
$.accordian('#list2 > dl', '#item21');
$('.popup').click(function(){raw_popup(this.getAttribute("href"));return false;});
});