
//***************************************WSOAS2.5及以前版本***********************************************
function openwin(w,h,url)
		{
		var l=(window.screen.width/2)-w/2;
		var t=(window.screen.height/2)-h/2;
		window.open(url,'','width='+w+',height='+h+',top='+t+',left='+l+',menubar=no,toobar=no,scrollbars=yes,resizable=yes,status=no,loation=no');
	
}
	   function Carcheck(form)
          {
         if(form.CarName.value=="")
            {
           alert("请输入车辆名!");
	       form.CarName.focus();
           return false;
            }
        if (form.CarDescribe.value=="")
        { 
         alert("请输入简要描述!");
         form.CarDescribe.focus();
         return false;
          }
         return true;
         }	

      function Meetingcheck(form)
       {
         if(form.MeetingName.value=="")
          {
           alert("请输入会议室名称!");
	       form.MeetingName.focus();
           return false;
               }
         if (form.MeetingDescribe.value=="")
          { 
          alert("请输入简要描述!");
          form.MeetingDescribe.focus();
          return false;
          }
        return true;
     }   
    function offieccheck()
     {
      var frm=document.form1;	
      if(frm.WS_OfficeName.value==""){
			   alert('名称不能为空!');
			   frm.WS_OfficeName.focus();
			   return false;
			   }
      if(frm.WS_OfficeManageName.value==""){
			   alert('请选择保管员!');
			   frm.WS_OfficeManageName.focus();
			   return false;
			   }			   
	return true;		   
	}
	
	 function propertycheck(form)
     {
		 if(form.pnumber.value==""){
			   alert('资产编号不能为空!');
			   form.pnumber.focus();
			   return false;
			   }
		 if(form.pname.value==""){
			   alert('资产名称不能为空!');
			   form.pname.focus();
			   return false;
			   }
	return true;		   
	}	
function CarReturncheck(form)
{if(form.carman.value=="")
     {
      alert("请输入司机名字!")
	  form.carman.focus();
      return false
     }
return true
}
function CustomCheck(form)
{if(form.InfoName.value=="")
     {
      alert("客户名称不能为空!")
	  form.InfoName.focus();
      return false
     }
return true
}
function CustomActCheck(form)
{if(form.ContactName.value=="")
     {
      alert("姓名不能为空!")
	  form.ContactName.focus();
      return false
     }
return true
}
function SaleShopCheck(form)
{if(form.SaleShopName.value=="")
     {
      alert("供应商名称不能为空!")
	  form.SaleShopName.focus();
      return false
     }
return true
}
function ProductCheck(form)
{if(form.ProductName.value=="")
     {
      alert("产品不能为空!")
	  form.ProductName.focus();
      return false
     }
return true
}
function chkall(e)
{
	if(form1.MAID)
	{
		form1.MAID.checked=e.checked;
		for(i=0;i<form1.MAID.length;i++)
		if(form1.MAID[i].disabled!=true) form1.MAID[i].checked=e.checked;
	}
}
function chkall1(e)
{
	if(form1.SMID)
	{
		form1.SMID.checked=e.checked;
		for(i=0;i<form1.SMID.length;i++)
		if(form1.SMID[i].disabled!=true) form1.SMID[i].checked=e.checked;
	}
}

function PersonalPDA(form)
{if(form.Pname.value=="")
     {
      alert("请输入姓名!")
	  form.Pname.focus();
      return false
     }
return true
}
function checkmm(from)
{
if (from.WS_ManName.value=="")
{ alert("不能没有发布人员!");
from.WS_ManName.focus();
  return false;
}
if (from.pathname.value=="")
{ alert("流程名称不能为空!");
  from.pathname.focus();
  return false;
}
if (from.statenumber.value=="")
{ alert("请选择公文类别!");
  from.statenumber.focus();
  return false;
}
return true
}
function SchEduleCheck(form)
{
if(form.title.value=="")
     {
      alert("请输入日程主题!");
	  form.title.focus();
      return false;
     }
if(form.AddMemo.value=="")
     {
      alert("请输入日程内容!");
	  form.AddMemo.focus();
      return false;
     }	 
return true
}
function WorkTypecheck(form)
{if(form.TypeName.value=="")
     {
      alert("请输入类别名称!")
	  form.TypeName.focus();
      return false
     }
return true
}
function aa()
{
	if(form1.WS_MailToName.value=="")
	{
		alert("请选择收件人!");
		form1.WS_MailToName.focus();
		return false;
	}
	if(form1.subject.value=="")
	{
		alert("标题不能为空");
		form1.subject.focus();
		return false;
	}
//form1.Content.value = frames.WSOAS1.document.body.innerHTML;
form1.submit();
}
function bb()
{
if(form1.subject.value=="")
  {
     alert("标题不能为空");
	 form1.subject.focus();
     return false;
  }
//form1.Content.value = frames.WSOAS1.document.body.innerHTML; 
form1.pagename.value="dosave";
form1.submit();
}
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}

function mscroll(n,id){
temp=n;
did=id;
if (temp==0) return;
switch(did){
case 1: div1.scrollTop=div1.scrollTop+temp;break;
case 2: div2.scrollTop=div2.scrollTop+temp;break;
case 3: div3.scrollTop=div3.scrollTop+temp;break;
}
setTimeout("mscroll(temp,did)",80);
}

