    /** 
    *    copyright 2008 Weisswo.com
    */
    
    /** 
    *    Constructor
    */   
function WeissWoFullScreen(elementId, subWidth, subHeight, onGoFull, onHideFull)
    {
        
        WeissWoFullScreen.prototype.singleton = this;
        
        this._subWidth = subWidth || 0;
        this._subHeight = subHeight || 0;
        this._fullScreenSubWidth = 0;
        this._fullScreenSubHeight = 0;
        this._fullscreenObject = document.getElementById(elementId);
        this._fullscreenObject._originalWidth = this._fullscreenObject.style.width;
        this._fullscreenObject._originalHeight = this._fullscreenObject.style.height;
        this._state = 0; 
        
        
        this._fullscreenContainer = this._fullscreenObject.parentNode; 
        this._fullscreenButtonUrl = 'http://pinpoint.weisswo.eu/lib/icons/goFull.png';
        this._fullscreenButtonWidth = 130;
        this._fullscreenButtonHeight = 35;
        this._fullscreenButtonText = '&nbsp;Full view';
        
        this.transparentUrl = 'http://pinpoint.weisswo.eu/lib/icons/transparent.gif';
        
        this._closeButtonUrl = 'http://pinpoint.weisswo.eu/lib/icons/transparent.png';
        this._closeButtonUrl = 'http://pinpoint.weisswo.eu/lib/icons/closeFull.png';
        this._closeButtonWidth = this._fullscreenButtonWidth;
        this._closeButtonHeight = this._fullscreenButtonHeight;
        this._closeButtonText = '&nbsp;&nbsp;Normal';
        this._ie6 = navigator.userAgent.search(new RegExp("MSIE 6"))>0;
        
        this._onGoFull = onGoFull || null;
        this._onHideFull = onHideFull || null;
        
        window.onload = function () { WeissWoFullScreen.prototype.singleton._setSize(1); };
        window.onresize = function () { WeissWoFullScreen.prototype.singleton._setSize(1); };
        this._setSize(1);
    };
       
WeissWoFullScreen.prototype.setFullScreenMargins = function (left, top)
    {
        this._fullScreenSubWidth = left;
        this._fullScreenSubHeight = top;
    };
    
WeissWoFullScreen.prototype.setButtonTexts = function (fullscreenButtonText,normalButtonText)
    {
        this._fullscreenButtonText = fullscreenButtonText;
        this._closeButtonText = normalButtonText;
    };
    
WeissWoFullScreen.prototype.setFullScreenButtonImage = function (fullscreenButtonUrl, fullscreenButtonWidth, fullscreenButtonHeight)
    {
        this._fullscreenButtonUrl = fullscreenButtonUrl;
        this._fullscreenButtonWidth = fullscreenButtonWidth;
        this._fullscreenButtonHeight = fullscreenButtonHeight;
    };
    
WeissWoFullScreen.prototype.setCloseButtonImage = function (closeButtonUrl, closeButtonWidth, closeButtonHeight)    
    {
        this._closeButtonUrl = closeButtonUrl;
        this._closeButtonWidth = closeButtonWidth;
        this._closeButtonHeight = closeButtonHeight;
    };
    
