var lb_Version='1.05'



var ShowContainer = null;
var curIndex = 0;
var arrImages;
var CancelFadeOut = 0;
var CancelFadeIn = 0;
var ResizeFunc;

var ImageDiv1 = null;
var ImageDiv2 = null;
var NextBtnDiv = null;
var PrevBtnDiv = null;

var PlayerFLV = null;
var PlayerDivFLV = null;
var DoPosFixed = false;
var nCallCounter = 0;
var lastImageNode = 0;

var ImageLeft = null;
var ImageRight = null;
var ImageLoading = null;

function loadjscssfile(filename, filetype) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}


// StudioLine Javascript Library
var TipContainer = null;
var ParentContainer = null;
var CurrentTippID = '';

function getActiveScriptPath() {
    var t = document.getElementsByTagName("script");
    for (cbI = 0; cbI < t.length; cbI++) {
        if (t[cbI].src.indexOf("lb.js") > -1)
            return (t[cbI].src.substr(0, t[cbI].src.indexOf("lb.js")));
    }
    return t[t.length - 1];
}

function InitLightBox(PosFixed) {
    DoPosFixed = PosFixed;
}

var inter_ChangeDelayedTipSource = 0;

function DelayedTipSource(theOwner,srcImg,TipContainer) {
    var d = new Date();
    var lastmod = d.getTime();
    delete d;
    if(inter_ChangeDelayedTipSource)
        clearInterval(inter_ChangeDelayedTipSource);
    inter_ChangeDelayedTipSource = 0;
    if (inter_ChangeDelayedTipSource == 0) {
        inter_ChangeDelayedTipSource = setInterval(function() {
            var dComp = new Date();
            var check = dComp.getTime();
            if (lastmod + 300 < check) {
                theOwner.src = srcImg;
                clearInterval(inter_ChangeDelayedTipSource);
                inter_ChangeDelayedTipSource = 0;
                TipContainer.style.visibility = "visible";

            }
            delete dComp;

        }, 300);
    }
}

function ShowTipp(PicSrc, parent, textTop, textBottom, ImgWidth, ImgHeight) {
    //    TipContainer = document.getElementById("PopUpBox");
    HideTipp();
	
	CurrentTippID = parent + '_tipp';
    ParentContainer = document.getElementById(parent);
    TipContainer = document.createElement("div");
    var ThumbWidth = 200;
    var ThumbHeight = 200;
    var ImageNode = document.createElement('img');
    var ImageDiv = document.createElement("div");
    var TopTextDiv = document.createElement("div");
    var bottomTextDiv = document.createElement("div");
	ImageNode.id = CurrentTippID;
	
	TipContainer.style.position = "absolute";
	TipContainer.style.top = "0px";
	TipContainer.style.left = "0px";
	TipContainer.style.border = "0px solid #101010";
	TipContainer.style.visibility = "hidden";
	TipContainer.style.zIndex = 80000;
	ImageDiv.style.visibility = "hidden";
	ImageDiv.style.overflow = "hidden";
	ImageDiv.style.width = "0px";
	ImageDiv.style.height = "0px";
    TipContainer.appendChild(TopTextDiv);
    TipContainer.appendChild(bottomTextDiv);
    ImageDiv.appendChild(ImageNode);
    TipContainer.appendChild(ImageDiv);
    document.body.appendChild(TipContainer);
	
    ImageNode.onload = function() {
		if (ParentContainer == null)
			return;
		if (ImageNode && ImageNode.id != CurrentTippID)
			return;

		ImageDiv.style.overflow = "visible";
		
        var ImgWidth = ImageNode.width;
        var ImgHeight = ImageNode.height;
        with (ImageNode) {

            var nThumbSize = 300;
            var Scaling = nThumbSize / Math.max(ImgHeight, ImgWidth);

            var ThumbWidth = Math.round(ImgWidth * Scaling);
            var ThumbHeight = Math.round(ImgHeight * Scaling);
            setAttribute('width', ThumbWidth);
            setAttribute('height', ThumbHeight);
        }

        ImageDiv.style.position = "absolute";
        ImageDiv.style.top = 5 + "px";
        ImageDiv.style.left = 7 + "px";
        ImageDiv.style.width = ThumbWidth + "px";
        ImageDiv.style.height = ThumbHeight + "px";
        ImageDiv.style.border = "2px solid white";
        ImageDiv.style.visibility = "visible";

        bottomTextDiv.style.position = "absolute";
        bottomTextDiv.style.top = 5 + ThumbHeight + 10 + "px";
        bottomTextDiv.style.left = 7 + "px";
        bottomTextDiv.style.width = ThumbWidth + "px";
        bottomTextDiv.style.font = "small Arial";
        bottomTextDiv.style.padding = "0px";
        bottomTextDiv.style.margin = "1px";
        bottomTextDiv.style.textAlign = "left";
        bottomTextDiv.style.fontSize = "12px";
        bottomTextDiv.style.color = "white";
        //    bottomTextDiv.style.height = ThumbHeight + "px";
        if (textBottom != undefined) {
            var Html = '<p>' +
    			    textBottom + '</p>';
            bottomTextDiv.innerHTML = Html;
        }
        var nWidth;
        var nHeight;
		if (typeof window.innerWidth != 'undefined') {
			nWidth = window.innerWidth - 10;
			nHeight = window.innerHeight;
		}
		else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
			nWidth = document.documentElement.clientWidth;
			nHeight = document.documentElement.clientHeight;
		}
		else {
			nWidth = document.getElementsByTagName('body')[0].clientWidth;
			nHeight = document.getElementsByTagName('body')[0].clientHeight;
		}

        var nTop = -10;
        var nLeft = 10;
		if (ParentContainer)
		{
			var OffsetContainer = ParentContainer;
			while (OffsetContainer) {
				nTop += OffsetContainer.offsetTop;
				nLeft += OffsetContainer.offsetLeft;
				OffsetContainer = OffsetContainer.offsetParent;
			}

			nLeft += ParentContainer.clientWidth;
			if (nLeft + ThumbWidth + 50 > nWidth) {
				nLeft -= ParentContainer.clientWidth + 10;
				nLeft -= ThumbWidth + 50;
			}
		}

		var nElementHeight = ThumbHeight + 30 + bottomTextDiv.scrollHeight;
        if (nTop + nElementHeight > nHeight -5)
            nTop = nHeight - nElementHeight -5;
        if (nTop < 0)
            nTop = 0;
        if (nTop == NaN)
            nTop = 0;
        if (nLeft < 0)
            nLeft = 0;
        if (nLeft == NaN)
            nTop = 0;

		if (TipContainer)
		{
			TipContainer.style.top = nTop + "px";
			TipContainer.style.left = nLeft + "px";
			TipContainer.style.width = ThumbWidth + 14 + 8 + "px";
			TipContainer.style.height = nElementHeight + "px";
			TipContainer.style.visibility = "visible";
			var newimage = "url(" + getActiveScriptPath() + "Shadow2.png)";
			TipContainer.style.backgroundImage = newimage;
		}
    }

    ImageNode.setAttribute('src', PicSrc);
    DelayedTipSource(ImageNode, PicSrc, TipContainer);
}