function workflowTocheck(form)
{

if(form.WS_WorkFlowToName.value=="")
     {
      alert("请选择收文人!");
	  form.WS_WorkFlowToName.focus();
      return false;
     }
if(form.Numbers.value=="")
     {
      alert("请输入来文单位!");
	  form.Numbers.focus();
      return false;
     }
if(form.FlowType.value==""){	
      alert("请选择公文类别!");
	  form.FlowType.focus();
      return false;
	}	 
if(form.Title.value=="")
     {
      alert("请输入来文标题!");
	  form.Title.focus();
      return false;
     }
if(form.ComeDate.value=="")
     {
      alert("请输入来文日期!");
	  form.ComeDate.focus();
      return false;
     }
	
if(form.Content.value=="")
     {
      alert("请输入具体公文内容!");
	  form.Content.focus();
      return false;
     }
return true
}
function checkadd(){
			if(document.frmAdd.FolderName.value==""){
				alert("请输入文件夹名称！");
				document.frmAdd.FolderName.focus();
				return false;
			}
		}
		function DoFolder(action){
			if(document.frmEdit.FolderId.value==""){
				alert("请选择要修改的文件夹！");
			}else{
				document.frmEdit.action.value=action;
				if(document.frmEdit.FolderName.value==""){
					alert("请输入文件夹名称！");
					document.frmEdit.FolderName.focus();
				}else{
					if(action=="delete"){
						if(confirm("确定要删除该文件夹吗？\n\n注意：删除该文件夹将删除该文件下的所有文件！")){
							document.frmEdit.submit();
						}
					}else{
						document.frmEdit.submit();
					}
				}
			}
		}
menu_flag=0;
var STATUS_BAR_MENU;

function show_WEBSMS()
{
   if(menu_flag==0)   
       STATUS_BAR_MENU=window.open("HX_WEBSMS/list.asp","STATUS_BAR_MENU","height=360,width=90,status=0,toolbar=no,menubar=no,location=no,scrollbars=no,top=200,left=150,resizable=no");
   STATUS_BAR_MENU.focus();
}
function CloseOpen(evt) {
   if(evt.clientX<=0 && evt.clientY<0) {
	location.href='HX_login.asp?action=loginout';
        if(!confirm('您已经安全的退出系统，按“确定”关闭浏览器，按“取消”重新登录？')){
         window.open('index.asp');
           return false;}
         else{
          window.close();
            return true;
          }
	}
}

   var MENU_ID_ARRAY = new Array();
    MENU_ID_ARRAY[0]="01";
    MENU_ID_ARRAY[1]="02";
    MENU_ID_ARRAY[2]="03";
    MENU_ID_ARRAY[3]="04";
    MENU_ID_ARRAY[4]="02";
    MENU_ID_ARRAY[5]="06";
    MENU_ID_ARRAY[6]="07";
	MENU_ID_ARRAY[7]="08";
	MENU_ID_ARRAY[8]="09";
	MENU_ID_ARRAY[9]="10";
	MENU_ID_ARRAY[6]="11";	
function check_all(menu_all,MENU_ID)
{
 for (i=0;i<document.all(MENU_ID).length;i++)
 {
   if(menu_all.checked)
      document.all(MENU_ID).item(i).checked=true;
   else
      document.all(MENU_ID).item(i).checked=false;
 }
}
 
