﻿// JScript 檔

//如果是開新瀏覽器的第一次進入，
//因為IE6.0中，第一次進入，一般公告的內容會顯示不出來
//顯此寫以下function來解決
function forIE6Refresh(){
    if (window.addEventListener){
        //如果支援addEventListener() method，就予以使用。
        //這樣就包含了相容於標準的瀏覽器，諸如
        //Netscape/Mozilla/firefox.
        //alert("MoZilla");
    }else if (window.attachEvent){
        //否則，如果存在著attachEvent() method，就予以使用。
        //這樣就包含了IE以及決定給予模擬的非標準瀏覽器。
        
        var version=window.navigator.appVersion;
        //判斷是否為IE6.0版本
        var isIE6=version.indexOf('MSIE 6.0');
        if (isIE6 != -1){
            var allcookies=document.cookie;
            var pos=allcookies.indexOf("isExist=");
            if (pos !=-1){
               //如果已有建cookie,代表不是開瀏覽器第一次進來，
               //而是重新整理或再按「公告」，則不refresh頁面
               //var start=pos+8;
               //var end=allcookies.indexOf(";",start);
               //if (end == -1){
                  //end=allcookies.length;
               //}
               //var value=allcookies.substring(start,end);
               //alert(value);
            }else{
               //如果是開新瀏覽器的第一次進入，
               //則建一個cookie，並refresh頁面
               //因為IE6.0中，第一次進入，一般公告的內容會顯示不出來
               document.cookie="isExist=T;";
               window.location.href="content.aspx"
            }   
        
        }
    }else{
        //否則，沒有method可用。
        //發生在不支援的DHML舊版瀏覽器身上。
        //alert("other");
    }
}



//顯示calendar
function getDate(name){
    //取得目標物物件
    var targetObj=document.getElementById(name);
    var top= getY(targetObj);
    var left='';
    //根據不同顯目標，位置也不一樣
    if (name=='postDate1tb' || name=='postDate2tb'){
       left= getX(targetObj)+95;
    }else{
       left= getX(targetObj)+160;
    }

    var url="Calendar.aspx?id="+name;
    var subWindowsObject=window.open(url,"日期選擇","width=200,height=180,status=0,menubar=0,resizable=0,top=" + (top+200) + ",left=" + left);
    subWindowsObject.focus();
}


//取得元素e的x座標
function getX(e){
   var x=0;
   while (e){
      x +=e.offsetLeft;
      e=e.offsetParent;
   }
   return x;
}

//取得元素e的y座標
function getY(e){
   var y=0;
   while (e){
      y +=e.offsetTop;
      e=e.offsetParent;
   }
   return y;
}

//取得公告的編號
function getIdinnerHTML(titlelbid,nolbid){
  //ctl00_ContentPlaceHolder1_no_reply_GridView1_ctl02_questionlb:滑鼠指到的資料<span>client id
  //ctl00_ContentPlaceHolder1_no_reply_GridView1_ctl02_nolb:儲存no的<span>client id
  //由於.net編碼的client id前面是一樣的，最後才是server id，因此取出前面一樣的部分，再加上server id
  //就可得知存放此筆資料編號的<span>編號
  var index=titlelbid.lastIndexOf('_');
  var noid=titlelbid.substring(0,index)+'_'+nolbid;
  var noidobject=document.getElementById(noid);
  return noidobject.innerHTML;
}

var request=null;
var titleObj='';  //記錄要顯示詳細資料的title，用來顯示詳細資料的位置
/*********************************************/
/*功能：傳送request
//********************************************/
function submitData(url,obj,readyfuc){
    titleObj=obj;
    createRequest();
    var noId=getIdinnerHTML(obj.id,'idlb');
    url += '?id=' + noId;
    request.open("GET",url,true);
    if (readyfuc=='getResult'){
        request.onreadystatechange=getResult;
    }else if (readyfuc=='getResult2'){
        request.onreadystatechange=getResult2;
    }else if (readyfuc=='getResultStuE'){
        request.onreadystatechange=getResultStuE;
    }else if (readyfuc=='getResultStuG'){
        request.onreadystatechange=getResultStuG;
    }else if (readyfuc=='getResultStuC'){
        request.onreadystatechange=getResultStuC;
    }else if (readyfuc=='getResultStuHistory'){
        request.onreadystatechange=getResultStuHistory;
    }else if (readyfuc=='getResultStuReferral'){
        request.onreadystatechange=getResultStuReferral;
    }
    request.send(null);
    return false;
}


