<?php

include("_dirinfo.php");
$sessionHandling = true;
	
include (PATH_TO_ROOT."init.php");


?>
if(!Ext.getCmp('sessionTimeoutWindow' ))
		{

	var loginForm = new Ext.FormPanel({
      
        width: 350,
        frame: false,
        autoHeight: true,
        padding: '10',
        labelWidth: 100,
        defaults: {
            anchor: '95%',
            allowBlank: false
        },
        items: [
        	{xtype:'textfield',name:'pass',
        	 fieldLabel:'Password',
        	 inputType:'password'
        	  }
        ],
		keys: [{
               key: [Ext.EventObject.ENTER], fn: function(){
                   Ext.getCmp('loginBtn').fireEvent('click');
               }
      		 }],
        buttons: [{
            text: 'Login',
            id:'loginBtn',
            listeners:{click: function(){
            		Ext.Ajax.request({
							   url: '_ajaxManipulators/ajax.Login.php',
							   
							   success: function ( result, request ) {
							   		
							   		if(result.responseText=='true')
							   		{
								   		 win1.close();
								   		 <?php if($loginSessionType == 'tabManager'){ 
								   		 	echo "var tabPar =  ".json_encode($_POST).';';
											echo "addTabAuto(tabPar.uniqueTabId,tabPar.uniqueTabUrl,tabPar)";
								   		 	
								   		 } 
								   		 if($_POST['loginSessionType'] == 'ajaxRequest' )
								   		 	echo stripslashes( $_POST['loginSessionTodo'] ).";";
								   		  ?>
								   		 
								   		 
							   		} else  {
							   			
							   				//Ext.MessageBox.ERROR('Login', 'Login Failed.')
							   				//Ext.Msg.alert('Login', 'Login Failed.');
							   				Ext.MessageBox.show({
											//	title:'Login Error',
											closable: true,
											//msg: 'testiranje',
											msg: '<div class=\'login_failed\'>Login Failed</div>',
											//msg: 'Login Failed fdsf  dfsfdsf sew rwe fds dsg ert ergf dg re tgert fg',
											icon: 'login_settings',
											//cls: 'caca',
											buttons: Ext.Msg.OK,
											width: 300
										});

							   		}
							   			
							   	},
							   params: { 
									   action:'login',
									   user: '<?php echo $_SESSION['UserInfo']['username'] ?>' || 'igor' ,
									   pass: loginForm.getForm().findField('pass').getValue()
									    }
							 
							});
            }
            }//eof listeners
        },{
            text: 'Cancel',
            handler: function(){
                 win1.close();
                 	window.onbeforeunload=function(){ };
                 	document.location = 'index.php';
            }
        }]
    });


	var win1 = new Ext.Window({
		id:'sessionTimeoutWindow',
		//closable:false,
		width:365,
       modal:true,
 		title: 'Session Timeout' ,
        closeAction:'close',
        plain: true,
		items: loginForm

    }).show();

    }
   

