//下拉菜单，IE所必须


function deploy(ID,type){
    obj=document.getElementById(ID);    
    if(obj.style.display=="none"){
        obj.style.display="";
    }else{
        obj.style.display="none";
    }
    return false;
}

function $(id)
{
    return document.getElementById(id);
}

function doZoom(x)
{
    var textId = document.getElementById('text-body');
    textId.style.fontSize=x+'px';
}

//此函数来自xoyo blog
function resizePic(ImgD,maxwidth,maxheight)
{
        var image=new Image();
        image.src = ImgD.src;
        ImgD.resized = false;

        iWidth  = image.width;
        iHeight = image.height;
        picwidth  = iWidth;
        picheight = iHeight;

        //大图缩小
        if(iWidth > maxwidth || iHeight > maxheight)
        {
            if (iWidth>iHeight)
            {
                if(iWidth>maxwidth)
                {
                    picwidth = maxwidth;
                    picheight = (iHeight*maxwidth)/iWidth;
                }
                if(picheight>maxheight)
                {
                    picheight = maxheight;
                    picwidth  = (iWidth*maxheight)/iHeight;
                }
            }
            else
            {
                if(iHeight>maxheight)
                {
                    picheight = maxheight;
                    picwidth  = (iWidth*maxheight)/iHeight;

                }
                if(picwidth>maxwidth)
                {
                    picwidth = maxwidth;
                    picheight = (iHeight*maxwidth)/iWidth;
                }
            }

            ImgD.resized = true;
        }
        else
        {
            //小图原样输出
            picwidth  = iWidth;
            picheight = iHeight;

        }

        ImgD.width  = parseInt(picwidth);
        ImgD.height = parseInt(picheight);
}

function searchCheck(obj)
{
    if (obj.keyword.value == '')
    {
        alert("请填写关键词");
        return false;
    }
    
    if (obj.keyword.value.length < 2)
    {
        alert("关键词太短,不能少于2个字符!");
        return false;
    }
    
    if (obj.keyword.value.length > 30)
    {
        alert("关键词太长,不能大于30个字符!");
        return false;
    }
    
    return true;
}

function postCommentCheck()
{
    if ($('comment_email').value == "")
    {
        alert("请填写Email!");
        return false;
    }
    if ($('content').value == "")
    {
        alert("请填写评论内容!");
        return false;
    }
    if ($('authcode').value == "")
    {
		alert("请填写验证码!");
		return false;
    }
    
    if ($('content').value.length > 400)
    {
        alert("评论内容不能超过400个字符!")
        return false;
    }
    
    return true;
}
