//ȫ�ֱ�
var y=0;
var iTime=0;
var iva;
var iva1;
var duratime = 10;
var xmlObj = null;
//ȫ�ֱ�

/************************************��������js�ļ�******************************************/


/************************************************************************************/
/**************************************ԭ�ͺ���**************************************/
/************************************************************************************/

//�ַ�ԭ�ͺ���trim�����ܣ�ȥ���ַ�ո���ߡ��ұ߻�����}�ߡ�

String.prototype.trim = function()
{
    var pos=arguments[0];
    
    if(pos==1)
    {
        return this.replace(/(^\s*)/g, "");	//ȥ�����
    }        
    else if(pos==2)
    {
        return this.replace(/(\s*$)/g, ""); //ȥ���ұ�       
    }
    else
    {
        return this.replace(/(^\s*)|(\s*$)/g, ""); //ȥ�����ұ�
    }
}


//�ַ�ԭ�ͺ���toCase�����ܣ����ַ�Ϊȫ��

String.prototype.toCase = function()
{
        var tmp = "";
        
        for(var i=0;i<this.length;i++)
        {
                if(this.charCodeAt(i)>0&&this.charCodeAt(i)<255)
                {
                        tmp += String.fromCharCode(this.charCodeAt(i)+65248);
                }
                else
                {
                        tmp += String.fromCharCode(this.charCodeAt(i));
                }
        }
        return tmp
}


//�ַ�ԭ�ͺ���isEmail�����ܣ��ж�һ���ַ��Ƿ��ǺϷ����ʼ���ַ

String.prototype.isEmail = function()
{
        return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this);
}

//�ַ�ԭ�ͺ���len�����ܣ���ȡ�ַ��ȣ���(���֡�������}���ֽڡ� 
 
String.prototype.len  = function()
{
    return this.replace(/[^\x00-\xff]/g, "!!").length;
}


//�ַ�ԭ�ͺ���toDate�����ܣ����ַ�ת��Ϊ����

String.prototype.toDate = function()
{
        try
        {
                return new Date(this.replace(/-/g, "\/"));
        }
        catch(e)
        {
                return null;
        }
}


//�ַ�ԭ�ͺ���toHtmlEncode�����ܣ����ַ����html����

/*String.prototype.toHtmlEncode = function()
{
        var str = this;
        
        str=str.replace(/&/g,"&amp;");
        
        str=str.replace(/</g,"&lt;");
        
        str=str.replace(/>/g,"&gt;");
        
        str=str.replace(/\'/g,"&#39;");
        
        str=str.replace(/\"/g,"&quot;");
        
        str=str.replace(/\n/g,"<br>");
        
        str=str.replace(/\ /g," ");
        
        str=str.replace(/\t/g,"    ");
        
        return str;
}
*/

//�ַ�ԭ�ͺ���isColor�����ܣ��ж��ַ��Ƿ��ǺϷ�����ɫֵ

