// Attach events to some elements

function init() {
    icons = $('main').getElements('div[class^=icon]');
    $$(icons).each(
        //pageNo = pageNo+1;
        function(el) {
            el.onmouseover = function() {
                return el.id='highlight';
            }
            el.onmouseout = function() {
                return el.id=null;
            }
            // Look for child link(s)
            childLinks = el.getElements('a');
            childLink = '';
            $$(childLinks).each(
                function(c) {
                    if (c.href && (childLink == '')) {
                        el.onclick = function() {
                            return window.location=c.href;
                        }
                        c.onfocus = function() {
                            return c.blur();
                        }
                    }

                }
            );


        }
    );

}

function getWindowHeight() {
    var windowHeight = 0;
    if (typeof(window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}

function setPageStyle() {
    var winH = getWindowHeight();
    if (winH > 650) { //565
        $('body').className = $('body').className + '_big';
    }
}

/* Portfolio Image Viewing */

function showPhotograph(imgGalleryEncoded, langTextImage, langTextOf, startIndex) {
    var imgGallery = eval(imgGalleryEncoded);
    return Lightbox.openExt(imgGallery, startIndex, langTextImage, langTextOf);
}

/* Initialization */

window.addEvent('load', function() {
    init();
    setPageStyle();
});
