function lytype()
{
    if(document.getElementById("txt_author").value=="匿名网友")
    {
        document.getElementById("userinfo").innerHTML='<b>用户名:</b><input id="txt_author" name="txt_author" type="text" value="" class="input1"/><b>密 码:</b><input id="txt_pwd" name="txt_pwd" type="password" value=""  class="input1"/>';
    }
    else
    {
        document.getElementById("userinfo").innerHTML='<b>匿 名:</b><input id="txt_author" name="txt_author" type="text" value="匿名网友" readonly="readonly" class="input1"/>';
    }
}
function woyaoniming()
{
   if(document.getElementById("txt_author").value=="匿名网友")
   {   
       document.getElementById("nm_dl").innerHTML="用户名";
       document.getElementById("txt_author").value=document.getElementById("hiddenniming").value;
   }
   else{
   document.getElementById("nm_dl").innerHTML="匿 名";
   document.getElementById("txt_author").value="匿名网友";}
}
function getstypes(aaa){document.getElementById("alltb").innerHTML=" ";document.getElementById("addtopicbtype").value=aaa;document.getElementById("addtopicstype").value="0";document.getElementById("tiebaid").value="0";var xh;if (window.ActiveXObject){xh = new ActiveXObject("MSXML2.XMLHTTP"); xh.open("POST","/doajax/getsmalltype.ashx",false); xh.send(aaa); }
else if(window.XMLHttpRequest){xh=new XMLHttpRequest();xh.open("POST","/doajax/getsmalltype.ashx",false);xh.send(aaa);} 
_res = xh.responseText;document.getElementById("smalltype").innerHTML=_res;
}
function gettieba(aaa){document.getElementById("addtopicstype").value=aaa;document.getElementById("tiebaid").value="0";var xh;if (window.ActiveXObject){xh = new ActiveXObject("MSXML2.XMLHTTP"); xh.open("POST","/doajax/gettieba.ashx",false); xh.send(aaa); }
else if(window.XMLHttpRequest){xh=new XMLHttpRequest();xh.open("POST","/doajax/gettieba.ashx",false);xh.send(aaa);} 
_res = xh.responseText;document.getElementById("alltb").innerHTML=_res;
}
function gettbid(aa){document.getElementById("tiebaid").value=aa;}
function getImge(){var rd = Math.random();document.getElementById("ccimg").innerHTML="<img id=\"checkcodeimg\" src=\"/checkcode/image.ashx?"+rd+"\" onclick=\"changeImge()\" title=\"看不清,点击换一张\" style=\"cursor:hand\"/>";}
function changeImge(){var rd = Math.random();document.getElementById("checkcodeimg").src="/checkcode/image.ashx?"+rd}

var oEditer; 

function FCKeditor_OnComplete( editorInstance ) 
{  
    oEditer = editorInstance; 
} 

function Cls() 
{  
    oEditer.SetHTML(""); 
} 
function CheckForm()
{
    var _content="";
    var flag=true;
    var errormsg = "出现下列错误!\n";
    if(document.getElementById("hiddenniming")=="")
    {
        if(document.getElementById("txt_author").value!="匿名网友"){
            if(document.getElementById("txt_author").value==""){errormsg +="\n请填写用户名！";flag = false;}if(document.getElementById("txt_pwd").value==""){errormsg += "\n请填写密码！";flag = false;}
        }
    }
    if(document.getElementById("addtopicbtype").value=="0" || document.getElementById("addtopicbtype").value==""){errormsg +="\n请选择社区！";flag = false;}
    if(document.getElementById("txt_title").value==""){errormsg+="\n请填写标题！"; flag=false;}
    
    
    _content = oEditer.GetHTML();
    if(_content=="")
    {
        errormsg +="\n请填写内容！";flag = false;
    }
    else
    {
        var jccon = _content.replace(/<[^>]+>/g,"");//去掉所有的html标记
        if(jccon=="")
        {
            errormsg +="\n除了图片，难道你就不想再说些什么!";flag = false;
        } 
        else
        {
            if(_content.length<10)
            {   
                errormsg +="\n内容少于10个字,请不要灌水!";flag = false;
            }
            else
            {
                document.getElementById("hiddencontent").value = _content;
            }
        }
    }
       
    if(document.getElementById("txt_email").value!="")
    {
        var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
        if(!sReg.test(document.getElementById("txt_email").value))
        {
            errormsg +="\n请填写正确的Email!";flag=false;
        }
    }
    
    if(document.getElementById("txt_checkcode").value=="")
    {
        errormsg +="\n请填写验证码!";flag=false;
    }
    else
    {
        if(isNaN(document.getElementById("txt_checkcode").value))
        {
            errormsg +="\n验证码为四位数字!";flag=false;
        }
    }
    if(!flag){alert(errormsg);}
    
    return flag;
}
