STMA.Vis = {
    lightBoxResize: function() {
        var viewportwidth;
        var viewportheight;
    
        if (typeof window.innerWidth != 'undefined') {
            viewportwidth = window.innerWidth,
            viewportheight = window.innerHeight
        } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
            viewportwidth = document.documentElement.clientWidth,
            viewportheight = document.documentElement.clientHeight
        } else {
            viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
            viewportheight = document.getElementsByTagName('body')[0].clientHeight
        }    
        maxW = 1000;
        maxH = 750;
        indent = 150;
        if (viewportheight < (maxH + indent) || viewportwidth < (maxW + indent)) {           
            rt = maxW / maxH;
            h = viewportheight - indent;
            w = viewportwidth - indent;
            r = w/h;
            if (r > rt) {
                newH = h;
                newW = Math.floor(h * rt);
            } else {
                newW = w;
                newH = Math.floor(w /rt);             
            }
            var a;
            var item;
            a = document.getElementsByTagName('a');
            for(i=0;i<a.length;i++) {
                item = a[i];
                if (item.rel.search('lightbox') != '-1') {
                    var str = item.href;
                    str = str.replace('width='+maxW+'&height='+maxH,'width='+newW+'&height='+newH);
                    item.href = str;
                }
            }
        } 
        window.onresize = function() {
            STMA.Vis.lightBoxResize();
        } 
    },
    changeThumb: function(i,v) {
        o = $g('varThumb_'+i+'_'+v)
        p = o.parentNode;
        if (o != p.set) {
            if ($g('varSizes_'+i) != null) {
                s = $g('varSizes_'+i);
                if (!s.set) {
                    s.set = s.firstChild;
                }
                s.set.className = 'hidden';
                n = $g('varSize_'+v);
                n.className = '';
                s.set = n;
            }
            if (!p.set) {
                p.set = p.firstChild;
            }
            p.set.className = 'hidden';
            o.className = '';
            p.set = o;            
        } else {
            return false;
        }

    }
}
/*
STMA.Thumbs = {}
STMA.Thumbs.draw = function() {
    nodes = new Array();
    var l;
    l = $('div.thumbL');
    for(i=0;i<l.length;i++) {
        nodes.push(l[i]);
    }    
    var sm;
    sm = $('div.thumbSm');
    for(i=0;i<sm.length;i++) {
        nodes.push(sm[i]);
    }
    
    if (nodes.length) {
        for(i=0;i<nodes.length;i++) {
            item = nodes[i];
            cl = item.className;
            thumbSelf = item.firstChild;
            
            img = document.createElement('img');
            img.src = '/frontend/gfx/'+cl+'.png';
            img.alt = thumbSelf.alt;
            img.title = thumbSelf.title;
            img.style.position = 'absolute';
            
            item.insertBefore(img, thumbSelf);
            
        }        
    }

}*/
