﻿//Trim方法


function ShowMailMessage(title,txt)
{
    if(txt.length > 4 && txt != "")
    {
	    window.top.document.all.PromptWindow_MailtitleEl.innerText = title;
	    window.top.document.all.PromptWindow_Mail_content.innerHTML = "<font style='font-family:宋体;font-size: 9pt;'>"+txt+"</font>";
	    window.top.PromptWindow_Mailespopup_ShowPopup(null);
	}
}
function  trim(str)
{
if(str !=null)
{
 return str.replace(/(^\s*)|(\s*$)/g, "");  
 }
 else
 {
 return "";
 }
} 

//不刷新提交
function SetXMLSumit(stype,spage)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open(stype, spage,false);
	xmlhttp.Send();
	return xmlhttp.responseText;	
}

// 设置父框架页面高度
function parentHigh()
{
	if(self!=top)
	{
		var i = document.body.scrollHeight;
		var di = 450;
		if(i > di)
		{
			parent.document.all.Main.style.height=i;
		}
		else
		{
			parent.document.all.Main.style.height=di;
		}
	}
}

function parent_High()
    {
	    if(self!=top)
	    {	   
		    var i = document.body.scrollHeight;
		    var di = 470;
		    if(i > di)
		    {	
		        parent.parent.document.all.Main.style.height=i+150;		    	   
			    parent.document.all.Type.style.height=i;
		    }
		    else
		    {
		        parent.parent.document.all.Main.style.height=di+150;	
			    parent.document.all.Type.style.height=di;
		    }
	    }
    }
    
    function IsSomeCheckd(gridID,alertMessage)
    {  
        if(alertMessage==undefined)
        {
            alertMessage="";
        }
        
         chs = document.getElementById(gridID).getElementsByTagName("INPUT");   
         n = 0;   
        for( i = 0; i<chs.length; i++ )   
        {   
            if(chs[i].type=='checkbox' && chs[i].id != 'Head')
            {
                if(chs[i].checked)   
                {   
                    n++;   
                 }   
            }
        }   
  
        if( n == 0 )   
        {   
            alert("您没有选中任何记录，请选择...");   
            return false;   
        }   
        else  
        {    
            return confirm(alertMessage+"\n\n您选中了" + n + "条记录，确定继续操作吗？");   
        }   
    }    
    
        function CheckedAll()
		{
		    var obj = document.all.tags("INPUT");
			for(i=0;i<obj.length;i++)
			{

    			if(obj[i].type=="checkbox" && obj[i].id.indexOf("myCheck") > -1)
				{
				    obj[i].checked = true;				
   				}
			}
			document.all.Head.onclick=CheckAll;
		}
		
		function CheckAll()
		{
			var obj = document.all.tags("INPUT");
			for(i=0;i<obj.length;i++)
			{
    			if(obj[i].type=="checkbox" && obj[i].id.indexOf("myCheck") > -1)
				{
					obj[i].checked = false;
   				}
			}
			document.all.Head.onclick=CheckedAll;
		}


// 设置父框架页面高度
function parentHigh1(offheight)
{
	if(self!=top)
	{
		var i = document.body.scrollHeight + offheight;
		var di = 550;
		if(i > di)
		{
			parent.document.all.Main.style.height=i;
		}
		else
		{
			parent.document.all.Main.style.height=di;
		}
	}
}

function ShowModalDialog(pagename,title,width,height)
{
     window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:no;")
}

function ShowModalDialog_Scroll(pagename,title,width,height)
{
     window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:Yes;")
}

function ShowModalDialog_Reload(pagename,title,width,height)
{
		ShowModalDialog_ReloadCtl(pagename,title,width,height,"EButton_Reload");		
}

function ShowModalDialog_ReloadCtl(pagename,title,width,height,ctl)
{
		var robj = window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:yes;")
		if(robj!=null && robj.type=='ok')
		{					
			document.all[ctl].click();
		}
}

function ShowModalDialog_ReloadGrid(pagename,title,width,height,ajaxUrl,key)
{
		var robj = window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:no;");
		
		if(robj!=null && robj.type=='ok')
		{		
		    var GridTable = document.getElementById("ModelListTable"+key);
		    if(GridTable)
		    {	
		            var str_List = SetXMLSumit("Post",ajaxUrl);        
			        GridTable.outerHTML = str_List;
		    }	
		}
}
         
function DelModelData(ajaxUrl,delkey,key)
    {     
        if(confirm("确定要删除该条信息？"))
          {
            var delUrl = "DelModelData.aspx";
            $.ajax({
                type:"GET",
                url:delUrl,
                dataType:"html",
                data:"key="+delkey,            
                success:function(msg)
                    {   
                       if(msg=="ok")
                       {                           	
		                    var GridTable = document.getElementById("ModelListTable"+key);
		                    if(GridTable)
		                    {	
		                            var str_List = SetXMLSumit("Post",ajaxUrl);        
			                        GridTable.outerHTML = str_List;
		                    }		    
                       } 
                       else if(msg=="no")
                       {
                            alert("删除失败，请和管理员联系！");
                       }                                        
                    },          
                 error:function()
                   {
                        //错误处理
                   }
            });
        }
    }
    
function ShowModalDialog_Reload_scroll(pagename,title,width,height)
{
		var robj = window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:yes;")
		if(robj!=null && robj.type=='ok')
		{					
			document.all.EButton_Reload.click();
		}
}

function ShowModalDialog_LoadThis(pagename,title,width,height,ctl)
{
		var robj = window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:no;")
		if(robj!=null && robj.type=='ok')
		{					
		location.href = this.location.href;
	        //  window.location.reload();   	            
		}
}

function ShowModalDialog_GoHistry(pagename,title,width,height,ctl)
{
		var robj = window.showModalDialog(pagename,title,"dialogHeight: "+ height +"px; dialogWidth: "+ width +"px;status:yes;scroll:no;")
		if(robj!=null && robj.type=='ok')
		{					
	          location.href=document.referrer;  	            
		}
}

 

// 转到指定页
function GoPage(LPage)
{
	location.href=LPage;
}

// 关闭窗口
function WClose()
{
	window.close();
}


function OpenWindow(pagename,width,height,top,left)
{
    window.open (pagename, "newwindow", "height="+ height +", width="+ width +", top="+ top +", left="+ left +", toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no") 
}