﻿//去掉左右空格
String.prototype.trim  =  function()  
{  
return  this.replace(/(^\s*)|(\s*$)/g,  "");  
}  

function CheckNotEmpty(obj, Message)
{
    if(obj != null && obj.value.trim().length ==0)
    {
        alert(Message);
        if(obj.type != "hidden")
        {
            obj.focus();
        }
        return false;
    }
    return true;
}

//全选/全取消页面的所有CheckBox
function CheckAll(check)
{
	var e = document.forms[0].elements;
	var l = e.length;
	var o;
	for(var i = 0; i < l; i++)
	{
		o = e[i];
		if (o.type == "checkbox")
		{
			o.checked = check;
		}
	}
}
/*
function:CheckValue(id,msg,type)
description:验证至少选中页面列表中的一条记录（以便进行其它删除等操作）
return value:true or false
*/
function CheckValue(id,msg,type)
{
	var e = document.all.tags("input");
	for (var i=0;i<e.length;i++)
    {
	   if (e[i].type==type && e[i].checked == true && e[i].id.lastIndexOf(id) >= 0)
	   {
	       return true;
	   }
    }
    alert(msg);
    return false;
}


/*
function:CheckIsSelectedAndConfirm(id,msg1,msg2,type)
description:验证至少选中页面列表中的一条记录并提示客户确认删除（以便进行真正删除等操作）
return value:true or false
*/
function CheckIsSelectedAndConfirm(id,msg1,msg2,type)
{    
	if(CheckValue(id,msg1,type))
	{
	  return  confirm(msg2);
	}
	return false;
}

//诗词查询
function OnSubmit()
{
    var SubmitType = document.getElementById('HeadMenu2_SubmitType').value;
    if(SubmitType=="1") //搜索
    {
        if(CheckNotEmpty(document.getElementById('SearchCommon1_TxtTitle'),"请输入查询关键字!"))
        {
            document.getElementById('SearchCommon1_TxtIsSearch').value = "1";
   	        document.form1.action="PoesySearch.aspx";
            document.form1.submit();
        }
        return false;
    }
    else if(SubmitType=="2") //评论
    {
         if(CheckNotEmpty(document.getElementById('MessageCommon1_TxtContent'),"请输入评论内容!"))
            {
                return true;
            }
            return false;
    }
    else if(SubmitType=="3") //字典查询
    {
       if(CheckNotEmpty(document.getElementById('ZiDianSearch1_TxtTitle'),"请输入查询关键字!"))
        {
         
         document.getElementById('ZiDianSearch1_TxtIsSearch').value = "1";
         
           form1.action="ZiDianSearch.aspx";
           form1.submit();
        }
        return false;
    }   
    else if(SubmitType=="4") //成语查询
    {
       
       if(CheckNotEmpty(document.getElementById('ZiDianSearch1_TxtTitle'),"请输入查询关键字!"))
        {
         
            document.getElementById('ZiDianSearch1_TxtIsSearch').value = "1";
           
           form1.action="ChengYuCiDian.aspx";
           form1.submit();
        }
        return false;
    }  
    return false;
}



