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 nCallCounter = 0;
var lastImageNode = 0;




// StudioLine Javascript Library
var TipContainer = null;

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 ShowTipp(PicSrc, parent, textTop, textBottom, ImgWidth, ImgHeight) {
    //    TipContainer = document.getElementById("PopUpBox");
    ParentContainer = document.getElementById(parent);
    HideTipp();
    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");

    TipContainer.appendChild(TopTextDiv);
    TipContainer.appendChild(bottomTextDiv);
    ImageDiv.appendChild(ImageNode);
    TipContainer.appendChild(ImageDiv);
    document.body.appendChild(TipContainer);


    with (ImageNode) {
        setAttribute('src', PicSrc);

        var nThumbSize = 300;
        var Scaling = nThumbSize / Math.max(ImgHeight, ImgWidth);

        ThumbWidth = Math.round(ImgWidth * Scaling);
        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 (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;
    var nTop = parseInt(ParentContainer.style.top) - 10;
    var nLeft = parseInt(ParentContainer.style.left) + (ParentContainer.clientWidth) + 10;
    if (nLeft + ThumbWidth + 30 > nWidth)
        nLeft = parseInt(ParentContainer.style.left) - (ThumbWidth + 30);

    if (nTop + nElementHeight > nHeight)
        nTop = nHeight - nElementHeight;
    if (nTop < 0)
        nTop = 0;
    if (nTop < 0)
        nTop = 0;

    if (nTop == NaN)
        nTop = 0;
    if (nLeft == NaN)
        nTop = 0;

    TipContainer.style.position = "absolute";
    TipContainer.style.top = nTop + "px";
    TipContainer.style.left = nLeft + "px";
    TipContainer.style.width = ThumbWidth + 14 + 8 + "px";
    TipContainer.style.height = nElementHeight + "px";
    TipContainer.style.border = "0px solid #101010";
    TipContainer.style.visibility = "visible";
    TipContainer.style.zIndex = 80000;
    var newimage = "url(" + getActiveScriptPath() + "Shadow2.png)";
    TipContainer.style.backgroundImage = newimage;


}

function HideTipp() {
    if (TipContainer != null) {
        document.body.removeChild(TipContainer);
        delete TipContainer;
        TipContainer = null;
    }
}




function NextImage() {
    ShowSlide(arrImages, curIndex + 1, true);
}

function PrevImage() {
    ShowSlide(arrImages, curIndex - 1, true);
}

function SameImage() {
    //   window.setTimeout("ShowSlide(arrImages, curIndex, false)", 5000);
    ShowSlide(arrImages, curIndex, false);
}

function CloseShow() {
    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 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) {
    setDivOpacity(div, 1);
    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() {
                setDivOpacity(div, 100)
                lastDiv = div;
            }, 1000);

        }, 1000);


    } else {
        parentDiv.onmouseover = function() {
            div.theMouseTimeOut = window.setTimeout(function() {
                if (div.theMouseTimeOut != null)
                    window.clearTimeout(div.theMouseTimeOut);
                setDivOpacity(div, 100)
            }, 1000);
        };
    }

    if (parentDiv.addEventListener) {
        parentDiv.addEventListener("mouseout", (function() {
            setDivOpacity(div, 1);
            if (div.theMouseTimeOut != null) {
                window.clearTimeout(div.theMouseTimeOut);
                theMouseTimeOut = null;
            }
        })
            , false);

    } else {
        parentDiv.onmouseout = function() {
            setDivOpacity(div, 1);
            if (div.theMouseTimeOut != null) {
                window.clearTimeout(div.theMouseTimeOut);
                div.theMouseTimeOut = null;
            }

        };
    }

    if (div.addEventListener) {
        div.addEventListener("mouseover", function() {
            setDivOpacity(div, 100);
        }, false)
    } else {
        div.onmouseover = function() {
            setDivOpacity(div, 100)
        };
    }

    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;
