//js script function
//////////////////////////////////////
//writer:gaoli
//version:1.0
//Copyright © 2009 yuanbokeji, Inc. All Rights Reserved. 
/////////////////////////////////////

/* ------------------------------------------------------------------------
 * 函数：$def(obj)
 * 参数：obj 要判定的对象，可以是字符串，变量
 * 功能：判断传入的对象是不是无意义的空值或者没有初始化
 * 返回值： 如果传入的对象是空值 或者 是个没有初始化的 变量， 一个空字符串 返回false  否则返回Trus
 * 用法：if（$def(obj) ） return obj；
 *
 ----------------------------------------------------------------------------*/
function $def(obj)
{
  //  if(obj != null && obj != "undefined")
    var type = typeof(obj);
    switch (type)
    {
        case "string" : 
                        if(obj != "")
                        return true;
                        break;
        case "object" : if(obj != null)
                        return true;
                        break;
        default :       if(obj != null && obj != "undefined")
                        return true;
                        break;
    }
    return false;
}
var $ = function(v){return document.getElementById(v);}

/////////////////////////////////////页面控件函数//////////////////////////////////
//创建层对象
function CreateDiv(pElement,id,left,top,width,height,position,zIndex,visibility,style,content,IsAppend)
{
	if(typeof(IsAppend)=="undefined")
	    this.obj=document.createElement("div");
	else
        this.obj=pElement.createElement("div");
	this.obj.id=id?id:"showDiv"+Math.random();
	this.obj.name=id?id:"showDiv"+Math.random();
	this.obj.style.left=parseInt(left)+"px";
	this.obj.style.top=parseInt(top)+"px";
	this.obj.style.width=parseInt(width)+"px";
	this.obj.style.height=parseInt(height)+"px";
	this.obj.style.position=position?position:"absolute";
	this.obj.unselectable="on";
	if(zIndex)this.obj.style.zIndex=zIndex;
	if(visibility)this.obj.style.visibility=visibility;
	if(style)this.obj.style.cssText=this.obj.style.cssText+";"+style;
	if(content)this.obj.innerHTML=content;
	if(typeof(IsAppend)=="undefined")
	{
	   if(pElement!=null)
		  pElement.appendChild(this.obj);
	}
	return this.obj;
};

//获得页面控件对象绝对位置
function GetClassPosition(ClassName)
{
  var obj=document.getElementById(ClassName);
  var n={x:obj.offsetLeft,y:obj.offsetTop};
  return(n);
};

function GetAbsolutePos(obj)
{
  var ow=[0,0];
  var pw=obj;
  while(pw&&pw.offsetParent)
  {
     ow[0]+=pw.offsetLeft;
	 ow[1]+=pw.offsetTop;
	 pw=pw.offsetParent;
  };
  return ow;
};

//获得页面尺寸
function getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
};

//获取元素信息
function getPos(e)
{
	var l = 0;
	var t  = 0;
	var w = intval(e.style.width);
	var h = intval(e.style.height);
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};

function GetSize(obj)
{
    var o = (typeof(obj)=="object")?obj:document.getElementById(obj);
    var r=[o.offsetWidth,o.offsetHeight];
    if(o==document.body&&!document.all){r[1]=o.clientHeight;    };
    if(!r[0]){r[0]=o.clientWidth;    };
    if(!r[0]){r[0]=parseInt(o.style.width);    };
    if(!r[1]){r[1]=o.clientHeight;    };
    if(!r[1]){r[1]=parseInt(o.style.height);    };
    if(!r[0]||!r[1])
    {
        var pw=o.parentElement;
        while(pw)
        {
            if(!r[0]&&pw.offsetWidth){r[0]=pw.offsetWidth;    };
            if(!r[1]&&pw.offsetHeight){r[1]=pw.offsetHeight;    };
            if(r[0]&&r[1]){break;    };
            pw=pw.parentElement;
        };
    };
    return r;
};

//转换为数字
function intval(v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};

////////////////////////////////////Ajax函数//////////////////////////////////////

var xmlHttp; //定义一个全局变量

function CreateXMLHttpRequest()
{
	if (window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		xmlHttp = new XMLHttpRequest();
	}
}