function calenderout(){                            
calendar = new Date(); 
month = calendar.getMonth();                                 
date = calendar.getDate();                                 
year = calendar.getYear();
hours= calendar.getHours();
if (year< 100)  year = 2000 + year;
 document.write(""+year+"年"+(month+1)+"月"+date+"日");                             
//提前十天提醒节日                                 
document.write("<br>"); 
//以下为元旦提醒 
if ((month == 11) && (date == 22))  document.write("距元旦还有十天！");
if ((month == 11) && (date == 23))  document.write("距元旦还有九天！");
if ((month == 11) && (date == 24))  document.write("距元旦还有八天！");
if ((month == 11) && (date == 25))  document.write("距元旦还有七天！");
if ((month == 11) && (date == 26))  document.write("距元旦还有六天！");
if ((month == 11) && (date == 27))  document.write("距元旦还有五天！");
if ((month == 11) && (date == 28))  document.write("距元旦还有四天！");
if ((month == 11) && (date == 29))  document.write("距元旦还有三天！");
if ((month == 11) && (date == 30))  document.write("距元旦还有二天！");
if ((month == 11) && (date == 31))  document.write("距元旦还有一天！");               
if ((month == 0) && (date == 1))  document.write("元旦快乐！");
//情人节提醒 
if ((month == 1) && (date == 4)) document.write("距情人节还有十天！");
if ((month == 1) && (date == 5)) document.write("距情人节还有九天！");
if ((month == 1) && (date == 6)) document.write("距情人节还有八天！");
if ((month == 1) && (date == 7)) document.write("距情人节还有七天！");
if ((month == 1) && (date == 8)) document.write("距情人节还有六天！");
if ((month == 1) && (date == 9)) document.write("距情人节还有五天！");
if ((month == 1) && (date == 10)) document.write("距情人节还有四天！");
if ((month == 1) && (date == 11)) document.write("距情人节还有三天！");
if ((month == 1) && (date == 12)) document.write("距情人节还有二天！");
if ((month == 1) && (date == 13)) document.write("距情人节还有一天！");                    
if ((month == 1) && (date == 14)) document.write("情人节快乐！");
//妇女节提醒，还要考虑是不是闰年的问题 
if ((((year%4)==0)&&((year%100)!=0))||((year%400)==0))
{
if ((month == 1) && (date == 26)) document.write("距劳动妇女节还有十天！");
if ((month == 1) && (date == 27)) document.write("距劳动妇女节还有九天！");
if ((month == 1) && (date == 28)) document.write("距劳动妇女节还有八天！");
if ((month == 1) && (date == 29)) document.write("距劳动妇女节还有七天！");
}
else
{
if ((month == 1) && (date == 25)) document.write("距劳动妇女节还有十天！");
if ((month == 1) && (date == 26)) document.write("距劳动妇女节还有九天！");
if ((month == 1) && (date == 27)) document.write("距劳动妇女节还有八天！");
if ((month == 1) && (date == 28)) document.write("距劳动妇女节还有七天！");
}


if ((month == 2) && (date == 1)) document.write("距劳动妇女节还有六天！");
if ((month == 2) && (date == 2)) document.write("距劳动妇女节还有五天！");
if ((month == 2) && (date == 3)) document.write("距劳动妇女节还有四天！");
if ((month == 2) && (date == 4)) document.write("距劳动妇女节还有三天！");
if ((month == 2) && (date == 6)) document.write("距劳动妇女节还有二天！");
if ((month == 2) && (date == 7)) document.write("距劳动妇女节还有一天！");         
if ((month == 2) && (date == 8)) document.write("今天是国际劳动妇女节！");
//儿童节提醒

if ((month == 4) && (date == 22)) document.write("距儿童节还有十天！");
if ((month == 4) && (date == 23)) document.write("距儿童节还有九天！");
if ((month == 4) && (date == 24)) document.write("距儿童节还有八天！");
if ((month == 4) && (date == 25)) document.write("距儿童节还有七天！");
if ((month == 4) && (date == 26)) document.write("距儿童节还有六天！");
if ((month == 4) && (date == 27)) document.write("距儿童节还有五天！");
if ((month == 4) && (date == 28)) document.write("距儿童节还有四天！");
if ((month == 4) && (date == 29)) document.write("距儿童节还有三天！");
if ((month == 4) && (date == 30)) document.write("距儿童节还有二天！");
if ((month == 4) && (date == 31)) document.write("距儿童节还有一天！");
if ((month == 5) && (date == 1)) document.write("今天是国际儿童节！");
//教师节提醒
if ((month == 7) && (date == 31)) document.write("距教师节还有十天！");
if ((month == 8) && (date == 1)) document.write("距教师节还有九天！");
if ((month == 8) && (date == 2)) document.write("距教师节还有八天！");
if ((month == 8) && (date == 3)) document.write("距教师节还有七天！");
if ((month == 8) && (date == 4)) document.write("距教师节还有六天！");
if ((month == 8) && (date == 5)) document.write("距教师节还有五天！");
if ((month == 8) && (date == 6)) document.write("距教师节还有四天！");
if ((month == 8) && (date == 7)) document.write("距教师节还有三天！");
if ((month == 8) && (date == 8)) document.write("距教师节还有二天！");
if ((month == 8) && (date == 9)) document.write("距教师节还有一天！");
if ((month == 8) && (date == 10)) document.write("今天是教师节！");
//国庆节提醒 
if ((month == 8) && (date == 21)) document.write("距国庆节还有十天！");
if ((month == 8) && (date == 22)) document.write("距国庆节还有九天！");
if ((month == 8) && (date == 23)) document.write("距国庆节还有八天！");
if ((month == 8) && (date == 24)) document.write("距国庆节还有七天！");
if ((month == 8) && (date == 25)) document.write("距国庆节还有六天！");
if ((month == 8) && (date == 26)) document.write("距国庆节还有五天！");
if ((month == 8) && (date == 27)) document.write("距国庆节还有四天！");
if ((month == 8) && (date == 28)) document.write("距国庆节还有三天！");
if ((month == 8) && (date == 29)) document.write("距国庆节还有二天！");
if ((month == 8) && (date == 30)) document.write("距国庆节还有一天！");           
if ((month == 9) && (date == 1)) document.write("今天是国庆节！");
//圣诞提醒  
if ((month == 11) && (date == 15)) document.write("距圣诞还有十天！");
if ((month == 11) && (date == 16)) document.write("距圣诞还有九天！");
if ((month == 11) && (date == 17)) document.write("距圣诞还有八天！");
if ((month == 11) && (date == 18)) document.write("距圣诞还有七天！");
if ((month == 11) && (date == 19)) document.write("距圣诞还有六天！");
if ((month == 11) && (date == 20)) document.write("距圣诞还有五天！");
if ((month == 11) && (date == 21)) document.write("距圣诞还有四天！");
if ((month == 11) && (date == 22)) document.write("距圣诞还有三天！");
if ((month == 11) && (date == 23)) document.write("距圣诞还有二天！");
if ((month == 11) && (date == 24)) document.write("距圣诞还有一天！");
if ((month == 11) && (date == 25)) document.write("圣诞快乐！");
document.write("</b></font>");  }  

