﻿/*
    Dependencies:
--------------------------------------------
    wun.common.js
*/

var undefined;

var wun = (wun == undefined) ? {} : wun;

/*

    wun.imageTooltip HTML:
--------------------------------------------  

    <div class="wunTooltipShadow"></div>
    
    

    wun.shadow CSS:
--------------------------------------------	

    .wunShadow {
        background-color: #000000;
        display: none;
        z-index: 25;
        position: absolute;
        left: 0px;
        top: 0px;
        filter: alpha(Opacity=25);
        opacity: .25;
        -moz-opacity: 0.25;
        -khtml-opacity: 0.25;
    }    
*/

wun.shadow = {
    element: undefined,
    create: function() {
        this.element = document.createElement('div');
        this.element.className = "wunShadow";
        wun.common.getBodyNode().appendChild(this.element);

        this.resize();
        window.onresize = function() { wun.shadow.resize(); }
    },

    initiated: function() {
        if (wun.common != undefined) {
            if (this.element == undefined) this.create();
        }
        return this.element != undefined;
    },

    visible: function() {
        if (this.initiated()) {
            return (this.element.display != 'none');
        }
    },

    show: function() {
        if (this.initiated()) this.element.style.display = 'block';
    },

    hide: function() {
        if (this.initiated()) this.element.style.display = 'none';
    },

    resize: function() {
        if (this.initiated()) {
            //height
            if (wun.common.getBodyNode().offsetHeight > wun.common.getHtmlNode().offsetHeight)
                this.element.style.height = wun.common.getBodyNode().offsetHeight + "px";
            else
                this.element.style.height = wun.common.getHtmlNode().offsetHeight + "px";

            //width
            if (wun.common.getBodyNode().offsetWidth > wun.common.getHtmlNode().offsetWidth)
                //wun.common.getBodyNode().offsetWidth
                this.element.style.width = wun.common.getBodyNode().offsetWidth + "px";
            else
                this.element.style.width = wun.common.getHtmlNode().offsetWidth + "px";
        }
    },

    setOnclick: function(func) {
        if (this.initiated()) {
            this.element.onclick = func;
        }
    }
}
