﻿/*
    Dependencies:
--------------------------------------------
    jQuery 1.3.2 (or later - http://jquery.com/)
*/

var undefined;

var wun = (wun == undefined) ? {} : wun;

/*
    wun.shadow css sample:
--------------------------------------------	

    .wunShadow {
	    background-color: #000000;
	    display: none;
	    z-index: 25;
	    overflow: hidden;
	    position: absolute;
	    left: 0px;
	    top: 0px;
	    filter: alpha(Opacity=25);
	    opacity: .25;
	    -moz-opacity: 0.25;
	    -khtml-opacity: 0.25;
	}   
*/

wun.shadow = function() {

    this.elements = {};
    
    this.create = function() {
    
        //modify viewport as required
        jQuery(document.body).css('height', 'auto').parent().css('height', '100%');
    	
    	//create shadow elements and attach to html document
    	this.elements.div = jQuery('<div></div>')
    		.addClass('wunShadow');

    	if (jQuery('#aspnetForm').html() != null)
    	    jQuery('#aspnetForm').append(this.elements.div);
    	else
    	    jQuery(document.body).append(this.elements.div);
		
        this.resize();
        
        jQuery(window).bind('resize', {sender: this}, function(event){
        	event.data.sender.resize();
    	});
		
    };
	
	this.isIE6 = function() {
		return ( jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 );
	};
	
    this.isVisible = function() {
		return this.element.div.is(':visible');
    };

    this.show = function() {
        this.elements.div.show();
        this.resize();
    };

    this.hide = function() {
        this.elements.div.hide();
   	};

    this.resize = function() {
        //height
        if (document.body.offsetHeight > document.body.parentNode.offsetHeight) {
            this.elements.div.css('height', document.body.offsetHeight + 'px');
        }
        else {
            this.elements.div.css('height', document.body.parentNode.offsetHeight + 'px');
        }

        //width
        if (document.body.offsetWidth == document.body.parentNode.offsetWidth)
            this.elements.div.css('width', '100%');
        else
            this.elements.div.css('width', document.body.offsetWidth + 'px');
    };

    this.click = function(fn) {
    	this.elements.div.click(fn);
    };
    
    this.create();
};