/*********************************************/
/*功能：建立http request object
//********************************************/
function createRequest(){
    try {
          //request = null;
          request = new XMLHttpRequest();
          return request;
    } catch (trymicrosoft) {
          try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
            return request;
          } catch (othermicrosoft) {
            try {
              request = new ActiveXObject("Microsoft.XMLHTTP");
              return request;
            } catch (failed) {
              request = null;
            }
          }
    }

    if (request == null)
      alert("Error creating request object!");
}


//系統管理者介面查看公告詳細內容
function getResult(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告內容的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            showDateWindowWindowObject.style.top=(getY(titleObj)-150) + 'px';
            showDateWindowWindowObject.style.left=(getX(titleObj)+200) + 'px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
         
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top=(getY(titleObj)-150) + 'px';
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            if (titleStr.length>17){
               showDateWindowWindowObject.style.left='480px';
            }else{
               var left=0;
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=12;
                       }
                   }
               }
               showDateWindowWindowObject.style.left=(left+270)+'px';
            }
            
             //儲存公告內容
            var contect;
            //防止在ie6中，<select>無法被div蓋住
            contect ="<div style='position:absolute;z-index:-1;left:0px;top:0;width:470px;'>"
            contect +="<iframe style='height:300px;width:100%;filter:alpha(opacity=0);-moz-opacity:0;'></iframe>"
            contect +="</div>"

            contect +='<table width="470px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#BDB4A2;color:#ffffff;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:350px;text-align:center;">內容</td>';
            contect +='</tr>';
            //公告內容
            
            //發佈日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //分類
            var category='';
            if (jsonData.proclamation[0].category=='E'){
               category='緊急公告';
            }else if(jsonData.proclamation[0].category=='G'){
               category='一般公告';
            }else{
               category='課程異動';
            }
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">分類</td>';
            contect +='<td style="width:350px;">'+category+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].link+'</td>';
            contect +='</tr>';
            //是否同步至學校首頁
            var syc='';
            if(jsonData.proclamation[0].syc=='Y'){
               syc='是';
            }else{
               syc='否';
            }
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">同步至學校首頁</td>';
            contect +='<td style="width:350px;">'+syc+'</td>';
            contect +='</tr>';
            //公告起始日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">首頁公告起始時間</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].startDate+'</td>';
            contect +='</tr>';
            //公告結束日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">首頁公告結束時間</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].endDate+'</td>';
            contect +='</tr>';
            
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//系統管理者介面查看公告詳細內容2
function getResult2(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告內容的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            showDateWindowWindowObject.style.top=(getY(titleObj)-150) + 'px';
            showDateWindowWindowObject.style.left=(getX(titleObj)+200) + 'px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
         
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top=(getY(titleObj)-150) + 'px';
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            if (titleStr.length>17){
               showDateWindowWindowObject.style.left='480px';
            }else{
               var left=0;
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=12;
                       }
                   }
               }
               showDateWindowWindowObject.style.left=(left+340)+'px';
            }
            
             //儲存公告內容
            var contect;
            //防止在ie6中，<select>無法被div蓋住
            contect ="<div style='position:absolute;z-index:-1;left:0px;top:0;width:470px;'>"
            contect +="<iframe style='height:300px;width:100%;filter:alpha(opacity=0);-moz-opacity:0;'></iframe>"
            contect +="</div>"
            
            contect +='<table width="470px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#BDB4A2;color:#ffffff;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:350px;text-align:center;">內容</td>';
            contect +='</tr>';
            //公告內容
            
            //發佈日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //分類
            var category='';
            if (jsonData.proclamation[0].category=='E'){
               category='緊急公告';
            }else if(jsonData.proclamation[0].category=='G'){
               category='一般公告';
            }else{
               category='課程異動';
            }
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">分類</td>';
            contect +='<td style="width:350px;">'+category+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].link+'</td>';
            contect +='</tr>';
            //是否同步至學校首頁
            var syc='';
            if(jsonData.proclamation[0].syc=='Y'){
               syc='是';
            }else{
               syc='否';
            }
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">同步至學校首頁</td>';
            contect +='<td style="width:350px;">'+syc+'</td>';
            contect +='</tr>';
            //公告起始日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">首頁公告起始時間</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].startDate+'</td>';
            contect +='</tr>';
            //公告結束日期
            contect +='<tr style="background-color:#F7F7F7">';
            contect +='<td style="width:120px;">首頁公告結束時間</td>';
            contect +='<td style="width:350px;">'+jsonData.proclamation[0].endDate+'</td>';
            contect +='</tr>';
            
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//學生查看緊急公告的詳細內容
function getResultStuE(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告資訊的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top='30px';
            showDateWindowWindowObject.style.left='350px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top=(getY(titleObj)-55)+'px';
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            var left=0;
            if (titleStr.length>17){
               left=480;
               showDateWindowWindowObject.style.left=left+'px';
            }else{
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=10;
                       }
                   }
               }
               left=left+255;
               showDateWindowWindowObject.style.left=left+'px';
            }
            
             //儲存公告內容
            var contect;
            contect ="<br/>"
            contect +='<table width="520px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#F2F1EE;color:#666666;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:400px;text-align:center;">內容</td>';
            contect +='</tr>';
            //公告內容
            
            //發佈日期
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#FCF8FA">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#FCF8FA">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#FCF8FA">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            var link=jsonData.proclamation[0].link;
            if (link==''){
                contect +='<td style="width:400px;">&nbsp;</td>';
            }else{
                contect +='<td style="width:400px;"><a href="'+link+'" TARGET="_BLANK">請按此進入<a></td>';
            }
            contect +='</tr>';
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
            
            //顯示提示
            var cueObj=document.getElementById('cue');
            cueObj.style.visibility='inherit';
            cueObj.style.top=(getY(titleObj)-55)+'px';
            cueObj.style.left=left+'px';
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//學生查看一般公告的詳細內容
function getResultStuG(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告資訊的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top='30px';
            showDateWindowWindowObject.style.left='350px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            //詳細資料位置和一般公告圖片對齊
            var imgObj=document.getElementById('imgG');
            showDateWindowWindowObject.style.top=(getY(imgObj)-20)+'px';
            
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            var left=0;
            if (titleStr.length>17){
               left=480;
               showDateWindowWindowObject.style.left=left+'px';
            }else{
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=10;
                       }
                   }
               }
               left=left+255;
               showDateWindowWindowObject.style.left=left+'px';
            }
            
             //儲存公告內容
            var contect;
            contect ="<br/>"
            contect +='<table width="520px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#F2F1EE;color:#666666;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:400px;text-align:center;">內容</td>';
            contect +='</tr>';
            //公告內容
            
            //發佈日期
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#EFF8F8">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#EFF8F8">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#EFF8F8">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            var link=jsonData.proclamation[0].link;
            if (link==''){
                contect +='<td style="width:400px;">&nbsp;</td>';
            }else{
                contect +='<td style="width:400px;"><a href="'+link+'" TARGET="_BLANK">請按此進入<a></td>';
            }
            contect +='</tr>';
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
            
            //顯示提示
            var cueObj=document.getElementById('cue');
            cueObj.style.visibility='inherit';
            cueObj.style.top=(getY(imgObj)-20)+'px';
            cueObj.style.left=left+'px';
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//學生查看課程異動的詳細內容
function getResultStuC(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告資訊的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'

            showDateWindowWindowObject.style.top='180px';
            showDateWindowWindowObject.style.left='350px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            //讓詳細資料對齊課程異動的圖片
            var imgObj=document.getElementById('imgC')
            showDateWindowWindowObject.style.top=(getY(imgObj)-40)+'px';
           //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            var left=0;
            if (titleStr.length>17){
               left=480;
               showDateWindowWindowObject.style.left=left+'px';
            }else{
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=10;
                       }
                   }
               }
               left=left+255;
               showDateWindowWindowObject.style.left=left+'px';
            }
            
             //儲存公告內容
            var contect;
            contect ="<br/>"
            contect +='<table width="520px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#F2F1EE;color:#666666;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:400px;text-align:center;">內容</td>';
            contect +='</tr>';
            //公告內容
            
            //發佈日期
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#F0F5FC">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#F0F5FC">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#F0F5FC">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            var link=jsonData.proclamation[0].link;
            if (link==''){
                contect +='<td style="width:400px;">&nbsp;</td>';
            }else{
                contect +='<td style="width:400px;"><a href="'+link+'" TARGET="_BLANK">請按此進入<a></td>';
            }
            contect +='</tr>';
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
            
            //顯示提示
            var cueObj=document.getElementById('cue');
            cueObj.style.visibility='inherit';
            cueObj.style.top=(getY(imgObj)-40)+'px';
            cueObj.style.left=left+'px';
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//學生查看歷史公告
function getResultStuHistory(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告資訊的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top='180px';
            showDateWindowWindowObject.style.left='350px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            
            showDateWindowWindowObject.style.visibility='inherit'
            //設定Y軸位置，防止pop的視窗超出視窗
            //var top=getY(titleObj)-50;
            //if (top>210){
                //showDateWindowWindowObject.style.top='210px';
            //}else{
                showDateWindowWindowObject.style.top=(getY(titleObj)-60) + 'px';
            //}
           
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            var left=0;
            if (titleStr.length>17){
               left=480;
               showDateWindowWindowObject.style.left=left+'px';
            }else{
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=10;
                       }
                   }
               }
               left=left+255;
               showDateWindowWindowObject.style.left=left+'px';
            }
            
             //儲存公告內容
            var contect;
            //防止在ie6中，<select>無法被div蓋住
            contect ="<div style='position:absolute;z-index:-1;left:0px;top:0;width:520px;'>"
            contect +="<iframe style='width:100%;filter:alpha(opacity=0);-moz-opacity:0;'></iframe>"
            contect +="</div>"
            
            contect +='<table width="520px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#F2F1EE;color:#666666;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:400px;text-align:center;">內容</td>';
            contect +='</tr>';
            //發佈日期
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#FFFEEC">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].editor+'</td>';
            contect +='</tr>';
            //分類
            var category='';
            if (jsonData.proclamation[0].category=='I'){
               category='重要公告';
            }else{
               category='一般公告';
            }
            contect +='<tr style="background-color:#FFFEEC">';
            contect +='<td style="width:120px;">分類</td>';
            contect +='<td style="width:350px;">'+category+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#FFFEEC">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].ext+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:400px;">'+jsonData.proclamation[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#FFFEEC">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            var link=jsonData.proclamation[0].link;
            if (link==''){
                contect +='<td style="width:400px;">&nbsp;</td>';
            }else{
                contect +='<td style="width:400px;"><a href="'+link+'" TARGET="_BLANK">請按此進入<a></td>';
            }
            contect +='</tr>';
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
            
            //顯示提示
            var cueObj=document.getElementById('cue');
            cueObj.style.visibility='inherit';
            cueObj.style.top=(getY(titleObj)-75) + 'px';
            cueObj.style.left=left+'px';
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}

