/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

    Ext.state.Manager.setProvider(
            new Ext.state.SessionProvider({state: Ext.appState}));

    var button = Ext.get('location');
    var datbutton = Ext.get('date');
	var win;
	var win2;
	
    button.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!win){
            win = new Ext.Window({
                applyTo     : 'hello-win',
                layout      : 'fit',
                width       : 500,
                height      : 300,
             	y 			: 300,
                closeAction :'hide',
                plain       : true,
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        win.hide();
                    }
                }, {
                    text     : 'OK',
                    handler  : function(){
                    	document.getElementById('locationform').submit();
                    }
                }]
            });
        }
        win.show(button);
    });
    
    
    datbutton.on('click', function(){
  // create the window on the first click and reuse on subsequent clicks
        if(!win2){
            win2 = new Ext.Window({
                applyTo     : 'date-win',
                layout      : 'fit',
                width       : 500,
                height      : 300,
                y 			: 300,
                closeAction :'hide',
                plain       : true,
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        win2.hide();
                    }
                }, {
                    text     : 'OK',
                    handler  : function(){
                    	document.getElementById('dateform').submit();
                    }
                }]
            });
        }
        win2.show(datbutton);
    });   
    
});