function Notfiycheck()
{
	if(form1.NotifyTitle.value=="")
	{
		alert("公告标题不能为空!");
		form1.NotifyTitle.focus();
		return false;
	}
	if(form1.WS_NCID.value=="")
	{
		alert("没有任何类别的权限,所以不能发公告,请与管理员联系!");
		form1.WS_NCID.focus();
		return false;
	}

	//if(form1.Content.value=="")
	//{
		//alert("公告内容不能为空!");
		//return false;
	//}
//form1.Content.value = frames.message.document.body.innerHTML;
//form1.submit();
}
function openlogin(url){
HeightValue=screen.height;
WidthValue=screen.width;
window.location.href=url;
window.moveTo(0,0);
window.resizeTo(WidthValue+6,HeightValue-23);
}
function setstyle(id){
var id;
if(id.className=='but'){
id.className='tddown';
switch(id){
case a1: say.saytext.style.fontWeight='bold';say.fontb.value='bold';break;
case a2: say.saytext.style.fontStyle='italic';say.fonti.value='italic';break;
case a3: say.saytext.style.textDecoration='underline';say.fontu.value='underline';break;
}}else{
id.className='but';
switch(id){
case a1: say.saytext.style.fontWeight='';say.fontb.value='';break;
case a2: say.saytext.style.fontStyle='';say.fonti.value='';break;
case a3: say.saytext.style.textDecoration='';say.fontu.value='';break;
}
}
}
function mover(id){
var id;
if(id.className=='')
id.className='but';
}
function mout(id){
var id;
if(id.className=='but')
id.className='';
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=='Netscape')&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function selectimg(image){
var image
document.say.saytext.value=document.say.saytext.value+image;
MM_showHideLayers('facelay','','hide');
}

function checkform()
{
 if(document.say.saytext.value==''){
	alert('不能发送空信息');
 return false ;
 }else{
	 if(document.say.showtmsgtext.value=='聊天模式(T)'){
		 this.document.say.submit();
		 window.close();
	 }else{
		var fontb=document.say.fontb.value;
		var fonti=document.say.fonti.value;
		var fontu=document.say.fontu.value;
		var recvnmb=document.say.recvnmb.value;
		var font=document.say.font.value;
		var fontcolor=document.say.fontcolor.value;
		var  fontsize=document.say.fontsize.value;
		var message=document.say.saytext.value;		
		send_root_request('../SelectWSOASAjax.Asp?Action=Send&fontb=' + fontb + '&fonti=' + fonti + '&fontu=' + fontu + '&recvnmb=' + recvnmb + '&font=' + font + '&fontcolor=' + fontcolor + '&fontsize=' + fontsize + '&message=' + message);
		//parent.showmetop.location.reload();
		document.say.saytext.value='';
		 }
 }
}

function send_root_request(url) {//初始化、指定处理函数、发送请求的函数
	 http_request = false;
	 if(window.XMLHttpRequest) {
	  http_request = new XMLHttpRequest();	  
	  if (http_request.overrideMimeType) {//设置MiME类别
		http_request.overrideMimeType('text/xml');
	  }
	}
	else if (window.ActiveXObject) { // IE浏览器
	  try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	  }catch (e){
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
	  }catch (e) {

		}
	  }
	}

	if (!http_request) { // 异常，创建对象实例失?
	  window.alert("不能创建XMLHttpRequest对象实例.");
	  return false;
	}
	http_request.onreadystatechange = processRootRequest;
	// 确定发送请求的方式和URL以及是否同步执行下段代码	
	http_request.open("POST", url, true);
	http_request.send(null);
	//
}
function processRootRequest() {		
if (http_request.readyState == 4) { // 判断对象状态
	if (http_request.status != 200) { // 信息已经成功返回，开始处理信息	 			   	
		 alert("您所请求的页面有异常。");
	   }
	}
}