function AjaxXmlProcess(request_str)
{
   //Ajax数据请求处理
   //判断浏览器类型
   var http_request;
   if (window.XMLHttpRequest) { // Mozilla, Safari, ... 
      http_request = new XMLHttpRequest();
   }  
   else if (window.ActiveXObject) { // IE
      http_request = new ActiveXObject("Microsoft.XMLHTTP");
   }
   //异步数据请求方式
   http_request.open("GET",request_str,false);
   http_request.send(null);
   //接收异步请求返回数据
   var returnstr=unescape(http_request.responseText);
   return returnstr;
};

///////////////////////////////////鼠标事件类函数///////////////////////////////////////
function mouseMove(ev) 
{ 
ev= ev || window.event; 
var mousePos = mouseCoords(ev); 
return mousePos;
} 

function mouseCoords(ev) 
{ 
if(ev.pageX || ev.pageY){ 
return {x:ev.pageX, y:ev.pageY}; 
} 
return { 
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
y:ev.clientY + document.body.scrollTop - document.body.clientTop 
}; 
} 

function showNotice(pElement,NoticeContent,Px,Py)
{
   var pObj = pElement?pElement:document.body;
   if(typeof(pObj) == "string")
     pObj=$(pObj);
   var NoticeObj = new Object();
   NoticeObj.Content = $def(NoticeContent)?NoticeContent:"";
   if(!$def(pElement))
   {
      NoticeObj.Px = $def(Px)&&Px>0?Px:0;
      NoticeObj.Py = $def(Py)&&Py>0?Py:0;
   }
   else
   {
     NoticeObj.Px = GetAbsolutePos(pObj)[0];
     NoticeObj.Py = GetAbsolutePos(pObj)[1];
   }
   var NoticeDivObj = $("NoticeMsg")?$("NoticeMsg"):CreateDiv(document.body,"NoticeMsg",NoticeObj.Px+10,NoticeObj.Py-10,250,47,"absolute",200,"visible","background-image:url(../images/NoticeBox.bmp);");
   var BlackDel = $("BlackDel")?$("BlackDel"):CreateDiv(NoticeDivObj,"BlackDel",235,4,6,7,"absolute",201,"visible","cursor:hand;background-repeat:no-repeat;background-image:url(../images/black_del.gif);");
    BlackDel.title="关闭";
    BlackDel.onclick="document.body.removeChild($('NoticeMsg'));";
   var ContentDiv = "<div id='ContentDiv' style='position:absolute;left:10;bottom:15;color:#999999;font-family:宋体_GB2312;font-size:12px;'>"+NoticeObj.Content+"</div>";
   NoticeDivObj.innerHTML += ContentDiv;
}

