﻿// JScript 文件
function SelectAll(tempControl)
{
    //将除头模板中的其它所有的CheckBox取反 

     var theBox=tempControl;
      xState=theBox.checked;    

     elem=theBox.form.elements;
     for(i=0;i<elem.length;i++)
     if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
      {
           if(elem[i].checked!=xState)
                 elem[i].click();
     }
}


function SelectCheck(tempControl)
{
     var theButton=tempControl;
     elem=theButton.form.elements;
     
     for(i=0;i<elem.length;i++)
     {
        if(elem[i].type=="checkbox" && elem[i].id!="headbox")
        {
           if(elem[i].checked)
           {
                return true;
           }
        }
     }     
     alert('提示：请先选择要处理的业务!');
     return false;
}

function showdemo(n,m,str)
{
    for (i=1;i<=m;i++)
	{
        if (i==n)
		{
	        document.getElementById(str+i).style.display = 'block';
		}
	    else
		{
		    document.getElementById(str+i).style.display = 'none';
		}
    }
}
function setvalue(str,value,type)
{
    if(type=="innerHTML")
    {
        document.getElementById(str).innerHTML=value;
    }
    else
    {
        document.getElementById(str).value=value;
    }
}
function selecttype(id,str,value)
{
    document.forms[0].timetype[id].checked=true;
    document.getElementById(str).innerHTML=value;
}
function changestyle(object,info)
{
if (object.value==info)
	{
	object.value=''
	object.style.color="#000033"
	}
}
function revertstyle(object,info)
{
if (object.value=='')
	{
	object.value=info
	object.style.color="#CCCCCC"
	}
}
function revertstylebyid(str,info)
{
var obj=document.getElementById(str);
if (obj.value=='')
	{
	obj.value=info
	obj.style.color="#CCCCCC"
	}
}

//验证用户名
function isLoginName(tmpname)
{
    var patrn=/^[\u4e00-\u9fa5|0-9|a-z|A-Z|\.@_]{6,20}$/;
    if (!patrn.exec(tmpname))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证密码
function isPassword(tmppwd)
{
    var patrn=/^[0-9a-zA-Z_]{6,15}$/;
    if (!patrn.exec(tmppwd))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证企业信用码
function isCcode(tmppwd)
{
    var patrn=/^\d{9}$/;
    if (!patrn.exec(tmppwd))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//固定电话+手机验证
function isPhone(str)
{
    var patrn=/(^[0-9]{3,4}-[0-9]{3,8}-[0-9]*$)|(^[0-9]{3,8}-[0-9]*$)|(^([0-9]{3,4})[0-9]{3,8}-[0-9]*$)|(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}(13|15)[0-9]{9}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证固定电话
function isTel(str)
{
    var patrn=/(^[0-9]{3,4}-[0-9]{3,8}-[0-9]*$)|(^[0-9]{3,8}-[0-9]*$)|(^([0-9]{3,4})[0-9]{3,8}-[0-9]*$)|(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证手机号码
function isMobile(str)
{
    var patrn=/(^0{0,1}(13|15)[0-9]{9}$)/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

//验证E-Mail
function isMail(str)
{
    //var patrn=/^[_a-z0-9\-\.]+@([_a-z0-9\-]+\.)+[a-z0-9]{2,3}$/;
    var patrn=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if (!patrn.exec(str))
    {
        return false;
    }
    else
    {
        return true;
    }
}

/*
* 图片滚动按钮
*/
var grouplistamount, grouplisttimer;
function scrollgrouplist()
{
	grouplistamount = arguments[0];
	grouplisttimer = setInterval("stepgrouplist()", arguments[1]);
}

function stepgrouplist()
{
	document.getElementById("grouplist").scrollLeft += grouplistamount;
}

function stopgrouplist()
{
	clearInterval(grouplisttimer);
}

function ShowGoods(id,img,pno,summary)
{
    stopgrouplist();
    document.getElementById("img").innerHTML="<a href='products.aspx?id=" + id + "'><img src='UpLoadImgs/" + img + "' alt='" + pno + "' width='260' height='180' border='0' id='focusimg' /></a>";
    document.getElementById("contents").innerHTML="<a href='products.aspx?id=" + id + "' class='zi_12hei_25c'>" + pno + "</a><br /><span class='zi_12hui'>" + summary + "</span>";
}