loadFLV/***********************************/

noSequence = 1;
noMedia = 1;
nbreElementsGalerie = 0;
bulleOuverte='';
infoGalerie = new Array();

var OS,browser,version,thestring;
detectBrowser();

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

function updateProduitsForCategorie(idElement,idCategorie){
	
	var idSelectProduit = 'id_produit_'+keepNumbers(idElement);
	var oSelectBox = document.getElementById(idSelectProduit);
	
	//On flush la liste des produits
	deleteAllOptions(oSelectBox);
	
	if(idCategorie != "" && listeProduits != null && listeProduits[idCategorie] != null){
		
		//On ajoute tous les produits liés à cette catégorie
		for(i=0;i<listeProduits[idCategorie].length;i++){
			addOption(oSelectBox,listeProduits[idCategorie][i][1],listeProduits[idCategorie][i][0]);
		}
		
	}
}

function detectBrowser(){
	
	var detect = navigator.userAgent.toLowerCase();
	
	//BROWSER
	if(inString(detect,'konqueror')){
		browser = "konqueror";
		OS = "linux";
	}else if(inString(detect,'safari')){
		browser = "safari";
	}else if(inString(detect,'omniweb')){
		browser = "omniweb";
	}else if(inString(detect,'opera')){
		browser = "opera";
	}else if (inString(detect,'webtv')){
		browser = "webtv";
	}else if (inString(detect,'icab')){
		browser = "icab"
	}else if (inString(detect,'msie')){
		browser = "ie"
	}else if (!inString(detect,'compatible')){
		browser = "mozilla";
		version = detect.charAt(8);
	}else{
		browser = "";
	}
	
	//VERSION
	if(!version){
		version = detect.charAt(place + thestring.length);
	}
	
	//PLATE-FORME
	if(!OS)
	{
		if(inString(detect,'linux')){
			OS = "linux";
		}else if(inString(detect,'x11')){
			OS = "unix";
		}else if(inString(detect,'mac')){
			OS = "mac";
		}else if(inString(detect,'win')){
			OS = "windows";
		}else{
			OS = "";
		}
	}
	
	/*
	alert(OS);
	alert(browser);
	alert(version);
	*/
}

function inString(src,needle)
{
	place = src.indexOf(needle) + 1;
	thestring = needle;
	return place;
}

function selectionnerTypeTemoignage(type){
	
	cacher('saisie_photo_1');
	cacher('saisie_photo_2');
	//cacher('saisie_video');
	cacher('saisie_video_youtube_1');
	cacher('saisie_video_youtube_2');
	
	if(type==2){
		//Vidéo Youtube
		montrer('saisie_video_youtube_1');
		montrer('saisie_video_youtube_2');
	}else if(type==1){
		//Vidéo
		//montrer('saisie_video');
	}else{
		//Photo
		montrer('saisie_photo_1');
		montrer('saisie_photo_2');
	}
}

function montrer(idElement){
	document.getElementById(idElement).style.display = '';
}


function cacher(idElement){
	document.getElementById(idElement).style.display = 'none';
}

function montrerCacher(idElement){
	if(document.getElementById(idElement).style.display != 'none'){
		document.getElementById(idElement).style.display = 'none';
	}else{
		document.getElementById(idElement).style.display = '';
	}
}

function carte(start, infoMarkers, lienMap){

	if(GBrowserIsCompatible()){
		
		var centerLatitude = start[0];
		var centerLongitude = start[1];
		var zoom = start[2];
		
		//Création de la map
		var map = new GMap2(document.getElementById("map"),
			{mapTypes:[G_HYBRID_MAP,G_SATELLITE_MAP,G_NORMAL_MAP]}
		);
		
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(centerLatitude, centerLongitude), zoom);
		
		for(var i=0;i<infoMarkers.length;i++){
			
			latitude = infoMarkers[i][0];
			longitude = infoMarkers[i][1];
			titre = infoMarkers[i][2];
			contenu = infoMarkers[i][3];
			
			//Création du marker
			marker = createMarker(latitude, longitude, titre, contenu, centerLatitude, centerLongitude, zoom, lienMap);
			
			//Ajout du marker
			map.addOverlay(marker);
		}
		
		//On ouvre aumatiquement la bulle
		//marker.openInfoWindowHtml(html);
	}
}

function createMarker(latitude, longitude, title, text, centerLatitude, centerLongitude, zoom, lienMap){
	
	var point = new GLatLng(latitude, longitude);
	
	//var urlDirection = "http://www.google.ca/maps?f=d&saddr=&daddr="+latitude+","+longitude+"&hl="+langue+"&geocode=&mra=dme&mrcr=0&mrsp=1&sz=11&sll=49.300054,-68.120041&sspn=0.318805,0.892639&ie=UTF8&t=h&z=11";
	
	var urlDirection = "http://www.google.ca/maps?f=d&saddr=&daddr="+latitude+","+longitude+"&hl="+langue+"&geocode=&mra=dme&mrcr=0&mrsp=1&sz=11&sll="+centerLatitude+","+centerLongitude+"&ie=UTF8&t=h&z="+zoom;
	
	text += "<br /><a href='"+urlDirection+"' onclick=\"window.open(this.href,'_blank');return false;\">"+lienMap+"</a>";
	
	var html = "<div class='googlemap_bulle'><strong>"+title+"</strong><br />"+text+"</div>";
	
	var marker = new GMarker(point,{title:title});
	GEvent.addListener( 
		marker, "click", function(){
			marker.openInfoWindowHtml(html);
	});
	return marker; 
}