function HideTipp() {
    if (TipContainer != null) {
        document.body.removeChild(TipContainer);
        delete TipContainer;
        TipContainer = null;
    }
	ParentContainer = null;
	CurrentTippID = '';
}


function NextImage() {
//	if (PlayerFLV)
//		return;
    ShowSlide(arrImages, curIndex + 1, true);
}

function PrevImage() {
//	if (PlayerFLV)
//		return;
    ShowSlide(arrImages, curIndex - 1, true);
}

function SameImage() {
//	if (PlayerFLV)
//		return;
	if (ShowContainer != null)
	{
//		window.setTimeout("ShowSlide(arrImages, curIndex, false)", 5000);
		ShowSlide(arrImages, curIndex, false);
	}
}

function CloseShow() {
	if (PlayerFLV)
	{
		if (PlayerDivFLV)
		{
			var player = PlayerDivFLV.cloneNode(true);
			PlayerDivFLV.id = "";

			PlayerDivFLV = player;
			PlayerDivFLV.style.visibility = "hidden";
			PlayerDivFLV.style.zIndex = 0;
			document.body.appendChild(PlayerDivFLV);
		}
		PlayerFLV.stop();
		delete PlayerFLV;
		PlayerFLV = null;
	}

	ShowContainer.style.display = 'none';
/*
    document.body.removeChild(ShowContainer);
    delete ShowContainer;
    ShowContainer = null;
*/
}

function setDivOpacity(obj, opval) {
    obj.style.opacity = opval / 100;
    obj.style.MozOpacity = opval / 100;
    obj.style.filter = "alpha(opacity=" + opval + ")";
}

function ShowNextImageButton() {
    setDivOpacity(NextBtnDiv, 100);
}

function HideNextImageButton() {
    setDivOpacity(NextBtnDiv, 1);
}

function KeyPressed(e) {
    var e = window.event || e;
    key = e.keyCode;

    switch (key) {
        case 39:
            NextImage();
            break;
        case 37:
            PrevImage();
            break;
        case 27:
            CloseShow();
            break;
    }
}

function DoBlendOut(div) {
    var Opacity = 100;
    CancelFadeOut = 0;
    var theInterval;
    var blendOut = function() {
        try {
            if (div != undefined) {
                if (Opacity > 1)
                    setDivOpacity(div, Opacity);
            }
            Opacity -= 10;
        }
        catch (err) {
            setDivOpacity(div, 0);
        }
        if (Opacity < 0 || CancelFadeOut != 0) {
            window.clearInterval(theInterval);
            setDivOpacity(div, 0);
            CancelFadeOut = 0;
        }
    }
    try {
        theInterval = window.setInterval(blendOut, 40);
    }
    catch (err) {
        setDivOpacity(div, 0);
    }
}

function TimedOut(timedOut) {
    timedOut = 1;
    return 1;
}

function DoBlendOver(div1, div2) {
    var Opacity = 100;
    var Opacity2 = 0;
    CancelFadeOut = 0;
    var theInterval;
    var timedOut = 0;
    var displayed = 0;
    var rate = 10;
    var clicks = 50;
    var maxTime = 250;
    var tmID;
    var tmID2;

    var blendOut = function() {
        try {
            if (div1 != undefined) {
                if (Opacity > 1) {
                    setDivOpacity(div1, Opacity);
                    setDivOpacity(div2, Opacity2);
                    displayed++;
                }
            }
            Opacity -= rate;
            Opacity2 += rate;
        }
        catch (err) {
            setDivOpacity(div1, 0);
            setDivOpacity(div2, 100);
        }
        if (Opacity < 0 || CancelFadeOut != 0 || timedOut == 1) {
            window.clearInterval(theInterval);
            setDivOpacity(div1, 0);
            setDivOpacity(div2, 100);
            CancelFadeOut = 0;
        }
    }
	rate = (100 / (maxTime / clicks)) + maxTime / clicks;

    try {
        theInterval = window.setInterval(blendOut, clicks);
        tmID = window.setTimeout(function() { timedOut = 1; clearTimeout(tmID); }, maxTime);
        tmID2 = window.setTimeout(function() {
            rate = clicks / ((maxTime - clicks * 3) / (100 - displayed));
            clearTimeout(tmID2);
        }, clicks * 3);

    }
    catch (err) {
        setDivOpacity(div1, 0);
        setDivOpacity(div2, 100);
    }
}


