
var monid;
var matable;
var monitem;
var win;
function show_win(id, title, items, idtable, table, height)
{
	//var element = Ext.get('body');
	//element.mask('Modification...', 'x-mask');
	
	monid = idtable;
	matable = table;
	monitem = items;
        if(parseInt(height)==0 || !parseInt(height)){
            height=660
        }else{
            height=parseInt(height);
        }
	var myButtons = [{text: 'Fermer',handler:function(){ win.hide(); }}];
	var myItems = items;
	if(!win){
		Ext.select('object').each(function(el) {
										  el.dom.style.visibility = 'hidden';									  
										  
										  });
		win = new Ext.Window({
			id:id,
			title:'Modification',
			layout:'fit',
			width:980,
			'height':height,
			autoScroll:true,
			maximizable:false,
			minimizable:false,
			modal:true,
			collapsible: false,
			closable: true,
			resizable: false,			
			buttonAlign:'center',
			closeAction:'close',
			plain: true,
			items: [myItems],
			buttons: myButtons
		});
		win.on('beforehide', destroyWin);
	}	
	win.show();
}


function showReponse(options, success, response){
	
	
	var resText = response.responseXML;
	if (success) {
		if (response.status == 200) {
			window.location.href= window.location.href
			
		} else {
			Ext.MessageBox.alert("Error!", 'Erreur lors de la sauvegarde');
		}
	} else {
		Ext.MessageBox.alert("Error!", 'Erreur lors de la sauvegarde');
	}
	destroyWin();
	//win.hide();
	
}

function destroyWin()
{
	if(win != null)
	{
		Ext.select('object').each(function(el) {
										  el.dom.style.visibility = 'visible';									  
										  
										  });
		
		win.destroy();
		win = null;
	}
	
}
