﻿var TopicID, num, limit, receiver, goaction ;



function SendMsg(rr,tid,n,lim,act){
    receiver = rr;
    TopicID = tid;
    goaction = act;
    num = n;
    limit = lim;
    popSignFlow1();
}
function popSignFlow1() {
   popCoverDiv2();  
   popSign1();  
   document.body.style.overflow = "hidden"; 
}
function popSign1(){
   var loginDivWidth = 600;
   var sign_in_flow = ''
        + '<div id="yauclaa" class="msg">'
	+ '<h4>傳送訊息</h4>'
        + '<form method=post  id="Msg_Form" name="Msg_Form" runat="server">'
        + '<div class="name">接收者：'+ receiver +'</div><hr/>'
	+ '<div id="info"></div>'
        + '<label>主旨：</label><input id="subject" type="text" size="60"></input><br/>'
        + '<label>內容：</label><textarea onkeyup="count(this.value)" id="reason" style="width: 400px; height: 100px;""></textarea>'
        + '<center class="txt-imp">請填寫欲傳送之訊息<br/>$ ! # $ % & * " ' + " '" +' 等符號將會無法顯示，html標籤語法也不能顯示<br/>您的每日傳訊上限為' + limit + '則，目前剩餘' + num + '則</center><hr/>'
        + '<center><input class="mylove" type="button" value="確定傳送" onclick="sendSign();"/>'
        + '<input class="mylove" type="button" value="取消" onclick="cancelSign2();" style="left: 150px; position: relative;"/></center>'
        + '</form></div>';
       	

   if (G("sign_div2")) {
    G("sign_div2").style.display = '';
    //alert(document.documentElement.scrollTop + document.documentElement.clientHeight/3);
    G("sign_div2").style.top =  300+  'px';
   } else {
    var signDiv = GC('div');
    document.body.appendChild(signDiv);
    signDiv.id = 'sign_div2';
    signDiv.align = "center";  
    with (signDiv.style) {
     position = 'absolute';
     left = (document.documentElement.clientWidth - loginDivWidth)/4 + 'px';
     top = '300px';
     width = loginDivWidth + 'px';
     zIndex = 999;
     background = '#FFFFFF';
    }
   }
    G("sign_div2").innerHTML = sign_in_flow;  
}


function sendSign(){
            var content = document.getElementById(id="reason").value.replace(/[\[\]\$!%^#\&*|"'><]/,"") 
            var subject = document.getElementById(id="subject").value.replace(/[\[\]\$!%^#\&*|"'><]/,"") 
            replacecarriagereturn(document.getElementById(id="subject"),"^M");
            replacecarriagereturn(document.getElementById(id="reason"),"^M");
	//alert(content);
    if ( num > 0  ){
        if (subject != "" && content != "") {
            //找出Enter並取代, 在vb中替換成<br/>
           if (content.length<=300){
                var url = "../newforum/SendMessage.aspx?goaction=" + goaction +"&receiver=" + receiver +"&TopicID=" + TopicID +  "&subject=" + encodeURI(subject);
                url = url + "&content=";
                url = url + encodeURI(content);               
                //location.href = url;
                setHref(url);                
            }else{
                alert("內容請控制在300字以內");
            }
        }else{
        alert("請輸入主旨和內容！！"); 
        }
    }else{
    alert("今日傳訊已超過上限！！");
    }
        
}
