/**********************************************************************/
/* Author   :Sugar
/* Date     :2005-8-26
/***********************************************************************/
//div显示隐藏程序
function showdiv(divid)
{
    if (divid.style.display=='none')
        divid.style.display="";
    else if (divid.style.display=='')
        divid.style.display="none";
}

//table显示隐藏程序
function table_display(t_id,i_id)
{
        var t_id;//表格ID
        var i_id;//图片ID
        var on_img="";//打开时图片
        var off_img="";//隐藏时图片
        if (t_id.style.display == "none") 
        {//如果为隐藏状态
               t_id.style.display="";//切换为显示状态
               i_id.src=on_img;//换图
        }
        else
        {//否则
               t_id.style.display="none";//切换为隐藏状态
               i_id.src=off_img;
        }//换图

}

//问候语
function ShowHello() 
{
	var welcomestring;
	var d = new Date();	
	h = d.getHours();
	if(h<6)
		welcomestring="凌晨好";
	else if (h<9)
		welcomestring="早上好";
	else if (h<12)
		welcomestring="上午好";
	else if (h<14)
		welcomestring="中午好";
	else if (h<17)
		welcomestring="下午好";
	else if (h<19)
		welcomestring="傍晚好";
	else if (h<22)
		welcomestring="晚上好";
	else
		welcomestring="夜里好";
	document.write(welcomestring);
}

<!--鼠标移动感应图片-->

function makevisible(cur,which)
{ 
	if (which==0)
		cur.filters.alpha.opacity=100;
	else
		cur.filters.alpha.opacity=20;
}
function IsPrice()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57) || (event.keyCode==46) );
}

function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
function PopPage(strURL, name, width, height, left, top)
{
    if(width==null) width=800;
    if(height==null) height=500;
    if(left==null) left = ( screen.width - width ) / 2;
    if(top==null) top  = ( screen.height - height ) / 2;
    temp = "width="+width+",height="+height+",left="+left+",top="+top+",scrollbars=1,toolbar=no,location=no,directories=no,status=no,resizable=no";
    w = window.open(strURL,name,temp);
    w.focus();
}
function openThisAbout()
{
    temp = "width=618,height=400,left=0,top=0,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no";
    window.open("/home/about/about_taobao.html","",temp);
}
function GetCookie(cookiename)
{
    var thebigcookie = document.cookie;
    var firstchar = thebigcookie.indexOf(cookiename);
    if (firstchar != -1) {
        firstchar += cookiename.length + 1;
        lastchar = thebigcookie.indexOf(";",firstchar);
        if(lastchar == -1) lastchar = thebigcookie.length;
        return unescape(thebigcookie.substring(firstchar, lastchar));
    }
    return "";
}
function setCookie(cookiename,cookievalue,cookieexpdate,domainname)
{
    document.cookie = cookiename + "=" + cookievalue
    + "; domain=" + domainname
    + "; path=" + "/"
    + "; expires=" + cookieexpdate.toGMTString();

}
function unloadpopup(cookiename,popurl,popwidth,popheight,domainname,tr)
{
    //return;
    try {
        if (!tr)
            return;
        if( GetCookie(cookiename) == "" )
        {
            var expdate = new Date();
            expdate.setTime(expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
            setCookie(cookiename,"yes",expdate,domainname);
            if( exitpop )
            {
                w = window.open(popurl,cookiename,"width="+popwidth+",height="+popheight+",scrollbars=1,toolbar=yes,location=yes,menubar=yes,status=yes,resizable=yes");
                w.focus;
            }
        }
    }catch (e) {}
}
function setCheckboxes(theForm, elementName, isChecked)
{
    var chkboxes = document.forms[theForm].elements[elementName];
    var count = chkboxes.length;

    if (count)
    {
        for (var i = 0; i < count; i++)
        {
            chkboxes[i].checked = isChecked;
        }
    }
    else
    {
        chkboxes.checked = isChecked;
    }
    return true;
}

var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0)
        imageObject.width=dW;imageObject.height=dH;
    if(state!='complete' || imageObject.width>MaxW || imageObject.height>MaxH) {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",40);
    }
}

function in_array(str, arr)
{
	var boolFlag = false;
	for(i = 0; i < arr.length; i++)
	{
		if(str == arr[i])
		{
			boolFlag = true;
			break;
		}
	}
	return boolFlag;
}

function CharCheck(RegExpStr)
{
	var InputChar = String.fromCharCode(event.keyCode);
	if(RegExpStr.test(InputChar))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function CheckEmail(email)
{
	var RegExpStr = /^([\w\_\-\.]{1,})(@)([\w\-\.]{1,})(\.)([a-zA-Z\.]{1,})$/;
	return RegExpStr.test(email);
}

function CheckDigit(str)
{
	var RegExpStr = /^[0-9]{1,}$/;
	return RegExpStr.test(str);
}

function isEnglishCode()
{
	return (event.keyCode < 128);
}