function addCat() {
    document.getElementById("addCatId").style.display = "none";
    document.getElementById("addCatFormId").style.display = "block";
    document.getElementById("catName").value="";
    document.getElementById("catName").focus();
}

function checkFrm() {
    var blogTypeName = document.getElementById("catName").value;
    
    if(blogTypeName == null || blogTypeName.length == 0 ){
        alert("日记分类名不能为空");
        document.getElementById("catName").focus();
        return false;
    } else if (blogTypeName.length > 10){
        alert("日记分类名不能超过10字");
        document.getElementById("catName").focus();
        return false;
    }
    
    diaryAjax.getDiaryTypeDTOByUser(setDiaryType,blogTypeName);
    
    document.getElementById("addCatId").style.display = "block";
    document.getElementById("addCatFormId").style.display = "none";
    
	//var myurl="addcat.php";
	//openUrl(myurl, value);
}

	

function setDiaryType(result){
	var select = document.getElementById('btid');
	select.options.length=0; 	
		
	for(i = 0; i < result.length; i++){
		select.options.add(new Option(result[i].blogTypeName,result[i].id));
	}	
}

function writeDiary(){
        var msg = document.getElementById("msg");
        document.getElementById("content").value = editor.document.Composition.document.body.innerHTML;
        var title = document.getElementById("title").value;
        var content = document.getElementById("content").value;
        if(title == ""){
			 msg.innerHTML='<font color=\"red\">请您填写好日记标题</font>';
			 document.getElementById("title").focus();
			 return;
	    }
	    if(title.length > 40){
			 msg.innerHTML='<font color=\"red\">您填写好日记标题过长，建议为40个汉字大小！</font>';
			 document.getElementById("title").focus();
			 return;
	    }
        document.diaryForm.submit();	
}
    
function changeDiary(){
        var msg = document.getElementById("msg");
        document.getElementById("content").value = editor.document.Composition.document.body.innerHTML;
        var title = document.getElementById("title").value;
        var content = document.getElementById("content").value;
        if(title == ""){
			 msg.innerHTML='<font color=\"red\">请您填写好日记标题</font>';
			 document.getElementById("title").focus();
			 return;
	    }
	    if(title.length > 40){
			 msg.innerHTML='<font color=\"red\">您填写好日记标题过长，建议为40个汉字大小！</font>';
			 document.getElementById("title").focus();
			 return;
	    }
        document.diaryForm.submit();	
}
    
function getValue(){
        document.getElementById("content").value = editor.document.Composition.document.body.innerHTML;
}
    
function setValue(){       
        editor.document.Composition.document.body.innerHTML = document.getElementById("content").value;
}
    
function resetForm(){
      editor.document.Composition.document.body.innerHTML ="";
      document.diaryForm.reset();
      return;
}
