﻿function wopenPos(url,name,width,height,k, top, left){
    //LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
    //TopPosition  = (screen.availHeight) ? (screen.availHeight-height)/2 : 0 ;
    //windowname = window.open(url,name,'top='+ TopPosition+',left='+ LeftPosition+ ',width='+width+',height='+height+',resizable=0,scrollbars='+k+',status=0');
    
    windowname = window.open(url,name,'top='+ top+',left='+ left+ ',width='+width+',height='+height+',resizable=0,scrollbars='+k+',status=0');
    windowname.focus();
    return windowname;
} 


Ext.onReady(function(){
    Ext.get('gtitle').dom.innerHTML = gametitle;
    
    var win = new Ext.Window({
        el:'hello-win',       
        layout:'fit',
        width:900,
        height:670,
        minHeight:600,
        minWidth:800,  
        closeAction:'hide',
        hideParent: true,
        plain: true,
        maskDisabled: false,
        maximizable: false,  
        expandOnShow: true,        
        collapsible: true,              
        pageX: 300, 
        
        items: new Ext.TabPanel({
                el: 'hello-tabs',
                autoTabs:true,
                activeTab:0,
                deferredRender:false,
                border:false
        })
        
        /* 
        buttons: [{
            text: 'Close',
            handler: function(){
                win.hide();
            }
        }]
        */
    });
    
    
    /*
    var btnPlay = new Ext.Button({
    	text: 'Play Game',
    	renderTo: 'playbutton'
    });
    */
    
    
    
    //var button = Ext.get('play');    
    var gameLoaded = false;
    //window.onscroll = function(){return false;}
   
    //document.onmousewheel=function(){return false};
    //document.onkeydown=function(){return event.keyCode==38 || event.keyCode==40 ? false : true;}  
    //document.body.onscroll = function(){alert('test')}
    
    win.on('beforehide', function(e){
        document.onmousewheel = function(){};
        document.onkeydown = function(){}  
    });
    
    //win.getEl().anchorTo(document, 't-t', [0,0], true, true);
    
    
//    btnPlay.on('click', function(e) {     
//        wopenPos('playgame.aspx?k='+ egid,'PlayGame' ,850 ,750 ,0)
//        
//        /*
//        win.show(this);          
//        
//        if(!gameLoaded){ 
//            document.onmousewheel = function(){return false};
//            document.onkeydown = function(){return event.keyCode==38 || event.keyCode==40 ? false : true;}  
//                                   
//            win.anchorTo(document.body, 't-t', [0,0], true);    
//            win.setPosition(100,0);
//        
//            gameLoaded = true;       
//            doframe(k);
//        } 
//        */       
//    });    
    

});


var btnPlay = Ext.get('play');

btnPlay.on('click', function(e) {     
    wopenPos('playgame.aspx?k='+ egid,'PlayGame' ,850 ,750 ,0)
    
    /*
    win.show(this);          
    
    if(!gameLoaded){ 
        document.onmousewheel = function(){return false};
        document.onkeydown = function(){return event.keyCode==38 || event.keyCode==40 ? false : true;}  
                               
        win.anchorTo(document.body, 't-t', [0,0], true);    
        win.setPosition(100,0);
    
        gameLoaded = true;       
        doframe(k);
    } 
    */       
});    