﻿//通用对话框(标题,提示信息,连接地址,坐标,是否按扭)
var winbox;

window.odel=function(obj){if(oo(obj)!=null){oo(obj).parentNode.removeChild(oo(obj))}}
window.oo=function(obj){return typeof(obj)=="string"?document.getElementById(obj):obj}       

function MyBox(WinTitle)
{ 
 var IHTML;
 winbox = document.createElement('div');
 document.body.appendChild(winbox);
 IHTML="";
 IHTML+="<div id=boxConter style='position:absolute;width:102%;height:102%;z-index:1000;background-color: #F3FBFF;'></div>";
 IHTML+="<div id=MsgBox style='position:absolute;margin-left:0px;text-align:left;background-color:#fff;z-index:2001;'>";
 IHTML+="<div id=Roundedborders>";
 IHTML+="  <b class=rb_1></b><b class=rb_2></b><b class=rb_3></b>";
 IHTML+="  <div class=Rounderbody>";
 IHTML+="    <div style='font-size:12px;color:#333;padding:5px;'>酉阳在线--"+WinTitle+"</div>";
 IHTML+="	<div style='font-size:12px;color:#707070;padding:25px;' id=MsgContent><img src='/images/loading.gif' align='absmiddle'>  数据处理中,稍后...</div>";
 IHTML+="	<hr style='width:80%;border:1px solid #efefef;height:1px'>";
 IHTML+="<div align='center' style='font-size:12px;color:#333;padding-top:5px;' id=MsgTool>";
 IHTML+="正在处理数据...";
 IHTML+="  </div>";
 IHTML+="  </div></div>";
 winbox.innerHTML=IHTML;
 oo("boxConter").style.filter="alpha(opacity=90)";
 oo("boxConter").style.MozOpacity=0.9;
 oo("boxConter").style.top=0;
 oo("boxConter").style.left=0;
 oo("boxConter").style.height=parseInt(document.body.scrollHeight);
 MsgCentent(); 
 Event.observe(window,'resize',MsgCentent,false);
 Event.observe(window,'scroll',MsgCentent,false);
 return false;
}

//显示工具栏信息
function ShowTool(Content)
{
  if(oo("MsgTool"))
  {
   oo("MsgContent").innerHTML="<img src='/images/loader.gif' align='absmiddle'>&nbsp;&nbsp;&nbsp;&nbsp;"+Content;
   oo("MsgTool").innerHTML="<a href='/Index.htm'>&lt;&lt;返回首页</a>　　　　　　　　<a href='Javascript:CloseMsg();'>关　　闭>></a>";
  }
}

//显示工具栏信息
function AutoUrl(Url,Content)
{
  if(Url=="")
    Url=window.location.href;
    
  if(oo("MsgTool"))
  {
   var tFadeIn=null;
   var tTime=3;
   tFadeIn=setInterval(function(){if(tTime==0){clearInterval(tFadeIn);window.location.href=Url;}else{oo("MsgTool").innerHTML="稍后,"+tTime+"秒后自动刷新..."; tTime-=1;}},500);
   oo("MsgContent").innerHTML="<img src='/images/loader.gif' align='absmiddle'>&nbsp;&nbsp;&nbsp;&nbsp;"+Content;   
  }
}
//对话框居中显示函数
function MsgCentent()
{
  if(oo("boxConter"))
   {
    oo("MsgBox").style.left=(parseInt(document.body.clientWidth)-320)/2+20;
    oo("MsgBox").style.top=(parseInt(document.body.clientHeight)-130)/2-30+parseInt(document.body.scrollTop); 
   }
}
//退出对话框
function CloseMsg()
{
   odel(winbox);     
}

//图像按比例显示
function DrawImage(ImgD,W,H)
{
 var image=new Image(); 
 var iwidth = W;  //定义允许图片宽度 
 var iheight = H;  //定义允许图片高度 
 image.src=ImgD.src; 
 
 if(image.width>0 && image.height>0)
    if(image.width/image.height>= iwidth/iheight)
	{
	  if(image.width>iwidth)
	    {ImgD.width=iwidth;ImgD.height=(image.height*iwidth)/image.width;}
	  else
	   {ImgD.width=image.width;ImgD.height=image.height;} 
    } 
   else
    {
     if(image.height>iheight)
	  {ImgD.height=iheight;ImgD.width=(image.width*iheight)/image.height;}
	 else
	  {ImgD.width=image.width;ImgD.height=image.height;} 
    }  
   ImgD.style.display="block";   
}
//初始化验证码
function InitCheckCode(obj,code)
{
  var Url;
  Url=obj.src;
  if(code=="" && Url.indexOf(".aspx?")>0)
    return ;
  
  Url="/CheckCode.aspx?id="+Math.ceil(Math.random()*1000);
  obj.src=Url;
}
//打开对模板话框
function gopen(url,w,h)
{
  var isMSIE= (navigator.appName == "Microsoft Internet Explorer");  //判断浏览器 
  if (isMSIE)
     var selProdWnd = window.showModalDialog(url, window, "dialogWidth="+w+"px;dialogHeight="+h+"px;status:0;scroll:no;status:yes;");
  else
  { 
      var selProdWnd = window.open(url, "mcePopup", "scrollbars=no,status=yes,dialog=yes,modal=yes,width=500,height=500,resizable=no"); 
      return false;
  } 
  if (selProdWnd!=undefined)
  {
	document.getElementById ("txtIcontent").value = document.getElementById ("txtIcontent").value + selProdWnd;		        
  }
}