Ext.onReady(function(){
    var onlySearchButtons;
	var dialogWidth;
	var dialogHeight;
    var Swin;
	var w;
	var link;
	var title;
	
        
        var MIF1 = new Ext.ux.ManagedIframePanel({
                   border: false,
                   bodyBorder: false,
                   defaultSrc:link,
                   listeners:{
                       domready : function(frame){
                             var fbody = frame.getBody();
                             w = Ext.getCmp('myFrameWin');
                             if(w && fbody){
                                  //calc current offsets for Window body border and padding
                                 var bHeightAdj = w.body.getHeight() - w.body.getHeight(true);
                                 var bWidthAdj  = w.body.getWidth()  - w.body.getWidth(true);
                                 //Window is rendered (has size) but invisible
                                 w.setSize(Math.max(dialogWidth) ,
                                           Math.max(w.minHeight || 0, fbody.scrollHeight +  w.getFrameHeight() + bHeightAdj) );
                                 //then show it sized to frame document
                                 w.show();
                             }
                       }
                   }
               });
			
			var windowFrame = new Ext.Window({
						   title: name,
						   width: 400,   //give it something to start with until the frame renders
						   height: 600,
						   hideMode:'visibility',
						   id:'myFrameWin',
						   hidden : true,   //wait till you know the size
						   title: title,
						   plain: true,
						   modal:true,
						   constrainHeader: true,
						   closable: false,
						   ddScroll: false,
						   border: false,
						   bodyBorder: false,
						   layout: 'fit',
						   buttonAlign:'center',
						   buttons: [{
								text: 'Close',
								handler: function(){
									windowFrame.hide();
								}
							}],
						   items:MIF1
					   });
			   windowFrame.render(Ext.getBody());
	
	
	onlySearchButtons = YAHOO.util.Dom.getElementsByClassName("openDialogSearch");
	for (i = 0; i < onlySearchButtons.length; i++){
		var onlySearchBttns = onlySearchButtons[i];
		var onlySearchBttnIds = onlySearchButtons[i].id;
		
		if(dialogWidth == '' || dialogWidth == null){
			dialogWidth = 600;
		}
		if(dialogHeight == '' || dialogHeight == null){
			dialogHeight = 400;
		}
		
		var Sbutton = Ext.get(onlySearchBttnIds);
		Sbutton.on('click', function(){
			//if(!windowFrame){
				dialogWidth = document.getElementById(this.id).getAttribute("dialogW");
				dialogHeight = document.getElementById(this.id).getAttribute("dialogH");
				
				if(dialogWidth == '' || dialogWidth == null){
					dialogWidth = 600;
				}
				else{
					dialogWidth = parseInt(dialogWidth);
				}
				if(dialogHeight == '' || dialogHeight == null){
					dialogHeight = 400;
				}
				else{
					dialogHeight = parseInt(dialogHeight);	
				}
			
			//}
                        var title = document.getElementById(this.id).getAttribute("dialogtitle");
			var link = eval(document.getElementById(this.id).getAttribute("link"));
                        MIF1.setSrc(link);
			windowFrame.setTitle(title);
			windowFrame.show();
			windowFrame.setWidth(dialogWidth);
		});
	}
	
	
	
});
function closeDialog(){
				wi = Ext.getCmp('myFrameWin');
                                wi.hide();
			}
