﻿var CacheArrayObject = new Array();
var mtmpobj = document.getElementById('aspxoutput');
var currentKey = '';
        
function loadLightBoxContent(content)
{
    mtmpobj = document.getElementById('aspxoutput');
    mtmpobj.innerHTML =  content.replace(/[\n]/g,'');
    CacheArrayObject[currentKey] = content;
    currentKey = '';
    mtmpobj.style.visibility = 'hidden';
    mtmpobj.style.display = '';
    mtmpobj.style.opacity = '0';
                    
    windowWidth = 0;
    windowHeight = 0;
                  
    if (loadDelay == 0)
    {
        setwidhei();
    }
                    
    if ((windowWidth < 50 || windowHeight < 50))
    {
        setTimeout("TryShow();", loadDelay);
    }
    else
    {
        Element.hide('aspxoutput');
        mtmpobj.style.visibility = '';
        myLightbox.resizeImageContainer(windowWidth, windowHeight);
        return false;
    }
}
        
function beforeLightBoxLoad(mpath, key)
{
    currentKey = '';
    if (CacheArrayObject[key] != null)
    {
        mtmpobj.innerHTML = CacheArrayObject[key];
        mtmpobj.style.visibility = 'hidden';
        mtmpobj.style.display = '';
        mtmpobj.style.opacity = '0';
              
        windowWidth = 0;
        windowHeight = 0;
                 
        if (loadDelay == 0)
        {   
            setwidhei();
        }  
                    
        if ((windowWidth < 50 || windowHeight < 50))
        {
            setTimeout("TryShow();", loadDelay);
            return false
        }
        else
        {
            Element.hide('aspxoutput');
            mtmpobj.style.visibility = '';
            myLightbox.resizeImageContainer(windowWidth, windowHeight);
            return false;
        }
    }
    
    Element.hide('aspxoutput');        
    currentKey = key;
    return true;
}
        
        function setwidhei()
        {   
            if (mtmpobj.childNodes.length == 1) {
                windowWidth = mtmpobj.firstChild.clientWidth;
		        windowHeight = mtmpobj.firstChild.clientHeight;}
            else {
                windowWidth = mtmpobj.clientWidth;
		        windowHeight = mtmpobj.clientHeight; }

            if ((windowWidth == 0 || windowHeight == 0)) {
                if (document.getElementById('aspxoutput').childNodes.length == 1) {
                    windowWidth = mtmpobj.firstChild.offsetWidth;
		            windowHeight = mtmpobj.firstChild.offsetHeight; }
                else
                {
                    windowWidth = mtmpobj.offsetWidth;
		            windowHeight = mtmpobj.offsetHeight; }
            }
            
            if (predefWidth != 0) { windowWidth = predefWidth; }
            if (predefHeight != 0){ windowHeight = predefHeight; }
        }
                 
        function TryShow()
        {
            setwidhei();
        if ((windowWidth < 50 || windowHeight < 50))
            {
                setTimeout("TryShow();", loadDelay)
            }
            else
            {
                Element.hide('aspxoutput');
                mtmpobj.style.visibility = '';
                myLightbox.resizeImageContainer(windowWidth, windowHeight);
            }
        }

