/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */


Ext.onReady(function(){
    var popup;
    
	//var nomeroot = 'linkroot' + i;
	//nomeroot = '#linkroot';
	//var nomelink = 'link_dett0';
	//var linkpop = Ext.get(nomelink);
	//var linkpop_a = Ext.query(nomeroot);
	
	var linkpop_all = Ext.DomQuery.select('a');
	var corpo = Ext.getBody();
	
	for(var k = 0, a; a = linkpop_all[k]; k++)
	{
		if (!a.id) Ext.id(a);
		var w = Ext.get(a.id);

		if (w.hasClass("popup-dettaglio"))
		{
			w.on('click', function(){
	        // create the window on the first click and reuse on subsequent clicks
	        	//alert(nomeroot);
		        if(!popup){
		            popup = new Ext.Window({
		                applyTo     : 'dettaglio-popup',
		                el		    : 'dettaglio-popup',
		                layout      : 'fit',
		               // width       : parseInt(corpo.getWidth() * 0.8),
		               // width       : parseInt(window.innerWidth * 0.8),
		               // width       : 'auto',
		                width       : 700,
		                //height      : parseInt(corpo.getViewSize().height * 0.8),
		                height      : parseInt(window.screen.availHeight * 0.8),
		                //height      : 400,
		                y			: parseInt(window.screen.availHeight * 0.1),
						//y			: parseInt(w.getY()+5),
						x 			: 50,		               
						 closeAction :'hide',
		                //closeAction :'close',
		                plain       : true,
		                autoScroll: true,
		                //bodyBorder	: false,
		                //border		: false,
		                //hideBorders : false,
		                //items		: divstampa,
		                
		                buttons: [{
		                    text     : 'Chiudi',
		                    handler  : function(){
		                        popup.hide();
		                        //divstampa.destroy();
		                        //popup.destroy();
		                    }
		                }]
		            });
		       
				   
		     }
		    popup.load({
					url: 'http://www.blumatica.it/dettaglio_soft_pop_ext.asp', 
					params: 'id=' + i,
					text: 'Caricamento...',
					nocache: true
				});
			//popup.center(this);
		    popup.show(this);
		   	//popup.show(linkpop);
		   	i = 0;	
			});
		}
		}	
});