///////////////////////////////////消息显示函数////////////////////////////////////
var timer;
function showMsgFunction(Statu,NoticeMsg,IsDelay,DelayTime,MsgType,IsCover)
//Statu消息状态:　1:显示|2:清除
//NoticeMsg消息文本
//IsDelay延时状态　1:延时|2:不延时
//DelayTime延时时间
//MsgType消息类型：1:成功|2:失败|3:警告|4:等待|5:公告
{
   var documentObject;
   if(top!=self) 
      documentObject=window.parent.document;
   else
      documentObject=document;
   var noticeDiv=document.getElementById("Notice");   
   /*
   var obj=documentObject.getElementById("coverDiv");
   if(obj==null)
	{
       obj=documentObject.createElement("div");
	   obj.id="coverDiv";
	   obj.name="coverDiv";
	   obj.top="0px";
	   obj.left="0px";
	   obj.width=documentObject.body.scrollWidth+"px";
	   if(top!=self)
		   obj.height=documentObject.body.scrollHeight+"px";
	   else
		   obj.height=window.screen.Height+"px";
	   obj.style.position="absolute";
	   obj.style.zIndex=99;
	   obj.style.visibility="hidden";
	   obj.style.display="none";
	   obj.style.cssText=obj.style.cssText+";background:blue;filter:alpha(opacity=15);";
       documentObject.body.appendChild(obj);
	}
   //obj=obj?obj:CreateDiv(documentObject.body,"coverDiv",0,0,documentObject.body.scrollWidth,window.screen.Height,"absolute",99,"hidden","display:none;background:blue;filter:alpha(opacity=15);");
   */
   var allSelectClass=documentObject.getElementsByTagName("select");   
   switch(Statu)
   {
   case 1:
   noticeDiv=CreateDiv(documentObject.body,"Notice",0,documentObject.documentElement.scrollTop+(window.screen.availHeight/2)-70,0,59,"absolute",98,"hidden","border:1px dashed #999999;display:none;background-repeat:repeat;background-image:url(../images/noticebj.JPG);filter:alpha(opacity=90);");
   //计算消息文本的像素长度
   var MsgTxtLength=JHshStrLen(NoticeMsg);
   var MsgTxtWidth=MsgTxtLength * 10 + 20;
   noticeDiv.style.width=(MsgTxtWidth) + "px";
   noticeDiv.style.left=(document.body.clientWidth/2 - MsgTxtWidth/2) + "px";   
      if(IsDelay)
	  { 
	    //clearInterval(timer);
        //timer=setInterval('showMsgFunction(0)',DelayTime);
        setTimeout('showMsgFunction(0)',DelayTime);
	  }
	  /*
	  if(typeof(IsCover)=="undefined")
	  {
        for(var i=0;i<allSelectClass.length;i++)
         allSelectClass[i].style.display="none";
        obj.style.display="inline";
		obj.style.visibility="visible";
	  }
	  */
         if(NoticeMsg!="")
		 {
           noticeDiv.style.display="inline";
           noticeDiv.style.visibility="visible";
           var str="<div style='position:absolute;bottom:10;width:"+noticeDiv.style.width+";height:30px;color:#FFFFFF;font-family:黑体_GB2312;font-size:15px;font-weight:bold;text-align:center;'>";
           switch(MsgType)
           {
             case 1:str+="<img src='../images/note_ok.gif'> ";
             break;
             case 2:str+="<img src='../images/warning.gif'> ";
             break;
             case 3:str+="<img src='../images/warning.gif'> ";
             break;	
             case 4:str+="<img src='../images/loading_small.gif'> ";
             break;
             case 5:str+="<img src='../images/notice.gif'> ";
             break;
           }
           str+=NoticeMsg+"</div>";
	       noticeDiv.innerHTML=str;
         }
      break;
   case 0:
      //clearInterval(timer);
      /*
      for(var i=0;i<allSelectClass.length;i++)
        allSelectClass[i].style.display="inline";
      obj.style.display="none";
      obj.style.visibility="hidden";
      */
      noticeDiv.style.display="none";
      noticeDiv.style.visibility="hidden";
      //documentObject.body.removeChild(obj);
      documentObject.body.removeChild(noticeDiv);
   }
};

function SetTimer(DoSomething,DelayTime)
{
    clearInterval(timer);
    timer=setInterval(DoSomething,DelayTime);
};

function GetDocumentObj()
{
  var documentObject;
  if(top!=self) 
     documentObject=window.parent.document;
  else
     documentObject=document;
  return documentObject;
};

function HiddenSelectCtrl(statu)
{
  var documentObject;
  documentObject=GetDocumentObj();
  var allSelectClass=documentObject.getElementsByTagName("select");
  if(statu==0)
  {
      for(var i=0;i<allSelectClass.length;i++)
       allSelectClass[i].style.display="none";
  }
  else if(statu==1)
  {
      for(var i=0;i<allSelectClass.length;i++)
       allSelectClass[i].style.display="inline";  
  }
}