function DoBlendIn(div, maxOpacity) {
    var Opacity = 0;
    if (maxOpacity == undefined)
        maxOpacity = 100;
    CancelFadeIn = 0;
    var theInterval;
    var blendOut = function() {
        try {
            if (div != undefined) {
                if (Opacity < maxOpacity + 1)
                    setDivOpacity(div, Opacity);
            }
            Opacity += 10;
        }
        catch (err) {
            setDivOpacity(div, maxOpacity);
        }
        if (Opacity > maxOpacity || CancelFadeIn != 0) {
            window.clearInterval(theInterval);
            setDivOpacity(div, 100);
            CancelFadeIn = 0;
        }
    }
    try {
        theInterval = window.setInterval(blendOut, 40);
    }
    catch (err) {
        setDivOpacity(div, 100);
    }
}

var theMouseTimeOut = null;
var lastDiv = null;

function SetMouseInOutEventHandler(parentDiv, div, clickfunc) {
    div.style.visibility = "hidden";
    if (div.theMouseTimeOut == undefined)
        div.theMouseTimeOut = null;
    if (div.theMouseTimeOut != null) {
        {
            window.clearTimeout(theMouseTimeOut);
            div.theMouseTimeOut = null;
            //            setDivOpacity(lastDiv, 1);

        }
    }
    if (parentDiv.addEventListener) {
        parentDiv.addEventListener("mouseover", function() {
            if (div.theMouseTimeOut != 0)
                window.clearTimeout(div.theMouseTimeOut);
            div.theMouseTimeOut = window.setTimeout(function() {
                div.style.visibility = "visible";
                lastDiv = div;
            }, 1000);

        }, 1000);


    } else {
        parentDiv.onmouseover = function() {
            div.theMouseTimeOut = window.setTimeout(function() {
                if (div.theMouseTimeOut != null)
                    window.clearTimeout(div.theMouseTimeOut);
                div.style.visibility = "visible";
            }, 1000);
        };
    }

    if (parentDiv.addEventListener) {
        parentDiv.addEventListener("mouseout", (function() {
            div.style.visibility = "hidden";
            if (div.theMouseTimeOut != null) {
                window.clearTimeout(div.theMouseTimeOut);
                theMouseTimeOut = null;
            }
        })
            , false);

    } else {
        parentDiv.onmouseout = function() {
            div.style.visibility = "hidden";
            if (div.theMouseTimeOut != null) {
                window.clearTimeout(div.theMouseTimeOut);
                div.theMouseTimeOut = null;
            }

        };
    }

    if (div.addEventListener) {
        div.addEventListener("mouseover", function() {
            div.style.visibility = "visible";
        }, false)
    } else {
        div.onmouseover = function() {
            div.style.visibility = "visible";
        };
    }

    if (div.addEventListener) {
        div.addEventListener("mouseout", function() {
            setDivOpacity(div, 0);
        }, false)
    } else {
        div.onmouseout = function() {
            setDivOpacity(div, 0)
        };
    }

    if (div.addEventListener) {
        div.addEventListener("click", clickfunc, false);

    } else {
        div.onclick = clickfunc;
    }

}

var trys = 0;
var LoadAgainTimeOut = null;
var PreloadImagesStart = 0;
var PreloadImagesNext = -1;

function PreloadNextImage()
{
	if (PreloadImagesStart != PreloadImagesNext)
	{
		var next = PreloadImagesNext;
		var img = document.createElement('img');
		img.onload = function() {
			PreloadNextImage();
			img = null;
		};

		PreloadImagesNext += 1;
		if (PreloadImagesNext >= arrImages.length)
			PreloadImagesNext = 0;

		img.style.visibility = "hidden";
		img.style.width = "0px";
		img.style.height = "0px";
		img.src = arrImages[next][0];
	}
}

function ShowImageLoading()
{
    if(ImageLoading!=null)
        ImageLoading.style.visibility = "visible";
}
 
function HideImageLoading()
{
	if (ImageLoading != null)
	{
		if (ImageLoading.parentNode == ShowContainer)
			ShowContainer.removeChild(ImageLoading);

		delete ImageLoading;
		ImageLoading = null;
	}
}