function videoYoutube(idBloc,codeVideo){

	//var idBloc = creerBlocFlash();
	
	var fo = new FlashObject("http://www.youtube.com/v/"+codeVideo, "flash_youtube", "425", "344", "8");
	
	fo.addVariable("allowScriptAccess", "sameDomain");
	fo.addParam("wmode", "transparent");
	fo.addVariable("quality", "high");
	
	fo.write(idBloc);
	////document.getElementById(idBloc).innerHTML += fo.getFlashHTML();	
}

function loadFLV(idBloc,nomFichier,autoplay){
	
	var pathFile = "librairie/"+nomFichier;
	
	//var idBloc = creerBlocFlash();
	
	var fo = new FlashObject("includes/flash/player.swf", "mymovie", "500", "440", "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);
	////document.getElementById(idBloc).innerHTML = fo.getFlashHTML();	
	fo.write(idBloc);
}

function flashPlayer(fichier,width,height,cssID,autoplay){

		var antiCache = "?t=" +new Date().getTime();
		var s1 = new SWFObject("includes/flash/player.swf"+antiCache,"player",width,height,"9","#000000","autostart");
		s1.addParam("allowfullscreen","false");
		s1.addParam("allowscriptaccess","always");
		s1.addVariable("width",width);
		s1.addVariable("height",height);
		s1.addVariable("displaywidth",width);
		s1.addVariable("displayheight",height);
		s1.addParam("wmode","opaque");
		s1.addParam("flashvars","&file="+fichier+"&autostart="+autoplay+"&repeat=none&menu=false&backcolor=000000&frontcolor=DDDDDD&lightcolor=DDDDDD&screencolor=000000");
		s1.write(cssID);
}

function flashPlayer2(fichier,width,height,cssID,autoplay){
	
	var antiCache = "?t=" +new Date().getTime();
				
	var so = new FlashObject("/flash/player.swf"+antiCache, "flash_flv", "176", "99", "9", "#FFFFFF","autostart");
	so.addParam("allowfullscreen","false");
	so.addParam("allowscriptaccess","always");
	so.addVariable("quality", "high");
	
	so.addVariable("width","176");
	so.addVariable("height","99");
	so.addVariable("displayheight","99");
	so.addParam("wmode","opaque");
	
	//&displayclick=link&linktarget=_self
	so.addParam("flashvars","&file="+fichier+"&autostart=false&repeat=false&menu=false");
	so.write(cssID);

}


/*
//Fonction d'affichage du player
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=='flv'){
		loadFLV(pathLibrairie+nomfichier,autoplay);
	}
	
	afficher('</div>');
}
*/

function setCookie(name, value)
{
	//nouvel objet date
	var aujourdhui = new Date() ;
	
	//nouvel objet date
	var expdate = new Date() ;
	 
	//expiration
	expdate.setTime( aujourdhui.getTime() + ( 7*24*60*60*1000 ) )
	
	//creation du cookie
	document.cookie = name + "=" + value + ";expires=" + expdate.toGMTString() ;
}

function afficherDiapo(urlFichiers,listeImages,listeUrl) {
	
	var so = new FlashObject("/flash/diapo/diapo.swf", "flash_diapo", "552", "206", "8");
	
	so.addVariable("allowScriptAccess", "sameDomain");
	so.addParam("wmode", "transparent");
	so.addVariable("quality", "high");
	
	so.addVariable("PATH_MEDIAS", urlFichiers);
	so.addVariable("DIAPO_LISTE_IMAGES", listeImages);
	so.addVariable("DIAPO_LISTE_URL", listeUrl);
	
	so.write("diapo");
}

function afficherFlash(file,largeur,hauteur,div){
	
	var so = new FlashObject(file, "flash_file", largeur, hauteur, "8");
	
	so.addVariable("allowScriptAccess", "sameDomain");
	so.addParam("wmode", "transparent");
	so.addVariable("quality", "high");
	
	so.write(div);
}

/*
function afficherBannieres(listeImages,listeURL,tempsAffichage,tempsTransition) {
	
	//var so = new FlashObject("flash/header/header_preload.swf", "flash_header", "814", "140", "8");
	var so = new FlashObject("flash/header/header.swf", "flash_header", "814", "140", "8");
	
	so.addVariable("allowScriptAccess", "sameDomain");
	so.addParam("wmode", "transparent");
	so.addVariable("quality", "high");
	
	so.addVariable("PATH_MEDIAS", pathBannieres);
	so.addVariable("DIAPO_LISTE_IMAGES", listeImages);
	so.addVariable("DIAPO_LISTE_URL", listeURL);
	so.addVariable("TEMPS_AFFICHAGE", tempsAffichage);
	so.addVariable("TEMPS_TRANSITION", tempsTransition);
	
	so.write("header_bannieres");
}
*/


function gotoSelect(idElement){
	for (i=0; i < document.getElementById(idElement).options.length; i++) {
		if (document.getElementById(idElement).options[i].selected == true) {
			rediriger(document.getElementById(idElement).options[i].value);
		}
	}
	return false;
}

function rediriger(urlPage,nouvellePage){
	
	if(urlPage != ''){
		
		if(nouvellePage != null){
			openPopup(urlPage);
		}else{
			window.location.href = urlPage;
		}
	}
}

function openPopup(urlPage){
	
	oWindow = window.open(urlPage,"");
}

function addInput(nom, valeur, typeInput, nomForm){
	
	if(nomForm==null){
		//On utilise le premier form existant
		var mainNode = document.getElementsByTagName("form");
		var leForm = mainNode[0];
	}else{
		var leForm = document.forms[nomForm];
	}
	
	element = document.createElement("input");
	element.setAttribute("name", nom);
	element.setAttribute("value", valeur);
	element.setAttribute("type", typeInput);
	leForm.appendChild(element);
}

function soumettreForm(oForm,nomBoutonSubmit,nomForm){
	
	var soumettreForm=true;
	
	//Soumission du formulaire
	if(oForm.onsubmit){
		if(oForm.onsubmit()){
			//OK	
		}else{
			soumettreForm=false;	
		}
	}
	
	if(soumettreForm){
		
		//Si on veut poster le nom du bouton submit
		if(nomBoutonSubmit != null){
			//On crée un input hidden pour qu'on poste le nom du bouton submit
			addInput(nomBoutonSubmit, 1, "hidden", nomForm);
		}
		//document.forms[nomForm].submit();
		oForm.submit();
	}
}

function checkEnter(e){
	
	var codeTouche=document.layers?e.which:document.all?event.keyCode:e.keyCode;
	if(codeTouche==13){	
		return false;
	};
	return true;
}

function bloquerEnter(){
	
	//document.forms[0].onkeypress=bloquerSubmit;
	
	var arrayInput = document.forms[0].getElementsByTagName("input");
	for (var i=0; i<arrayInput.length; i++ ) {
		
		oInput = arrayInput[i];
		
		if (oInput.tagName == "INPUT" && oInput.getAttribute("type") == "text") {
			oInput.onkeypress=bloquerSubmit;
			//oInput.onkeypress=function(e){	return bloquerSubmit(e); }
		}
	}
}

function bloquerSubmit(e){
	
	if(window.event){
		if(window.event.keyCode == 13){
			//IE
			return false;
		}
	}else if(e.which){
		//FIREFOX
		if(e.which == 13){
			return false;
		}
	}
	return true;
}

function getLargeurFenetre()
{
	if(window.innerWidth)
		return window.innerWidth;
	else if(document.body && document.body.offsetWidth)
		return document.body.offsetWidth;
	else
		return 0;
}

function getHauteurFenetre()
{
	if(window.innerHeight)
		return window.innerHeight;
	else if(document.body && document.body.offsetHeight)
		return document.body.offsetHeight;
	else
		return 0;
}

function getCentre(largeur,hauteur){
	
	//largeurTotale = screen.availWidth;
	//hauteurTotale = screen.availHeight;
	
	//OK
	//alert(largeur);
	var pointx=(screen.availWidth-largeur)/2;
	
	//NON
	//alert(hauteur);
	var pointy=(screen.availHeight-hauteur)/2;
	
	var points = new Array(pointx,pointy);
	return points;
}

function findPosition(oElement){
	
	var posX = 0;
	var poxY = 0;
	
	
	if(typeof(oElement.offsetParent) != 'undefined'){
		for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ){
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
	}else{
		posX = oElement.x;
		poxY = oElement.y;
	}
	
	if(document.all){
		//alert("IE");
		posY += 10;
	}else{
		//alert("MOZILLA");
		posY -= 50;
	}
	
	return [posX,posY];
}

function creerNouveauDiv(){

	var id='media'+noMedia;
	
	afficher('<div id="'+id+'" name="'+id+'"></div>');
	noMedia++;
	
	return id;
}

function creerNouveauSpan(){

	var id='media'+noMedia;
	
	afficher('<span id="'+id+'" name="'+id+'"></span>');
	noMedia++;
	
	return id;
}

function afficher(message){
	document.write(message);
	//document.getElementById('contenupage').innerHTML = document.getElementById('contenupage').innerHTML+message;
}

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;"><strong>Pour visualiser ce contenu, vous devez mettre à jour votre Flash Player</strong></div><div style="color: #000000;"><a style="color: #000000;" 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 decode(tChaine){
  while (true) {
    var i = tChaine.indexOf('+');
    if (i < 0) break;
    tChaine = tChaine.substring(0,i) + '%20' + tChaine.substring(i + 1, tChaine.length);
  }
  return unescape(tChaine)
}
function goURL(url){
	window.location=url;
}