<!--    
    var specValueNumber=0;
    var specRowNumber=0;
    var goodsSourceValue={};
    var goodsSpecArray={};
    var goodsSpecValueArray={};
    var autoSpecValueData=new Array(    
        '<span onclick="deleteGoods(this);" style="cursor:pointer;">删除</span>', 
        '<input name="goodsCode" value="_GoodsCode" onblur="checkIsCode(this);" maxlength="18" size="18" /><input type="hidden" value="_GoodsID" name="goodsId" />',           
        '<input name="goodsStore" value="_GoodsStore" onblur="checkIsUNumber(this,_GoodsStore);" maxlength="10" size="10" />',
        '<input name="goodsPrice" id="goodsPrice_proSpecRowNumber" value="_GoodsPrice" onblur="checkIsMoney(this,_GoodsPrice);" maxlength="19" size="10" /><span style="cursor:pointer;" class="spec_pic" onclick="getDegreePrice(&quot;goodsPrice_proSpecRowNumber&quot;,&quot;degreePrice_proSpecRowNumber&quot;);">会员价</span><input type="hidden" value="_GoodsDegreePrice" name="goodsDegreePrice" id="degreePrice_proSpecRowNumber" />',
        '<input name="goodsCost" value="_GoodsCost" onblur="checkIsMoney(this,_GoodsCost);" maxlength="19" size="10" />',
        '<input name="goodsWeight" value="_GoodsWeight" onblur="checkIsWeight(this,_GoodsWeight);" size="10" maxlength="13" />'
    );   
    var tmpSpecValueData= autoSpecValueData;
    
    function changeAutoSpecValueData(specArray)
    {
        if(typeof(specArray)=='object'){
            goodsSpecArray=specArray;
            
            var objDiv=document.getElementById("div_useSpec");   
            if(objDiv==null) return;
            
            var tmpHtml ="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  class=\"fortable\" style=\"margin-top:5px;\">";
                tmpHtml+="<tr><td align=\"left\"><input type=\"button\" value=\"添加一个货品\" class=\"blueinput\" onclick=\"addGoods();\" />";
                tmpHtml+="&nbsp;&nbsp;<input type=\"button\" value=\"关闭规格\" class=\"blueinput\" onclick=\"closeSpecList('关闭规格将删除所有货品，确定要删除吗？');\" /></td></tr></table>";
                tmpHtml+="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  class=\"fortable\" style=\"margin-top:2px;\" id=\"proSpecValueTable\">";
                tmpHtml+="<thead><tr><td align=\"center\">操作</td><td align=\"center\">货号</td>";
                  
            var tmpArray=new Array();
            var i=0;
            for(var spec in specArray){   
                tmpArray.push('<div id="specValues_proSpecValueNumber" onclick="selectSpecValue(this,proSpecRowNumber,' + spec + ');">_SpecValueHTML_</div><input type="hidden" value="_SpecValueId" forRow="proSpecRowNumber" id="for_specValues_proSpecValueNumber" name="goodsSpecValues_' + spec + '" />');
                tmpHtml+="<td align=\"center\">"+specArray[spec].specName+"</td>";    
                i++;           
            }                                       
                tmpHtml+="<td align=\"center\">库存</td><td align=\"center\">销售价</td><td align=\"center\">成本价</td><td align=\"center\">重量</td></tr></thead>";           
                tmpHtml+="<tr style=\"display:none; height:0px;\"><td colspan=\"" + (6+i) + "\">&nbsp;</td></tr></table>";                               
            
                tmpHtml+="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  class=\"fortable\" style=\"margin-top:2px;margin-bottom:5px;\">";
                tmpHtml+="<tr><td align=\"left\"><input type=\"button\" value=\"添加一个货品\" class=\"blueinput\" onclick=\"addGoods();\" />";
                tmpHtml+="&nbsp;&nbsp;<input type=\"button\" value=\"关闭规格\" class=\"blueinput\" onclick=\"closeSpecList('关闭规格将删除所有货品，确定要删除吗？');\" /></td></tr></table>";
                
            if(tmpArray.length>0){
                tmpSpecValueData=autoSpecValueData.slice(0,2).concat(tmpArray).concat(autoSpecValueData.slice(2,autoSpecValueData.length));    
            }
            else{
                tmpSpecValueData=autoSpecValueData;
            }  
            objDiv.innerHTML=tmpHtml;
            
            specValueNumber=0;
            specRowNumber=0;
            goodsSpecValueArray={};
        }            
    }
    function Op(o)
    {
        var x=y=0;
        do{
            x+=o.offsetLeft;
            y+=o.offsetTop;
        }
        while (o=o.offsetParent);
        return {"x":x,"y":y};
    }
    function selectSpecValue(obj,rowNum,specId)
    {
        var objDiv=document.getElementById('div_specValueList');
        var tmpHtml='';  
        var valueCount=0;      
        if(objDiv!=null && goodsSpecArray[specId]){
            var values=goodsSpecArray[specId].specValues;            
            if(values){
                tmpHtml+='<ul for="div_specValueList">';              
                for(var v in values){                    
                    if(checkSelectable(specId,values[v].id,rowNum)) {                    
                        tmpHtml+="<li for=\"div_specValueList\" style=\"float:left;padding-left:5px;\" onclick=\"setSpecValue('" + obj.id + "'," + specId  + "," + values[v].id + "," + rowNum + ");\">";
                        if(values[v].isImage.toLowerCase()=='true'){
                            tmpHtml+='<img class="spec_list" style="cursor:pointer;" src="' + values[v].image + '" title="' + values[v].value + '" alt="' + values[v].value + '" width="30px" height="30px" />';
                        }else{
                            tmpHtml+='<span style="cursor:pointer;" class="spec_list">' + values[v].value + '</span>';
                        }
                        values[v].value + "</li>";
                        valueCount++;
                    }
                }
                tmpHtml+='</ul>';    
            }
            if(valueCount>0)
            {
                var oop=Op(obj);
                objDiv.innerHTML=tmpHtml;                
                objDiv.style.display='';  
                objDiv.style.left=oop.x + 'px';
                objDiv.style.top=oop.y + obj.offsetHeight + 5 + 'px';       
                document.body.onclick=function(e){
                    var targ=null;
                    if (!e){
                        var e = window.event;
                    }
                    if (e.target){
                        targ = e.target;
                    }else if (e.srcElement){
                        targ = e.srcElement;
                    }                   
                    if (targ!=null && targ.nodeType == 3){ 
                       targ = targ.parentNode;
                    }  
                    var targId=targ!=null ? (targ.id || targ.parentNode.id):'';
                    if(targId=='' || !(targId==objDiv.id || targId==obj.id || (obj.parentNode!=null && targId==obj.parentNode.id) || (targ.getAttribute('for')!=null && targ.getAttribute('for')==objDiv.id))){
                        objDiv.innerHTML= '';                
                        objDiv.style.display='none';  
                    }
                }                            
            }
        }
    }
    function checkSelectable(specId,vId,rowNum)
    {   
        var total=0;
        var specCount=0;
        var bo=false;
        
        for(var spec in goodsSpecArray) {
            if(total==0){
                total=goodsSpecArray[spec].specValueCount;
            }else{
                total=total*goodsSpecArray[spec].specValueCount;
            }
            if(spec==specId){
               bo=true;
            }
            specCount++; 
        }       
        if(!bo){
            return false;
        }        
        var count=total/goodsSpecArray[specId].specValueCount;        
        for(var n=1;n<=specRowNumber&&count>0;n++){  
            if(n!=rowNum){  
                var nv=goodsSpecValueArray['goodsSpecValues_'+specId+'_'+n];               
                if(nv!=null&&typeof(nv)!='undefined'&&nv==vId){ 
                    count--;                    
                    if(count>0){                     
                        var sCount=specCount;
                        for(var spec in goodsSpecArray) {  
                            if(specId==spec){
                                 sCount--;            
                            }else{
                                var rnv=goodsSpecValueArray['goodsSpecValues_'+spec+'_'+rowNum];
                                if(rnv==null || typeof(rnv)=='undefined' || rnv==0){
                                    break;
                                }else{
                                    var snv=goodsSpecValueArray['goodsSpecValues_'+spec+'_'+n]; 
                                    if(snv!=null&&typeof(snv)!='undefined'&&snv==rnv){
                                        sCount--;
                                    }
                                }
                            }
                        }       
                        
                        if(sCount<=0){
                            return false;
                        }
                    }
                }
            }
        }
        if(count<=0){
            return false;
        }else{
            return true;
        }
    }
    function setSpecValue(id,specId,vId,rowNum)
    {
        var objTarget=document.getElementById(id);
        var objTargetFor=document.getElementById('for_' + id);
        var objs=getTagElements('input','forRow',rowNum); 
        if(objs!=null && objs.length>0 && objTarget!=null && objTargetFor!=null && goodsSpecArray[specId] && goodsSpecArray[specId].specValues[vId]){
            var sv=goodsSpecArray[specId].specValues[vId];            
            if(sv.isImage.toLowerCase()=='true'){
                objTarget.innerHTML='<img class="spec_pic" style="cursor:pointer;" src="' + sv.image + '" title="' + sv.value + '" alt="' + sv.value + '" width="30px" height="30px"/>';
            }else{
                objTarget.innerHTML='<span style="cursor:pointer;" class="spec_pic">' + sv.value + '</span>';
            }
            objTargetFor.value=vId;           
            for(var i=0;i<objs.length;i++){
                goodsSpecValueArray[objs[i].name+'_'+rowNum]=objs[i].value;
            }                    
        }      
        var objDiv=document.getElementById('div_specValueList');
        if(objDiv){
            objDiv.innerHTML='';
            objDiv.style.display='none';
        }
    }
    function getTagElements(tag, name, value)
    {   
        var arr = new Array(); 
        var elem = document.getElementsByTagName(tag);
        if(elem!=null)
        {   
            if(name!='')
            {
                for(i = 0,iarr = 0; i < elem.length; i++) {
                    var att = elem[i].getAttribute(name);
                    if(att!=null && att == value) {
                         arr[iarr] = elem[i];
                         iarr++;
                    }
                }
            }
            else
            {
                arr=elem;
            }
        }
        return arr;
    }   
    function checkIsNo(obj)
    {
        var rValue=false;
        var value=obj.value.replace(/(^\s*)|(\s*$)/g,'').replace(/,/g,'');
        obj.value=value.length>18?value.substr(value.length-18):value;     
    }  
    function checkIsCode(obj)
    {
        var objs=getTagElements('input','name',obj.name);
        var rValue=false;
        var value=obj.value.replace(/(^\s*)|(\s*$)/g,'').replace(/,/g,'');
        value=value.length>18?value.substr(value.length-18):value;
        obj.value='';
        if(objs!=null&&value!='')
        {
            for(var i=0;i<objs.length;i++)
            {
                if(objs[i].value==value)
                {
                    rValue=true;
                    break;
                }
            }            
        }
        if(!rValue){
            obj.value=value;
        }
    }   
    function checkIsUNumber(obj,defValue)
    {
        if(obj!=null && obj.type=="text")
        {
            var r=/[^\d]*([\d]*)[\D]*/; 
            var value=obj.value;
            var P=value.match(r);
            if(P[1]==null || P[1]==''){  
                value=(defValue!=null&&typeof(defValue)=='number')?defValue:'0';
            }else{
                value=P[1];
            }
            try{
                value=parseInt(value);
                if(!isNaN(value) && value>=0 && value<=2147483647){
                    obj.value=value;
                }else{
                    obj.value='0';
                }
            }catch(e){
                obj.value='0';
            }
        }
    }
    function checkIsMoney(obj,defValue)
    {
        if(obj!=null && obj.type=="text")
        {
            var r=/[^\d]*([\d]{1,15})([.][\d]{1,3})?/; 
            var value=obj.value;
            var P=value.match(r);                 
            if(P==null|| ((P[1]==null || P[1]=='') && (P[2]==null || P[2]==''))){  
                value=(defValue!=null&&typeof(defValue)=='number')?defValue:'0.000';
            }else{
                value=((P[1]==null||P[1]=='')?'0':P[1])+((P[2]==null||P[2]=='')?'.000':P[2]);
            }
            try{               
                if(!isNaN(parseFloat(value)) && value>0 && value<=922337203685477.5807){
                    obj.value=value;
                }else{
                    obj.value='0.000';
                }
            }catch(e){
                obj.value='0.000';
            }
        }
    }
    function checkIsWeight(obj,defValue)
    {
        if(obj!=null && obj.type=="text")
        {
            var r=/[^\d]*([\d]{1,9})([.][\d]{1,3})?/; 
            var value=obj.value;
            var P=value.match(r);                 
            if(P==null|| ((P[1]==null || P[1]=='') && (P[2]==null || P[2]==''))){  
                value=(defValue!=null&&typeof(defValue)=='number')?defValue:'0.000';
            }else{
                value=((P[1]==null||P[1]=='')?'0':P[1])+((P[2]==null||P[2]=='')?'.000':P[2]);
            }
            try{               
                if(!isNaN(parseFloat(value)) && value>0 && value<=999999999.999){
                    obj.value=value;
                }else{
                    obj.value='0.000';
                }
            }catch(e){
                obj.value='0.000';
            }
        }
    }
    function checkGoodsSpecValues()
    {
        var rValue=true;
        for(var spec in goodsSpecArray){
            var objs=document.getElementsByName('goodsSpecValues_'+spec);            
            if(objs!=null && objs.length>0){
                for(var i=0;i<objs.length;i++){
                    if(parseInt(objs[i].value)<=0){
                        rValue=false;  
                        break;
                    }
                }
            }
            if(!rValue){
                alert('规格值必须选择，请删除多余的货品');
                break;
            }
        }
        if(rValue){        
            setDefaultValues('input','name','goodsIds','0');
            setDefaultValues('input','name','goodsCode','*');
            setDefaultValues('input','name','goodsStore','0');
            setDefaultValues('input','name','goodsPrice','0.000');
            setDefaultValues('input','name','goodsDegreePrice','*');
            setDefaultValues('input','name','goodsCost','0.000');
            setDefaultValues('input','name','goodsWeight','0.000');        
        }       
        return rValue;
    }
    function setDefaultValues(tagName,attr,attrValue,defValue)
    {
        var objs=getTagElements(tagName,attr,attrValue);
        var rValue=true;
        if(objs!=null)
        {
            for(var i=0;i<objs.length;i++)
            {
                if(objs[i].value.indexOf(',')>=0){
                    objs[i].value=objs[i].value.replace(/,/g,'');
                }
                if(objs[i].value=='')
                {
                    objs[i].value=defValue;                   
                } 
            }
        }
    }
    function deleteGoods(obj)
    {
        var objTable=document.getElementById("proSpecValueTable");
        var objTR=obj.parentNode.parentNode;
        if(objTable!=null && objTR!=null)
        {
            if(confirm("删除货品之后将不能恢复，确认要删除吗？"))
            {
                var rowIndex=objTR.rowIndex;
                if(rowIndex!=-1)
                {
                    objTable.deleteRow(rowIndex);                       
                    if(objTable.rows.length<=2){
                        closeSpecList();
                    }                    
                }
            }
        }        
    }  
    function appendGoods(id,code,store,price,cost,weight,degreePrice)
    {
        var objTable=document.getElementById("proSpecValueTable");
       
        if(objTable!=null)
        {
            var objTR=objTable.insertRow(objTable.rows.length);  
            specRowNumber++;
            for(var i=0;i<tmpSpecValueData.length;i++){   
                objTD=objTR.insertCell(-1); 
                objTD.align='center'; 
                specValueNumber++;
                var innerHtml=tmpSpecValueData[i].replace(/proSpecValueNumber/g,specValueNumber);
                innerHtml=innerHtml.replace(/proSpecRowNumber/g,specRowNumber);
                innerHtml=innerHtml.replace(/_GoodsID/g,id);                
                innerHtml=innerHtml.replace(/_GoodsCode/g,code!=''?(code+'-'+specRowNumber):'');
                innerHtml=innerHtml.replace(/_GoodsStore/g,store!=''?store:'0');
                innerHtml=innerHtml.replace(/_GoodsPrice/g,price!=''?price:'0.000');
                innerHtml=innerHtml.replace(/_GoodsCost/g,cost!=''?cost:'0.000');
                innerHtml=innerHtml.replace(/_GoodsWeight/g,weight!=''?weight:'0.000');                   
                innerHtml=innerHtml.replace(/_SpecValueId/g,0);      
                innerHtml=innerHtml.replace(/_GoodsDegreePrice/g,degreePrice);
                
                innerHtml=innerHtml.replace(/_SpecValueHTML_/g,'<span class="spec_pic" style="cursor:pointer;">请选择</span>');
                objTD.innerHTML=innerHtml;      
            } 
        }        
    } 
    function initProductGoods(id,code,store,price,cost,weight,spValues,degreePrice)
    {
        var objTable=document.getElementById("proSpecValueTable");      
        if(objTable!=null)
        {
            var objTR=objTable.insertRow(objTable.rows.length);  
            specRowNumber++;
            var spValueArray=spValues.split(',');
            var spIndex=0;
            for(var i=0;i<tmpSpecValueData.length;i++){   
                objTD=objTR.insertCell(-1); 
                objTD.align='center'; 
                specValueNumber++;
                
                var innerHtml=tmpSpecValueData[i].replace(/proSpecValueNumber/g,specValueNumber);
                innerHtml=innerHtml.replace(/proSpecRowNumber/g,specRowNumber);
                innerHtml=innerHtml.replace(/_GoodsID/g,id);                        
                innerHtml=innerHtml.replace(/_GoodsCode/g,code);
                innerHtml=innerHtml.replace(/_GoodsStore/g,store!=''?store:'0');
                innerHtml=innerHtml.replace(/_GoodsPrice/g,price!=''?price:'0.000');
                innerHtml=innerHtml.replace(/_GoodsCost/g,cost!=''?cost:'0.000');
                innerHtml=innerHtml.replace(/_GoodsWeight/g,weight!=''?weight:'0.000');
                innerHtml=innerHtml.replace(/_GoodsDegreePrice/g,degreePrice);
                if(i>1 && i<tmpSpecValueData.length-4 && spIndex<spValueArray.length)
                {          
                    var values=spValueArray[spIndex].split(':');
                    if(goodsSpecArray[values[0]]!=null && goodsSpecArray[values[0]].specValues[values[1]]!=null){
                        var svalue=goodsSpecArray[values[0]].specValues[values[1]];
                        innerHtml=innerHtml.replace(/_SpecValueId/g,svalue.id); 
                        goodsSpecValueArray['goodsSpecValues_'+values[0]+'_'+specRowNumber]=svalue.id;
                        if(svalue.isImage.toLowerCase()=='true'){
                            innerHtml=innerHtml.replace(/_SpecValueHTML_/g,'<img class="spec_pic" style="cursor:pointer;" src="' + svalue.image + '" title="' + svalue.value + '" alt="' + svalue.value + '" width="30px" height="30px"/>');
                        }else{
                            innerHtml=innerHtml.replace(/_SpecValueHTML_/g,'<span style="cursor:pointer;" class="spec_pic">' + svalue.value + '</span>');
                        }
                    }    
                    spIndex++;                   
                }
                else{              
                    innerHtml=innerHtml.replace(/_SpecValueId/g,0); 
                }                
                objTD.innerHTML=innerHtml;      
            }        
        }        
    }
-->
