//*****************************************************************
//函数名：ShowDialog()
//作  用：打开无边界窗口
//参  数：url, title, width, height, scrollbar
//*****************************************************************
function ShowDialog(url, title, width, height, scrollbar) {
	var o={};
	o.title = title;			    
	o.url = url;
	o.scrolling = scrollbar;
	var retval=window.showModalDialog("ModalDialog.htm", o, "help:no; scroll:no; status:no; dialogHeight:" + height + "px; dialogWidth:" + width + "px;");				
	if (retval=="ok")
	{
	  window.location.reload(true);
	}			    			    
  }	
//*****************************************************************
//函数名：ShowDialog()
//作  用：关闭无边界窗口不返回值
//*****************************************************************
function clickCancel(){
	window.returnValue = document.getElementById('returnValueNull').value;
	window.close();
}
//*****************************************************************
//函数名：addOrModifyOK()
//作  用：提示保存成功并返回值
//参  数：title, url
//*****************************************************************
function addOrModifyOK(title, url){
	var s = confirm("" + title + "成功，是否继续？");
	if (s){
		window.location = url;
	}else{
		window.returnValue = 'ok';
		window.close();
	}		 
}

//*****************************************************************
//函数名：CheckAll()
//作  用：批量选中
//参  数：form
//*****************************************************************
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
    document.all.SelectAll.innerHTML="全部选中(<span style='text-decoration: underline'>S</span>)";
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled==false)
       e.checked = form.chkAll.checked;
    }
	if(form.chkAll.checked==false){
		document.all.SelectAll.innerHTML="全部选中(<span style='text-decoration: underline'>S</span>)";
	}else{
		document.all.SelectAll.innerHTML="取消选中(<span style='text-decoration: underline'>S</span>)";
	}
  }

//*****************************************************************
//函数名：regInput()
//作  用：限制输入字符类型
//参  数：obj, reg, inputStr
//*****************************************************************
function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}

//*****************************************************************
//函数名：__setOverTime()，__overTimeCheck()
//作  用：监测登陆时间是否超时
//参  数：overTime，msg
//*****************************************************************
	var overTime = false;
	var msg = "您的登陆已经过期，需要重新登陆!"
		window.onload = function()
		{
		   window.setTimeout(__setOverTime,120000);
		}
		function __setOverTime()
		{
		    overTime = true;
		}
		function __overTimeCheck()
		{
		    if (overTime)
		    {
		        alert(msg);
		       
		        window.location.href="Admin_Index_Logout.Asp";
		        
		    }
		}

//*****************************************************************
//函数名：TemplatesView()
//作  用：预览模版
//参  数：Code
//*****************************************************************
function TemplatesView(Code){
	txtRun=Code;
	window.open("Admin_Template_View.asp?Action=Run","Templates_View")
}

//*****************************************************************
//函数名：ResizeImage()
//作  用：保持图片大小比例,使其在网页显示的时候不变型
//参  数：obj, MaxW, MaxH
//*****************************************************************
var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0)
        imageObject.width=dW;imageObject.height=dH;
    if(state!='complete' || imageObject.width>MaxW || imageObject.height>MaxH) {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",40);
    }
}

//*****************************************************************
//函数名：SetWinHeight()
//作  用：iframe自适应高度
//参  数：obj
//*****************************************************************
function SetWinHeight(obj)
{
 var win=obj;
 if (document.getElementById)
 {
  if (win && !window.opera)
  {
   if (win.contentDocument && win.contentDocument.body.offsetHeight) 

    win.height = win.contentDocument.body.offsetHeight; 
   else if(win.Document && win.Document.body.scrollHeight)
    win.height = win.Document.body.scrollHeight;
  }
 }
}