var Overlay = new Class({
    getOptions: function(){
        return {
            colour: "#000",
            opacity: 0.8,
            zIndex: 1,
            container: document.body,
            onClick: new Class
        };
    },
    initialize: function(options){
        this.setOptions(this.getOptions(), options);
        this.options.container = $(this.options.container);
        this.container = (new Element("div")).setProperty("id", "OverlayContainer").setStyles({
            position: "absolute",
            left: "0px",
            top: "0px",
            width: "100%",
            visibility: "hidden",
            overflow: "hidden",
            zIndex: this.options.zIndex
        }).inject(this.options.container, "inside");
        this.iframe = (new Element("iframe")).setProperties({
            id: "OverlayIframe",
            name: "OverlayIframe",
            src: "javascript:void(0);",
            frameborder: 1,
            scrolling: "no"
        }).setStyles({
            position: "absolute",
            top: 0,
            left: 0,
            width: "100%",
            height: "100%",
            filter: "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)",
            opacity: 0,
            zIndex: 1
        }).inject(this.container, "inside");
        this.overlay = (new Element("div")).setProperty("id", "Overlay").setStyles({
            position: "absolute",
            left: "0px",
            top: "0px",
            width: "100%",
            height: "100%",
            zIndex: 2,
            backgroundColor: this.options.colour
        }).inject(this.container, "inside");
        this.container.addEvent("click", function(){
            this.options.onClick();
        }
.bind(this));
        this.fade = (new (Fx.Morph)(this.container, "opacity")).set(0);
        this.position();
        window.addEvent("resize", this.position.bind(this));
    },
    position: function(){
        if (this.options.container == document.body) {
            var h = document.getScrollSize().y + "px";
            this.container.setStyles({
                top: "0px",
                height: h
            });
        }
        else {
            var myCoords = this.options.container.getCoordinates();
            this.container.setStyles({
                top: myCoords.top + "px",
                height: myCoords.height + "px",
                left: myCoords.left + "px",
                width: myCoords.width + "px"
            });
        }
    },
    show: function(){
        this.fade.start({
            opacity: [0, this.options.opacity],
            visibility: "visible"
        });
    },
    hide: function(){
        this.fade.start({
            opacity: [0, this.options.opacity],
            visibility: "hidden"
        });
    }
});
Overlay.implement(new Options);
var LightBox = new Class({
    getOptions: function(){
        return {
            initialWidth: 714,
            initialHeight: 421,
            container: document.body,
            containerId: "LightBoxContainer",
            useOverlay: true,
            contentColor: "#FFF",
            showNumbers: true,
            showControls: true,
            waitDuration: 2000,
            descClassName: false,
            descMinWidth: 400,
            descMaxWidth: 600,
            movieWidth: 400,
            movieHeight: 300,
            offset: {
                x: 0,
                y: 0
            },
            fixedTop: false,
            path: "files/",
            onOpen: new Class,
            onClose: new Class,
            openFromLink: true,
            relativeToWindow: true,
            customOptions: new Array()
        };
    },
    initialize: function(className, options){
		this.className = className;
        this.setOptions(this.getOptions(), options);
        this.openClosePos = {};
        this.timer = 0;
        this.contentToLoad = {};
        this.index = 0;
        this.opened = false;
        this.contentObj = {};
        this.containerDefaults = {};
        this.controlsContainerDefaults = {};
        if (this.options.useOverlay) {
            this.overlay = new Overlay({
                container: this.options.container,
                onClick: this.close.bind(this),
				colour: this.options.colour || "#000"
            });
        }
        this.content = $$("." + className);
        if (this.options.descClassName) {
            this.descriptions = $$("." + this.options.descClassName);
            this.descriptions.each(function(el){
                el.setStyle("display", "none");
            });
        }
        this.container = (new Element("div", {id: this.options.containerId || "LightBoxContainer"})).addClass("LightBoxContainer").inject(this.options.container, "inside");
        this.iframe = (new Element("iframe")).setProperties({
            id: "LightBoxIframe",
            name: "lightBoxIframe",
            src: "javascript:void(0);",
            frameborder: 1,
            scrolling: "no"
        }).setStyles({
            position: "absolute",
            top: -20,
            left: -20,
            width: "115%",
            height: "115%",
            filter: "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)",
            opacity: 0
        }).injectInside(this.container);
        this.box = (new Element("div")).addClass("LightBoxContent").inject(this.container, "inside");
        this.closeButton = (new Element("div")).addClass("LightBoxClose").injectInside(this.container).addEvent("click", this.close.bind(this));
        this.closeText = (new Element("div")).addClass("LightBoxCloseText").injectInside(this.container).addEvent("click", this.close.bind(this));
        this.icon = (new Element("div", {id: "LightBoxIcon"})).addClass("LightBoxIcon").injectInside(this.container);
        this.controlsContainer = (new Element("div")).addClass("LightBoxControlsContainer").inject(this.container, "inside");
        this.controls = (new Element("div")).addClass("LightBoxControls").inject(this.controlsContainer, "inside");
        this.previousButton = (new Element("div")).addClass("LightBoxPrevious").inject(this.controls, "inside").addEvent("click", this.previous.bind(this));
        this.nextButton = (new Element("div")).addClass("LightBoxNext").inject(this.controls, "inside").addEvent("click", this.next.bind(this));
        this.title = (new Element("div")).addClass("LightBoxTitle").inject(this.controls, "inside");
        this.number = (new Element("div")).addClass("LightBoxNumber").inject(this.controls, "inside");
        this.description = (new Element("div")).addClass("LightBoxDescription").inject(this.controls, "inside");
        if (this.content.length == 1) {
            this.title.setStyles({
                'margin-left': 0
            });
            this.description.setStyles({
                'margin-left': 0
            });
            this.previousButton.setStyle("display", "none");
            this.nextButton.setStyle("display", "none");
            this.number.setStyle("display", "none");
        }
        (new Element("div")).setStyle("clear", "both").inject(this.controls, "inside");
        this.content.each(function(el, i){
            el.index = i;
            el.addEvent("click", function(e){
                (new Event(e)).stop();
                this.open(el);
            }
.bind(this));
            if (el.href.indexOf("#") > -1) {
                el.content = $(el.href.substr(el.href.indexOf("#") + 1));
                if (el.content) {
                    el.content.setStyle("display", "none");
                }
            }
        }, this);
        this.containerEffects = new (Fx.Morph)(this.container, {
            duration: 400
        });
        this.controlEffects = new (Fx.Morph)(this.controlsContainer, {
            duration: 300
        });
        this.reset();
    },
    setContentType: function(link){
        var str = link.href.substr(link.href.lastIndexOf(".") + 1).toLowerCase();
        var contentOptions = {};
        if ($chk(link.rel)) {
            var optArr = link.rel.split(",");
            optArr.each(function(el){
                var ta = el.split(":");
                contentOptions[ta[0]] = ta[1];
            });
        }
        if (contentOptions.type != undefined) {
            str = contentOptions.type;
        }
        this.contentObj = {};
        this.contentObj.url = link.href;
        this.contentObj.xH = 0;
        if (contentOptions.width) {
            this.contentObj.width = contentOptions.width;
        }
        else {
            this.contentObj.width = this.options.movieWidth;
        }
        if (contentOptions.height) {
            this.contentObj.height = contentOptions.height;
        }
        else {
            this.contentObj.height = this.options.movieHeight;
        }
        if (contentOptions.panel) {
            this.panelPosition = contentOptions.panel;
        }
        else {
            this.panelPosition = this.options.panel;
        }
        switch (str) {
            case "jpg":
            case "gif":
            case "png":
                this.type = "image";
                break;
            case "swf":
                this.type = "flash";
                break;
            case "flv":
                this.type = "flashVideo";
                this.contentObj.xH = 70;
                break;
            case "mov":
                this.type = "quicktime";
                break;
            case "wmv":
                this.type = "windowsMedia";
                break;
            case "rv":
            case "rm":
            case "rmvb":
                this.type = "real";
                break;
            case "mp3":
                this.type = "flashMp3";
                this.contentObj.width = 320;
                this.contentObj.height = 70;
                break;
            case "element":
                this.type = "htmlelement";
                this.elementContent = link.content;
                this.elementContent.setStyles({
                    display: "block",
                    opacity: 0
                });
                if (this.elementContent.getStyle("width") != "auto") {
                    this.contentObj.width = this.elementContent.getStyle("width");
                }
                this.contentObj.height = this.elementContent.getSize().y;
                this.elementContent.setStyles({
                    display: "none",
                    opacity: 1
                });
                break;
            default:
                this.type = "iframe";
                if (contentOptions.ajax) {
                    this.type = "ajax";
                }
		        if (!$chk(link.rel)) {
		            this.contentObj.width = this.options.initialWidth;
		            this.contentObj.height = this.options.initialHeight;
		        }
                break;
        }
    },
    getContentType: function(link){
        var str = link.href.substr(link.href.lastIndexOf(".") + 1).toLowerCase();
        var contentOptions = {};
        if ($chk(link.rel)) {
            var optArr = link.rel.split(",");
            optArr.each(function(el){
                var ta = el.split(":");
                contentOptions[ta[0]] = ta[1];
            });
        }
        if (contentOptions.type != undefined) {
            str = contentOptions.type;
        }
        switch (str) {
            case "jpg":
            case "gif":
            case "png":
                return "image";
                break;
            case "swf":
                return "flash";
                break;
            case "flv":
                return "flashVideo";
                break;
            case "mov":
                return "quicktime";
                break;
            case "wmv":
                return "windowsMedia";
                break;
            case "rv":
            case "rm":
            case "rmvb":
                return "real";
                break;
            case "mp3":
                return "flashMp3";
                break;
            case "element":
                return "htmlelement";
                break;
            default:
                if (contentOptions.ajax) {
                    return "ajax";
                }
                return "iframe";
                break;
        }
    },
    reset: function(){
        this.container.setStyles({
            opacity: 0,
            display: "none"
        });
        this.controlsContainer.setStyles({
            height: 0
        });
        this.removeContent();
        this.previousButton.removeClass("LightBoxButtonDisabled");
        this.nextButton.removeClass("LightBoxButtonDisabled");
        this.opened = false;
		if(this.options.customOptions.from == 'link'){
			this.options.openFromLink = true;
		}
    },
    getOpenClosePos: function(el){
        if (this.options.openFromLink) {
            if (el.getFirst()) {
                var w = el.getFirst().getCoordinates().width - this.container.getStyle("border").toInt() * 2;
                if (w < 0) {
                    w = 0;
                }
                var h = el.getFirst().getCoordinates().height - this.container.getStyle("border").toInt() * 2;
                if (h < 0) {
                    h = 0;
                }
                this.openClosePos = {
                    width: w,
                    height: h,
                    top: el.getFirst().getCoordinates().top,
                    left: el.getFirst().getCoordinates().left
                };
            }
            else {
                var w = el.getCoordinates().width - this.container.getStyle("border").toInt() * 2;
                if (w < 0) {
                    w = 0;
                }
                var h = el.getCoordinates().height - this.container.getStyle("border").toInt() * 2;
                if (h < 0) {
                    h = 0;
                }
                this.openClosePos = {
                    width: w,
                    height: h,
                    top: el.getCoordinates().top,
                    left: el.getCoordinates().left
                };
            }
        }
        else {
            if (this.options.fixedTop) {
                var top = this.options.fixedTop;
            }
            else {
                var top = ((window.getHeight() / 2) - this.options.initialHeight / 2 - this.container.getStyle("border").toInt()) + this.options.offset.y;
            }
            this.openClosePos = {
                width: this.options.initialWidth,
                height: this.options.initialHeight,
                top: top,
                left: ((window.getWidth() / 2) - this.options.initialWidth / 2 - this.container.getStyle("border").toInt()) + this.options.offset.x
            };
        }
        return this.openClosePos;
    },
    open: function(el){
        if ($chk(el.rev)) {
            var optArr = el.rev.split(",");
            optArr.each(function(el){
                var ta = el.split(":");
                this.options.customOptions[ta[0]] = ta[1];
            }.bind(this));
        }
        this.index = this.content.indexOf(el);
        this.openId = el.getProperty("id");
        this.openIsAsync = el.hasClass("aSync");
        if (!this.opened) {
            this.opened = true;
            if (this.options.useOverlay) {
                this.overlay.show();
            }
            this.container.setStyles(this.getOpenClosePos(el));
            this.container.setStyles({
                opacity: 0,
                display: "block"
            });
            if (this.options.fixedTop) {
                var top = this.options.fixedTop;
            }
            else {
                var top = ((window.getHeight() / 2) - this.options.initialHeight / 2 - this.container.getStyle("border").toInt()) + this.options.offset.y;
            }
            this.containerEffects.start({
                width: this.options.initialWidth,
                height: this.options.initialHeight,
                top: top,
                left: ((window.getWidth() / 2) - this.options.initialWidth / 2 - this.container.getStyle("border").toInt()) + this.options.offset.x,
                opacity: [0, 1]
            });
			if(this.options.customOptions.hide == 'controls'){
				this.hideControlsContainer();
			}
			else{
				this.showControlsContainer();
			}
			if(this.options.customOptions.from == 'link'){
				this.options.openFromLink = true;
			}
            this.load(this.index);
        }
        else {
            if (this.options.showControls) {
                this.hideControls();
            }
            this.getOpenClosePos(this.content[this.index]);
            this.timer = this.hideContent.bind(this).delay(500);
            this.timer = this.load.pass(this.index, this).delay(1100);
        }
    },
    getContent: function(index){
        this.setContentType(this.content[index]);
        var desc = {};
        if (this.options.descClassName) {
            this.descriptions.each(function(el, i){
                if (el.hasClass(this.openId)) {
                    desc = el.clone();
                }
            }, this);
        }
        this.contentToLoad = {
            title: this.content[index].title || "&nbsp;",
            desc: desc,
            number: index + 1
        };
    },
    close: function(){
        if (this.options.useOverlay) {
            this.overlay.hide();
        }
        if (this.options.showControls) {
            this.hideControls();
        }
        this.hideContent();
        this.containerEffects.cancel();
        this.zoomOut.bind(this).delay(500);
		if(this.options.customOptions.from == 'link'){
			this.options.openFromLink = true;
		}
        this.options.onClose();
    },
    zoomOut: function(){
        this.containerEffects.start({
            width: this.openClosePos.width,
            height: this.openClosePos.height,
            top: this.openClosePos.top,
            left: this.openClosePos.left,
            opacity: 0
        });
        this.reset.bind(this).delay(500);
    },
    load: function(index){
        this.box.addClass("LightBoxLoading");
        this.getContent(index);
        if (this.type == "image") {
            var xH = this.contentObj.xH;
            this.contentObj = new (Asset.image)(this.content[index].href, {
                onload: this.resize.bind(this)
            });
            this.contentObj.xH = xH;
        }
        else {
            this.resize();
        }
    },
    resize: function(){
        if (this.options.fixedTop) {
            var top = this.options.fixedTop;
        }
        else {
            var top = ((window.getHeight() / 2) - (Number(this.contentObj.height) + this.contentObj.xH) / 2 - this.container.getStyle("border").toInt() + window.getScrollTop()) + this.options.offset.y;
        }
        var left = ((window.getWidth() / 2) - this.contentObj.width / 2 - this.container.getStyle("border").toInt()) + this.options.offset.x;
        if (top < 0) {
            top = 0;
        }
        if (left < 0) {
            left = 0;
        }
        this.containerEffects.cancel();
        this.containerEffects.start({
            width: this.contentObj.width,
            height: Number(this.contentObj.height) + this.contentObj.xH,
            top: top,
            left: left,
            opacity: 1
        });
        this.timer = this.showContent.bind(this).delay(500);
    },
    showContent: function(){
        this.box.removeClass("LightBoxLoading");
        this.removeContent();
        this.contentContainer = (new Element("div")).setProperties({
            id: "LightBoxContentContainer"
        }).setStyles({
            opacity: 0,
            width: this.contentObj.width + "px",
            height: (Number(this.contentObj.height) + this.contentObj.xH) + "px"
        }).inject(this.box, "inside");
        if (this.type == "image") {
            this.contentObj.inject(this.contentContainer, "inside");
        }
        else 
            if (this.type == "iframe") {
                (new Element("iframe")).setProperties({
                    id: "iFrame" + (new Date).getTime(),
                    width: this.contentObj.width,
                    height: this.contentObj.height,
                    src: this.contentObj.url,
                    frameborder: 0,
                    scrolling: "auto"
                }).inject(this.contentContainer, "inside");
            }
            else 
                if (this.type == "htmlelement") {
                    this.elementContent.clone().setStyle("display", "block").inject(this.contentContainer, "inside");
                }
                else 
                    if (this.type == "ajax" && this.openIsAsync) {
						$each(this.content, function(el, i){
							//if (el.hasClass('aSync') && this.openId == 'aSync-' + i) {
							if (el.hasClass('aSync') && this.openId == el.get('id')) {
								(new Request.HTML({
									url: this.contentObj.url,
									data: el.getParent('form').toQueryString() + '&comingFrom=ajax',
									onSuccess: function(html){
										$("LightBoxContentContainer").adopt(html);
									},
									evalScripts: true,
									autoCancel: true
								})).send();
							}
						}.bind(this))
                    }
                    else {
                        var obj = this.createEmbedObject().inject(this.contentContainer, "inside");
                        if (this.str != "") {
                            $("LightBoxMediaObject").innerHTML = this.str;
                        }
                    }
        this.contentEffects = new (Fx.Morph)(this.contentContainer, {
            duration: 500
        });
        this.contentEffects.start({
            opacity: 1
        });
        this.title.set("html", this.contentToLoad.title);
        this.number.set("html", this.contentToLoad.number + " of " + this.content.length);
        if (this.options.descClassName) {
            if (this.description.getFirst()) {
                this.description.getFirst().destroy();
            }
            this.contentToLoad.desc.inject(this.description, "inside").setStyles({
                display: "block"
            });
        }
        if (this.options.showControls) {
            this.timer = this.showControls.bind(this).delay(800);
        }
    },
    hideContent: function(){
        this.box.addClass("LightBoxLoading");
        this.contentEffects.start({
            opacity: 0
        });
        this.removeContent.bind(this).delay(500);
    },
    removeContent: function(){
        if ($("LightBoxMediaObject")) {
            $("LightBoxMediaObject").destroy();
        }
        if ($("LightBoxContentContainer")) {
            $("LightBoxContentContainer").destroy();
        }
    },
    showControls: function(){
        this.clicked = false;
        if (this.container.getStyle("height") != "auto") {
            this.containerDefaults.height = this.container.getStyle("height");
            this.containerDefaults.backgroundColor = this.options.contentColor;
        }
        this.container.setStyles({
            height: "auto"
        });
        if (this.contentToLoad.number == 1 || ($chk(this.content[this.contentToLoad.number-2]) && this.getContentType(this.content[this.contentToLoad.number-2]) != this.type)) {
            this.previousButton.addClass("LightBoxPreviousDisabled");
			if (($chk(this.content[this.contentToLoad.number - 2]) && this.getContentType(this.content[this.contentToLoad.number - 2]) != this.type)) {
				this.previousButton.addClass("hidden");
			}
        }
        else {
            this.previousButton.removeClass("LightBoxPreviousDisabled");
			this.previousButton.removeClass("hidden");
        }
        if (this.contentToLoad.number == this.content.length || ($chk(this.content[this.contentToLoad.number]) && this.getContentType(this.content[this.contentToLoad.number]) != this.type)) {
            this.nextButton.addClass("LightBoxNextDisabled");
			if (($chk(this.content[this.contentToLoad.number]) && this.getContentType(this.content[this.contentToLoad.number]) != this.type)) {
				this.nextButton.addClass("hidden");
			}
        }
        else {
            this.nextButton.removeClass("LightBoxNextDisabled");
            this.nextButton.removeClass("hidden");
        }
        this.controlEffects.start({
            height: this.controls.getStyle("height")
        });
    },
    hideControls: function(num){
        this.controlEffects.start({
            height: 0
        }).chain(function(){
            this.container.setStyles(this.containerDefaults);
    }
.bind(this));
    },
    showThumbnails: function(){
    },
    next: function(){
        if (this.index < this.content.length - 1) {
            this.index++;
            this.openId = this.content[this.index].getProperty("id");
            if (this.options.showControls) {
                this.hideControls();
            }
            this.getOpenClosePos(this.content[this.index]);
            this.timer = this.hideContent.bind(this).delay(500);
            this.timer = this.load.pass(this.index, this).delay(1100);
        }
    },
    previous: function(){
        if (this.index > 0) {
            this.index--;
            this.openId = this.content[this.index].getProperty("id");
            if (this.options.showControls) {
                this.hideControls();
            }
            this.getOpenClosePos(this.content[this.index]);
            this.timer = this.hideContent.bind(this).delay(500);
            this.timer = this.load.pass(this.index, this).delay(1000);
        }
    },
    createEmbedObject: function(){
        if (this.type == "flash") {
            var url = this.contentObj.url;
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + this.contentObj.height + "\" ";
            this.str += "title=\"LightBoxMedia\">";
            this.str += "<param name=\"movie\" value=\"" + url + "\" />";
            this.str += "<param name=\"quality\" value=\"high\" />";
            this.str += "<embed src=\"" + url + "\" ";
            this.str += "quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + this.contentObj.height + "\"></embed>";
            this.str += "</object>";
        }
        if (this.type == "flashVideo") {
            var url = this.contentObj.url;
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + (Number(this.contentObj.height) + this.contentObj.xH) + "\" ";
            this.str += "title=\"LightBoxMedia\">";
            this.str += "<param name=\"movie\" value=\"" + this.options.path + "flvplayer.swf\" />";
            this.str += "<param name=\"quality\" value=\"high\" />";
            this.str += "<param name=\"salign\" value=\"TL\" />";
            this.str += "<param name=\"scale\" value=\"noScale\" />";
            this.str += "<param name=\"FlashVars\" value=\"path=" + url + "\" />";
            this.str += "<embed src=\"" + this.options.path + "flvplayer.swf\" ";
            this.str += "quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + (Number(this.contentObj.height) + this.contentObj.xH) + "\"";
            this.str += "salign=\"TL\" ";
            this.str += "scale=\"noScale\" ";
            this.str += "FlashVars=\"path=" + url + "\"";
            this.str += "></embed>";
            this.str += "</object>";
        }
        if (this.type == "flashMp3") {
            var url = this.contentObj.url;
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + this.contentObj.height + "\" ";
            this.str += "title=\"LightBoxMedia\">";
            this.str += "<param name=\"movie\" value=\"" + this.options.path + "mp3player.swf\" />";
            this.str += "<param name=\"quality\" value=\"high\" />";
            this.str += "<param name=\"salign\" value=\"TL\" />";
            this.str += "<param name=\"scale\" value=\"noScale\" />";
            this.str += "<param name=\"FlashVars\" value=\"path=" + url + "\" />";
            this.str += "<embed src=\"" + this.options.path + "mp3player.swf\" ";
            this.str += "quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" ";
            this.str += "width=\"" + this.contentObj.width + "\" ";
            this.str += "height=\"" + this.contentObj.height + "\"";
            this.str += "salign=\"TL\" ";
            this.str += "scale=\"noScale\" ";
            this.str += "FlashVars=\"path=" + url + "\"";
            this.str += "></embed>";
            this.str += "</object>";
        }
        if (this.type == "quicktime") {
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object type=\"video/quicktime\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"";
            this.str += " width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\">";
            this.str += "<param name=\"src\" value=\"" + this.contentObj.url + "\" />";
            this.str += "<param name=\"autoplay\" value=\"true\" />";
            this.str += "<param name=\"controller\" value=\"true\" />";
            this.str += "<param name=\"enablejavascript\" value=\"true\" />";
            this.str += "<embed src=\"" + this.contentObj.url + "\" autoplay=\"true\" pluginspage=\"http://www.apple.com/quicktime/download/\" width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\"></embed>";
            this.str += "<object/>";
        }
        if (this.type == "windowsMedia") {
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object type=\"application/x-oleobject\" classid=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\"";
            this.str += " width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\">";
            this.str += "<param name=\"filename\" value=\"" + this.contentObj.url + "\" />";
            this.str += "<param name=\"Showcontrols\" value=\"true\" />";
            this.str += "<param name=\"autoStart\" value=\"true\" />";
            this.str += "<embed type=\"application/x-mplayer2\" src=\"" + this.contentObj.url + "\" Showcontrols=\"true\" autoStart=\"true\" width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\"></embed>";
            this.str += "<object/>";
        }
        if (this.type == "real") {
            var obj = (new Element("div")).setProperties({
                id: "LightBoxMediaObject"
            });
            this.str = "<object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\"";
            this.str += " width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\">";
            this.str += "<param name=\"src\" value=\"" + this.contentObj.url + "\" />";
            this.str += "<param name=\"controls\" value=\"ImageWindow\" />";
            this.str += "<param name=\"autostart\" value=\"true\" />";
            this.str += "<embed src=\"" + this.contentObj.url + "\" controls=\"ImageWindow\" autostart=\"true\" width=\"" + this.contentObj.width + "\" height=\"" + this.contentObj.height + "\"></embed>";
            this.str += "<object/>";
        }
        return obj;
    },
	setContainerBg: function(newBg, newIconBg){
		this.containerBg = this.container.getStyle('background-image');
		this.iconBg = this.icon.getStyle('background-image');
		this.container.setStyle('background-image', 'url(/images/commun/popup/' + newBg + '.png)');
		this.icon.setStyle('background-image', 'url(/images/commun/popup/' + newIconBg + '.png)');
		this.options.onClose = function(){
			this.resetContainerBg.bind(this).delay(1000);
		}.bind(this)
	},
	resetContainerBg: function(){
		this.container.setStyle('background-image', this.containerBg);
		this.icon.setStyle('background-image', this.iconBg);
		this.title.set('class', 'LightBoxTitle');
	},
	setContainerId: function(newId){
		this.containerId = this.container.get('id');
		this.container.set('id', newId);
		this.options.onClose = function(){
			this.resetContainerId.bind(this).delay(1000);
		}.bind(this)
	},
	resetContainerId: function(){
		this.container.set('id', this.containerId);
	},
	setIconBg: function(newIconBg){
		//on a besoin d'avoir l'id du body pour toutes les icones sauf pour le quizz
		newIconBgPrefix = document.body.id + '-';
		if(newIconBg == 'goToQuizzIcon'){
			newIconBgPrefix = '';
		}
		this.icon.setStyle('background-image', 'url(/images/commun/popup/' + newIconBgPrefix + newIconBg + '.png)');
	},
    showControlsContainer: function(){
        this.controlsContainer.set('style', 'display: block;');
    },
    hideControlsContainer: function(){
        this.controlsContainer.set('style', 'display: none;');
    }
});
LightBox.implement(new Options);
LightBox.implement(new Events);

