﻿function CATALOGUS_IMPL() {

    /* Privates */
    
    var posx_; 
    var posy_;

    function getMousex(e) {
        posx_ = 0; posy_ = 0;
        var ev = (!e) ? window.event : e; //Moz:IE
        if (ev.pageX) { posx_ = ev.pageX; posy_ = ev.pageY } //Mozilla or compatible
//        else if (ev.clientX) {
//            posx_ = ev.clientX;
//            posy_ = ev.clientY + (document.documentElement.scrollTop ?
//                    document.documentElement.scrollTop :
//                    document.body.scrollTop)
//        } //IE or compatible
        else if (ev.x) {
            posx_ = ev.x;
            posy_ = ev.y + (document.documentElement.scrollTop ?
                    document.documentElement.scrollTop :
                    document.body.scrollTop)
        } //IE or compatible
        else { return false } //old browsers
        posy_ -= 150;
    }

    function HourGlassUpdate() {
        getMousex(event);
        var theId = 'HOURGLASSDIV';
        if (document.getElementById(theId)) {
            document.getElementById(theId).className = 'hourglass';
            setTimeout("document.getElementById('HOURGLASSDIV').className = 'hourglasshidden';", 3000);
            document.getElementById('HOURGLASSDIV').style.left = posx_ + 'px';
            document.getElementById('HOURGLASSDIV').style.top = posy_ + 130 + 'px';
        }
    }

    /* public */
    
    this.show = function(src) {
        getMousex(event);
        if (document.getElementById('popup') && document.getElementById('img')) {
            document.getElementById('img').src = src;
            document.getElementById('popup').className = 'mouseoverDiv';

            if (posx_ > 700) posx_ = 700;
            document.getElementById('popup').style.left = posx_ + 'px';
            document.getElementById('popup').style.top = posy_ + 'px';
            document.getElementById('popup').style.zIndex = 2;
        }
    }

    this.showpopup = function(id) {
        getMousex(event);
        var theId = id + '_MainDiv';
        if (document.getElementById('popupKweker') && document.getElementById(theId)) {
            document.getElementById('popupKweker').innerHTML = document.getElementById(theId).innerHTML;
            document.getElementById('popupKweker').className = 'mouseoverDivKweker';

            if (posx_ > 700) posx_ = 700;
            document.getElementById('popupKweker').style.left = posx_ + 'px';
            document.getElementById('popupKweker').style.top = posy_ + 'px';
            document.getElementById('popupKweker').style.zIndex = 2;
        }
    }

    this.hide = function() {
        if (document.getElementById('popup')) {
            document.getElementById('popup').className = 'mouseoutDiv';
        }
    }

    this.hidepopup = function() {
        if (document.getElementById('popupKweker')) {
            document.getElementById('popupKweker').className = 'mouseoutDiv';
        }
    }

    this.navigate = function(imgsrc) {    
        document.location = imgsrc;
    }

    this.dohourglass = function(x) {
        
    }

    //http://tiredblogger.wordpress.com/2007/09/25/catching-enter-on-web-pages-with-javascript/
    this.catchEnter = function (e) {
        // Catch IE’s window.event if the 
        // ‘e’ variable is null.
        // FireFox and others populate the
        // e variable automagically.
        if (!e) e = window.event;

        // Catch the keyCode into a variable. 
        // IE = keyCode, DOM = which.
        var code = (e.keyCode) ? e.keyCode : e.which;

        // If code = 13 (enter) or 3 (return),
        // cancel it out; else keep going and
        // process the key.
        if (code == 13 || code == 3) return false;
        else return true;
    }

    this.resizemydiv = function(offset) { document.getElementById('scrolldiv').style.height = document.documentElement.clientHeight - offset; }
}
if (typeof CATALOGUS == "undefined") { var CATALOGUS = new CATALOGUS_IMPL(); }