String.prototype.isColor = function()
{
        var temp        = this;
        
        if (temp=="") return true;
        
        if (temp.length!=7) return false;
        
        return (temp.search(/\#[a-fA-F0-9]{6}/) != -1);
}


//�ַ�ԭ�ͺ���isNumberic�����ܣ��ж��ַ��Ƿ������֡�flag��ʾ���Ե��������͡�

String.prototype.isNumeric = function(flag)
{
        //��֤�Ƿ�������
        if(isNaN(this))
        {
                return false;
        }

        switch(flag)
        {
                case null:        //����
                case "":
                        return true;
                case "+":        //����
                        return                /(^\+?|^\d?)\d*\.?\d+$/.test(this);
                case "-":        //����
                        return                /^-\d*\.?\d+$/.test(this);
                case "i":        //����
                        return                /(^-?|^\+?|\d)\d+$/.test(this);
                case "+i":        //������
                        return                /(^\d+$)|(^\+?\d+$)/.test(this);                        
                case "-i":        //������
                        return                /^[-]\d+$/.test(this);
                case "f":        //������
                        return                /(^-?|^\+?|^\d?)\d*\.\d+$/.test(this);
                case "+f":        //�����
                        return                /(^\+?|^\d?)\d*\.\d+$/.test(this);                        
                case "-f":        //��������
                        return                /^[-]\d*\.\d$/.test(this);                
                default:        //ȱʡ
                        return true;                        
        }
}


//�ַ�ԭ�ͺ���isPhone�����ܣ��ж��ַ��Ƿ�����Ч�ĵ绰����(�й�)

String.prototype.isPhone = function()
{
        return /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(this);
}


//�ַ�ԭ�ͺ���isIDCard�����ܣ��ж��ַ��Ƿ�����Ч�����֤���롾�й�

String.prototype.isIDCard = function()
{
        var iSum=0;
        
        var info="";
        
        var sId = this;

        var aCity={11:"����",12:"���",13:"�ӱ�",14:"ɽ��",15:"���ɹ�",21:"����",22:"����",23:"����",31:"�Ϻ�",32:"����",33:"�㽭",34:"����",35:"����",36:"����",37:"ɽ��",41:"����",42:"����",43:"����",44:"�㶫",45:"����",46:"����",50:"����",51:"�Ĵ�",52:"����",53:"����",54:"���",61:"����",62:"����",63:"�ຣ",64:"����",65:"�½�",71:"̨��",81:"���",82:"����",91:"����"};

        if(!/^\d{17}(\d|x)$/i.test(sId))
        {
                return false;
        }
        
        sId=sId.replace(/x$/i,"a");
        
        //�Ƿ�����
        if(aCity[parseInt(sId.substr(0,2))]==null)
        {
                return false;
        }

        var sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));

        var d=new Date(sBirthday.replace(/-/g,"/"))
        
        //�Ƿ�����
        if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
        {
                return false;
        }
        
        for(var i = 17;i>=0;i--) 
        {
                iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11);
        }

        if(iSum%11!=1)
        {
                return false;
        }
        
        return true;
}


//�ַ�ԭ�ͺ���isUrl�����ܣ��ж��ַ��Ƿ�����Чl�ӡ���ַ��

String.prototype.isUrl = function()
{
        return /^http[s]?:\/\/([\w-]+\.)+[\w-]+([\w-./?%&=]*)?$/i.test(this);
}


//�ַ�ԭ�ͺ���isFileName�����ܣ��ж��ַ��Ƿ�����Ч�ļ����Ŀ¼��

String.prototype.isFileName = function()
{
        return !/[\\\/\*\?\|:"<>]/g.test(this);
}


//�ַ�ԭ�ͺ���existChinese�����ܣ��ж��ַ��Ƿ���к���

String.prototype.existChinese = function()
{
        //[\u4E00-\u9FA5]��h�֩o[\uFE30-\uFFA0]��ȫ�Ƿ�̖
        return /^[\x00-\xff]*$/.test(this);
}


//�ַ�ԭ�ͺ���isZipCode�����ܣ��ж��ַ��Ƿ����ʱ�

String.prototype.isZipCode = function()
{
        return /^[\d]{6}$/.test(this);
}


//�Ƿ����ֻ�
String.prototype.isMobile = function()
{
        return /^0{0,1}13[0-9]{9}$/.test(this);
}


//�ַ�ԭ�ͺ���isDate�����ܣ��ж��ַ��Ƿ�����ȷ������

String.prototype.isDate = function()
{
        return this.isLongDate()||this.isShortDate();
}


//�ַ�ԭ�ͺ���isShortDate�����ܣ��ж��ַ��Ƿ�����ȷ�Ķ�����

String.prototype.isShortDate = function()
{
        var r = this.replace(/(^\s*)|(\s*$)/g, "").match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
        
        if(r==null)
        {
                return false; 
        }
        
        var d = new Date(r[1], r[3]-1, r[4]); 
        
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}


//�ַ�ԭ�ͺ���isLongDate�����ܣ��ж��ַ��Ƿ�����ȷ�ĳ�����

String.prototype.isLongDate = function()
{
        var r = this.replace(/(^\s*)|(\s*$)/g, "").match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})(\d{1,2})(\d{1,2})(\d{1,2})$/);
        
        if(r==null)
        {
                return false; 
        }
        
        var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
        
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}


