/////////////////////////////////////////////////公共部分


function reimg()
{//1-刷新验证码
    document.getElementById("NYZM").src = "zverify.aspx?temp=" + (new Date()).getTime();
}

function  Atrim(str)
{//2-删除所有的空格
var temp1=str;
return   temp1.replace(/^\s*/g,"");     
}

function  UTMP(temp1)
{//3-用||TMP转换&
return   temp1.replace(/&/g,"||TMP");     
}

function  UVBM(temp1)
{//4-用MvbNlineM 替换 \r\n

temp1=temp1.replace(/\r\n/g,"MvbNlineM");
temp1=temp1.replace(/\n\r/g,"MvbNlineM");
temp1=temp1.replace(/\r/g,"MvbNlineM");
temp1=temp1.replace(/\n/g,"MvbNlineM");
return   temp1;     
}

function ReplaceDemo(str)
{//5-替换所有的换行
  var temp1=str;
return   temp1.replace(/\r/ig,"EDUCHREDU");  
//return   temp1.replace(/\r/ig,"EDUCHREDU").replace(/\n/ig,"EDUCHNEDU");    
//return   temp1.replace(/\r/ig,"<br>").replace(/\n/ig,"<br>");   
}


function SELEALL(KJMC)
{//6-选择全部
var temp1=document.getElementsByName(KJMC).length;

for (i=0;i<=(parseInt(temp1)-1);i++)
{
if (!(document.getElementsByName(KJMC)[i].disabled))
{
document.getElementsByName(KJMC)[i].checked =document.getElementById("CHA").checked;}

}
}




function XSENDAJAX(strtemp)
{//7-发送AJAX
    strtemp = encodeURI((strtemp));
  // alert(strtemp.length);
    $.ajax({
        type: "Post",
        url: strtemp,
          data: {data1:'13D17C93EDB',},
          cache: false,
          contentType: "application/x-www-form-urlencoded; charset=UTF-8",  
          success: function (tempstr) {
          Zsend(tempstr);   // XRETUAJAX(tempstr);
        }
    });

}



function isDate(date, fmt)
 {
//8-判断是否是日期(是否合法日期)
//*
//用途：判断是否是日期
//输入：date：日期；fmt：日期格式
//返回：如果通过验证返回true,否则返回false
//*/
if (fmt==null) fmt="yyyyMMdd";
var yIndex = fmt.indexOf("yyyy");
if(yIndex==-1) return false;
var year = date.substring(yIndex,yIndex+4);
var mIndex = fmt.indexOf("MM");
if(mIndex==-1) return false;
var month = date.substring(mIndex,mIndex+2);
var dIndex = fmt.indexOf("dd");
if(dIndex==-1) return false;
var day = date.substring(dIndex,dIndex+2);
//alert(year);
if(!isNumber(year)||year>"2100" || year< "1900") return false;
if(!isNumber(month)||month>"12" || month< "01") return false;
if(day>getMaxDay(year,month) || day< "01") return false;
return true;
}
function getMaxDay(year,month) {
if(month==4||month==6||month==9||month==11)
return "30";
if(month==2)
if(year%4==0&&year%100!=0 || year%400==0)
return "29";
else
return "28";
return "31";
}

function isNumber( s ){ 
//9-是否是数字
var regu = "^[0-9]+$";
var re = new RegExp(regu);
if (s.search(re) != -1) {
return true;
} else {
return false;
}
}

function checkEmail(strEmail) {
//10-mail地址格式是否合法
//var emailReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
var emailReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
if( emailReg.test(strEmail) ){
return true;
}else{
//alert("您输入的Email地址格式不正确！");
return false;
}
}

function checkIP(strIP) {
//11-检查IP是否合法
var IPReg = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if( IPReg.test(strIP) ){
return true;
}else{
return false;
}
}

function GetExtend(filename){
//12-获得扩展名
var result =/\.[^\.]+/.exec(filename);
return result.toString().substring(1);
}



function SendQuit(Action)
{//13-发送退出动作
var var1="aeduajax.aspx?ACT="+Action+"";
var1 =encodeURI((var1));
 var xmlHttp=new ActiveXObject( "Microsoft.XMLHTTP"); 
  xmlHttp.open("POST",var1,false);
  xmlHttp.send();
  temptext=xmlHttp.ResponseText;
if (temptext.indexOf("成功退出")>-1)
 { 
    window.document.location.reload();
 return false;
 }
}




function loginout() {
//14-退出登录
        layer.confirm('确认退出登录？', {
            icon: 3, btn: ['确定', '取消'] //按钮
        }, function () {
            var var1 = "beduajax.aspx?ACT=9E940960D9FE0BD9";
            var1 = encodeURI((var1));
            $.ajax({
                type: "Post",
                url: var1,
                data: { data1: '13D17C93EDB', },
                cache: false,
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function (temptext) {
                    layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
                        window.location.href = "index.aspx";
                    });
                }
            });


            //
            //var1 =encodeURI((var1));
            // var xmlHttp=new ActiveXObject( "Microsoft.XMLHTTP"); 
            //   xmlHttp.open("POST",var1,false);
            //     xmlHttp.send();
            //      temptext=xmlHttp.ResponseText;
            //       layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
            //             window.location.href = "index.aspx";
            //          });
        });
}

function FormatDate(date) {
    //JS 日期转换成yyyyMMdd  -
    var var1 = "";
    var1 = date.replace(/-/g, "A");
    var1 = var1.replace(/\//g, "A");
    //var1 = var1.replace(//g, "/");
    return var1;
}

function edumsg()

{
    // alert("CDFRT");
    layer.msg('请先提交本学期课程信息，再进行预约', { icon: 1, btn: ['确定'] }, function () {
        window.location.href = "fkcxx.aspx";
    });
}