<!--

Initialise.addEvent(function() {

    try {

        /*
         * build overlay
         */
         var ArtgrpOverlay = new Element('div', {
            'id' : 'ArtgrpOverlay',
            'style' : 'display: none; position: fixed;'
        });

        var MoviesWin = new Element('div', {
            'id' : 'ArtgrpWin',
            'class' : 'window',
            'style' : 'display: none;'
        });
        $('page').insert(MoviesWin);
        $('page').insert(ArtgrpOverlay);

        /*
         * Add event handler info box.
         */
         ArticleInfoBox.initialize();
         
         MovieEvent.initialize();

        if ($$(".groupMovie")) {
            $$(".groupMovie").each(function (item) {
                item.observe("click", MovieEvent.handleMovieEvent);
            });
        }
    }
    catch (e) {

    }
});

/*
 * @object: MovieEvent
 * 
 * ImageList is provided by artpage.module
 * 
 */

MovieEvent = {

    initialize : function() {},

    handleMovieEvent: function (handler) {

        // display a preloader
        var arrayPageSize = Helper.getPageSize();
        MovieEvent.screenWidth = arrayPageSize[0];
        MovieEvent.screenHeight = arrayPageSize[1];

        $('ArtgrpOverlay').setStyle({
            width: MovieEvent.screenWidth + 'px',
            height: MovieEvent.screenHeight + 'px',
            position: 'fixed'
        });

        $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });

        new Effect.Appear($('ArtgrpOverlay'),{
            duration: .4,
            from: 0.0,
            to: 0.4,
            afterFinish : function() {

                // load images
                new Ajax.Updater('ArtgrpWin', '/xhr/artgrp/media.php', {
                    parameters : {
                        media : MediaConf.requestURL
                    },
                    method : 'post',
                    asynchronous : true,
                    evalScripts : true,
                    onComplete : function() {

                        // register close icons
                        MovieEvent.registerCloseIcons();

                        // now begin to appear image section
                        Effect.Appear($('ArtgrpWin'), {
                            duration: 0.2,
                            afterFinish : function() {}
                        });
                    }
                });

            }
        });
    },

    closeWindow: function () {

        new Effect.Fade($('ArtgrpOverlay'));

        $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
        $('ArtgrpWin').hide();

        $('zoomImage').src = '/img/misc/spacer.gif';
    },

    registerCloseIcons : function() {

        windowClosers = $$('a.windowCloser');

        if (windowClosers) {
            windowClosers.each(function(item) {
                item.observe("click",MovieEvent.closeWindow);
            });
        }
        if ($('ArtgrpOverlay')) {
            $('ArtgrpOverlay').observe("click",MovieEvent.closeWindow);
        }

    }
};

/*
 * @object: ArticleInfoBox
 * 
 */

ArticleInfoBox = {
    
    target : false,
    
    currentBox : false,
    
    initialize : function() {
        
        links = $$('a.article-info-box-link');
        
        links.each(function(item) {
            item.observe('mouseover', ArticleInfoBox.show, false);
            item.observe('mouseout', ArticleInfoBox.hide, false);
        });  
        
        boxes = $$('div.article-info-box');
        
        boxes.each(function(item) {
            item.observe('mouseover', ArticleInfoBox.hold, false);
            item.observe('mouseout', ArticleInfoBox.hideBox, false);
        });
    
    },
    
    hold : function() {
        
        if (document.viewport.getWidth() < 1000) {
            $('articleInfoBox' + ArticleInfoBox.target).addClassName('right');
        } else {
            $('articleInfoBox' + ArticleInfoBox.target).removeClassName('right');
        }
        
        this.show();
        
    },
    
    hideBox : function() {
        
        this.hide();
        
    },
    
    show : function() {
        
        ArticleInfoBox.target = this.readAttribute('name');
        
        if (document.viewport.getWidth() < 1000) {
            $('articleInfoBox' + ArticleInfoBox.target).addClassName('right');
        } else {
            $('articleInfoBox' + ArticleInfoBox.target).removeClassName('right');
        }
        
        if (ArticleInfoBox.currentBox) {
            $('articleInfoBox' + ArticleInfoBox.currentBox).hide();
        }
        
        $('articleInfoBox' + ArticleInfoBox.target).show();
        
        ArticleInfoBox.currentBox = ArticleInfoBox.target;
        
    },
    
    hide : function() {

        $('articleInfoBox' + ArticleInfoBox.target).removeClassName('right');

        ArticleInfoBox.target = this.readAttribute('name');

        $('articleInfoBox' + ArticleInfoBox.target).hide();
        
        ArticleInfoBox.currentBox = false;

    }
};

Helper = {
    getPageSize: function() {
            
         var xScroll, yScroll;

        if (window.innerHeight && window.scrollMaxY) {  
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){
            // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else {
            // Explorer Mac...would also work in Explorer 6 Strict,
            // Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

        var windowWidth, windowHeight;

        if (self.innerHeight) {
            // all except Explorer
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth; 
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer
            // 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }

        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else { 
            pageHeight = yScroll;
        }

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
            pageWidth = xScroll;
        } else {
            pageWidth = windowWidth;
        }

        return [pageWidth,pageHeight];
    }
};
-->
