﻿function $P(strObj)
{
	return document.getElementById(strObj);
}
//自定义函数--根据tagName获取对象
function $Tag(strObj)
{
    return (typeof(strObj)!="undefined")?document.getElementsByTagName(strObj):"";
}
//用于大量数据的长度验证（汉字也按照1个字符）
//传入文本控件的ID 要限制的长度  显示当前字数的文本I控件D
function textCheck(thisArea, maxLength,messageCount)
{
	if ($(thisArea).value.length > maxLength)
	{
	  $P(thisArea).value = $(thisArea).value.substring(0,maxLength);
	  $P(thisArea).focus();
	 }
		/*回写span的值，当前填写文字的数量*/
	$P(messageCount).innerHTML= maxLength-$(thisArea).value.length;
}

function Warning()
{
    if(confirm("确定该操作吗？！"))
    {
        return true;
    }
    else
    {
        return false;
    }
}
function Checkconfirm()
{
     var Con=$Tag("input");
    var i=0;
    var j=-1; 
    for(i=0;i<Con.length;i++)
    {
        if(Con[i].type=="checkbox")
        { 
                if(Con[i].checked)
                {
                     j=1;
                    break; 
                }
        }
    }
   if(j==-1)
   {
    alert("没有选定任何数据啊！至少选定一项数据！");
    return false; 
   } 
   else
   {
        if(confirm("是否要进行该操作！"))
        {
            if(GetSelectValue())
            {
                return true;
            }
            else
            {
                alert("选中项的标示值获取失败，无法执行操作！");
            }
        }
        else
        {
            return false;
        }
   }
}
//全选 反选
function SelectAll(strType)
{
    var Con=$Tag("input");
    var i=0;
    for(i=0;i<Con.length;i++)
    {
        if(Con[i].type=="checkbox")
        {
            if(strType=="select")
            {
                Con[i].checked=true;
            }
            else
            {
                if(Con[i].checked)
                {
                    Con[i].checked=false;
                }
                else
                {
                    Con[i].checked=true;
                }
            }
        }
    }    
}
//批量删除 获取所有的选中项的ID 写入cookies 传递
function GetSelectValue()
{
    var Con=$Tag("input");
    var i=0;
    var SelectValue=""; 
    for(i=0;i<Con.length;i++)
    {
        if(Con[i].type=="checkbox")
        {
            if(Con[i].checked)
            {
                SelectValue+="|"+Con[i].value;
            }
        } 
    } 
   if(SelectValue=="")
   {
        return false;
   } 
   else
   {
        SelectValue=SelectValue.substring(1,SelectValue.length);
        SetCookie("SelectValue",SelectValue);
        return true;
   }
}