//學生查看參考資料
function getResultStuReferral(){
  if (request.readyState==4){
    if (request.status==200){
       var result=request.responseText;
       while (result.indexOf('\r\n') != -1){
          result=result.replace('\r\n','<br/>');
       }
       
       //檢查此編號是否有公告資料
       if (result=='查無資料'){
       //輸入的編號沒有公告資料

             //取出顯示公告資訊的視窗(div)物件
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            showDateWindowWindowObject.style.visibility='inherit'
            
            showDateWindowWindowObject.style.top='180px';
            showDateWindowWindowObject.style.left='350px';
            
            showDateWindowWindowObject.innerHTML='<br/>＊查無資料!!<br/><br/>';
       }else{
       //輸入的編號有公告資料
            var jsonData =result.parseJSON();
       
            var showDateWindowWindowObject=document.getElementById('showDateWindow')
            
            showDateWindowWindowObject.style.visibility='inherit'
            //設定Y軸位置，防止pop的視窗超出視窗
            //var top=getY(titleObj)-50;
            //if (top>210){
                //showDateWindowWindowObject.style.top='210px';
            //}else{
                showDateWindowWindowObject.style.top=(getY(titleObj)-30) + 'px';
            //}
           
            //設定詳細內容的位置，如果字數太少，詳細內容離太遠，滑鼠會移不過去
            var titleStr=titleObj.firstChild.nodeValue;
            var left=0;
            if (titleStr.length>17){
               left=480;
               showDateWindowWindowObject.style.left=left+'px';
            }else{
               for (var i=0;i<titleStr.length;i++){
                   if (checkNum(titleStr.substring(i,i+1))==true){
                       //代表是數字
                       left+=6;
                   }else{
                       //代表是文字，但包含符號，符號和數字一樣只佔6，如果是文字就佔12
                       if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='/'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='*'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='-'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='+'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='.'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==','){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='?'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='>'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='<'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='\''){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='"'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==';'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==':'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==']'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='['){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='}'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='{'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='|'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='_'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)==')'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='('){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='&'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='^'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='%'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='$'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='#'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='@'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='!'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='~'){
                             left+=6;
                       }else if (titleStr.substring(i,i+1)=='`'){
                             left+=6;
                       }else{
                             left+=10;
                       }
                   }
               }
               left=left+255;
               showDateWindowWindowObject.style.left=left+'px';
            }
            
             //儲存公告內容
            var contect;
            contect ="<br/>"
            contect +='<table width="520px" cellpadding="4" cellspacing="0" style="border-color:#ffffff;border-right: #999999 1px solid; border-top: #999999 1px solid; border-left: #999999 1px solid;border-bottom: #999999 1px solid;">';
            //標題
            contect +='<tr style="background-color:#F2F1EE;color:#666666;">';
            contect +='<td style="width:120px;text-align:center;">項目</td>';
            contect +='<td style="width:400px;text-align:center;">內容</td>';
            contect +='</tr>';
            //發佈日期
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">發佈日期</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].postDate+'</td>';
            contect +='</tr>';
            //標題
            contect +='<tr style="background-color:#F3F3F3">';
            contect +='<td style="width:120px;">標題</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].title+'</td>';
            contect +='</tr>';
            //聯絡人
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].editor+'</td>';
            contect +='</tr>';
            //公告單位
            contect +='<tr style="background-color:#F3F3F3">';
            contect +='<td style="width:120px;">公告單位</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].dept+'</td>';
            contect +='</tr>';   
            //聯絡人分機
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">聯絡人分機</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].ext+'</td>';
            contect +='</tr>';
            //公告內容
            contect +='<tr style="background-color:#F3F3F3">';
            contect +='<td style="width:120px;">公告內容</td>';
            contect +='<td style="width:400px;">'+jsonData.referral[0].content+'</td>';
            contect +='</tr>';
            //詳細內容連結
            contect +='<tr style="background-color:#ffffff">';
            contect +='<td style="width:120px;">詳細內容連結</td>';
            var link=jsonData.referral[0].link;
            if (link==''){
                contect +='<td style="width:400px;">&nbsp;</td>';
            }else{
                contect +='<td style="width:400px;"><a href="'+link+'" TARGET="_BLANK">請按此進入<a></td>';
            }
            contect +='</tr>';
            contect +='</table>';
            contect +="<br/>"
            showDateWindowWindowObject.innerHTML=contect;
            
            //顯示提示
            var cueObj=document.getElementById('cue');
            cueObj.style.visibility='inherit';
            cueObj.style.top=(getY(titleObj)-30) + 'px';
            cueObj.style.left=left+'px';
       }
    }else{
       alert('Error!Request status is ' + request.status);
    }
  }
}


