// JavaScript Document
$(document).ready(
        function()
        {
                $('#windowOpen').bind(
                        'click',
                        function() {
                                if($('#window').css('display') == 'none') {
                                        $(this).TransferTo(
                                                {
                                                        to:'window',
                                                        className:'transferer2', 
                                                        duration: 400,
                                                        complete: function()
                                                        {
                                                                $('#window').show();
                                                        }
                                                }
                                        );
                                }
                                this.blur();
                                return false;
                        }
                );
                $('#windowClose').bind(
                        'click',
                        function()
                        {
                                $('#window').TransferTo(
                                        {
                                                to:'windowOpen',
                                                className:'transferer2', 
                                                duration: 400
                                        }
                                ).hide();
                        }
                );
                $('#windowMin').bind(
                        'click',
                        function()
                        {
                                $('#windowContent').SlideToggleUp(300);
                                $('#windowBottom, #windowBottomContent').animate({height: 10}, 300);
                                $('#window').animate({height:40},300).get(0).isMinimized = true;
                                $(this).hide();
                                $('#windowResize').hide();
                                $('#windowMax').show();
                        }
                );
                $('#windowMax').bind(
                        'click',
                        function()
                        {
                                var windowSize = $.iUtil.getSize(document.getElementById('windowContent'));
                                $('#windowContent').SlideToggleUp(300);
                                $('#windowBottom, #windowBottomContent').animate({height: windowSize.hb + 13}, 300);
                                $('#window').animate({height:windowSize.hb+43}, 300).get(0).isMinimized = false;
                                $(this).hide();
                                $('#windowMin, #windowResize').show();
                        }
                );
                $('#window').Resizable(
                        {
                                minWidth: 200,
                                minHeight: 60,
                                maxWidth: 700,
                                maxHeight: 400,
                                dragHandle: '#windowTop',
                                handlers: {
                                        se: '#windowResize'
                                },
                                onResize : function(size, position) {
                                        $('#windowBottom, #windowBottomContent').css('height', size.height-33 + 'px');
                                        var windowContentEl = $('#windowContent').css('width', size.width - 25 + 'px');
                                        if (!document.getElementById('window').isMinimized) {
                                                windowContentEl.css('height', size.height - 48 + 'px');
                                        }
                                }
                        }
                );
        }
);

$(document).ready(
        function()
        {
                $('#windowOpen2').bind(
                        'click',
                        function() {
                                if($('#window2').css('display') == 'none') {
                                        $(this).TransferTo(
                                                {
                                                        to:'window2',
                                                        className:'transferer22', 
                                                        duration: 400,
                                                        complete: function()
                                                        {
                                                                $('#window2').show();
                                                        }
                                                }
                                        );
                                }
                                this.blur();
                                return false;
                        }
                );
                $('#windowClose2').bind(
                        'click',
                        function()
                        {
                                $('#window2').TransferTo(
                                        {
                                                to:'windowOpen2',
                                                className:'transferer22', 
                                                duration: 400
                                        }
                                ).hide();
                        }
                );
                $('#windowMin2').bind(
                        'click',
                        function()
                        {
                                $('#windowContent2').SlideToggleUp(300);
                                $('#windowBottom2, #windowBottomContent2').animate({height: 10}, 300);
                                $('#window2').animate({height:40},300).get(0).isMinimized = true;
                                $(this).hide();
                                $('#windowResize2').hide();
                                $('#windowMax2').show();
                        }
                );
                $('#windowMax2').bind(
                        'click',
                        function()
                        {
                                var windowSize = $.iUtil.getSize(document.getElementById('windowContent2'));
                                $('#windowContent2').SlideToggleUp(300);
                                $('#windowBottom2, #windowBottomContent2').animate({height: windowSize.hb + 13}, 300);
                                $('#window2').animate({height:windowSize.hb+43}, 300).get(0).isMinimized = false;
                                $(this).hide();
                                $('#windowMin2, #windowResize2').show();
                        }
                );
                $('#window2').Resizable(
                        {
                                minWidth: 200,
                                minHeight: 60,
                                maxWidth: 850,
                                maxHeight: 750,
                                dragHandle: '#windowTop2',
                                handlers: {
                                        se: '#windowResize2'
                                },
                                onResize : function(size, position) {
                                        $('#windowBottom2, #windowBottomContent2').css('height', size.height-33 + 'px');
                                        var windowContentEl = $('#windowContent2').css('width', size.width - 25 + 'px');
                                        if (!document.getElementById('window2').isMinimized) {
                                                windowContentEl.css('height', size.height - 48 + 'px');
                                        }
                                }
                        }
                );
        }
);


