﻿// JScript 文件


//淡出一个模态页面
 var dialogDept,dialogStaff,dialogStaffB,dialogProject;
 var dialogFile,dialogCA;
 
 function showDialog(el,dlgName,nWidth,nHeight,frameName,tableName){
   // alert(dlgName);
	var showElement = Ext.get(el);
	//alert(showElement.dom.value);
	if (showElement != undefined && showElement != null)
	{
		showElement.dom.disabled = true;
	
		if(tableName=="Dept")
		{
		   dialogDept=createDialog(dialogDept,dlgName,nWidth,nHeight,frameName,showElement);
		  
		   
		}
		//show里面的参数是为了有一种淡入淡出效果        else if(tableName=="Staff")
        {
           dialogStaff=createDialog(dialogStaff,dlgName,nWidth,nHeight,frameName,showElement);
        }
        else if(tableName == "Attachment")
        {
            dialogFile = createDialog(dialogFile,dlgName,nWidth,nHeight,frameName,showElement);
        }
        else if(tableName=="StaffB")
        {
           dialogStaffB=createDialog(dialogStaffB,dlgName,nWidth,nHeight,frameName,showElement);
        }
        else if(tableName=="AttachmentCA")
        {
           dialogCA=createDialog(dialogCA,dlgName,nWidth,nHeight,frameName,showElement);
        }
        else 
        {
          dialogProject=createDialog(dialogProject,dlgName,nWidth,nHeight,frameName,showElement);
        }
	   
	   //alert(document.all["MSD"].style.pixelHeight);
	   if(document.all[frameName].style.pixelHeight <= 0)
	   {
	        document.all[frameName].style.pixelHeight = 650;
	   }
//	   if(document.all[frameName].style.pixelWidth <= 0)
//	   {
//	        document.all[frameName].style.pixelWidth = 600;
//	   }
		
	}
}

function onSubmit(dlg,el,frameName)
{   
   	//dlg = null;
   	if(frameName == "frmFile")
   	{
   	  el.disabled = false;
	  setFileList();
	  //alert(parent.name);
	  dlg.hide();
	  return;
   	}
   	if(frameName == "frmFileCA")
   	{
   	  el.disabled = false;
	  setFileListCA();
	  //alert(parent.name);
	  dlg.hide();
	  return;
   	}
   	String.prototype.Trim = function()
    {
        return this.replace(/(^\s*)|(\s*$)/g, "");
    }
	var ShowRecord = document.frames(frameName).getRecords();
    el.value="";
    if(ShowRecord != null)
    {
        for(i=0;i<ShowRecord.length-1;i++)
        {
           el.value += ShowRecord[i][0].Trim()+",";   
        }
        el.value +=ShowRecord[ShowRecord.length-1][0];
        el.disabled = false;
	    dlg.hide();
	    dlg = null;
	}
	else
	{
	  el.disabled = false;
	  dlg.hide();
	  dlg = null;
	}
	
}


function createDialog(dialog,dlgName,nWidth,nHeight,frameName,showElement)
{  
   if(!dialog)
		{ // lazy initialize the dialog and only create it once

			if (nWidth == undefined || nWidth == null)
			{
				nWidth = 520;
			}
			if (nHeight == undefined || nHeight == null)
			{
				nHeight = 650;
			}
			dialog = new Ext.BasicDialog(dlgName, { 
					autoTabs:false,
					width:nWidth,
					height:nHeight,
					shadow:false,
					minWidth:300,
					minHeight:250,
					proxyDrag: false,
					autoScroll: true,
					closable:false
			});
			
            var btnClose  = dialog.addButton({
				text:'关闭',
				handler: onSubmit.createDelegate(this, [dialog,showElement.dom,frameName])
			});
		}
		 dialog.show(showElement.dom);
		 return dialog;
}