﻿function ChkSubmit()
{
    if(PostContent.textarea.value.length<1)
    {
        alert("请输入您要发表的内容");
        return false;
    }
    return true;
}

function ChkReSubmit()
{
    if(ReContent.textarea.value.length<1)
    {
        alert("请输入您要发表的内容");
        return false;
    }
    return true;
}
function image(){
       dzcode=window.prompt("请输入图片地址:","http://bbs.gupzs.cn/templates/default/skins/default/images/logo.gif");
       if (dzcode!=null){
       dzcode='[img]'+dzcode+'[/img]';
       //dzcode='<img src='+dzcode+'>';
       PostContent.textarea.value+=dzcode;}
}

function ResizeImages(obj){
 if(obj.width/obj.height>1){
  obj.width=(obj.width>800)?800:obj.width;
  }else{
  obj.height=(obj.height>800)?800:obj.height;
  }
}

function showmuti(){
       if (face.style.display == "none")
       {
              
              face.style.display = "";
       }
       else{
              
              face.style.display = "none";
       }
}
function ReOnlineChat(id)
{
    var obj = parent.document.getElementById("ReDiv");
    if(obj==null)
    {
        alert("回复主题 请先登录");
    }
    else
    {
        obj.style.display = "block";//(obj.style.display=="none") ? "block":"none";
        
        if(obj.style.display=="block")
        {
            parent.document.ReContent.ReID.value = id;
            parent.document.ReContent.textarea.focus();
        }
    }
}

function OnChatPageKeyDown()
{
	if (window.event)
	{
		if(window.event.keyCode == 13)
		{
			//ongoto();
			//直接用ongoto()时，在线列表分页的文本框中输入页数后回车会在新窗口中打开
			var page = document.getElementById("gotopage").value;
	        if (isNaN(page))
	        {
		        page = "1";
	        }
	        
	        originUrl = document.getElementById("originUrl").value;

	        location.href = originUrl+"&nPage="+page;

		}
	}
}

function DeleteOnlineChat(id)
{
    if(confirm("您确定要删除该主题么？"))
    {
        var page = document.getElementById("gotopage").value;
	    if (isNaN(page))
	    {
		    page = "1";
	    }
	    originUrl = document.getElementById("originUrl").value;
	    
	    originUrl = originUrl.replace("ChatFrame","OnlineChat");
	 
	    location.href = "Save"+originUrl+"&nPage="+page+"&deleteid="+id;
    }
}


function PostFilterJumpList(filterlist)
{
	var list = filterlist.split(",");
	var retvl = "";
	
	for(var i = 0;i<list.length;i++)
	{
	    var sValue=location.search.match(new RegExp("[?&]BoardID=([^&]*)(&?)","i")) 
	    //var BoardID = sValue[1];
	    var BoardID = 15;
		retvl += "<a href='/onlinechat.aspx?BoardID="+ BoardID +"&PostFilter="+ list[i] +"' style='padding-left: 1px;'>" + list[i] + "</a><br />";
	}
	
	if ("" !== retvl)
	{
		retvl = "<div class='menuitems'>" + retvl + "</div>";
	}
	
	return retvl;
}

var timeout = 300;
function TimeRefresh()
{
    timeout--;
    if(timeout<=0)
    {
        document.frames("chatframe").location.reload();
        timeout = 300;
    }
    else
    {
        var objPost = document.getElementById("timecount");
        if(objPost!=null)
            objPost.innerHTML = "页面刷新： <font color='#FF0000' face='aril'><b>"+timeout+"</b><font>";
        var obj = document.getElementById("Retimecount");
        if(obj!=null)
            obj.innerHTML = "页面刷新： <font color='#FF0000' face='aril'><b>"+timeout+"</b><font>";
    }
    setTimeout("TimeRefresh()",1000)
}

function ctlent(re)
{
    if (event.ctrlKey && event.keyCode == 13)
    { 
        if(re=="0")
        {
            if(ChkSubmit())
                PostContent.submit();
        }
        else
        {   
            if(ChkReSubmit())
                ReContent.submit();
        }
    }
}