function ShowSlide(arrInpImages, index, DoAnim) {

    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;
    }

    scrolly = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
    scrollx = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;



    ParentContainer = document.getElementById(parent);
    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
        for (var i = 0; i < arrImages.length; i++) {
            var img = document.createElement('img');
            img.onload = function() {
                img = null;
            };
            img.src = arrInpImages[i];
        }
        ImageDiv1 = document.createElement("div");
        ImageDiv1.id = "ImageDiv1";
        ImageDiv2 = document.createElement("div");
        ImageDiv2.id = "ImageDiv2";
        ShowBack = document.createElement("div");

        ShowContainer.appendChild(ShowBack);

        ShowBack.style.width = "100%";
        ShowBack.style.height = "100%";
        ShowBack.style.background = "black";
        //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)
            ShowContainer.removeChild(ImageLeft);
        if (ImageRight)
            ShowContainer.removeChild(ImageRight);
        ShowContainer.removeChild(CloseLeft);
        ShowContainer.removeChild(CloseRight);
    }
    var ThumbWidth = 200;
    var ThumbHeight = 200;
    if (ImageDiv1.style.opacity < 1) {
        ImageDiv = ImageDiv1;
        ImageDivBevore = ImageDiv2;
        setDivOpacity(ImageDiv, 0);
        setDivOpacity(ImageDivBevore, 100);
        window.status = "ImageDiv1 " + ImageDiv1.style.opacity;
        window.status += "_ImageDiv2 " + ImageDiv2.style.opacity;
    }
    else {
        ImageDiv = ImageDiv2;
        ImageDivBevore = ImageDiv1;
        setDivOpacity(ImageDiv, 0);
        setDivOpacity(ImageDivBevore, 100);
        window.status = "ImageDiv2 " + ImageDiv2.style.opacity;
        window.status += "_ImageDiv1 " + ImageDiv1.style.opacity;
    }
    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++;


    //  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.onload = function() {

        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 - 20;

        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 - 20 - nTextHight;
        if (nThumbSize > WinHeight - 20 - nTextHight)
            nThumbSize = WinHeight - 20 - nTextHight;

        var Scaling = nThumbSize / Math.max(ImgHeight, ImgWidth);
        if (Scaling > 1)
            Scaling = 1;
        ThumbWidth = Math.round(ImgWidth * Scaling);
        ThumbHeight = Math.round(ImgHeight * Scaling);
        this.setAttribute('width', ThumbWidth);
        this.setAttribute('height', ThumbHeight);



        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) / 2 + "px";
            ImageLeft.style.left = (WinWidth - ThumbWidth) / 2 + "px";
            ImageLeft.style.width = ThumbWidth / 2 + "px";
            ImageLeft.style.height = ThumbHeight + "px";
            ImageLeft.style.zIndex = 80001;
            ImageLeft.style.background = "black";
            ImageLeft.style.zIndex = 90000;
            ImageLeft.style.cursor = "pointer";
            setDivOpacity(ImageLeft, 1);

            if (ImageLeft.addEventListener) {
                ImageLeft.addEventListener("click", PrevImage, false);

            } else {
                ImageLeft.onclick = PrevImage;
            }
            PrevBtnDiv.style.position = "absolute";
            PrevBtnDiv.style.top = ((WinHeight - ThumbHeight) / 2)
            PrevBtnDiv.style.left = ((WinWidth - ThumbWidth) / 2) + "px";
            PrevBtnDiv.style.width = 40 + "px";
            PrevBtnDiv.style.height = 30 + "px";
            PrevBtnDiv.style.zIndex = 900003;
            PrevBtnDiv.style.cursor = "pointer";
            PrevBtnDiv.style.visibility = "visible";

            PrevBtnDiv.style.color = "grey";
            PrevBtnDiv.innerHTML = "<img src='" + getActiveScriptPath() + "prevlabel.gif'>";
            //      PrevBtnDiv.style.background = "white";
            SetMouseInOutEventHandler(ImageLeft, PrevBtnDiv, PrevImage);


        }
        else
            ImageLeft = null;

        if (curIndex < arrImages.length - 1) {
            ImageRight = document.createElement("div");
            ShowContainer.appendChild(ImageRight);
            ImageRight.style.position = "absolute";
            ImageRight.style.top = ((WinHeight - ThumbHeight) / 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 = ((WinHeight - ThumbHeight) / 2)
            NextBtnDiv.style.left = (ThumbWidth + (WinWidth - ThumbWidth) / 2) - 100 + "px";
            NextBtnDiv.style.width = 100 + "px";
            NextBtnDiv.style.height = 30 + "px";
            NextBtnDiv.style.zIndex = 900003;
            NextBtnDiv.style.align = "right";
            NextBtnDiv.style.cursor = "pointer";
            NextBtnDiv.style.visibility = "visible";

            NextBtnDiv.innerHTML = "<img src='" + getActiveScriptPath() + "nextlabel.gif'>";
            var ImageNext = document.createElement('img');
            ImageNext.onload = function() {
                NextBtnDiv.style.left = (ThumbWidth + (WinWidth - ThumbWidth) / 2) - ImageNext.width + "px";
                ImageNext = null;
            }
            ImageNext.src = getActiveScriptPath() + 'nextlabel.gif';

            //        NextBtnDiv.style.background = "yellow";
            SetMouseInOutEventHandler(ImageRight, NextBtnDiv, NextImage);

            if (ImageRight.addEventListener) {
                ImageRight.addEventListener("click", NextImage, false);

            } else {
                ImageRight.onclick = NextImage;
            }

        }
        else
            ImageRight = null;


        CloseLeft = document.createElement("div");
        ShowContainer.appendChild(CloseLeft);
        CloseLeft.style.position = "absolute";
        CloseLeft.style.top = "0px";
        CloseLeft.style.left = "0px";
        CloseLeft.style.width = (WinWidth - ThumbWidth) / 2 + "px"; ;
        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.style.top = ThumbHeight + (nBorder) + "px";
        bottomTextDiv.style.left = nBorder + "px";
        bottomTextDiv.style.width = ThumbWidth + "px";

        bottomTextDiv.style.fontFamily = 'Arial,Helvetica,sans-serif';
        bottomTextDiv.style.padding = "0px";
        bottomTextDiv.style.margin = "1px";
        bottomTextDiv.style.textAlign = "left";
        bottomTextDiv.style.fontSize = "12px";
        bottomTextDiv.style.color = "#333333";
        bottomTextDiv.style.fontWeight = "bold"
        bottomTextDiv.style.height = 21 + "px";

        //        bottomTextDiv.style.background = "yellow";

        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';
        CounterDiv.style.padding = "0px";
        CounterDiv.style.margin = "1px";
        CounterDiv.style.textAlign = "left";
        CounterDiv.style.fontSize = "10px";
        CounterDiv.style.color = "#444444";
        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 = newText;

        var CloseDiv = document.createElement("div");
        this.ImageDiv.appendChild(CloseDiv);
        var ImageClose = document.createElement('img');
        CloseDiv.appendChild(ImageClose);
        ImageClose.onload = function() {

            CloseDiv.style.position = "absolute";
            CloseDiv.style.top = ThumbHeight + (nBorder) + 10 + "px";
            CloseDiv.style.left = ThumbWidth - ImageClose.width + "px";
            CloseDiv.style.width = ImageClose.width + "px";
            CloseDiv.style.height = ImageClose.height + "px";
            CloseDiv.style.cursor = "pointer";
        }
        if (CloseDiv.addEventListener) {
            CloseDiv.addEventListener("click", CloseShow, false);

        } else {
            CloseDiv.onclick = CloseShow;
        }

        ImageClose.src = getActiveScriptPath() + "closelabel.gif";

        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)
                DoBlendOut(this.ImageDivBevore);
            DoBlendIn(this.ImageDiv);
        }
        else
            setDivOpacity(this.ImageDiv, 100);
    }
    ImageNode.setAttribute('src', arrImages[index][0]);
    ShowContainer.style.position = "absolute";
    ShowContainer.style.top = scrolly + "px";
    ShowContainer.style.left = 0 + "px";
    ShowContainer.style.width = WinWidth + "px";
    ShowContainer.style.height = WinHeight + "px";
    ShowContainer.style.border = "0px solid #101010";
    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;
}