function center(){
if(event.ctrlKey && window.event.keyCode==13){checkform();}
if (window.say.saytext.value.length > 210) 
window.say.saytext.value = window.say.saytext.value.substring(0,210);
}
function show(id){
	var ChatMessageWin; 
	if (ChatMessageWin && ChatMessageWin.open && !ChatMessageWin.closed)
	{   
		return;
	}else{
	   ChatMessageWin = window.open("../HX_WEBSMS/send.asp?id="+id,"ChatMessageWin","width=395,height=210,resizable=0,top=200,left=300,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
	}   
}
function showhis(){
if(document.say.histext.value=='聊天记录(H)'){
resizeTo(404,358);
document.say.histext.value='关闭记录(H)';
document.say.saytext.focus();
}else{
resizeTo(404,238);
document.say.histext.value='聊天记录(H)';
document.say.saytext.focus();
}
}

function showtmsg(){
	if(document.say.showtmsgtext.value=='聊天模式(T)'){
		resizeTo(404,358);
		document.all["showmessage"].style.display='';
		document.say.showtmsgtext.value='消息模式(T)';
		document.say.saytext.focus();
	}else{
		document.all["showmessage"].style.display='none';
		resizeTo(404,238);
		document.say.showtmsgtext.value='聊天模式(T)';
		document.say.saytext.focus();
	}	
}

function checkfrm_upload(){
		if(document.frm_upload.doc.value==""){
			alert("请选择要上传的附件！");
			return false;
		}
	}
function jg_onchange(){
jgnum=0;
if(document.form1.WS_wage.value==""||isNaN(document.form1.WS_wage.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_wage.value);
}
if(document.form1.WS_pay.value=="")document.form1.WS_pay.value=0
if(isNaN(document.form1.WS_pay.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_pay.value);
}
if(document.form1.WS_house.value=="")document.form1.WS_house.value=0
if(isNaN(document.form1.WS_house.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_house.value);
}
if(document.form1.WS_lunch.value=="")document.form1.WS_lunch.value=0
if(isNaN(document.form1.WS_lunch.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_lunch.value);
}
if(document.form1.WS_outpay.value=="")document.form1.WS_outpay.value=0
if(isNaN(document.form1.WS_outpay.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_outpay.value);
}
if(document.form1.WS_bonus.value=="")document.form1.WS_bonus.value=0
if(isNaN(document.form1.WS_bonus.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum+parseFloat(document.form1.WS_bonus.value);
}
if(document.form1.WS_card.value=="")document.form1.WS_card.value=0
if(isNaN(document.form1.WS_card.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum-parseFloat(document.form1.WS_card.value);
}
if(document.form1.WS_ratal.value=="")document.form1.WS_ratal.value=0
if(isNaN(document.form1.WS_ratal.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum-parseFloat(document.form1.WS_ratal.value);
}
if(document.form1.WS_safe.value=="")document.form1.WS_safe.value=0
if(isNaN(document.form1.WS_safe.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum-parseFloat(document.form1.WS_safe.value);
}
if(document.form1.WS_other.value=="")document.form1.WS_other.value=0
if(isNaN(document.form1.WS_other.value))
{
alert("只能输入数字");
}
else
{
jgnum=jgnum-parseFloat(document.form1.WS_other.value);
document.form1.WS_lastmoney.value=eval("jgnum");
}
}
//--------------------------------------附件功能---------------------------------------------------
var currFocus;
var ExistAttaInfo = new Array();
var oldDelAttas = new Array();
var attaIdx = 0;
var IsIE;
function fInitMSIE(){
	if (navigator.userAgent.indexOf("MSIE") != -1){
		IsIE = true;
	}else{
		IsIE = false;
	}
}
fInitMSIE();



function fTrim(str){
	str = str.replace(/(^\s*)/,"");
	str = str.replace(/(\s*$)/,"");
	return str;
}
//****************************WSOAS3.0************************************************************

//本js文件用于compose.htm同时发送多个附件的js函数，支持 IE 和 NNx 系列。
//所有的函数都适用于 IE 和 NNx 系列，直接调用就可以
//函数里面会根据语句判断浏览器类型，然后依据不同的bowser属性增加元素
//主要功能是动态创建 各种表单元素 和 删除表单元素
//written by xpr

//    function list
//    -------------------------------------------------------------------------------------------------------------------
//    IsIEBrowser()  返回值: true(IE) false(NNx)
//    exist(fileId)  判断fileId是否已经存在
//    addInputFile(spanId,fileId)  在名为spanId 的元素里面增加序号为index的input file
//    addbr(spanId,brId)  在名为spanId 的元素里面增加id为brId的换行符
//    adddel(spanId,index) 在名为spanId 的元素里面增加序号为index的"删除"按钮，他可以删除相应的input file 和 br
//    addhidden(spanId,hiddenId,value)  在名为spanId 的元素里面增加id为hiddenId，值为value的input type=hidden
//    -------------------------------------------------------------------------------------------------------------------

var IsIE;
var attaIdx = 0;

//search,全局变量
//-----------------------------------------------------------------------------------------------------------
function IsIEBrowser() {
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		return true;
		} else {
		return false;
		}
}

// 增加附件函数 ()，增加到 idfilespan,基数为 attaIdx 。

function add() {

	addfile("idfilespan",attaIdx);
	attaIdx++;
	return false;
}

//----------------------------------------fileexist()----------------------------------------------------------
//edited by alun
function exist(fileId) {
      var file = document.getElementById(fileId);
	  var result = false;
	  if ( file !=null ) {
			if ( file.value != null && file.value != "") {
				result = existFile( file);
				
			}//if
	  }
	  if( result)
	  {
		alert("这个附件您已经添加过了,新添加的附件将已被删除");
		//document.sendmail."+fileId+".value=""";
		var attach_num = fileId.substring(10,12);
		
		delfile("idfilespan",attach_num);
		 
		//--attaIdx;
		//document.getElementById( "idAttachOper"+ attaIdx).click();
	  }
	add();
}//end of function
//added by alun
function getfilename( attaName ) {
	var s = attaName.lastIndexOf( '\\' );
	return attaName.substr(s+1, attaName.length - s -1);
}
//added by alun
function existFile( file)
{
	var form = document.sendmail;
	for ( var i= 0 ; i < form.elements.length ; i ++ ) {				    
		if ( form.elements[i].type == "file" && form.elements[i].name != file.name ) {
			if ( file.value == form.elements[i].value ) {
				//alert(form.elements[i].value=null);
				return true;
			}
		}
	}//for
	for (var i=0; i<ExistAttaInfo.length; i++) {
		var theName = ExistAttaInfo[i];
		if ( theName != null && theName != "" && theName == getfilename(file.name) ) {
			return true;
		}
	}
	return false;
}
//----------------------------------------addfile(spanId,index)----------------------------------------------
function addfile(spanId,index)
{
       var strIndex = "" + index;
	   
	   var fileId = "attachfile"+ strIndex;
	   var brId = "idAttachBr" + strIndex;
	   addInputFile(spanId,fileId);

	   adddel(spanId,index);

	   addbr(spanId,brId);
	   //document.getElementById( "attachfile"+ strIndex).click();
	   return;
}
//-------------------------------------------sub fuction addInputFile-----------------------------------------
function addInputFile(spanId,fileId)
{
	  var span = document.getElementById(spanId);
	  if ( span !=null ) {
	                if ( !IsIE ) {
						var fileObj = document.createElement("input");
						if ( fileObj != null ) {
							fileObj.type="file";
							fileObj.name = fileId;
							fileObj.id = fileId;
							fileObj.size="50";
							var clickEvent = "exist('" + fileId + "')";
							fileObj.setAttribute("onclick",clickEvent,0);  
							span.appendChild(fileObj);
						}//if fileObj
					}// !IsIE

					if ( IsIE ) {
						var fileTag = "<input type='file'  id ='" + fileId + "' size=46 name='file" + fileId + "' onchange=exist('" + fileId + "')>";
						var fileObj = document.createElement(fileTag); 
						span.appendChild(fileObj);
					}//IsIE if
			
	  }//if span
}

function addbr(spanId,brId)
{
	  var span = document.getElementById(spanId);
	  if ( span !=null ) {
			var brObj = document.createElement("br");
			if ( brObj !=null ) {
				brObj.name = brId;
				brObj.id = brId;
				span.appendChild(brObj);
            }//i2f
     }//if
	 return;
}

function adddel(spanId,index)
{
      var strIndex = "" + index;
	  var delId = "idAttachOper" + strIndex;
	  var span = document.getElementById(spanId);
	  if ( span != null ) {
			var oTextNode = document.createElement("SPAN");
			oTextNode.style.width = "5px";
			span.appendChild(oTextNode);
		    if ( IsIE ) {
	        var tag = "<input type='submit' class=button style='BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; OVERFLOW: no; BORDER-LEFT: #000000 1px solid;  BORDER-BOTTOM: #000000 1px solid; HEIGHT: 20' size=46 value=''  id='" + delId + "' onclick=delfile('" + spanId + "',"+strIndex+")></input>";
			var delObj = document.createElement(tag);
			if ( delObj != null ) {
				span.appendChild(delObj);
			}//if

			}// Is IE
			
	        if ( !IsIE ) {
				var delObj = document.createElement("input");
				if ( delObj != null ) {
					delObj.name = delId;
					delObj.id = delId;
					delObj.type = "button";
					var clickEvent = "return delfile('" + spanId + "',"+strIndex+");";
					delObj.setAttribute("onclick",clickEvent);  
					span.appendChild(delObj);
				}//if
			}// !IsIE if
			if( delObj != null) delObj.value = "删除附件";
		}//main if
		return;
}


//-------------------------------------------------------------------------------------------------------------


//---------------------------------------------delete input file-----------------------------------------------
function delfile(spanId,index)
{
	   var strIndex = "" + index;
	   var fileId = "attachfile"+ strIndex;
	   var brId = "idAttachBr" + strIndex;
	   var delId = "idAttachOper" + strIndex;
	   //first,get the element
       var span = document.getElementById(spanId);
	   //alert(  "del span: " + span  );
	   if ( span == null ) return false;

	   var fileObj = document.getElementById(fileId);
	   if ( fileObj == null ) return false;

	   var brObj = document.getElementById(brId);
	   if ( brObj ==null ) return false;

	   var delObj = document.getElementById(delId );
	   //alert(  "del delId: " + delObj  );
	   if ( delObj == null ) return false;

       //second,create the replace element
	   var temp= document.createElement("SPAN");
	   //third,replace it
	    span.replaceChild(temp,fileObj);
		span.replaceChild(temp,brObj);
		// Added by Harry, Repair Remove attached bug 2005/04/04
		span.removeChild(delObj.previousSibling);
		var attach = document.getElementById("attach");
		if(span.getElementsByTagName("INPUT").length == 1) attach.childNodes[0].nodeValue='添加附件';
		// End
		span.replaceChild(temp,delObj);	
		
		return false;
}


ie4=(document.all)?true:false;
ns4=(document.layers)?true:false;




function toExit(){
var args=toExit.arguments;
var visible=args[0];
if(ns4){
        theObj=eval("document.layers[\'"+args[1]+"\']");
        if(theObj)theObj.visibility=visible;
        }
else if(ie4){
        if(visible=='show')visible='visible';
        if(visible=='hide')visible='hidden';
        theObj=eval("document.all[\'"+args[1]+"\']");
        if(theObj)theObj.style.visibility=visible;
        }

}

//****************************WSOAS3.5************************************************************
function OnloadPage()
{ 
    if (top.location==self.location) 
	   top.location="../" 
	}

function Elementdisplay(objname)
{
document.getElementById(objname).style.display='';
}

function Elementdisplaynone(objname)
{
document.getElementById(objname).style.display='none';
}

function ShareDisplay(objname)
{
  var sharedisplay=document.getElementById(objname).style.display;
  if(objname=="Panel1")
  { 
    document.getElementById(objname).style.display='';
    document.getElementById('Panel2').style.display='none';
    document.getElementById('Panel3').style.display='none';	
	}
	else if(objname=="Panel2")
    { 
      document.getElementById(objname).style.display='';
      document.getElementById('Panel1').style.display='none';
       document.getElementById('Panel3').style.display='none';	
	   }
	   else if(objname=="Panel2")
          { 
           document.getElementById(objname).style.display='';
           document.getElementById('Panel1').style.display='none';
           document.getElementById('Panel3').style.display='none';	
	        }
			else if(objname=="Panel3")
              { 
              document.getElementById(objname).style.display='';
              document.getElementById('Panel1').style.display='none';
              document.getElementById('Panel2').style.display='none';	
	            }
	           else
                { 
                  document.getElementById('Panel1').style.display='none';
                  document.getElementById('Panel2').style.display='none';
                  document.getElementById('Panel3').style.display='none';	
	               }
	
	}
  
function window.onload()
{
   var olink = document.links;
   var str = "\u6B22\u8FCE\u60A8\u7684\u5149\u4E34\uFF01";
   for(var i=0;i<olink.length;i++)
   {
       olink[i].onmouseover=function(){window.status=str;return true;}
       olink[i].onfocus=function(){window.status=str;return true;}
   }
}

var clickmessage="\u8BF7\u5DE6\u51FB\uFF01"
function disableclick(e) {
	if (document.all) {
		if (event.button==2||event.button==3) {
			if (document.all["PhotoPic"]!=undefined){	
			alert(clickmessage);
			return false;
			}
		}
	}
	if (document.layers) {
		if (e.which == 3) {
		alert(clickmessage);
		return false;
		}
	}
}

function associateimages(){
	for(I=0;I<document.images.length;I++)
	document.images[I].onmousedown=disableclick;
}

if (document.all)
	document.onmousedown=disableclick
else if (document.layers)
	associateimages()


function settimes(){   
	  var time= new Date();   
	  hours  = time.getHours();   
	  mins  = time.getMinutes();   
	  secs  = time.getSeconds();   
	  if(hours<10)hours="0"+hours;   
	  if(mins<10)mins="0"+mins;   
	  if(secs<10)secs="0"+secs;	     
	  eval("document.all.timediv.innerHTML='时间："+hours+":"+mins+":"+secs+"'");   
	  setTimeout("settimes()",1000);   
  }

function VideoSend(id){

	  window.open("../HX_WEBSMS/MemberVideoSend.asp?recvid="+id,"","width=720,height=620,resizable=0,top=50,left=50,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"); 
	
}

function CheckForm()
{
   if(document.form1.TO_ID.value=="")
   { alert("请添加收信人！");
     return (false);
   }

   if(document.form1.CONTENT.value=="")
   { alert("短信内容不能为空！");
     return (false);
   }

   return (true);
}

function notice()
{
   msg="注意：\n\n所发送的手机短信将在本系统中进行记录，\n请勿发送与工作无关的涉及个人隐私的信息，\n请提醒接收方：其直接回复的信息也可能导致隐私泄露。";
   alert(msg);
}

function clear_user()
{
  document.form1.TO_NAME.value="";
  document.form1.send_no.value="";
}

function LoadWindow()
{
  URL="HXINCLUDE/MobileSelect.asp";
  loc_x=document.body.scrollLeft+event.clientX-event.offsetX-100;
  loc_y=document.body.scrollTop+event.clientY-event.offsetY+210;
  window.showModalDialog(URL,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:400px;dialogHeight:350px;dialogTop:"+loc_y+"px;dialogLeft:"+loc_x+"px");
}

function CheckSend()
{
  if(event.keyCode==10)
  {
    if(CheckForm())
       document.form1.submit();
  }
}

 var cap_max=140;

 function getLeftChars(varField)
 {
    var i = 0;
    var counter = 0;
    var cap = cap_max;
    var leftchars = cap - varField.value.length;

    return (leftchars);
 }

 function onCharsChange(varField)
 {
     var leftChars = getLeftChars(varField);
     if ( leftChars >= 0)
     {
 	document.form1.charsmonitor1.value=cap_max-leftChars;
 	document.form1.charsmonitor2.value=leftChars;
 	return true;
     }
     else
     {
     	document.form1.charsmonitor1.value=cap_max;
     	document.form1.charsmonitor2.value="0";
     	window.alert("短信内容超过字数限制!");
     	var len = document.form1.CONTENT.value.length + leftChars;
 	document.form1.CONTENT.value = document.form1.CONTENT.value.substring(0, len);
 	leftChars = getLeftChars(document.form1.CONTENT);
     	if ( leftChars >= 0)
     	{
 	    document.form1.charsmonitor1.value=cap_max-leftChars;
 	    document.form1.charsmonitor2.value=leftChars;
	}
        return false;
     }
 }


function LoadDo()
{
  SignName();
}

function SignName()
{
  document.form1.CONTENT.value+=":";
  onCharsChange(document.form1.CONTENT);
  document.form1.CONTENT.focus();
}
function ClearContent()
{
  document.form1.CONTENT.value="";
  onCharsChange(document.form1.CONTENT);
  document.form1.CONTENT.focus();
}
function LoadWindow3()
{
  URL="HXINCLUDE/MobileSelect.asp?FIELD=MOBIL_NO&TO_ID=TO_ID1";
  loc_x=document.body.scrollLeft+event.clientX-event.offsetX-100;
  loc_y=document.body.scrollTop+event.clientY-event.offsetY+170;
  //window.open(URL,"read_notify","height=400,width=550,status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,top=150,left=150,resizable=yes");
  window.showModalDialog(URL,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:450px;dialogHeight:350px;dialogTop:"+loc_y+"px;dialogLeft:"+loc_x+"px");
}

function td_calendar(fieldname)
{
  myleft=document.body.scrollLeft+event.clientX-event.offsetX-80;
  mytop=document.body.scrollTop+event.clientY-event.offsetY+140;

  window.showModalDialog("HXINCLUDE/calendar.asp?FIELDNAME="+fieldname,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:280px;dialogHeight:215px;dialogTop:"+mytop+"px;dialogLeft:"+myleft+"px");
  change_remind();
}

function td_clock(fieldname)
{
  myleft=document.body.scrollLeft+event.clientX-event.offsetX-80;
  mytop=document.body.scrollTop+event.clientY-event.offsetY+140;

  window.showModalDialog("HXINCLUDE/clock.asp?FIELDNAME="+fieldname,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:280px;dialogHeight:120px;dialogTop:"+mytop+"px;dialogLeft:"+myleft+"px");
}

function td_clock1(fieldname)
{
  myleft=document.body.scrollLeft+event.clientX-event.offsetX-80;
  mytop=document.body.scrollTop+event.clientY-event.offsetY+140;

  window.showModalDialog("../HXINCLUDE/clock.asp?FIELDNAME="+fieldname,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:280px;dialogHeight:120px;dialogTop:"+mytop+"px;dialogLeft:"+myleft+"px");
}

function td_clock1(fieldname)
{
  myleft=document.body.scrollLeft+event.clientX-event.offsetX-80;
  mytop=document.body.scrollTop+event.clientY-event.offsetY+140;

  window.showModalDialog("../HXINCLUDE/clock.asp?FIELDNAME="+fieldname,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:280px;dialogHeight:120px;dialogTop:"+mytop+"px;dialogLeft:"+myleft+"px");
}


function $(objID) {
  return document.getElementById(objID)
}

function $F(objID) {
  return document.getElementById(objID).value
}
 
var XMLHttp=function(){
	try {return new ActiveXObject("Msxml5.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml4.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml3.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
	try {return new XMLHttpRequest();}catch(e){}
	return null;
}

function updater(objid,url,method,parameters,loading,async){
	var req=new XMLHttp();
	var objid=objid;
	var url=url;
	var method=method;
	var parameters=parameters;
	var loading=loading;
	var async=async;
	if (req!=null){
		req.onreadystatechange = function(){
			if (req.readyState==4){
				if(req.status==200){
					//window.status=""
					$(loading).style.display="none";
					$(objid).innerHTML=req.responseText;
				}else{
					//window.status="服务器出错,错误代码："+req.statusText
					alert("服务器出错,错误代码："+req.statusText)
				}
			}else{
				// window.status="正在加载......"
				 $(loading).style.display="block";
			}
		}
		if (parameters=="") url=url;
		else url+="?"+parameters;
		url+=(url.indexOf("?") >= 0)?"&nowtime="+new Date().getTime():"?nowtime=" + new Date().getTime();
		if (method=='get'){
			req.open('GET',url,async);
			req.send(null);
		}else if (method=='post'){
			req.open('POST',url,async);
			req.setRequestHeader("Content-Length",parameters.length); 
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
			req.send(parameters);
		}else{
		    alert("请至少使用一种传送方式");
		}
	}else{
		alert("无法创建xmlhttp");
	}
}

function updater1(url,method,parameters,async){
	var req=new XMLHttp();
	var url=url;
	var method=method;
	var parameters=parameters;
	var async=async;
	if (req!=null){
		req.onreadystatechange = function(){
			if (req.readyState==4){
				if(req.status==200){
					//window.status=""
					document.write(req.responseText);					
				}else{
					//window.status="服务器出错,错误代码："+req.statusText
					alert("服务器出错,错误代码："+req.statusText)
				}
			}else{
				// window.status="正在加载......"				 
			}
		}
		if (parameters=="") url=url;
		else url+="?"+parameters;
		url+=(url.indexOf("?") >= 0)?"&nowtime="+new Date().getTime():"?nowtime=" + new Date().getTime();
		if (method=='get'){
			req.open('GET',url,async);
			req.send(null);
		}else if (method=='post'){
			req.open('POST',url,async);
			req.setRequestHeader("Content-Length",parameters.length); 
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
			req.send(parameters);
		}else{
		    alert("请至少使用一种传送方式");
		}
	}else{
		alert("无法创建xmlhttp");
	}
}



