﻿// JScript 文件

function GetHttpRequest(url)
{
    var xmlhttp;
    if(typeof XMLHttpRequest == "undefined" && window.ActiveXObject)
    {
        xmlhttp = new ActiveXObject("Microsoft.xmlHTTP");
    }
    else
    {
        xmlhttp = new XMLHttpRequest();
    }
    xmlhttp.open("post",url,true);
    return xmlhttp;
}

function CheckAll(obj)
{
    for(var i=0;i<10;i++)
    {
        if(document.getElementById("che" + i) != null)
        {
            if(obj.checked == true)
            {
                document.getElementById("che" + i).checked = "checked";
            }
            else
            {
                document.getElementById("che" + i).checked = "";
            }
        }
    }
}

function $(id) {
    return document.getElementById(id);
}

function isPicture(fileObj)
{
    var fileName = fileObj.value;
    if(fileName!=null && fileName !="")
    {
        //lastIndexOf如果没有搜索到则返回为-1
        if (fileName.lastIndexOf(".")!=-1) 
        {
            var fileType = (fileName.substring(fileName.lastIndexOf(".")+1,fileName.length)).toLowerCase();
            var suppotFile = new Array();
            suppotFile[0] = "jpg";
            suppotFile[1] = "gif";
            suppotFile[2] = "bmp";
            suppotFile[3] = "png";
            suppotFile[4] = "jpeg";
            for (var i =0;i<suppotFile.length;i++) 
            {
                if (suppotFile[i]==fileType) 
                {
                    return true;
                } 
                else
                {
                    continue;
                }
            }
            alert("文件类型不合法,只能是jpg、gif、bmp、png、jpeg类型！");
            //alert(fileObj.select());
            fileObj.select();
            document.execCommand("delete", false, ""); 
            fileObj.blur();
            return false;
        } 
        else
        {
            alert("文件类型不合法,只能是 jpg、gif、bmp、png、jpeg 类型！");
            fileObj.select();
            document.execCommand("delete", false, ""); 
            fileObj.blur();
            return false;
        }
    }
}