function ShowSlide(arrInpImages, index, DoAnim)
{
	HideTipp();

    var WinHeight = 0;
    var WinWidth = 0;
    var ImageDivBevore = null;
    //    CancelFadeOut = 1;
    //    CancelFadeIn = 1;
    var ImageDiv = null;

    if (index >= arrInpImages.length)
        return;
    if (index < 0)
        return;
    arrImages = arrInpImages;
    curIndex = index;
    var ImgHeight = 0;
    var ImgWidth = 0;

    if (LoadAgainTimeOut != null)
        window.clearTimeout(LoadAgainTimeOut);
    if (lastImageNode == 1) {
        LoadAgainTimeOut = window.setTimeout("SameImage()", 1000);
        //        return;
    }

    trys = 0;
    LoadAgainTimeOut = null;

    if (typeof window.innerWidth != 'undefined') {
        WinWidth = window.innerWidth - 10;
        WinHeight = window.innerHeight;
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
        WinWidth = document.documentElement.clientWidth;
        WinHeight = document.documentElement.clientHeight;
    }
    else {
        WinWidth = document.getElementsByTagName('body')[0].clientWidth;
        WinHeight = document.getElementsByTagName('body')[0].clientHeight;
    }

    ParentContainer = document.getElementById(parent);
	if (ShowContainer != null && ShowContainer.style.display == 'none')
	{
		document.body.removeChild(ShowContainer);
		delete ShowContainer;
		ShowContainer = null;
	}
    if (ShowContainer == null) {
        var qLanguage;
        if (navigator.browserLanguage && navigator.browserLanguage > '  ')
            qLanguage = navigator.browserLanguage.substring(0, 2);
        else
            if (navigator.language != undefined)
            qLanguage = navigator.language;
        else
            qLanguage = "EN";
        // Localize Strings
        arrStringsLanguage(qLanguage);

        ShowContainer = document.createElement("div");

        //preload images
		if (PreloadImagesNext < 0)
		{
			PreloadImagesStart = index;
			PreloadImagesNext = index+1;
			if (PreloadImagesNext >= arrImages.length)
				PreloadImagesNext = 0;
		}
/*
        for (var i = 0; i < arrImages.length; i++) {
            var img = document.createElement('img');
            img.onload = function() {
                img = null;
            };
            img.src = arrInpImages[i][0];
        }
*/
        ImageDiv1 = document.createElement("div");
        ImageDiv1.id = "ImageDiv1";
        ImageDiv2 = document.createElement("div");
        ImageDiv2.id = "ImageDiv2";
        ShowBack = document.createElement("div");

        ShowContainer.appendChild(ShowBack);

        ShowBack.style.position = "absolute";
        ShowBack.style.top = "0px";
        ShowBack.style.left = "0px";
        ShowBack.style.width = "100%";
        ShowBack.style.height = "100%";
        ShowBack.style.background = "black";
        ShowBack.style.zIndex = 80000;

        //DoBlendIn(ShowBack, 50);
        setDivOpacity(ShowBack, 50);
        ShowContainer.appendChild(ImageDiv1);
        ShowContainer.appendChild(ImageDiv2);

        NextBtnDiv = document.createElement("div");
        ShowContainer.appendChild(NextBtnDiv);
        PrevBtnDiv = document.createElement("div");
        ShowContainer.appendChild(PrevBtnDiv);
    }
    else {
        if (ImageLeft && ImageLeft.parentNode == ShowContainer)
            ShowContainer.removeChild(ImageLeft);
        if (ImageRight && ImageRight.parentNode == ShowContainer)
            ShowContainer.removeChild(ImageRight);
    }
    var ThumbWidth = 200;
    var ThumbHeight = 200;
    if (ImageDiv1.style.opacity < 1) {
        ImageDiv = ImageDiv1;
        ImageDivBevore = ImageDiv2;
        setDivOpacity(ImageDiv, 0);
        setDivOpacity(ImageDivBevore, 100);
    }
    else {
        ImageDiv = ImageDiv2;
        ImageDivBevore = ImageDiv1;
        setDivOpacity(ImageDiv, 0);
        setDivOpacity(ImageDivBevore, 100);
    }
    var textBottom = arrImages[index][1];
    PrevBtnDiv.style.visibility = "hidden";
    NextBtnDiv.style.visibility = "hidden";

    if (!DoAnim) {
        ImageDiv2.style.visibility = "hidden";
        ImageDiv1.style.visibility = "hidden";
    }
    else
        nCallCounter++;

    loadjscssfile(getActiveScriptPath() + 'SL.css', 'css');

    if (ImageLoading == null)
	{
        ImageLoading = document.createElement('div');
        ImageLoading.className = "LoadingAnimation";
 
        ImageLoading.style.position = "absolute";
	    ImageLoading.style.color = "#666";
	    ImageLoading.style.lineHeight = "1.4em";
	    ImageLoading.style.textAlign = "center";
	    ImageLoading.style.border = "1px solid #aaa";
	    ImageLoading.style.padding = "5px 10px";
	    ImageLoading.style.background = "white";
		ImageLoading.style.zIndex = 90010;

        var ImagePreview = document.createElement('img');
//        ImagePreview.src = getActiveScriptPath() + "loadingAnimation.gif";
        ImagePreview.src = getActiveScriptPath() + "loading.gif";
		ImagePreview.style.marginBottom = "3px";

        ImageLoading.appendChild(ImagePreview);
        var text = arrStrings["Loading"];
        ImageLoading.innerHTML += '<br>'+text;

        ImageLoading.style.visibility = "hidden";
		ImageLoading.style.left = (WinWidth - ImageLoading.style.width) /2  +"px";
        ImageLoading.style.top = (WinHeight - ImageLoading.style.height) /2 +"px";
       
        ShowContainer.appendChild(ImageLoading);
        window.setTimeout("ShowImageLoading()",500);
    }

    //  ShowContainer.appendChild(TopTextDiv);
    // ShowContainer.appendChild(bottomTextDiv);
    document.body.appendChild(ShowContainer);
    if (ImageDiv != null)
        ImageDiv.style.visibility = "hidden";
    ImageDiv.style.top = "-200px";
    ImageDiv.style.left = "-200px";
    ImageDiv.style.width = "0px";
    ImageDiv.style.height = "0px";


    var ImageNode = document.createElement('img');
    lastImageNode = 1;
    ImageInner = document.createElement("div");
    while (ImageDiv.firstChild != null)
        ImageDiv.removeChild(ImageDiv.firstChild);
    ImageInner.appendChild(ImageNode);
    ImageDiv.appendChild(ImageInner);

    ImageNode.ImageDiv = ImageDiv;
    ImageNode.ImageDivBevore = ImageDivBevore;
    lastImageNode.ready = false;
    ImageNode.setAttribute('src', "");
    ImageNode.style.width = "0px";
    ImageNode.style.height = "0px";
	ImageNode.style.visibility = "hidden";

    ImageNode.onload = function() {

		HideImageLoading();		
		if (ShowContainer == null)
			return;

		this.style.width = "";
		this.style.height = "";

        var nTextHight = 30;
        var nBorder = 10;
        var newimage = document.createElement('img');
        newimage.src = getActiveScriptPath() + "Shadow2.png";
        var nextimage; //= "url(" + getActiveScriptPath() + "nextlabel.gif)";
        var nThumbSize = WinWidth - 40;

        this.ImageDiv.style.visibility = "visible";
        if (ImageNode.height && ImageNode.height != ImgHeight)
            ImgHeight = ImageNode.height;
        if (ImageNode.width && ImageNode.width != ImgWidth)
            ImgWidth = ImageNode.width;
        if (ImgHeight > ImgWidth)
            nThumbSize = WinHeight - 40 - nTextHight;
        if (nThumbSize > WinHeight - 40 - nTextHight)
            nThumbSize = WinHeight - 40 - nTextHight;
        var Scaling;
        if (ImgHeight > ImgWidth) {
            nThumbSize = WinHeight - 40 - nTextHight;
            Scaling = nThumbSize / ImgHeight;
        }
        else {
            nThumbSize = WinWidth - 40;
            Scaling = nThumbSize / ImgWidth;
            if (ImgHeight > WinHeight - 40 - nTextHight) {
                nThumbSize = WinHeight - 40 - nTextHight;
                Scaling = nThumbSize / ImgHeight;
            }
        }
        if (Scaling > 1)
            Scaling = 1;
        ThumbWidth = Math.round(ImgWidth * Scaling);
        ThumbHeight = Math.round(ImgHeight * Scaling);
        this.setAttribute('width', ThumbWidth);
        this.setAttribute('height', ThumbHeight);
		this.style.visibility = "visible";

        this.ImageDiv.style.position = "absolute";
        this.ImageDiv.style.top = (WinHeight - ThumbHeight - (nBorder * 2) - nTextHight) / 2 + "px";
        this.ImageDiv.style.left = (WinWidth - ThumbWidth - (nBorder * 2)) / 2 + "px";
        this.ImageDiv.style.width = ThumbWidth + (nBorder * 2) + "px";
        this.ImageDiv.style.height = ThumbHeight + (nBorder * 2) + nTextHight + "px";
        this.ImageDiv.style.zIndex = 80001;
        this.ImageDiv.style.background = "white";

        //        alert(ImageNode.ImageDiv.style.left + ImageNode.ImageDiv.id);

        ImageInner.style.position = "absolute";
        ImageInner.style.top = nBorder + "px";
        ImageInner.style.left = nBorder + "px";
        ImageInner.style.width = ThumbWidth + "px";
        ImageInner.style.height = ThumbHeight + "px";
        ImageInner.style.zIndex = 80001;

        setDivOpacity(ImageNode.ImageDiv, 1);

        //        ImageNode.ImageDiv.style.border = "2px solid white";
        ImageNode.ImageDiv.style.visibility = "visible";
        if (curIndex > 0) {
            ImageLeft = document.createElement("div");
            ShowContainer.appendChild(ImageLeft);
            ImageLeft.style.position = "absolute";
            ImageLeft.style.top = (WinHeight - ThumbHeight - nTextHight) / 2 + "px";
            ImageLeft.style.left = (WinWidth - ThumbWidth) / 2 + "px";
            ImageLeft.style.width = ThumbWidth / 2 + "px";
            ImageLeft.style.height = ThumbHeight + "px";
            ImageLeft.style.zIndex = 90000;
            ImageLeft.style.cursor = "pointer";
            ImageLeft.style.background = "black";
            setDivOpacity(ImageLeft, 1);

            if (ImageLeft.addEventListener) {
                ImageLeft.addEventListener("click", PrevImage, false);
            } else {
                ImageLeft.onclick = PrevImage;
            }
            PrevBtnDiv.style.position = "absolute";
            PrevBtnDiv.style.top = 30 + (WinHeight - ThumbHeight - nTextHight) / 2 + "px";
            PrevBtnDiv.style.left = ((WinWidth - ThumbWidth) / 2) + "px";
            PrevBtnDiv.style.width = 80 + "px";
            PrevBtnDiv.style.height = 31 + "px";
            PrevBtnDiv.style.zIndex = 900003;
            PrevBtnDiv.style.align = "left";
            PrevBtnDiv.style.cursor = "pointer";
            PrevBtnDiv.style.visibility = "hidden";

            PrevBtnDiv.innerHTML = "<img src='" + getActiveScriptPath() + "left.png'>";
            SetMouseInOutEventHandler(ImageLeft, PrevBtnDiv, PrevImage);
        }
        else
		{
            window.clearTimeout(PrevBtnDiv.theMouseTimeOut);
            PrevBtnDiv.style.visibility = "hidden";

			if (ImageLeft)
			{
				if (ImageLeft.parentNode == ShowContainer)
					ShowContainer.removeChild(ImageLeft);
				delete ImageLeft;
			}
            ImageLeft = null;
		}

        if (curIndex < arrImages.length - 1) {
            ImageRight = document.createElement("div");
            ShowContainer.appendChild(ImageRight);
            ImageRight.style.position = "absolute";
            ImageRight.style.top = (WinHeight - ThumbHeight - nTextHight) / 2 + "px";
            ImageRight.style.left = ThumbWidth / 2 + (WinWidth - ThumbWidth) / 2 + "px";
            ImageRight.style.width = ThumbWidth / 2 + "px";
            ImageRight.style.height = ThumbHeight + "px";
            ImageRight.style.zIndex = 90000;
            ImageRight.style.cursor = "pointer";
            ImageRight.style.background = "black";
            setDivOpacity(ImageRight, 1);

            NextBtnDiv.style.position = "absolute";
            NextBtnDiv.style.top = 30 + (WinHeight - ThumbHeight - nTextHight) / 2 + "px";
            NextBtnDiv.style.left = (ThumbWidth + (WinWidth - ThumbWidth) / 2) - 80 + "px";
            NextBtnDiv.style.width = 80 + "px";
            NextBtnDiv.style.height = 31 + "px";
            NextBtnDiv.style.zIndex = 900003;
            NextBtnDiv.style.align = "right";
            NextBtnDiv.style.textAlign = "right";
            NextBtnDiv.style.cursor = "pointer";
            NextBtnDiv.style.visibility = "hidden";

            NextBtnDiv.innerHTML = "<img src='" + getActiveScriptPath() + "right.png'>";
            SetMouseInOutEventHandler(ImageRight, NextBtnDiv, NextImage);

            if (ImageRight.addEventListener) {
                ImageRight.addEventListener("click", NextImage, false);

            } else {
                ImageRight.onclick = NextImage;
            }

        }
        else
		{
            window.clearTimeout(NextBtnDiv.theMouseTimeOut);
            NextBtnDiv.style.visibility = "hidden";

			if (ImageRight)
			{
				if (ImageRight.parentNode == ShowContainer)
					ShowContainer.removeChild(ImageRight);
				delete ImageRight;
			}
            ImageRight = null;
		}


        CloseLeft = document.createElement("div");
        ShowContainer.appendChild(CloseLeft);
        CloseLeft.style.position = "absolute";
        CloseLeft.style.top = "0px";
        CloseLeft.style.left = "0px";
        if (WinWidth > ThumbWidth)
            CloseLeft.style.width = (WinWidth - ThumbWidth) / 2 + "px";
        else
            CloseLeft.style.width = "1px";

        CloseLeft.style.height = WinHeight + "px";
        CloseLeft.style.zIndex = 90000;
        CloseLeft.style.background = "black";
        setDivOpacity(CloseLeft, 1);

        if (CloseLeft.addEventListener) {
            CloseLeft.addEventListener("click", CloseShow, false);
        } else {
            CloseLeft.onclick = CloseShow;
        }
        CloseRight = document.createElement("div");
        ShowContainer.appendChild(CloseRight);
        CloseRight.style.position = "absolute";
        CloseRight.style.top = "0px";
        CloseRight.style.left = ThumbWidth / 2 + ((WinWidth - ThumbWidth) / 2) + (ThumbWidth / 2) + "px";
        CloseRight.style.width = WinWidth - parseInt(CloseRight.style.left) + "px";
        CloseRight.style.height = WinHeight + "px";
        CloseRight.style.zIndex = 90000;
        CloseRight.style.background = "black";
        setDivOpacity(CloseRight, 1);

        if (CloseRight.addEventListener) {
            CloseRight.addEventListener("click", CloseShow, false);
        } else {
            CloseRight.onclick = CloseShow;
        }
        var bottomTextDiv = document.createElement("div");
        this.ImageDiv.appendChild(bottomTextDiv);
        if (textBottom != undefined) {
            bottomTextDiv.innerHTML = textBottom;
        }
        bottomTextDiv.style.position = "absolute";
        bottomTextDiv.id = "lbDescription";

        bottomTextDiv.style.top = ThumbHeight + (nBorder) + 4 + "px";
        bottomTextDiv.style.left = nBorder + "px";
        bottomTextDiv.style.width = ThumbWidth + "px";
        if (bottomTextDiv.scrollHeight > 16) {
            var diff = bottomTextDiv.scrollHeight - 16;
            this.ImageDiv.style.height = ThumbHeight + (nBorder * 2) + nTextHight + diff + "px";
            ThumbHeight += diff;
        }

        var CounterDiv = document.createElement("div");
        CounterDiv.style.position = "absolute";
        CounterDiv.style.top = ThumbHeight + (nBorder) + 16 + 5 + "px";
        CounterDiv.style.left = nBorder + "px";
        CounterDiv.style.width = ThumbWidth + "px";
        //        CounterDiv.style.fontFamily = 'Arial,Helvetica,sans-serif';
        //      bottomTextDiv.style.font = 'small arial';
        CounterDiv.style.padding = "0px";
        CounterDiv.style.margin = "1px";
        //        CounterDiv.style.textAlign = "left";
        //        CounterDiv.style.fontSize = "10px";
        CounterDiv.style.color = "#666666";
        this.ImageDiv.appendChild(CounterDiv);
        CounterDiv.style.height = 21 + "px";
        //        CounterDiv.innerHTML = (curIndex + 1) + '/' + arrImages.length;
        var CounterText = arrStrings["ImgCount"];
        var newText = CounterText.replace(/{x}/g, curIndex + 1).replace(/{y}/g, arrImages.length);

        CounterDiv.innerHTML = '<span id=lbBottom>' + newText + '</span>';

        var CloseDiv = document.createElement("div");
        this.ImageDiv.appendChild(CloseDiv);
        CloseDiv.style.position = "absolute";
        CloseDiv.style.top = CounterDiv.style.top;
        CloseDiv.style.left = ThumbWidth + nBorder - 200 + "px";
        CloseDiv.style.width = 200 + "px";
        CloseDiv.style.height = nTextHight + "px";
        CloseDiv.style.cursor = "pointer";
        CloseDiv.style.textAlign = 'right';
        CloseDiv.style.verticalAlign = 'bottom';
        //        CloseDiv.style.background= 'white';
        CloseDiv.innerHTML = '<span id=lbClose>' + arrStrings["Close"] + '<span id=fatClose> X</span></span>';

        if (CloseDiv.addEventListener) {
            CloseDiv.addEventListener("click", CloseShow, false);

        } else {
            CloseDiv.onclick = CloseShow;
        }


        var nWidth;
        var nHeight;
        if (window.outerWidth)
            nWidth = window.outerWidth;
        else
            if (document.body)
            nWidth = document.body.offsetWidth;
        if (window.outerHeight)
            nHeight = window.outerHeight;
        else
            if (document.body)
            nHeight = document.body.offsetHeight;
        var nElementHeight = ThumbHeight + 30 + bottomTextDiv.scrollHeight;
        lastImageNode = 2;
        if (DoAnim) {
            if (!this.canceled)
                if (ImageDivBevore != null)
                DoBlendOver(this.ImageDivBevore, this.ImageDiv);
        }
        else
            setDivOpacity(this.ImageDiv, 100);

		PreloadNextImage();
		HideImageLoading();		
    }

	ImageNode.setAttribute('src', arrImages[index][0]);
    if (DoPosFixed) {
        ShowContainer.style.position = "fixed";
        ShowContainer.style.top = "0px";
        ShowContainer.style.left = "0px";
    }
    else {
        scrolly = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
        scrollx = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
        ShowContainer.style.position = "absolute";
        ShowContainer.style.top = scrolly + "px";
        ShowContainer.style.left = "0px";
    }
    ShowContainer.style.width = WinWidth + "px";
    ShowContainer.style.height = WinHeight + "px";
    ShowContainer.style.border = "0px solid";
    ShowContainer.style.visibility = "visible";
    ShowContainer.style.zIndex = 80000;
    //    var newimage = "url(" + getActiveScriptPath() + "Shadow2.png)";
    //    ShowContainer.style.backgroundImage = newimage;
    if (window.addEventListener) {
        window.addEventListener("resize", SameImage, false);
        //        ResizeFunc = window.getEventListener("resize");
    } else {
        ResizeFunc = window.onResize;
        window.onresize = SameImage;
    }
    if (document.addEventListener) {
        document.addEventListener("keyup", KeyPressed, false);
    }
    else
        document.onkeyup = KeyPressed;
}

