function sendcode()
{
  var img=document.getElementById("img");
  img.src="verify.php?d=" + Math.round(Math.random()*47842); //产生0-47842之间的随机整数
}
function ToggleNode(node)
{
  nodeObject = document.getElementById(node);
  if (nodeObject.style.display == '' || nodeObject.style.display == 'block')
  {
    nodeObject.style.display = 'none';
  }
  else
  {
    nodeObject.style.display = 'block';
  }
}
function cface(face)
{
  var content=document.getElementById("content").value+"[img]images/face/"+face+"[/img]";
  document.getElementById("content").value=content;
}
function detection_am()
{
  var email=document.getElementById("email").value;
  var rs=/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$/;
  if(email=="" || document.getElementById("reason").value=="")
  {
    document.getElementById("waring").innerHTML = '<span style="color:#FF0000">* 对不起，请将信息填写完整</span>';
    return false;
  }
  else if(!rs.test(email))
  {
    document.getElementById("waring").innerHTML = '<span style="color:#FF0000">* 对不起，请填入正确邮箱</span>';
	return false;
  }
  else
  {
	 return true;
  }
}
function detection_beb()
{
  if(getlength(document.getElementById("keyword").value)>255 || getlength(document.getElementById("description").value)>255)
  {
    document.getElementById("waring").innerHTML = '<span style="color:#FF0000">* Meta关键词或Meta描述不能多于127个汉字</span>';
    return false;
  }
  else
  {
	 return true;
  }
}
function detection_ce()
{
  if(document.getElementById("verify"))
  {
	if(getCookie("auth")!=document.getElementById("verify").value)
	{
	  document.getElementById("waring").innerHTML = '<span style="color:#FF0000">对不起，验证码错误</span>';
	  return false;
    }
  }
  if(document.getElementById("present").value=="")
  {
     document.getElementById("waring").innerHTML = '<span style="color:#FF0000">对不起，请将信息填写完整</span>';
	 return false;
  }
  else
  {
	 return true;
  }
}
function detection_lw()
{
  if($("#username").val()=="")
  {
     document.getElementById("waring").innerHTML = '<span style="color:#FF0000">对不起，请将信息填写完整</span>';
	 return false;
  }
  else
  {
	 return true;
  }
}
function getlength(str){
	var len=str.length;
	var relen=0;
	for(var i=0;i<len;i++){
		if(str.charCodeAt(i)<27||str.charCodeAt(i)>126){
			relen+=2
		}else{
			relen++;
		}
	}
	return relen;
}
function setCaretAtEnd(pfloor){  
    window.location.hash="post";
    var theme=document.getElementById("theme").value+" 对"+pfloor+"楼说";
    document.getElementById("theme").value=theme;
} 
function divshow(type){
	var text="视频";
	if(type=="img"){
		var text="图片";}
	else if(type=="wmv"){
		var text="音乐";}
	else if(type=="face"){
	    var text="表情";}
	else if(type=="quote"){
	    var text="引用";}
	var divshow = document.createElement("DIV");
	divshow.id = "divcover";
	divshow.style.top = "0px";
	divshow.style.height=document.body.scrollHeight+"px";
	var divshow1 = document.createElement("DIV");
	divshow1.id = "divcreate";
	divshow1.style.top=(document.body.scrollTop+200)+"px";
	divshow1.style.left=(document.body.clientWidth/2-150)+"px"
	if(type=="face"){
	    var strHtml="<div style='background:#EFF8FC; height:20px; width:100%; text-align:right;'><a href='JavaScript:' onClick='divclose()'>[关闭]</a>&nbsp;</div><div id='divcreate1' style='padding:5px;'>";
	    for(var i=1;i<=24;i++){
	        strHtml+="<div style='float:left; width:48px; height:45px;'><a href='JavaScript:' onclick='cface(\""+i+".gif\")'><img src='images/face/"+i+".gif' width='40' height='40' style='border:0px;'/></a></div>";}
	    strHtml+="</div>";
	    divshow1.innerHTML=strHtml;}
	else if(type=="quote"){
	    divshow1.innerHTML="<div style='background:#EFF8FC; height:20px; width:100%; text-align:right;'><a href='JavaScript:' onClick='divclose()'>[关闭]</a>&nbsp;</div><div id='divcreate1' style='padding:5px;'><br>请输入要插入的引用：<br><textarea id='createpf' name='createpf' class='box1' cols='40' rows='3'></textarea><br><br><input type='button' onclick='c"+type+"()'  value='插入"+text+"' /></div>";}
	else{
	    divshow1.innerHTML="<div style='background:#EFF8FC; height:20px; width:100%; text-align:right;'><a href='JavaScript:' onClick='divclose()'>[关闭]</a>&nbsp;</div><div id='divcreate1' style='padding:5px;'><br>"+text+"链接：<input id='createpf' name='createpf' type='text' class='box1' size='40' value='http://' /><br><br><input type='button' onclick='c"+type+"()'  value='插入"+text+"' /></div>";}
	document.body.appendChild(divshow);
	document.body.appendChild(divshow1);
}
function divclose(){
	document.body.removeChild(divcover);
    document.body.removeChild(divcreate);
}
function cimg()
{
    var content=document.getElementById("content").value+"[img]"+$("#createpf").val()+"[/img]";
  	divclose();
    document.getElementById("content").value=content;
}
function cflash()
{
    var content=document.getElementById("content").value+"[swf]"+$("#createpf").val()+"[/swf]";
  	divclose();
    document.getElementById("content").value=content;
}
function cwmv()
{
    var content=document.getElementById("content").value+"[wmv]"+$("#createpf").val()+"[/wmv]";
  	divclose();
    document.getElementById("content").value=content;
}
function cquote()
{
    var content="[quote]"+$("#createpf").val()+"[/quote]\n"+document.getElementById("content").value;
  	divclose();
    document.getElementById("content").value=content;
}
function sAlert(txt){
	var divshow = document.createElement("DIV");
	divshow.id = "divcover";
	divshow.style.top = "0px";
	divshow.style.height=document.body.scrollHeight+"px";
	if (document.body.clientHeight>document.body.scrollHeight){
	    divshow.style.height=document.body.clientHeight+"px";}
	var divshow1 = document.createElement("DIV");
	divshow1.id = "divcreate";
	divshow1.style.top=(document.body.scrollTop+200)+"px";
	divshow1.style.left=(document.body.clientWidth/2-150)+"px"
	divshow1.innerHTML="<div style='background:#EFF8FC; height:20px; width:100%; text-align:right;'><a href='JavaScript:' onClick='divclose()'>[关闭]</a>&nbsp;</div><div id='divcreate1' style='padding:5px; text-align:center;'>"+txt+"</div>";
	document.body.appendChild(divshow);
	document.body.appendChild(divshow1);
}