//�ַ�ԭ�ͺ���isIP�����ܣ��ж��ַ��Ƿ�����ȷ��ip

String.prototype.isIP = function()
{

        var reSpaceCheck = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;

        if (reSpaceCheck.test(this))
        {
                this.match(reSpaceCheck);
                
                if (RegExp.$1 <= 255 && RegExp.$1 >= 0 
                 && RegExp.$2 <= 255 && RegExp.$2 >= 0 
                 && RegExp.$3 <= 255 && RegExp.$3 >= 0 
                 && RegExp.$4 <= 255 && RegExp.$4 >= 0) 
                {
                        return true;     
                }
                else
                {
                        return false;
                }
        }
        else
        {
                return false;
        }
}


//�ַ�ԭ�ͺ���InStrRev�����ܣ����ַ��ﷴ�������һ�ַ�:λ��0��ʼ

String.prototype.InStrRev = function(str)
{

        if(str==null)
        {
                str = "";
        }
        
        return this.lastIndexOf(str);
}


//�ַ�ԭ�ͺ���InStr�����ܣ����ַ��������һ�ַ�:λ�ô�0��ʼ

String.prototype.InStr = function(str)
{

        if(str==null)
        {
                str = "";
        }
        
        return this.indexOf(str);
}


//�ַ�ԭ�ͺ���Mid�����ܣ��õ��м���ַ�,ע���0��ʼ

String.prototype.Mid = function(start,len)
{
        return this.substr(start,len);
}


//�ַ�ԭ�ͺ���Right�����ܣ��õ��ұߵ��ַ�

String.prototype.Right = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substring(this.length-len,this.length);
}


//�ַ�ԭ�ͺ���Left�����ܣ��õ���ߵ��ַ�

String.prototype.Left = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substr(0,len);
}


//�ַ�ԭ�ͺ���filterScript�����ܣ��滻�ַ��е�js�ű�

String.prototype.filterScript = function()
{
    return this.replace(/<\/?script(\s)*(.)*>/gi,"");
}




/****************************************************************************/
/*****************************������****************************************/
/****************************************************************************/


function stopMov(objID)
 {
    if(iTime < duratime)
    {
        iTime++;
        
        iva = setTimeout('stopMov(objID)',1000);
    } 
    else 
    {
        clearTimeout(iva);
        
        iTime = 0;
        
        document.getElementById(objID).style.display ='none';
    }
}

function boxClose(objID)
{
    clearTimeout(iva);
    
    iTime = 0;
        
    document.getElementById(objID).style.display ='none';
}

function startMov(objID)
{
    var winBox = document.getElementById(objID);
       
    if(winBox != null)
	{
	    y = y + 4;

		winBox.style.top = (document.body.scrollTop + y - 151);
	}
	if(y < 152)
	{
	    iva1 = setTimeout('startMov()',1);
	}
	else
	{   
	    clearTimeout(iva1);
	    
	    y = 0;
	     
	    stopMov();
	}
}

