    (function($){
        $.fn.centerInClient = function(options) {
            
            var opt = { forceAbsolute: false,
                        container: window,    // selector of element to center in
                        completeHandler: null
                      };
            $.extend(opt, options);
           
            return this.each(function(i) {
                var el = $(this);
                var jWin = $(opt.container);
                var isWin = opt.container == window;

                // force to the top of document to ENSURE that 
                // document absolute positioning is available
                if (opt.forceAbsolute) {
                    if (isWin)
                        el.remove().appendTo("body");
                    else
                        el.remove().appendTo(jWin.get(0));
                }

                // have to make absolute
                el.css("position", "absolute");

                // height is off a bit so fudge it
                var heightFudge = isWin ? 2.0 : 1.8;

                var x = (isWin ? jWin.width() : jWin.outerWidth()) / 2 - el.outerWidth() / 2;
                var y = (isWin ? jWin.height() : jWin.outerHeight()) / heightFudge - el.outerHeight() / 2;

                el.css("top", y + jWin.scrollTop());

                // if specified make callback and pass element
                if (opt.completeHandler)
                    opt.completeHandler(this);
            });
        }
    })(jQuery);
    jQuery(function($) { 
        $(document).ready(function() {	
            
            launchWindow('#dialog');   
            
            //if close button is clicked
            $('.window .close').click(function () {
	            //$('#mask').hide();
	            $('.window').hide();
	            //$("select, embed, object").css('visibility','visible');
            });		
        	
            //if mask is clicked
//            $('#mask').click(function () {
//	            $(this).hide();
//	            $('.window').hide();
//	            $("select, embed, object").css('visibility','visible');
//            });			
        	
        });

        function launchWindow(id) {

	        //transition effect		
	        //$('#mask').fadeIn("fast");	
	        //$('#mask').fadeTo("fast",0.8);	
    	
	        //Get the window height and width
	        var winH = $(window).height();
	        var winW = $(window).width();
                  
	        //Set the popup window to center
	        $(id).css('left', winW/2-$(id).width()/2);
	        
	        //transition effect
	        //$(id).fadeIn("fast"); 
	        
	        $(id).centerInClient();
	        
	        $(id).show("drop", { direction: "up" }, 2000);
	        
	        //$("select, embed, object").css('visibility','hidden');

        }
         
    });       