//隱藏某物件
function hide(objid){
   var obj=document.getElementById(objid);
   //obj.style.display='none';
   obj.style.visibility='hidden'
}

//顯示某物件
function show(objid){
   var obj=document.getElementById(objid);
   //obj.style.display='block';
   obj.style.visibility='inherit';
}



//讓視窗隨著滑鼠移動　
function moveWindow(divid,obj,event){
　 var win=document.getElementById(divid);
　 
　 //拖曳起始的滑鼠位置(視窗座標)
　 var startX=event.clientX;
　 var startY=event.clientY;
　 
　 //被拖曳的元素的原有位置
　 var winX=win.offsetLeft;
　 var winY=win.offsetTop;
　 
　 //計算座標差異
　 var deltaX=startX-winX;
　 var deltaY=startY-winY;
　 
　 //註冊會回應mousemove和mouseup事件
　 if (document.addEventListener){    //DOM Level 2事件模型
　     document.addEventListener("mousemove",moveHandler, true);
　     document.addEventListener("mouseup",upHandler,true);
   }
   else if(document.attachEvent){     //IE5 Event Model
       obj.setCapture();              //建立對像和鼠標之間的通訊，也就是說鼠標作用在此對象上時才跟蹤鼠標
       obj.attachEvent("onmousemove",moveHandler);
       obj.attachEvent("onmouseup",upHandler);
       obj.attachEvent("onlosecapture",upHandler);
   }
   else{                             //IE4 Event Model
       var oldmovehandler=document.onmousemove;
       var olduphandler=document.onmouseup;
       document.onmousemove=moveHandler;
       document.onmouseup=upHandler;
   }
   
   
   //我們已處理此事件。不要讓其它人再看見
   if (event.stopPropagation){
      event.stopPropagation();   //DOM Level 2
   }else{
      event.cancelBubble=true;   //IE
   }
   
   //現在，阻止任何預設動作
   if (event.preventDefault)  event.preventDefault();   //DOM Level 2
   else  event.returnValue=false;                       //IE
   
   
   /**
    *這是當元素被拖曳時，捕捉mousemove事件的處理器。
    *此函式負責移動元素。
    **/
   function moveHandler(e){
       if (!e) e=window.event  //IE Event Model
       
       //把元素移動到當前滑鼠位置，以最初滑鼠點擊之偏移量做必要調整
       win.style.left=(e.clientX-deltaX) + 'px';
       win.style.top=(e.clientY-deltaY) + 'px';
       
       //然後，不要讓其它任何人看見此事件
       if (e.stopPropagation) e.stopPropagation();
       else e.cancelBubble=true;
   } 
   
   /**
    *這是捕捉拖曳終了時最後發生的mouseup事件的處理器
    *
    **/
   function upHandler(e){
       
       if (!e) e=window.event; //IE Event Model
       
       //對捕捉事件處理器解除註冊
       if (document.removeEventListener){   //DOM事件模型
           document.removeEventListener("mouseup",upHandler,true);
           document.removeEventListener("mousemove",moveHandler,true);
       }
       else if (document.detachEvent){      //IE5 Event Model
           obj.releaseCapture();            //切斷對像和鼠標之間的通訊
           obj.detachEvent("onmousemove",moveHandler);
           obj.detachEvent("onmouseup",upHandler); 
           obj.detachEvent("onlosecapture",upHandler);
       }
       else {                               //IE 4 Event Model
           document.onmouseup=olduphandler;
           document.onmousemove=oldmovehandler;
       }
       
       //然後，不要讓事件再度傳播
       if (e.stopPropagation) e.stopPropagation();
       else e.cancelBubble=true;
        
   }
}

