/* addRemoveEvent
********************/
function addRemoveEvent(add, el, evt, func){
	if(add){
		if(el.addEventListener) el.addEventListener(evt, func, false);
		else if (el.attachEvent) el.attachEvent("on" + evt, func);
	}else{
		if(el.removeEventListener) el.removeEventListener(evt, func, false);
		else if (el.detachEvent) el.detachEvent("on" + evt, func);
	}
}

/* swf object
********************/
function injectSO(){
	var isacc = document.getElementById("flass_acc");
	if (isacc){
		var so_acc = new SWFObject("swf-xml/acc.swf", "photo", "470", "340", "8", "#FFFFFF");
		so_acc.addParam("wmode", "transparent");
		so_acc.write("flass_acc");
	}
	var ispellicule = document.getElementById("pellicule1");
	if (ispellicule){
		var so_pellicule = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule.addVariable("rub", "images/peinture");
		so_pellicule.addVariable("thexml", "swf-xml/pellicule_1.xml");
		so_pellicule.write("pellicule1");
	}
	var ispellicule2 = document.getElementById("pellicule2");
	if (ispellicule2){
		var so_pellicule2 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule2.addVariable("rub", "images/peinture");
		so_pellicule2.addVariable("thexml", "swf-xml/pellicule_2.xml");
		so_pellicule2.write("pellicule2");
	}
	var ispellicule3 = document.getElementById("pellicule3");
	if (ispellicule3){
		var so_pellicule3 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule3.addVariable("rub", "images/peinture");
		so_pellicule3.addVariable("thexml", "swf-xml/pellicule_3.xml");
		so_pellicule3.write("pellicule3");
	}
	var ispellicule4 = document.getElementById("pellicule4");
	if (ispellicule4){
		var so_pellicule4 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule4.addVariable("rub", "images/peinture");
		so_pellicule4.addVariable("thexml", "swf-xml/pellicule_4.xml");
		so_pellicule4.write("pellicule4");
	}
	var ispellicule5 = document.getElementById("pellicule5");
	if (ispellicule5){
		var so_pellicule5 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule5.addVariable("rub", "images/peinture");
		so_pellicule5.addVariable("thexml", "swf-xml/pellicule_5.xml");
		so_pellicule5.write("pellicule5");
	}
	var ispellicule6 = document.getElementById("pellicule6");
	if (ispellicule6){
		var so_pellicule6 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule6.addVariable("rub", "images/peinture");
		so_pellicule6.addVariable("thexml", "swf-xml/pellicule_6.xml");
		so_pellicule6.write("pellicule6");
	}
	var ispellicule7 = document.getElementById("pellicule7");
	if (ispellicule7){
		var so_pellicule7 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule7.addVariable("rub", "images/peinture");
		so_pellicule7.addVariable("thexml", "swf-xml/pellicule_7.xml");
		so_pellicule7.write("pellicule7");
	}
	var ispellicule8 = document.getElementById("pellicule8");
	if (ispellicule8){
		var so_pellicule8 = new SWFObject("swf-xml/pellicule.swf", "photo", "990", "323", "8", "#000000");
		so_pellicule8.addVariable("rub", "images/peinture");
		so_pellicule8.addVariable("thexml", "swf-xml/pellicule_8.xml");
		so_pellicule8.write("pellicule8");
	}
	var isunivers = document.getElementById("univers");
	if (isunivers){
		var so_univers = new SWFObject("swf-xml/univers.swf", "photo", "990", "323", "8", "#000000");
		//so_univers.addParam("wmode", "transparent");
		so_univers.addVariable("dossier", "images/univers");
		so_univers.addVariable("titre", "L'univers artistique");
		so_univers.write("univers");
	}
	var isportrait = document.getElementById("portrait");
	if (isportrait){
		var so_univers = new SWFObject("swf-xml/portraits.swf", "photo", "990", "323", "8", "#000000");
		so_univers.addParam("wmode", "transparent");
		so_univers.addVariable("dossier", "images/univers");
		so_univers.write("portrait");
	}
	var isautoportrait = document.getElementById("autoportrait");
	if (isautoportrait){
		var so_autoportrait = new SWFObject("swf-xml/autoportrait.swf", "photo", "990", "323", "8", "#000000");
		so_autoportrait.addParam("wmode", "transparent");
		so_autoportrait.addVariable("dossier", "images/autoportrait");
		so_autoportrait.write("autoportrait");
	}
}

/* anchors
********************/
function initAnchors(){
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; ++i){
		if (!anchors[i].getAttribute("href") || !anchors[i].getAttribute("rel")) continue;
		var relation = String(anchors[i].getAttribute("rel"));
		if (relation.match("popup")) anchors[i].onclick=popup;
		if (relation == "external") anchors[i].onclick=external;
	}
}
function popup(){
	var relation = String(this.getAttribute("rel"));
	if(relation == "popup"){
		window.open(this, "pop", "scrollbars=no");
	}else{
		var arguments = relation.substring(6,relation.length-1).split(";");
		window.open(this,arguments[0],'toolbar=0,location=0,directories=0,status=0,menubar=0,' + arguments[1] + ',resizable=no,width=' + arguments[2] + ',height=' + arguments[3] + ',top=' + arguments[4] + ',left=' + arguments[5]);
	}
	return false;
}
function external(){
	window.open(this);
	return false;
}

/* scrollbars
********************/
function initScrollBars(){
	CSBfleXcroll("scrollable");
	CSBfleXcroll("livreor");
	CSBfleXcroll("curriculum");
}

/* init
********************/
addRemoveEvent(true, window, "load", injectSO);
addRemoveEvent(true, window, "load", initAnchors);
addRemoveEvent(true, window, "load", initScrollBars);