function ShowSlideQT(mediaFile, mediaText, mediaWidth, mediaHeight)
{
	mediaHeight += 50;	// Add enough space for the controls...

	var wmpDiv = document.createElement("div");
	wmpDiv.id = "aviPlayer";
	wmpDiv.innerHTML = '<embed pluginspage="http://www.apple.com/quicktime/download/" src="' +mediaFile+ '" width="' +mediaWidth+ '" height="' +mediaHeight+ '" controller="true" autoplay="true" cache="true"></embed>';

	ShowSlideFrame(wmpDiv, mediaWidth, mediaHeight, mediaText);
}

function ShowSlideFLV(mediaFile, mediaText)
{
	if (PlayerDivFLV == null)
	{
		PlayerDivFLV = document.createElement("div");
		PlayerDivFLV.id = "flvPlayer";
	}
	else
	{
		while (PlayerDivFLV.firstChild != null)
			PlayerDivFLV.removeChild(PlayerDivFLV.firstChild);
	}
	if (PlayerFLV)
		delete PlayerFLV;
	PlayerFLV = new FAVideo("flvPlayer", mediaFile, 0, 0, { autoLoad:true, autoPlay:false, skinVisible:true, skinAutoHide:true }, "../favideo/");
	PlayerFLV.setVideoScaleMode("noScale");
	PlayerFLV.setVideoAlign("center");
	PlayerFLV.setSkinPath("../favideo/skins/ClearOverAll.swf");

	var flvWidth = PlayerFLV.width;
	var flvHeight = PlayerFLV.height;

	delete PlayerFLV;

	ShowSlideFrame(PlayerDivFLV, flvWidth, flvHeight, mediaText);
	PlayerDivFLV.style.visibility = "visible";

	PlayerFLV = new FAVideo("flvPlayer", mediaFile, 0, 0, { autoLoad:true, autoPlay:true, skinVisible:true, skinAutoHide:true }, "../favideo/");
	PlayerFLV.setVideoScaleMode("noScale");
	PlayerFLV.setVideoAlign("center");
	PlayerFLV.setSkinPath("../favideo/skins/ClearOverAll.swf");
}

