﻿// lightbox webcast GIE FORMA-DIS - auteur : Sébastien Fanger
// affichages photos avec ajax

var lightbox = null;
var masque = null;
var webcastPlayer = null;
var flashObj = null;
var indexXMLList = null;
var cheminDuXML = "App_Themes/Naturadis/WebCast/xml"
var code = null;
var designation = null;

function getLightbox (width,height,lightbox_bckgr,index,typeContains,idPdf)
{
    $j(document).ready(function() {
        indexXMLList = index;

        lightbox = this.createElement("div");
        lightbox.setAttribute("id", "lightbox");
        masque = this.createElement("div");
        masque.setAttribute("id", "masque");
        webcastPlayer = this.createElement("div");
        webcastPlayer.setAttribute("id", "webcastPlayer");

        flashObj = this.createElement("div");
        flashObj.setAttribute("id", "flashObj");
        webcastPlayer.appendChild(flashObj);

        lightbox.appendChild(masque);
        lightbox.appendChild(webcastPlayer);
        webcastPlayer.style.width = width + "px";
        webcastPlayer.style.height = height + "px";
        webcastPlayer.style.marginLeft = "-" + (width / 2) + "px";
        webcastPlayer.style.marginTop = "-" + (height / 2) + "px";

        this.body.appendChild(lightbox);

        $j('#webcastPlayer').css('backgroundColor', lightbox_bckgr.backgroundColor);
        if (lightbox_bckgr.image != null) {
            $j('#webcastPlayer').css(lightbox_bckgr.image);
        }
        // Flash
        if (typeContains == 'flash') {
            $j('#masque').animate({ opacity: 0.75 }, 'slow', addWebcastPlayer);
        }
        else {
            // Pdf             
            $j('#masque').animate({ opacity: 0.75 }, 'slow', addPdf);
            
            // Code Pdf
            code = $j('#' + idPdf).attr("code")
            designation = $j('#' + idPdf).attr("alt")
            
            // créer le Lien Pdf
            $j('#LinkPdf').attr("href", "FrmCor1.aspx?" + code);
                        $j('#LinkPdf').html('<img src="App_Themes/Naturadis/Images/CarNotPdf_P.png"/>' + designation);
        }
    });
}

function addPdf() {
    $j('#webcastPlayer').slideDown('fast', function() {
        flashObj.innerHTML = document.getElementById("InfPdf").innerHTML;
        
        $j('#masque').click(animationDeSortie);
    });
}


function addWebcastPlayer ()
{
	$j('#webcastPlayer').slideDown('fast',function(){
												  
		flashObj.innerHTML = '<p>Vous devez installez ou mettre à jour votre version de Flash PLayer. Javascript doit également être activé. <br />'
    		+ '<a href="http://www.adobe.com/go/FR-H-GET-FLASH">Obtenir la dernière version de Flash Player</a> <br />'
			+ '<a href="http://www.adobe.com/go/FR-H-GET-FLASH"><img src="App_Themes/Naturadis/WebCast/images/get_adobe_flash_player.png" width="158" height="39" alt="" /></a></p>';
			
		var expressInstall = null;
		
		var flashVars = new Object();
		flashVars.indexXMLList = indexXMLList;
		flashVars.fonction = 'animationDeSortie';
		flashVars.chemin = cheminDuXML;
		
		var parametres = new Object();
		
		if (lightbox_bckgr.image == null) {
			parametres.bgcolor = lightbox_bckgr.backgroundColor;
		} else {
			parametres.wmode="transparent";
		}
		
		parametres.allowfullscreen="true";
		parametres.allowscriptaccess="always";
		parametres.scale="noborder";
		
		var attributs = new Object();
		attributs.id = "movie";
		attributs.name = "movie";

		swfobject.embedSWF("Player/webcast_player.swf", "flashObj", "100%", "100%", "9.0.115", expressInstall, flashVars, parametres, attributs);
		$j('#masque').click(animationDeSortie);
	});
}
function animationDeSortie () {
	webcastPlayer.style.display = 'none';
	$j('#masque').fadeOut('slow',removeDIV);
}
function removeDIV ()
{
	lightbox.parentNode.removeChild(lightbox);
}

