function doZoom(size){
	document.getElementById("zwsky_content").style.fontSize=size+'px'
}
function getCookieVal(offset)
{
  if(document.cookie.length>0)
  {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
  }
  return "";
}

function SetCookie (name, value)
{
    document.cookie = name + "=" + escape (value)
}
function GetCookie(name)   {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
   // alert(alen)
    var i = 0;
    while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
    }
    return null;
}
function validate() {

	if (document.form.title.value=="") {
		alert("没有填写标题");
		document.form.title.focus();
                document.getElementById("btnImage").style.visibility ="visible";
		return false;
	}

	 if (trim(FCKeditorAPI.GetInstance('content').GetXHTML(false)) == "") {
           alert("请输入内容！");
           document.getElementById("btnImage").style.visibility ="visible";
           FCKeditorAPI.GetInstance('content').EditorWindow.focus();
           return false;
         }

         if (getLength()>8000) {
           alert("内容最多不能超过8000个字符!");
           document.getElementById("btnImage").style.visibility ="visible";
           FCKeditorAPI.GetInstance('content').EditorWindow.focus();
           return false;
         }

        if (document.form.verifyCode.value=="") {
          alert("没有填写验证码");
          document.getElementById("btnImage").style.visibility ="visible";
          document.form.verifyCode.focus();
          return false;
        }
        return true
 }

function caculate_length(check_area) //检测剩余可输入字符数  by skyhappy 2007-2-28 11:42
{
	if (check_area == 'title') {
		var text_length = document.getElementById("title").value.length;
		var text_max_length = 32;
		var target_div = document.getElementById("title_length");
		var text_remain = text_max_length - text_length;
		target_div.innerHTML = '<font color=#ff0000>已输入字符：'+text_length+'，剩余字符数：'+text_remain+'</font>';
	}else if (check_area == 'body') {
		//document.getElementById("cbalert").innerHTML = tip1;
		var text_length = document.getElementById("thebody").value.length;
		var text_max_length = 8000;
		var target_div = document.getElementById("body_length");
		var text_remain = text_max_length - text_length;
		target_div.innerHTML = '<font color=#ff0000>已输入字符：'+text_length+'，剩余字符数：'+text_remain+'</font>';
	}
}

var boardid = "shishi";

  function doPost(frm) {
    //alert(html2ubb(form.body.value))
    SetCookie("errors","");
    if (validate()==false) {
      return false;
    }
      return true;
  }

 function inputs(inputid) {
            var oEditor = FCKeditorAPI.GetInstance("content");
    var html = "<img src='${pageContext.request.contextPath}/images/act/"+inputid+".gif'/>";
     oEditor.InsertHtml(html);
}


  function inertContent(content) {
   	if(content==''){
		alert("没有需要添加的内容！");
		return;
	}
        form.content.value += content;
  }


function insertImg(){
	if(form.insertimg.value==''){
		alert("请填写图片地址！");
		return;
	}
	form.content.value=form.content.value+'\n[img]' + form.insertimg.value+'[/img]\n';
	form.insertimg.value = "";
}

function getLength()
{
	// This functions shows that you can interact directly with the editor area
	// DOM. In this way you have the freedom to do anything you want with it.

	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('content') ;

	// Get the Editor Area DOM (Document object).
	var oDOM = oEditor.EditorDocument ;

	var iLength ;

	// The are two diffent ways to get the text (without HTML markups).
	// It is browser specific.

	if ( document.all )		// If Internet Explorer.
	{
		iLength = oDOM.body.innerText.length ;
	}
	else					// If Gecko.
	{
		var r = oDOM.createRange() ;
		r.selectNodeContents( oDOM.body ) ;
		iLength = r.toString().length ;
	}

	return iLength;
}

  function resizeimg(ImgD,iwidth,iheight) {
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
      if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){
          ImgD.width=iwidth;
          ImgD.height=(image.height*iwidth)/image.width;
        }else{
          ImgD.width=image.width;
          ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
      }
      else{
        if(image.height>iheight){
          ImgD.height=iheight;
          ImgD.width=(image.width*iheight)/image.height;
        }else{
          ImgD.width=image.width;
          ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;

      }
    }
  }

