function EVT_cancelBubble(e) {
  e = (e || window.event);
  e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

var EVT_mouseX;
var EVT_mouseY;

function EVT_captureMouse(e) {
  if (e) {
    EVT_mouseX = e.pageX;
    EVT_mouseY = e.pageY;
  } 
  else {
    EVT_mouseX = event.x + document.body.scrollLeft;
    EVT_mouseY = event.y + document.body.scrollTop;
  }  
}

var id_menu_flottant;
var etat_menu_click = 0;
       
function afficherMenuFlottant(id_menu, decaler_droite) {    
    posX = (decaler_droite != null ? EVT_mouseX - decaler_droite : EVT_mouseX);    
    posY = EVT_mouseY + 10;       
    menu = document.getElementById(id_menu);    
    id_menu_flottant = id_menu;
    if (menu.parentNode.nodeName != "BODY") {
      conteneur = document.getElementById("_menu_flottant");      
      conteneur.style.left = posX+"px";
      conteneur.style.top = posY+"px";
      conteneur.innerHTML = "<div class="+menu.className+" style='display:block'>"+menu.innerHTML+"</div>";
      if (!conteneur.onclick) conteneur.onclick = function() { etat_menu_click = 1; }
      conteneur.style.visibility = "visible";
    }            
    else {    
      menu.style.left = posX+"px";      
      menu.style.top = posY+"px";
      if (!menu.onclick) menu.onclick = function() { etat_menu_click = 1; }
      menu.style.display = "block";    
    }    
}

function masquerMenuFlottant() {    
  if (id_menu_flottant) {
    menu = document.getElementById(id_menu_flottant);
    if (menu.parentNode.nodeName != "BODY") {
      document.getElementById("_menu_flottant").style.visibility = "hidden";
    }
    else {
      menu.style.display = "none";
    }
  }  
  id_menu_flottant = null;
}

document.onmousemove = EVT_captureMouse;
document.onclick = function() {
  if (!etat_menu_click) masquerMenuFlottant();
  etat_menu_click = 0;
}

function fct_popUp(parametresGet, valWidth, valHeight, valLeft, valTop, nom_popup)
{
    if (valLeft == null || valLeft == -1) valLeft = parseInt(screen.availWidth / 2) - parseInt(valWidth / 2);
    if (valTop == null || valTop == -1) valTop = parseInt(screen.availHeight / 2) - parseInt(valHeight / 2);
    if (nom_popup == null) nom_popup = "popup_oredia";
		var w=window.open(parametresGet+'&PHPSESSID=7495dd575d0bc209ec3a1d2b15d0aefb', nom_popup, "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, height="+valHeight+", width="+valWidth+", left="+valLeft+", top="+valTop);
		w.document.close();
    w.focus();
}

// Fonction gérant le popUp affichant les informations des photos
function fct_infosPhotos(parametresGet)
{		
    // wpreview = window.open("?idPageWeb=77&popUp_infosPhoto=1"+parametresGet+"&PHPSESSID=7495dd575d0bc209ec3a1d2b15d0aefb", "wpreview_oredia", "width=750,height=630,left="+parseInt(screen.availWidth / 2 - 375)+",top="+parseInt(screen.availHeight / 2 - 315));
    wpreview = window.open("?idPageWeb=77&popUp_infosPhoto=1"+parametresGet+"&PHPSESSID=7495dd575d0bc209ec3a1d2b15d0aefb", "wpreview_oredia", "width=800,height=730,left="+parseInt(screen.availWidth / 2 - 400)+",top="+parseInt(screen.availHeight / 2 - 325));
    wpreview.focus(); 
}

function telechargerPhoto(id_photo, format, nom_fichier) {
    nom_fichier = 'Ore_'+nom_fichier;
    url = '/oredia3/photoalias/'+nom_fichier+'.jpg?idPageWeb=77&popUp_telecharger=1&commencerTelechargement=1&formatPhoto='+format+'&tblIdPhoto[0]='+id_photo+'&nomFichier='+nom_fichier;
    if (document.frames)
      document.frames['iframe_chargement'].location.replace(url);
    else 
      document.getElementById('iframe_chargement').src = url;
}

function imprimerPhoto(id_photo, format) {
    url = '?idPageWeb=77&popUp_imprimerInfosPhoto=1&formatPhoto='+format+'&tblIdPhoto[0]='+id_photo;
    fct_popUp(url, parseInt(screen.availWidth / 2), parseInt(screen.availHeight / 2), parseInt(screen.availWidth / 4), parseInt(screen.availHeight / 4), "imprimer_"+id_photo);                
}

function imprimerTexteAssocie(id_texte) {
    // url = '?idPageWeb=77&imprimer_texte_associe='+id_texte;
    url = '/oredia3/kaaWeb/tableLumineuse/imprimer_textassoc.php?id_texte='+id_texte;
    fct_popUp(url, parseInt(screen.availWidth / 2), parseInt(screen.availHeight / 2), parseInt(screen.availWidth / 4), parseInt(screen.availHeight / 4), "imprimer_texte_"+id_texte);
}

function telechargerSelection(id_selection, format, nom_fichier) {
    nom_fichier = 'Ore_'+nom_fichier;   
    url = '/oredia3/photoalias/'+nom_fichier+'.zip?idPageWeb=77&popUp_telecharger=1&telechargerSelection='+id_selection+'&formatPhoto='+format+'&nomFichier='+nom_fichier;
    if (format == 'hr') document.getElementById("chargement_encours").style.display = 'block';
    if (document.frames)
      document.frames['iframe_chargement'].location.replace(url);
    else
      document.getElementById('iframe_chargement').src = url;    
}

function imprimerSelection(id_selection, format) {
    url = '/oredia3/?idPageWeb=77&popUp_imprimerInfosPhoto=1&formatPhoto='+format+'&imprimerSelection='+id_selection;
    fct_popUp(url, parseInt(screen.availWidth / 2), parseInt(screen.availHeight / 2), parseInt(screen.availWidth / 4), parseInt(screen.availHeight / 4), "imprimer_"+id_selection);
}

function ajouterPhotoSelection(id_photo, id_selection)
{
    url = "?idPageWeb=77&popUp_selectionner=1&tblIdPhoto[0]="+id_photo+"&ajouterPhotoDsSelection=1&idPageWebParent=77";        
    if (id_selection) url += "&idSelection="+id_selection;
    if (document.frames)
      document.frames['iframe_chargement'].location.replace(url);
    else 
      document.getElementById('iframe_chargement').src = url;
}

function popupTelechargerPhoto(id_photo) {
  url = '/oredia3/kaaWeb/tableLumineuse/telecharger.php?id_photo='+id_photo;
  fct_popUp(url, 310, 110, parseInt(screen.availWidth / 2) - 150, parseInt(screen.availHeight / 2) - 55);    
}

function popupTelechargerSelection(id_selection) {
  url = '/oredia3/kaaWeb/tableLumineuse/telecharger.php?id_selection='+id_selection;
  fct_popUp(url, 310, 110, parseInt(screen.availWidth / 2) - 150, parseInt(screen.availHeight / 2) - 55);
}

function popupImprimerSelection(id_selection) {
  url = '/oredia3/kaaWeb/tableLumineuse/telecharger.php?imprimer=1&id_selection='+id_selection;
  fct_popUp(url, 310, 90, parseInt(screen.availWidth / 2) - 150, parseInt(screen.availHeight / 2) - 45);
}

function rien() {}

