/** lite manage of opening internal windows **/

        var ids =2;
        function task_window_focus(){}
        
        function display_references_window(url_, args){
            foo =open_window(Object.extend(args,{ url:url_, icon:"../d30/img/new_object.png", width:960, height:630}));
            return foo;
        }
        
        function display_login_window(login_url,center,parent_win_id){
            foo = open_window({url:login_url,icon: "../d30/desktop/images/web_search.gif", width:600, height:420, title: "Login", closable : true,url:login_url});
            return foo;
        }
        
        function open_window(args){

            if(args.url){
                if(args.url.indexOf('?')>0){
                    if (args.url.indexOf('&win=')<=0) args.url += '&win=win'+ids;
                    if (args.url.indexOf('&desktop=')<=0) args.url += '&desktop=true';
                }
            }
            
            if(typeof args.className == "undefined") args.className = "avicend";
            args.draggable = true;
            
            foo = new Window('win'+ids, args);
            
            DestroyObserver = {
                onDestroy: function(eventName, win) {
                        Windows.removeObserver(this);
                    }
                }
            var modal = false;
            if(args.modal == true) modal = true;
            Windows.addObserver(DestroyObserver);
            foo.setDestroyOnClose();
            if(args.left && args.top){
                foo.show(modal);
            } else{
                foo.showCenter(modal);
            }
            foo.toFront();
            ids++;	
            return foo;
        }
        /** this function should be revised : 
            centering problem : I think that this pb is in the welcome_alert.css file because it works with the avicend classname 
        **/
        /*
        function open_dialog(message,args){
            var args1 = {width:250, height:150, okLabel: close_button_title,
                            ok:function(win) {
                                    return true;
                                }
                        };
            if(typeof args == 'object') args1 = Object.extend(args1,args);
            var foo = Dialog.alert(message, args1);
        }
        */
        
        function open_windows_array(win_array){
            var k=0;
            var task;
            var foo;
            for (k=0;k< win_array.length;k++){
                task = win_array[k];
                if((typeof task.args.parent_id != "undefined") && (task.args.parent_id != null)){
                    task.args.parent = $(task.args.parent_id);
                }
                if(task.left && task.top) task.args =  Object.extend(task.args,{left: task.left, top: task.top});
                foo = null;
                switch (task.action){
                    case 'open_window':
                        foo = open_window(task.args);
                        break;
                    default :
                        alert_window('Window lite mode can not display this kind of windows: '+task.action);
                        break;
                }

                if(foo && task.title) foo.setTitle(task.title);
            }
        }
        
        function close_focused_window(){
            foo = Windows.getFocusedWindow();
            foo.destroy();
        }
        
        function close_window(win_id){
            var foo = Windows.getWindow(win_id);
            if(foo){
                foo.destroy();
            } 
        }
        
        function set_window_title(id,text){
            var foo = Windows.getWindow(id);
            if(foo) foo.setTitle(text);
        }