/***********************************/

pathLibrairie = 'librairie/';
noSequence = 1;


function afficher(message){
	document.write(message);
}

//Fonction d'affichage d'un sous-titre
function soustitre(soustitre){
	afficher('<span class="soustitre">');
	afficher(soustitre);
	afficher('</span>');
}

//Fonction d'affichage d'un url à l'interne
function urlinterne(urlinterne,nom){
	afficher('<a href="'+urlinterne+'">');
	afficher(nom);
	afficher('</a>');
}

//Fonction d'affichage d'un url à l'externe
function urlexterne(urlexterne,nom){
	afficher('<a href="'+urlexterne+'" target="_blank">');
	afficher(nom);
	afficher('</a>');
}

//Fonction d'affichage d'une image à gauche
function imagegauche(nomimage){
	afficher('<div class="imageleft">');
	afficher('<img src="'+pathLibrairie+nomimage+'" class="imagegauche">');
	afficher('</div>');
}

//Fonction d'affichage d'une image à droite
function imagedroite(nomimage){
	afficher('<div class="imageright">');
	afficher('<img src="'+pathLibrairie+nomimage+'" class="imagedroite">');
	afficher('</div>');
}

//Fonction d'affichage d'une strophe avec marge à gauche
function strophe1(strophe, marge){
	afficher('<div class="strophe" style="margin-left:'+marge+'px;">');
	afficher(strophe);
	afficher('</div>');
}

//Fonction d'affichage d'une strophe alignée au centre
function strophe2(strophe){
	afficher('<div class="strophe" style="text-align:center;">');
	afficher(strophe);
	afficher('</div>');
}

//Fonction d'affichage d'une strophe alignée au centre
function player(nomfichier,autoplay){
	
	var strFichier = new String(nomfichier);
	var extension = strFichier.substr(strFichier.length-3, 4);
	
	afficher('<div style="text-align:center;">');
	
	if(extension=='mp3'){
		loadMP3(pathLibrairie+nomfichier,autoplay);
	}
	if(extension=='flv'){
		loadFLV(pathLibrairie+nomfichier,autoplay);
	}
	
	afficher('</div>');
}

function loadFLV(pathFile,autoplay) {
	
	var idBloc = creerBlocFlash();
	
	var fo = new FlashObject("00-videoplayer.swf", "mymovie", "480", "398", "8");
	fo.addParam("wmode", "transparent");
	fo.addVariable("allowScriptAccess", "sameDomain");
	fo.addVariable("quality", "high");
	fo.addVariable("MEDIA_FILENAME", pathFile);
	fo.addVariable("AUTO_PLAY", autoplay);
	fo.write(idBloc);
}

function loadMP3(pathFile,autoplay) {
	
	var idBloc = creerBlocFlash();
	
	var fo = new FlashObject("00-mp3player.swf", "mymp3", "300", "80", "8");
	fo.addParam("wmode", "transparent");
	fo.addVariable("allowScriptAccess", "sameDomain");
	fo.addVariable("quality", "high");
	fo.addVariable("MEDIA_FILENAME", pathFile);
	fo.addVariable("AUTO_PLAY", autoplay);
	fo.write(idBloc);
}

/*
Paramètres possibles :

	&randomstart=1
	&showbuttons=1
	&alignbuttons=top
	&alignbuttons=bottom
	&timer=3
	&transition=fade (défaut), slide, push, pop, warp, blur, none (pas de transition).
	&speed=20
*/
function diaporama(largeur,hauteur,fichierXML,parametres) {

	fichierXML = 'xml/getXML.php?xml='+fichierXML+'&rand='+randomString();
	if(parametres==null){
		parametres="";	
	}
	
	var idBloc = creerBlocFlash();
	
	var fo = new FlashObject("dewslider5.swf?xml="+fichierXML+parametres, "mydiapo", largeur, hauteur, "8");
	fo.addParam("wmode", "transparent");
	fo.addVariable("allowScriptAccess", "sameDomain");
	fo.addVariable("quality", "high");
	fo.write(idBloc);
}

function creerBlocFlash(){
	
	var idBloc = "emplacementFlash"+noSequence;

	document.write('<div id="'+idBloc+'">');
	document.write('<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><div style="color: #000000;font-size:12px;"><strong>Pour visualiser ce contenu, vous devez mettre à jour votre Flash Player</strong></div><div style="color: #000000;"><a style="color: #000000;font-size:12px;" href="http://www.macromedia.com/go/getflashplayer" target="_blank">Cliquez ici pour télécharger la version la plus récente</a></div><br />');
	document.write('</div>');
	
	noSequence++;
	
	return idBloc;
}

/***********************************/

function MM_preloadImages() { 
	//v3.0
	var d=document;
	if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
	for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){
			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		}
	}
}

function WM_imageSwap(daImage, daSrc){
	var objStr,obj;
	// Check to make sure that images are supported in the DOM.
	if(document.images){
		// Check to see whether you are using a name, number, or object
		if (typeof(daImage) == 'string') {
			// This whole objStr nonesense is here solely to gain compatability
			// with ie3 for the mac.
			objStr = 'document.' + daImage;
			obj = eval(objStr);
			obj.src = daSrc;
		} else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
			daImage.src = daSrc;
		}
	}
}

function xpreload() {
}

function xshowdate() {
	var now    = new Date();
	var hour        = now.getHours();
	var minute      = now.getMinutes();
	var second      = now.getSeconds();
	var monthnumber = now.getMonth() + 1;
	var monthday    = now.getDate();
	var year        = now.getYear();
	if(year < 2000) { year = year + 1900; }
	document.write(year + "/" + monthnumber + "/" + monthday);
}

function openimaget(ximage,xwidth,xheight,xlang)
{
	var xx="00-photot.php?ximage="+ximage+"&xlang="+xlang;
	var xwidth=xwidth + 20;
	var xheight=xheight + 55;
	xtemp = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0,width="+xwidth+"px,height="+xheight+"px";
	window.open(xx,"",xtemp);
}

function randomString()
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