//改變圖片位置
function changeImg(obj,imgName){
  obj.src="../images/"+imgName;
}

//判斷str是數字或文字
function checkNum(str){
   return  str.match(/\D/)==null;
}

 //把物件中文字的<及>換成＜及＞
function changeSign(id){
    var obj=document.getElementById(id);
    if (obj != null){
        var text=obj.value;
        while (text.indexOf('<') != -1) {
           text=text.replace('<','＜');
        }
        while (text.indexOf('>') != -1) {
           text=text.replace('>','＞');
        }
        document.getElementById(id).value=text;
    }
} 

 //把物件中文字的/及\換成／及＼
function changeSign2(id){
    var obj=document.getElementById(id);
    if (obj != null){
        var text=obj.value;
        while (text.indexOf('/') != -1) {
           text=text.replace('/','／');
        }
        while (text.indexOf('\\') != -1) {
           text=text.replace('\\','＼');
        }
        document.getElementById(id).value=text;
    }
} 

//當新增公告時，如果有輸入<、>、/、\符號將符號轉成大寫
function insertChangeSign(){
     changeSign('ctl00_ContentPlaceHolder1_titletb');    //公告主旨
     changeSign('ctl00_ContentPlaceHolder1_depttb');     //單位
     changeSign('ctl00_ContentPlaceHolder1_editortb');   //聯絡人
     changeSign('ctl00_ContentPlaceHolder1_exttb');      //分機
     changeSign('ctl00_ContentPlaceHolder1_contenttb');  //公告內容
     changeSign('ctl00_ContentPlaceHolder1_startDatetb');//公告起始時間
     changeSign('ctl00_ContentPlaceHolder1_endDatetb');  //公告結束時間
     //changeSign('filepathful');//上傳檔案，<input type='file'不能指定值
     changeSign('ctl00_ContentPlaceHolder1_linktb');     //連結位置
     
     changeSign2('ctl00_ContentPlaceHolder1_titletb');    //公告主旨
     changeSign2('ctl00_ContentPlaceHolder1_depttb');     //單位
     changeSign2('ctl00_ContentPlaceHolder1_editortb');   //聯絡人
     changeSign2('ctl00_ContentPlaceHolder1_exttb');      //分機
     changeSign2('ctl00_ContentPlaceHolder1_contenttb');  //公告內容
}