///////////////////////////////////////////通用对话框控件类/////////////////////////////////////
function Dialog(DialogType,DialogStyle)
{
    window.DialogObject=this;
    this.DivObj=new Array();
    this.DivPosition=new Object();
	this.MousePosition=new Object();
	this.DialogStatu=0;       //对话框缩放状态值，0:最小化; 2:最大化。
	this.DialogTypeValue=-1;  //初始化对话框状态，0:Div层; 2:页面
	this.DialogStyleValue=-1; //对话框风格，0:默认风格; 1:蓝色风格...
	//初始化对话框位置及尺寸
	this.DialogMinSize=new Object();
	this.DialogMaxSize=new Object();
	this.DialogMinSize.Left=0;
	this.DialogMinSize.Top=0;
	this.DialogMinSize.Width=0;
	this.DialogMinSize.Height=0;
	this.DialogMaxSize.Left=0;
	this.DialogMaxSize.Top=0;
	this.DialogMaxSize.Width=0;
	this.DialogMaxSize.Height=0;
	if(DialogType=="Page"||!$def(DialogType))
	   this.DialogTypeValue=1;
	else if(DialogType=="Div")
	   this.DialogTypeValue=0;
	if(DialogStyle=="Default"||!$def(DialogStyle))
	   this.DialogStyleValue=0;
	else if(DialogStyle=="Blue")
	   this.DialogStyleValue=1;
	this.CreateDialog=function(TitleName,DialogBodySrc,width,height,DialogDivObject)
	{
     var DialogContent;
	if(this.DialogTypeValue==-1)
	   return false;	
	else if(this.DialogTypeValue==1)
	      {
	       if(!$def(DialogBodySrc))
	          return false;
	       else
	         DialogContent=DialogBodySrc;
	      }
	else if(this.DialogTypeValue==0)
	      {
	       if(!$def(DialogDivObject))
	          return false;
	       else
	         DialogContent=DialogDivObject;
	      }
	if(!$def(TitleName))
	   TitleName="无标题";	
	var titlebgimage;
	var buttonimage;
	if(this.DialogStyleValue==0)
	{
	   titlebgimage="../images/titlebg.bmp";
	   buttonimage="../images/msgClose.jpg";
	}
	else if(this.DialogStyleValue==1)
	{
	   titlebgimage="../images/ctitlebg.bmp";
	   buttonimage="../images/cbutton.bmp";	
	}
    var documentObject;
    documentObject=GetDocumentObj();	
	DialogObject.width=width;
    DialogObject.height=height;
	this.DialogMinSize.Left=documentObject.body.clientWidth/2-DialogObject.width/2;
	this.DialogMinSize.Top=(documentObject.documentElement.scrollTop+((window.screen.height-window.screenTop)/2)-(DialogObject.height)/2)-30;
	this.DialogMinSize.Width=DialogObject.width-20;
	this.DialogMinSize.Height=DialogObject.height-50;
	this.DialogMaxSize.Left=20;
	this.DialogMaxSize.Top=documentObject.documentElement.scrollTop+10;
	this.DialogMaxSize.Width=window.screen.width-50;
	this.DialogMaxSize.Height=window.screen.height-200;
    HiddenSelectCtrl(0);
	var yyobj=documentObject.getElementById("yyDiv"); //容器底层
	if(yyobj==null)
	{
	   yyobj=CreateDiv(documentObject,"yyDiv",DialogObject.DialogMinSize.Left,DialogObject.DialogMinSize.Top,DialogObject.width,DialogObject.height,"absolute",100,"visible","background:#999999;","","");
       documentObject.body.appendChild(yyobj);
	   this.DivObj.push(yyobj);
	}
	
    var obj=documentObject.getElementById("LabelDiv"); //对话框窗体层
    if(obj==null){
       obj=CreateDiv(documentObject,"LabelDiv",0,0,DialogObject.width,DialogObject.height,"relative",101,"visible","background:#FFFFFF;border:1px dashed #dddddd;","","");
	   yyobj.appendChild(obj);
       this.DivObj.push(obj);
    }
    
	obj.innerHTML="<div id='titleDiv' unselectable='on' style='background-image:url("+titlebgimage+");width:"+DialogObject.width+";height:33px;'></div>";
    obj.innerHTML+="<div id='Dialog' unselectable='off' style='PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px;'></div>";
    var DialogContentHTML;
    if(this.DialogTypeValue==1)
        DialogContentHTML="<iframe frameborder='0' id='OpenDialog' name='OpenDialog' scrolling='auto' src='" + DialogContent + "' style='height:" + DialogObject.DialogMinSize.Height + "px; width:" + DialogObject.DialogMinSize.Width + "'></iframe>";
	else if(this.DialogTypeValue==0)
	    DialogContentHTML="<Div id='OpenDialog' name='OpenDialog' style='height:" + DialogObject.DialogMinSize.Height + "px; width:" + DialogObject.DialogMinSize.Width + "'>" + DialogContent.innerHTML +"</div>";
	$("Dialog").innerHTML=DialogContentHTML;
	
     var title=documentObject.getElementById("titleDiv");    //对话框标题栏
	//title.innerHTML=;
	//var titlenameobj=documentObject.getElementById("titlename");
    TJEvent.addListener(title, "dblclick", this.OnbuttonDivMouseUp, false);
    TJEvent.addListener(title, "mousedown", this.DialogFocus, false);    
	TJEvent.addListener(title, "mousedown", this.OnLabelDivMouseDown, false);   
	TJEvent.addListener(title, "mousemove", this.OnLabelDivMouseMove, false);   
		
    var titlenameobj=documentObject.getElementById("titlename"); //标题区
	if(titlenameobj==null){
       titlenameobj=CreateDiv(documentObject,"titlename",obj.clientLeft+10,obj.clientTop+8,200,33,"absolute",103,"visible","","","");
	   titlenameobj.innerHTML="<div id='titlenamediv'><font size=2><B>" + TitleName + "</B></font></div>";
	   title.appendChild(titlenameobj);
	   this.DivObj.push(titlenameobj);
	}
	
	var button=documentObject.getElementById("buttonDiv"); //对话框缩放按钮
	if(button==null){
       button=CreateDiv(documentObject,"buttonDiv",title.clientWidth-38,title.clientTop+7,13,13,"absolute",104,"visible","","","");
	   TJEvent.addListener(button, "mouseup", this.OnbuttonDivMouseUp, false);  
	   button.innerHTML="<span onmouseover=this.style.cssText='cursor:hand;color:#000000;' title='最大化' style='color:#000000;'><font color=#000000><font face=Webdings>1</font></font></span>";
	   title.appendChild(button);
	   this.DivObj.push(button);
	}	
     
	var close=documentObject.getElementById("closeDiv"); //关闭按钮
	if(close==null){
       close=CreateDiv(documentObject,"closeDiv",title.clientWidth-20,title.clientTop+10,13,13,"absolute",105,"visible","","","");
	   TJEvent.addListener(close, "mouseup", this.OnCloseDivMouseUp, false);  
	   close.innerHTML="<img src="+buttonimage+" width=13 height=13 onmouseover=this.style.cssText='cursor:hand' title='关闭'>";
	   title.appendChild(close);
	   this.DivObj.push(close);
	}
	
	/*
	var move=documentObject.getElementById("moveDiv"); //移动按钮
	if(move==null){
       move=CreateDiv(documentObject,"moveDiv",GetSize(obj)[0]-17,title.clientTop-10,16,16,"absolute",104,"visible","","","");
	   TJEvent.addListener(move, "mousedown", this.OnLabelDivMouseDown, false);   
	   TJEvent.addListener(move, "mousemove", this.OnLabelDivMouseMove, false);   
	   move.innerHTML="<img src=../images/move.bmp onmouseover=this.style.cssText='cursor:move' title='移动'>";
	   obj.appendChild(move);
	   this.DivObj.push(move);
	}
	*/
	
	var DialogBody=documentObject.getElementById("OpenDialog");   //对话框窗体页面
    this.DivObj.push(DialogBody);
    /*
   for (var i=0; i<this.DivObj.length-1; i++)
   {
      this.DivObj[i].style.display="inline";
   }
    */
   //TJEvent.addListener(document.body, "mousedown", this.DialogBlur, false);   
 };

this.DialogFocus=function(Evnt)
{
   var documentObject;
   documentObject=GetDocumentObj();
   var titleObj=documentObject.getElementById("titleDiv");
   //if(titleObj)
   //   titleObj.style.background="#E7EFFE";
};

this.DialogBlur=function(Evnt)
{
   var documentObject;
   documentObject=GetDocumentObj();
   var titleObj=documentObject.getElementById("titleDiv");
   //if(titleObj)
   //   titleObj.style.background="#D4D0C8";
};

this.DestoryDialog=function()
{
    var documentObject;
	documentObject=GetDocumentObj();
	var yyobj=documentObject.getElementById("yyDiv"); 
    var obj=documentObject.getElementById("LabelDiv");
    var title=documentObject.getElementById("titleDiv");     
	var close=documentObject.getElementById("closeDiv"); 
	//销毁对话框控件
	if(close&&obj&&yyobj)
	{
	   TJEvent.removeListener(title, "mousedown", this.OnLabelDivMouseDown, false);   
	   TJEvent.removeListener(title, "mousemove", this.OnLabelDivMouseMove, false);   	
       TJEvent.removeListener(close, "mouseup", this.OnCloseDivMouseUp, false);
       documentObject.body.removeChild(yyobj);
	}
	HiddenSelectCtrl(1);
};

this.OnbuttonDivMouseUp=function(Evnt)
{
   var documentObject;
   documentObject=GetDocumentObj();
   titleobj=document.getElementById("titlediv");
   if(DialogObject.DialogStatu==1)
   {

      DialogObject.DivObj[0].style.top=DialogObject.DialogMinSize.Top+"px";
	  DialogObject.DivObj[0].style.left=DialogObject.DialogMinSize.Left+"px";
      DialogObject.DivObj[0].style.width=DialogObject.width+"px";
      DialogObject.DivObj[0].style.height=DialogObject.height+"px";
      DialogObject.DivObj[1].style.width=DialogObject.width+"px";
      DialogObject.DivObj[1].style.height=DialogObject.height+"px";
      titleobj.style.width=DialogObject.width+"px";
      DialogObject.DivObj[DialogObject.DivObj.length-1].style.width=DialogObject.DialogMinSize.Width+"px";
      DialogObject.DivObj[DialogObject.DivObj.length-1].style.height=DialogObject.DialogMinSize.Height+"px";

	  DialogObject.DivObj[3].innerHTML="<span onmouseover=this.style.cssText='cursor:hand' title='最大化'><font color=#000000><font face=Webdings>1</font></font></span>";
      DialogObject.DialogStatu=0;
   }
   else
   {
      DialogObject.DivObj[0].style.top=DialogObject.DialogMaxSize.Top+"px";
	  DialogObject.DivObj[0].style.left=DialogObject.DialogMaxSize.Left+"px";
      DialogObject.DivObj[0].style.width=DialogObject.DialogMaxSize.Width+"px";
      DialogObject.DivObj[0].style.height=DialogObject.DialogMaxSize.Height+"px";
      DialogObject.DivObj[1].style.width=DialogObject.DialogMaxSize.Width+"px";
      DialogObject.DivObj[1].style.height=DialogObject.DialogMaxSize.Height+"px";
      titleobj.style.width=DialogObject.DialogMaxSize.Width+"px";
      DialogObject.DivObj[DialogObject.DivObj.length-1].style.width=DialogObject.DialogMaxSize.Width-20+"px";
      DialogObject.DivObj[DialogObject.DivObj.length-1].style.height=DialogObject.DialogMaxSize.Height-20+"px";
	  DialogObject.DivObj[3].innerHTML="<span onmouseover=this.style.cssText='cursor:hand' title='向下还原'><font color=#000000><font face=Webdings>2</font></font></span>";
	  DialogObject.DialogStatu=1;
   }
      //DialogObject.DivObj[1].style.top="-5px";
	  //DialogObject.DivObj[1].style.left="-5px";
      DialogObject.DivObj[2].style.top=DialogObject.DivObj[1].clientTop+8+"px";
	  DialogObject.DivObj[2].style.left=DialogObject.DivObj[1].clientLeft+10+"px";
      DialogObject.DivObj[3].style.top=DialogObject.DivObj[1].clientTop+7+"px";
	  DialogObject.DivObj[3].style.left=DialogObject.DivObj[1].clientWidth-38+"px";
      DialogObject.DivObj[4].style.top=DialogObject.DivObj[1].clientTop+10+"px";
	  DialogObject.DivObj[4].style.left=DialogObject.DivObj[1].clientWidth-20+"px";
};

this.OnCloseDivMouseUp=function(Evnt)
{
   var e=Evnt?Evnt:event;
   DialogObject.DialogStatu=0;
   DialogObject.DivObj=new Array();
   DialogObject.DestoryDialog();
   //StopDefault(e);
   //StopBubble(e);
};

this.OnLabelDivMouseDown=function(Evnt)
{
   var e=Evnt?Evnt:event;
   var CurDivPosition=new Array();
   for(var i=0;i<DialogObject.DivObj.length-1;i++)   
      CurDivPosition.push(GetAbsolutePos(DialogObject.DivObj[i]));
   DialogObject.DivPosition=CurDivPosition;
   DialogObject.MousePosition=[e.clientX,e.clientY];
   DialogObject.DialogFocus();

   //StopDefault(e);
   //StopBubble(e);
};

this.OnLabelDivMouseUp=function(Evnt)
{
};

this.OnLabelDivMouseMove=function(Evnt)
{
    var Pressing;
    var e=Evnt?Evnt:event;
    var MX=e.clientX;
    var MY=e.clientY;
    if(e.button == 1) Pressing=true;
	else Pressing=false;
    if(Pressing)
	{
	    if(DialogObject.DivPosition && DialogObject.MousePosition){
           DialogObject.DivObj[0].style.left=DialogObject.DivPosition[0][0]+e.clientX-DialogObject.MousePosition[0]+"px";
           DialogObject.DivObj[0].style.top=DialogObject.DivPosition[0][1]+e.clientY-DialogObject.MousePosition[1]+"px";
		}
	}
   //StopDefault(e);
   //StopBubble(e);
};
};