WeissWoFullScreen.prototype.activateFullScreen = function(activateButtonId,toggle,pngFixOff)
    {
        this._fullscreenContainer.style.position = "relative"; 
        
        if(activateButtonId)
        {
            var x = document.getElementById(activateButtonId);
            if(toggle)
                x.onclick = function () { WeissWoFullScreen.prototype.singleton.toggleFullScreen(); };
            else
                x.onclick = function () { WeissWoFullScreen.prototype.singleton.goFullScreen(); };
        }
        else
        {
            var l = document.createElement('a');
            l.setAttribute('href','#');
            l.onclick = function () { WeissWoFullScreen.prototype.singleton.goFullScreen(); };
            
            var c = document.createElement('img');
            c.style.width = this._fullscreenButtonWidth+'px';
            c.style.height = this._fullscreenButtonHeight+'px';
            if(this._ie6 && !pngFixOff)
            {
                c.src = this.transparentUrl;
                c.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this._fullscreenButtonUrl + "',sizingMethod='scale')";
            }
            else
                c.src = this._fullscreenButtonUrl;
            
            l.appendChild(c);
            
            var d = document.createElement('div');
            d.innerHTML = this._fullscreenButtonText;
            l.appendChild(d);
            
            this._fullscreenButtonDiv = document.createElement('div');
            this._fullscreenButtonDiv.id = 'weissWoFullScreenButton';
            this._fullscreenButtonDiv.appendChild(l);
            
            this._fullscreenContainer.appendChild(this._fullscreenButtonDiv);
        }
        
        l = document.createElement('a');
        l.setAttribute('href','#');
        l.onclick = function () { WeissWoFullScreen.prototype.singleton.hideFullScreen(); };
        
        var b = document.createElement('img');
        b.style.width = this._closeButtonWidth+'px';
        b.style.height = this._closeButtonHeight+'px';
        if(this._ie6 && !pngFixOff)
        {
            b.src = this.transparentUrl;
            b.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this._closeButtonUrl + "',sizingMethod='scale')";
        }
        else
            b.src = this._closeButtonUrl;
        
        l.appendChild(b);
        
        var t = document.createElement('div');
        t.innerHTML = this._closeButtonText;
        l.appendChild(t);
        
        this._closeContainer = document.createElement('div');
        this._closeContainer.id = 'weissWoCloseButton';
        this._closeContainer.style.zIndex = '150';
        this._closeContainer.appendChild(l);
    };

WeissWoFullScreen.prototype.toggleFullScreen = function ()
    {
        if(this._state == 1)
            this.hideFullScreen();
        else
            this.goFullScreen();
    };
    
    
WeissWoFullScreen.prototype.goFullScreen = function ()
    {
        if(this._onGoFull) this._onGoFull.call(this);
        
        this._fullscreenContainer.style.position = ""; 
        
        this._fullscreenObject.style.position = 'absolute';
        this._fullscreenObject.style.left = this._fullScreenSubWidth+'px';
        this._fullscreenObject.style.top = this._fullScreenSubHeight+'px';
        this._fullscreenObject.style.zIndex = '100';
        
        document.getElementsByTagName('html')[0].style.overflowX = 'hidden';
        document.getElementsByTagName('html')[0].style.overflowY = 'hidden';
        
        this._closeContainer.style.display = '';
        this._fullscreenObject.parentNode.appendChild(this._closeContainer);
        
        this._state = 1;
        this._setSize(1);
    };
    

WeissWoFullScreen.prototype.hideFullScreen = function() 
    {        
        if(this._onHideFull) this._onHideFull.call(this);
        
        this._fullscreenContainer.style.position = "relative"; 
        
        this._closeContainer.style.display = 'none';
        
        this._fullscreenObject.style.position = '';
        this._fullscreenObject.style.height = this._fullscreenObject._originalHeight;
        this._fullscreenObject.style.width = this._fullscreenObject._originalWidth;
        this._fullscreenObject.style.border = 'none';
        this._fullscreenObject.style.display = '';
        this._fullscreenObject.style.overflow = ''; 
        
        document.getElementsByTagName('html')[0].style.overflowX = '';
        document.getElementsByTagName('html')[0].style.overflowY = '';
        
        this._state = 0;
        this._setSize(1);
    };
    

WeissWoFullScreen.prototype._setSize = function(iEfIx) 
    {
        var h,w;
        
        if((this._subWidth == 0 && this._subHeight == 0) && this._state != 1)
            return;

        if( typeof( window.innerWidth ) == 'number' ) 
        {
            w = window.innerWidth;
            h = window.innerHeight;
            
        } 
        else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
        {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        }
        else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
        {
            w = document.body.clientWidth;
            h = document.body.clientHeight;
        }
        
        if(this._state == 0)
        {
            w -= this._subWidth;
            h -= this._subHeight;
        }
        else if(this._state == 1)
        {
            w -= this._fullScreenSubWidth;
            h -= this._fullScreenSubHeight;
        }
        
        if(iEfIx<0 || this._fullscreenObject.style.width == w+'px' && this._fullscreenObject.style.height == h+'px') 
            return;
        
        this._fullscreenObject.style.width = (w-iEfIx)+'px';
        this._fullscreenObject.style.height = (h-iEfIx)+'px';
        this._fullscreenObject.scrollIntoView();
        
        var me=this;
        setTimeout(function(){me._setSize(iEfIx-1)},1000); 
    };
