function deploy(ID)
{
    obj=$(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';
}

function resizePic(ImgD,maxwidth,maxheight)
{
	return;
}

//此函数来自xoyo blog
function resizePic1(ImgD,maxwidth,maxheight)
{
        var image=new Image();
        image.src = ImgD.src;
        ImgD.resized = false;

        iWidth  = image.width;
        iHeight = image.height;
		diyw = ImgD.width;
		diyh = ImgD.height;
        picwidth  = iWidth;
        picheight = iHeight;

        //大图缩小
        if(diyw > maxwidth || diyh > 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;

			ImgD.width  = parseInt(picwidth);
			ImgD.height = parseInt(picheight);
        }

}
function DrawImage(ImgD,iwidth,iheight){
	var image=new Image();
	if(!iwidth)iwidth = 90;
	if(!iheight)iheight = 90; //定义允许高度，当宽度大于这个值时等比例缩小
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		var flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}else{
			if(image.height>iheight){ 
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
	}
};
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 GetCharLength(str)
{
	var iLength = 0;
	for(var i = 0;i<str.length;i++)
	{
		if(str.charCodeAt(i) >255)
		{
			iLength += 2;
		}else{
			iLength += 1;
		}
	}
	return iLength;
}

function switchTab(id,num){		//主展示区的TAB
	for(i=0; i<=num; i++) {
		if($('txt_'+i) != null) {
			$('txt_'+i).style.display = i==id ? '': 'none';
		}		
		if($('tab_'+i) != null) {
			$('tab_'+i).className = $('tab_'+i) != null && i != id ? '' : 'active';
		}
	}
}

function createCookie(C,D,E){	//创建Cookie
	if(E){
		var B=new Date();
		B.setTime(B.getTime()+(E*24*60*60*1000));
		var A="; expires="+B.toGMTString()
	}else{A=""}
	document.cookie=C+"="+D+A+";path=/"
}

function readCookie(B){			//取Cookie
	var D=B+"=";
	var A=document.cookie.split(";");
	for(var C=0;C<A.length;C++){
		var E=A[C];
		while(E.charAt(0)==" "){
			E=E.substring(1,E.length)
		}
		if(E.indexOf(D)==0){return E.substring(D.length,E.length)}
	}
	return null
}
