var launch = {
    fullscreen: function (b) {
     var overlayCSS = {
        'background-color':'#000',
        'cursor':'pointer',
        'display':'none',
        'height':'6000px',
        'left':'0',
        'position':'absolute',
        'top':'0',
        'width':'100%',
        'z-index':'100000'
         };
      var holderCSS = {  
        //'background-color':'#FFF',
        'display':'none',
        'height':'auto',
        'padding':'10px',
        'position':'fixed',
        'width':'auto',
        'z-index':'200000'
        };
      var closeCSS = {  
        'height':'30px',
        'position':'absolute',
        'right':'-15px',
        'top':'-15px',
        'width':'30px'
        };  

	var origWrapperWidth = $('#wrapper').css('width');
	$('#wrapper').css('width', '100%');

        var popup = $(b);
        var overlay = '<div id="fs_overlay"></div>';
        var holder = '<div id="fs_holder"></div>';
        var close = '<div id="fs_close"><img src="/img/close.png" /></div>';
    
        $('#popup_holder_inside_form').append(holder);
        $('#popup_holder_inside_form').append(overlay);
        $('#fs_holder').prepend(close);
        $('#fs_holder').append(popup);
        $('#fs_overlay').css(overlayCSS);
        $('#fs_overlay').fadeTo('fast', 0.8);
        $('#fs_holder').css(holderCSS);
        $('#fs_close').css(closeCSS);
        window.scrollTo(0, 5000);
        $('#fs_holder').show();
        $(popup).show();
        $('#fs_overlay').show();
      
            function closePopup() {
	$('#wrapper').css('width', origWrapperWidth);
           $('body').prepend(popup);
           $(popup).hide();
           $('#fs_holder').remove();
           $('#fs_overlay').remove();
                }
            
         $('#fs_close').click(function() {
		closePopup();
          });  
         $('.comment-cancel-button').click(function() {
		closePopup();
          });  
           
        
          $(window).resize(function () {
             centerPopup();
          });
          $(window).scroll(function () {
              centerPopup();
          });

            function centerPopup() {
                if (typeof(window.innerWidth) == 'number') {
                    winW = window.innerWidth;
                    winH = window.innerHeight;
                } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                    winW = document.documentElement.clientWidth;
                    winH = document.documentElement.clientHeight;
                } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                    winW = document.body.clientWidth;
                    winH = document.body.clientHeight;
                }
                winW = winW / 2;
                winH = winH / 2;
                PopupW = $(popup).width() / 2;
                PopupH = $(popup).height() / 2;
                PopupL = Math.round((winW - PopupW));
                PopupT = Math.round((winH - PopupH));
                $('#fs_holder').css({
                    "left": PopupL,
                    "top": PopupT
                });
              
            }     
	centerPopup();
    }
}

