/**
Fonction myLightBox()
Permet d'ouvrir une URL distante dans un fenetre type LightBox
*/
 
// Paramètrage :
var lightBoxDivId = 'lightBoxDiv';
var lightBoxDivposition = 'absolute';
var lightBoxDivZindex = 5000;
var largeur = screen.width;
var lightBoxDivTop = 100;
var lightBoxDivLeft = 200;
//var lightBoxDivWidth = '650px';
//var lightBoxDivHeight = '650px';
var lightBoxDivIframeWidth = 850;
var lightBoxDivIframeHeight = 200;
var lightBoxDivBorder = '0px red solid';
var lightBoxDivIframeBorder = '2px #D7D7D7 solid';
 
function actu_iframe(){
    var ifr = document.getElementById("id_iframe");
    if(ifr){
	     if (document.all){
	    	if(ifr.Document.body.scrollHeight < 200){
	    		ifr.style.height = 200+"px";
	    	}else{
	    		ifr.style.height = ifr.Document.body.scrollHeight+"px";
	    	}
	    }else{
	    	if(ifr.contentDocument.body.scrollHeight < 200){
	    		ifr.style.height = 200+"px";
	    	}else{
	    		ifr.style.height = ifr.contentDocument.body.scrollHeight+"px";
	    	}
	    }
    }
}
// Ouverture du layer par rapport a la souris:
function myLightBox(evt, myUrl,ImageFront){
 	
	// Position de la souris (IE/FF) :
	var e = (window.event) ? window.event : evt; 
 
	// Récupération du DIV :
	$myLightBoxDiv = document.getElementById(lightBoxDivId);
 
	// Positionnement du DIV :
	$myLightBoxDiv.style.position = lightBoxDivposition;
	$myLightBoxDiv.style.zIndex = lightBoxDivZindex;
	if(largeur == 1024){
		lightBoxDivLeft = 50;
	}
	$myLightBoxDiv.style.left =  Math.round(lightBoxDivLeft) + "px";
	$myLightBoxDiv.style.top =  Math.round(lightBoxDivTop) + "px";
	/*$myLightBoxDiv.style.left =  Math.round(e.clientX + document.body.scrollLeft-50) + "px";
	//alert(e.clientY + document.body.scrollTop);
	if(e.clientY + document.body.scrollTop > 500){
		$myLightBoxDiv.style.top = Math.round(e.clientY + document.body.scrollTop-450) + "px";
	}else{
		$myLightBoxDiv.style.top = Math.round(e.clientY + document.body.scrollTop-150) + "px";
	}*/
 
 
	// Taille + Style du DIV :
	$myLightBoxDiv.style.border = lightBoxDivBorder;
 
 
	// Insertion de l'iframe + Récupération du contenu :
	$myLightBoxDiv.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td height=\"42\" align=\"right\"><img style=\"cursor:pointer;\" src=\""+ImageFront+"/close_layer.gif\" onclick=\"javascript:ClosePlayer();closemyLightBox();\"></td></tr><tr><td style=\"border:"+lightBoxDivIframeBorder+";\"><iframe name=\"name_iframe\" id=\"id_iframe\" onLoad=\"javascript:actu_iframe();\" frameborder=\"0\" src=\""+myUrl+"\" width=\""+lightBoxDivIframeWidth+"\"  height=\""+lightBoxDivIframeHeight+"\"></iframe></td></tr></table>";
 
	// Affichage :
	$myLightBoxDiv.style.display = 'block';
 
	// Sortie (pour empecher le lien href)
	return false;
}