function InitPage()
{
    var documentObject;
	documentObject=GetDocumentObj();
	var yyobj=documentObject.getElementById("yyDiv"); 
	if(yyobj)
	{
       documentObject.body.removeChild(yyobj);
	}
	HiddenSelectCtrl(1);
};

///////////////////////////////////////////页面锚点控制函数/////////////////////////////////////

//获取滚动条信息
function getScroll() 
{
	var t, l, w, h;
	
	if (document.documentElement && document.documentElement.scrollTop) {
		t = document.documentElement.scrollTop;
		l = document.documentElement.scrollLeft;
		w = document.documentElement.scrollWidth;
		h = document.documentElement.scrollHeight;
	} else if (document.body) {
		t = document.body.scrollTop;
		l = document.body.scrollLeft;
		w = document.body.scrollWidth;
		h = document.body.scrollHeight;
	}
	return { t: t, l: l, w: w, h: h };
};

//锚点(Anchor)间平滑跳转
function scroller(el, duration)
{
	if(typeof el != 'object') { el = document.getElementById(el); }
	if(!el) return;
	var z = this;
	z.el = el;
	z.p = getPos(el);
	z.s = getScroll();
	if(document.body.scrollHeight-z.s.t==document.body.clientHeight)
	{
		return;
	}
	z.clear = function(){window.clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / duration;
		if (t >= duration + z.t) {
			z.clear();
			window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer = window.setInterval(function(){z.step();},13);
};

/////////////////////////////////////////////转换类函数//////////////////////////////////////////////
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
};
Array.prototype.max=function()
{ 
   var i, max = this[0];
   for (i = 1; i < this.length; i++)
   {
       if (max < this[i])
       max = this[i];
   }
   return max;
};
Array.prototype.min=function()
{ 
   var i, min = this[0];
   for (i = 1; i < this.length; i++)
   {
       if (min > this[i])
       min = this[i];
   }
   return min;
};

////////////////////////////////////////////字符串函数///////////////////////////////////////////
//返回字符串的长度
String.prototype.lengthCN=function(){ 
 return this.replace(/[^\x00-\xff]/g,"**").length; 
};

function JHshStrLen(sString)
{
   var sStr,iCount,i,strTemp ;

   iCount = 0 ;
   if(sString)
	{
     sStr = sString.split("");
     for (i = 0 ; i < sStr.length ; i ++)
     {
         strTemp = escape(sStr[i]);
          if (strTemp.indexOf("%u",0) == -1)
          {
              iCount = iCount + 1 ;
          }
          else
          {
              iCount = iCount + 2 ;
          }
      }
	}
      return iCount ;
};

////////////////////////////////////////////事件类函数///////////////////////////////////////////
function StopBubble(e)
{
    if ( e && e.stopPropagation )
        e.stopPropagation();
    else
        window.event.cancelBubble = true;
};
function StopDefault(e)
{
    if ( e && e.preventDefault )
        e.preventDefault();
    else
        window.event.returnValue = false;
    return false;
};

/////////////////////////////////////////////事件监听类函数/////////////////////////////////////////
var TJEvent = new Object();
//绑定事件监听
TJEvent.addListener=function(o, evType, f, capture) 
{
	if(o.addEventListener) 
	{
	    if(typeof(capture)=="undefined")
	        capture = false;
		o.addEventListener(evType, f, capture);
	}
 	else if (o.attachEvent) 
  	    o.attachEvent("on" + evType, f);
    else 
  	    eval("o.on" + evType + "=f;");
}; 

//解除事件绑定
TJEvent.removeListener=function(o, evType, f, capture)
{
	if(o.removeEventListener)
	{ 
	    if(typeof(capture)=="undefined")
	        capture = false;
		o.removeEventListener(evType, f, capture);
	}
    else if (o.detachEvent) 
		o.detachEvent("on" + evType, f);
	else 
   	    eval("o.on" + evType + "=null;");
};

TJEvent.clearEvent=function(o,evType)
{
    eval("o.on" + evType + "=null;");
};

/////////////////////////////////////////////图形类函数/////////////////////////////////////////////
function GetImgSize(url)
{
    var oImg=new Image();
    oImg.src=url;
    var size=[];
    size[0] = oImg.width;
    size[1] = oImg.height;   
    return size;
};

/////////////////////////////////////////////XML处理函数////////////////////////////////////////////