//當修改公告時，如果有輸入<、>、/、\符號將符號轉成大寫
function updateChangeSign(){
     changeSign('ctl00_ContentPlaceHolder1_titleUtb');    //公告主旨
     changeSign('ctl00_ContentPlaceHolder1_deptUtb');     //單位
     changeSign('ctl00_ContentPlaceHolder1_editorUtb');   //聯絡人
     changeSign('ctl00_ContentPlaceHolder1_extUtb');      //分機
     changeSign('ctl00_ContentPlaceHolder1_contentUtb');  //公告內容
     changeSign('ctl00_ContentPlaceHolder1_startDateUtb');//公告起始時間
     changeSign('ctl00_ContentPlaceHolder1_endDateUtb');  //公告結束時間
     //changeSign('filepathful');//上傳檔案，<input type='file'不能指定值
     changeSign('ctl00_ContentPlaceHolder1_linkUtb');     //連結位置
     
     changeSign2('ctl00_ContentPlaceHolder1_titleUtb');    //公告主旨
     changeSign2('ctl00_ContentPlaceHolder1_deptUtb');     //單位
     changeSign2('ctl00_ContentPlaceHolder1_editorUtb');   //聯絡人
     changeSign2('ctl00_ContentPlaceHolder1_extUtb');      //分機
     changeSign2('ctl00_ContentPlaceHolder1_contentUtb');  //公告內容
}