function myLightBoxDecodeur(evt, myUrl,ImageFront, ZoneTemplateId){
 	
	// Position de la souris (IE/FF) :
	var e = (window.event) ? window.event : evt; 
 
	// Récupération du DIV :
	$myLightBoxDiv = document.getElementById(lightBoxDivId);
 
	// Positionnement du DIV :
	$myLightBoxDiv.style.position = lightBoxDivposition;
	$myLightBoxDiv.style.zIndex = lightBoxDivZindex;
	if(largeur == 1024){
		lightBoxDivLeft = 50;
	}
	$myLightBoxDiv.style.left =  Math.round(lightBoxDivLeft) + "px";
	$myLightBoxDiv.style.top =  Math.round(lightBoxDivTop) + "px";
	/*$myLightBoxDiv.style.left =  Math.round(e.clientX + document.body.scrollLeft-50) + "px";
	//alert(e.clientY + document.body.scrollTop);
	if(e.clientY + document.body.scrollTop > 500){
		$myLightBoxDiv.style.top = Math.round(e.clientY + document.body.scrollTop-450) + "px";
	}else{
		$myLightBoxDiv.style.top = Math.round(e.clientY + document.body.scrollTop-150) + "px";
	}*/
 
 
	// Taille + Style du DIV :
	$myLightBoxDiv.style.border = lightBoxDivBorder;
 
 
	// Insertion de l'iframe + Récupération du contenu :
	$myLightBoxDiv.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td height=\"42\" align=\"right\"><img style=\"cursor:pointer;\" src=\""+ImageFront+"/close_layer.gif\" onclick=\"javascript:ClosePlayer();closemyLightBox();\"></td></tr><tr><td style=\"border:"+lightBoxDivIframeBorder+";\"><iframe name=\"name_iframe\" id=\"id_iframe\" onLoad=\"javascript:actu_iframe();\" frameborder=\"0\" src=\""+myUrl+"&bic="+ZoneTemplateId+"\" width=\""+lightBoxDivIframeWidth+"\"  height=\""+lightBoxDivIframeHeight+"\" scrolling=\"no\" ></iframe></td></tr></table>";
 
	// Affichage :
	$myLightBoxDiv.style.display = 'block';
 
	// Sortie (pour empecher le lien href)
	return false;
}
 
// Ouverture du layer sans action de souris :
function myLightBoxNoEvent(myUrl,ImageFront){
 
	// Récupération du DIV :
	$myLightBoxDiv = document.getElementById(lightBoxDivId);
 
	// Positionnement du DIV :
	$myLightBoxDiv.style.position = lightBoxDivposition;
	$myLightBoxDiv.style.zIndex = lightBoxDivZindex;
 
	// Taille + Style du DIV :
	$myLightBoxDiv.style.border = lightBoxDivBorder;
 
 
	// Insertion de l'iframe + Récupération du contenu :
	$myLightBoxDiv.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td height=\"42\" align=\"right\"><img style=\"cursor:pointer;\" src=\""+ImageFront+"/close_layer.gif\" onclick=\"javascript:ClosePlayer();closemyLightBox();\"></td></tr><tr><td align=\"center\" style=\"border:"+lightBoxDivIframeBorder+";\" width=\""+lightBoxDivIframeWidth+"\"  height=\""+lightBoxDivIframeHeight+"\"><iframe name=\"name_iframe\" id=\"id_iframe\" onLoad=\"javascript:actu_iframe();\" frameborder=\"0\" src=\""+myUrl+"\" width=\""+lightBoxDivIframeWidth+"\"  height=\""+lightBoxDivIframeHeight+"\"></iframe></td></tr></table>";
 
	// Affichage :
	$myLightBoxDiv.style.display = 'block';
 
	// Sortie (pour empecher le lien href)
	return false;
}
 
// Fermeture du layer :
function closemyLightBox(){
	// Récupération du DIV :
	$myLightBoxDiv = document.getElementById(lightBoxDivId);
	// Masquage :
	$myLightBoxDiv.style.display = 'none';
}
 
// Positionnement manuel du layer :
function locateMyLightBox(theTop, theLeft){
 
	// Récupération du DIV :
	$myLightBoxDiv.style.left =  Math.round(theLeft) + "px";
	$myLightBoxDiv.style.top = Math.round(theTop) + "px";
}
function ClosePlayer(){
 
	window.parent.document.getElementById("id_iframe").src="";
 
 
}