function ShowSlideFrame(ImageInnerDiv, ThumbWidth, ThumbHeight, textBottom, ImageIndex)
{
	var WinHeight = 0;
	var WinWidth = 0;

	var nTextHight = 30;
	var nBorder = 10;
	
	if (ThumbWidth == 0 && ThumbHeight == 0)
	{
		if (ImageInnerDiv == null)
			return;

		ThumbWidth = ImageInnerDiv.width;
		ThumbHeight = ImageInnerDiv.height;
	}

	var ImageDiv = null;
	if (typeof window.innerWidth != 'undefined') {
		WinWidth = window.innerWidth - 10;
		WinHeight = window.innerHeight;
	}
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		WinWidth = document.documentElement.clientWidth;
		WinHeight = document.documentElement.clientHeight;
	}
	else {
		WinWidth = document.getElementsByTagName('body')[0].clientWidth;
		WinHeight = document.getElementsByTagName('body')[0].clientHeight;
	}

	if (ShowContainer == null) {
		var qLanguage;
		if (navigator.browserLanguage && navigator.browserLanguage > '  ')
			qLanguage = navigator.browserLanguage.substring(0, 2);
		else
			if (navigator.language != undefined)
				qLanguage = navigator.language;
			else
				qLanguage = "EN";

		// Localize Strings
		arrStringsLanguage(qLanguage);

		ShowContainer = document.createElement("div");

		ShowBack = document.createElement("div");
		ShowContainer.appendChild(ShowBack);

		ShowBack.style.width = "100%";
		ShowBack.style.height = "100%";
		ShowBack.style.background = "black";
		setDivOpacity(ShowBack, 50);

		ImageDiv = document.createElement("div");
		ShowContainer.appendChild(ImageDiv);
	}
	else
	{
		while (ImageDiv.firstChild != null)
			ImageDiv.removeChild(ImageDiv.firstChild);
	}

	loadjscssfile(getActiveScriptPath() + 'SL.css', 'css');
	document.body.appendChild(ShowContainer);
	
	if (ImageInnerDiv)
	{
		ImageDiv.appendChild(ImageInnerDiv);
        ImageInnerDiv.style.position = "absolute";
        ImageInnerDiv.style.top = nBorder + "px";
        ImageInnerDiv.style.left = nBorder + "px";
		ImageInnerDiv.style.width = ThumbWidth + "px";
		ImageInnerDiv.style.height = ThumbHeight + "px";
        ImageInnerDiv.style.zIndex = 80001;
	}
	
	ImageDiv.style.visibility = "visible";
	ImageDiv.style.position = "absolute";
	ImageDiv.style.top = (WinHeight - ThumbHeight - (nBorder * 2) - nTextHight) / 2 + "px";
	ImageDiv.style.left = (WinWidth - ThumbWidth - (nBorder * 2)) / 2 + "px";
	ImageDiv.style.width = ThumbWidth + (nBorder * 2) + "px";
	ImageDiv.style.height = ThumbHeight + (nBorder * 2) + nTextHight + "px";
	ImageDiv.style.zIndex = 80001;
	ImageDiv.style.background = "white";

	// Description text
	var bottomTextDiv = document.createElement("div");
	ImageDiv.appendChild(bottomTextDiv);

	if (textBottom != undefined)
		bottomTextDiv.innerHTML = textBottom;

	bottomTextDiv.style.position = "absolute";
	bottomTextDiv.id = "lbDescription";
	bottomTextDiv.style.top = ThumbHeight + (nBorder) + 4 + "px";
	bottomTextDiv.style.left = nBorder + "px";
	bottomTextDiv.style.width = ThumbWidth + "px";
	if (bottomTextDiv.scrollHeight > 16) {
		var diff = bottomTextDiv.scrollHeight - 16;
		ImageDiv.style.height = ThumbHeight + (nBorder * 2) + nTextHight + diff + "px";
		ThumbHeight += diff;
	}
	// Close button
	var CloseDiv = document.createElement("div");
	ImageDiv.appendChild(CloseDiv);
	CloseDiv.style.position = "absolute";
	CloseDiv.style.top = ThumbHeight + (nBorder) + 16 + 5 + "px";
	CloseDiv.style.left = ThumbWidth + nBorder - 200 + "px";
	CloseDiv.style.width = 200 + "px";
	CloseDiv.style.height = nTextHight + "px";
	CloseDiv.style.cursor = "pointer";
	CloseDiv.style.textAlign = 'right';
	CloseDiv.style.verticalAlign = 'bottom';
	CloseDiv.innerHTML = '<span id=lbClose>' + arrStrings["Close"] + '<span id=fatClose> X</span></span>';

	if (CloseDiv.addEventListener)
		CloseDiv.addEventListener("click", CloseShow, false);
	else
		CloseDiv.onclick = CloseShow;

	if (ImageIndex && ImageIndex >= 0 && ImageIndex < arrImages.length)
	{
		// Counter text
		var CounterDiv = document.createElement("div");
		ImageDiv.appendChild(CounterDiv);

		CounterDiv.style.position = "absolute";
		CounterDiv.style.top = CloseDiv.style.top;
		CounterDiv.style.left = nBorder + "px";
		CounterDiv.style.width = ThumbWidth + "px";
		CounterDiv.style.padding = "0px";
		CounterDiv.style.margin = "1px";
		CounterDiv.style.color = "#666666";
		CounterDiv.style.height = 21 + "px";
		var CounterText = arrStrings["ImgCount"];
		var newText = CounterText.replace(/{x}/g, curIndex + 1).replace(/{y}/g, arrImages.length);
		CounterDiv.innerHTML = '<span id=lbBottom>' + newText + '</span>';
	}
	setDivOpacity(ImageDiv, 100);

	ShowContainer.style.position = "absolute";	// "fixed" doesn't work in IE properly :( !!!
	ShowContainer.style.top = "0px";
	ShowContainer.style.left = "0px";
	ShowContainer.style.width = WinWidth + "px";
	ShowContainer.style.height = WinHeight + "px";
	ShowContainer.style.border = "0px solid #101010";
	ShowContainer.style.visibility = "visible";
	ShowContainer.style.zIndex = 80000;
	if (document.addEventListener)
		document.addEventListener("keyup", KeyPressed, false);
	else
		document.onkeyup = KeyPressed;
}