//當修改公告時，如果有輸入<、>、/、\符號將符號轉成大寫
function referralChangeSign(){
     changeSign('ctl00_ContentPlaceHolder1_titleRtb');    //公告主旨
     changeSign('ctl00_ContentPlaceHolder1_deptRtb');     //單位
     changeSign('ctl00_ContentPlaceHolder1_editorRtb');   //聯絡人
     changeSign('ctl00_ContentPlaceHolder1_extRtb');      //分機
     changeSign('ctl00_ContentPlaceHolder1_contentRtb');  //公告內容
     //changeSign('filepathful');//上傳檔案，<input type='file'不能指定值
     changeSign('ctl00_ContentPlaceHolder1_linkRtb');     //連結位置
     
     changeSign2('ctl00_ContentPlaceHolder1_titleRtb');    //公告主旨
     changeSign2('ctl00_ContentPlaceHolder1_deptRtb');     //單位
     changeSign2('ctl00_ContentPlaceHolder1_editorRtb');   //聯絡人
     changeSign2('ctl00_ContentPlaceHolder1_extRtb');      //分機
     changeSign2('ctl00_ContentPlaceHolder1_contentRtb');  //公告內容
}


function changeFontSize(size){
  var body=document.getElementsByTagName("body");
  body[0].style.fontSize=size;
  
  var div=document.getElementById('showDateWindow');
  div.style.fontSize=size;
}

//將使用者選取的字型大小存在cookies中，
//讓換頁面時，可以取用此cookies值，使用之前的設定來重設字型大小
function setck(size){
   //取出舊cookie的值，再將之刪除
   var allcookies=document.cookie;
   var pos=allcookies.indexOf("size=");
   if (pos != -1){
      var start=pos+5;
      var end=allcookies.indexOf(";",start);
      if (end ==-1){
         end=allcookies.length;
      }
      var value=allcookies.substring(start,end);
      //消除cookie
      document.cookie="size="+value+
                      "; max-age=0";
   }
        
   //再新建cookie
   document.cookie="size="+size+
                   "; max-age="+(60*60*24*365);
}

//如果使用者端已有設定的cookies，就使用他之前設定的字型大小
function readck(){
   //取出舊cookie的值
   var allcookies=document.cookie;
   var pos=allcookies.indexOf("size=");
   if (pos != -1){
      var start=pos+5;
      var end=allcookies.indexOf(";",start);
      if (end ==-1){
         end=allcookies.length;
      }
      var value=allcookies.substring(start,end);
      changeFontSize(value);
   }
}