function displayBox(type,title,content,durtime,objID) 
{
    if(type=='T')
    {
        alert('����ɹ�');
        
        document.location.href=content;
    }
    else
    {
    	var color=(type=='E'?'red':(type=='R'?'green':'#ee679c'));
    
    	var s = "<table border='0' cellspacing='0' cellpadding='0' width='180px' height='150px'>";
    
    	s += "<tr onmouseover=\"this.style.cursor='arrow'\"><td colspan='2' height='25' valign='middle' align='center'>";
    
    	s += title + "</td></tr><tr><td valign='top' colspan='2' height='97px'>";
    
    	s += "<div style='z-index: 148;padding-top:7px;padding-left:5px;width:178px;height:100%;overflow: auto;border-bottom:outset 0px white;";
    
    	s += "border-top:groove 0px;'><font color='" + color + "'>" + content;
    
    	s += "</font></div></td></tr><tr><td colspan='2' align='center' valign='middle' height='22'>";
    
    	s += "<input type='button' style='border:groove 1px;' value='�ر�' onclick=\"boxClose();\"></td></tr></table>";
    
    	var winBox = document.getElementById(objID); 
    
    	winBox.innerHTML = s;
    
    	winBox.style.left = (document.body.clientWidth-182);
    
    	winBox.style.top = document.body.scrollTop-151;
    
    	if(winBox.style.display == 'none')
    	{
        	winBox.style.display = '';
    	}
    	
    	duratime = durtime;
    	
    	startMov();
    }
}


	function SelectAll(idChk,strChk)
	{
		var objSet = document.forms[0].getElementsByTagName('input');
		
		var len = objSet.length;

		for(var i=0;i<len;i++)
		{
			if(objSet.item(i).id.toString().toUpperCase().indexOf(strChk)!=-1)
			{
				objSet.item(i).checked = idChk.checked;
			}
		}
	}
	
	function setBColor(obj,dgID,url)
    {
	    var children = document.getElementsByTagName("table");
				
		var dd;
				
		for(var a=0;a<children.length;a++)
		{
		    if(children[a].id.indexOf(dgID)>0)
			{
			    dd=children[a];
			    
				break;
		    }
		}	
			
		for(var i=0;i<dd.rows.length;i++)
		{
		    if(i%2==0)
			{
			    dd.rows[i].style.backgroundColor='white';
			}
			else
			{
				dd.rows[i].style.backgroundColor='#F7F6F3';
			}            
		}
			
		obj.style.backgroundColor = "Tan";
		
		if(url)
		{
		    window.parent.orderdetail.document.location.href=url;
		}
	}
	
	function searchBoxControl(objid)
    {
        var objSrc = event.srcElement;
        
        var obj = document.getElementById(objid);
            
        if(obj.style.display == 'none')
        {
            obj.style.display = '';
               
            objSrc.innerText = '5';
            
            objSrc.title = '����������';
        }
        else
        {
            obj.style.display = 'none';
                
            objSrc.innerText = '6';
            
            objSrc.title = '��ʾ������';
        }
     }
     
     function ddop(objid,objValue)
     {
        var oop = document.getElementById(objValue);
        
        var obj = document.getElementById(objid);
        
        if(oop.value=='0')
        {
            obj.style.display='none';
        }
        else
        {
            obj.style.display='';
        }
     }
     
     //������߲˵���   
     function menuControl()
     {
        var frameContent = window.parent.MenuContentFrame;
	
		if(!frameContent)
		{
			frameContent = window.parent.parent.MenuContentFrame;
		}
            
        var srcE = event.srcElement;
            
        if(frameContent.cols=="200,*")
        {
            frameContent.cols="0,*";
            
            event.srcElement.innerText ='4';
            
            event.srcElement.title ='��ʾ�˵�';
            
            document.getElementById('ttb').style.width="101.5%";
        }
        else
        {
            frameContent.cols="200,*";
            
            event.srcElement.innerText ='3';
            
            event.srcElement.title = '���ز˵�';
            
            document.getElementById('ttb').style.width="102%";
        }
    }
    
    function menuControlSwitch(obj)
    {
        var frameContent = window.parent.MenuContentFrame;
        
		if(!frameContent)
		{
			frameContent = window.parent.parent.MenuContentFrame;
		}
    
        if(frameContent.cols=="200,*")
        {
            obj.innerHTML ='<font face=Webdings>3</font>';
            
            obj.title ='���ز˵�';
        }
        else
        {         
            obj.innerHTML ='<font face=Webdings>4</font>';
            
            obj.title = '��ʾ�˵�';
        }
    }


    
function initHttpRequestObj()
{
	var xObj = null;
	
	if(window.XMLHttpRequest)
	{
      	xObj = new XMLHttpRequest();
  	} 
  	else if(window.ActiveXObject)
  	{
      	xObj = new ActiveXObject("Microsoft.XMLHTTP");
  	} 
  	else 
  	{
      	;
  	}
  	
  	return xObj;
}

function checkmail(temail) 
{ 
	 var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
	 if(pattern.test(temail)) { 
	  return true; 
	 } 
	 else { 
	  return false; 
	 } 
} 
function checkcharacter(item,num)
{
	if(item.length >= num)
	return;
	else
	return false;
}