﻿var locListDivTips = null;
var txtValue=null;
var txtID=null;

var onblurTxtValue=null;

var ishref="";


function SubmissionValue(id,txt)
{
   txtID=id;
   txtValue=txt;
}



function setlocListDivTips(sender,onvalue)
{
    onblurTxtValue=onvalue;
    //判断输入的是否和原来相等，如果相等不提示是否更新信息
    if(onblurTxtValue == "")
    {
        alert("请输入商品数量");
        document.getElementById(txtID).value=txtValue;
        //document.getElementById(txtID).value="1";
    }
    else if(onblurTxtValue=="0"||onblurTxtValue == "00"||onblurTxtValue == "000"||onblurTxtValue == "0000"||onblurTxtValue == "00000")
    {
        alert("商品数量不能为0");
        //document.getElementById(txtID).value="1";
        document.getElementById(txtID).value=txtValue;
    }
    else if(!CheckChinese(onblurTxtValue))
    {
        alert("禁止输入非数字");
        //document.getElementById(txtID).value="1";
        document.getElementById(txtID).value=txtValue;
    }
    else if(onblurTxtValue!=txtValue)
    {
        locListDivTips =  document.getElementById("locListDiv");  
        locListDivTips.innerHTML="<div class='content_3'><p class='t_c'></p><p style='text-align:center;' >是否更新该商品数量？</p><p class='t_c' style='text-align:center;' ><a onmouseover='link_hover(this)' onmouseout='link_out(this)' onclick='javascript:saveDivTips();'>是</a>&nbsp;&nbsp;&nbsp;<a onmouseover='link_hover(this)' onmouseout='link_out(this)' onclick='javascript:hidelocListDivTips();'>否</a></p></div><div class='c_b_3'></div>";
        locListDivTips.className = "box_window_3";
        
        locListDivTips.style.top=(getposOffset(sender,"top")-80)+"px";
	    locListDivTips.style.left=(getposOffset(sender,"left")-65)+"px";
	    locListDivTips.style.display="block";
    	
	    ishref="div";
	}
}
//没有中文返回true
//谢路2009-3-25日修改 禁止输入非数字
function CheckChinese(str)
{
    for(var i=0;i<str.length;i++) 
    {
         //if(str.charCodeAt(i)<0||str.charCodeAt(i)>255) 
         if(str.charCodeAt(i)<48||str.charCodeAt(i)>57) 
         {
             return false;
         }
    }
    return true;
}

function getposOffset(what, offsettype)
{ 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
} 

function saveDivTips()
{
    locListDivTips = document.getElementById("locListDiv"); 
    if(onblurTxtValue!=txtValue)
    {
        document.getElementById("btnUpdata").click(); 
        ishref="";
    }
    else
    {
       locListDivTips.style.display = "none";   
       ishref="";
    }
}

function hidelocListDivTips()
{
    locListDivTips.style.display = "none";   
    document.getElementById(txtID).value=txtValue;
    ishref="";   
}

function link_hover(link_obj)
{
    
    link_obj.className='remove_hover';
}

function link_out(link_obj)
{
    link_obj.className='';
}


function locationhref()
{
    if(ishref == "")
    {
        window.location.href="shopingUser.aspx";
    }
}


function  selectAll(chkVal)
{
    var frm = document.forms[0];
    for (i=0; i<frm.length; i++)
    {
    var c = frm.elements[i].type;
    if (c == 'checkbox')
     {
         if(chkVal == true)
          {
            frm.elements[i].checked = true;
          } 
        else 
         {
           frm.elements[i].checked = false;
         }
      }
    }
}
             
             
 
function isCheckBox()
{
 var frm = document.forms[0];
 for (i=0; i<frm.length; i++)
 {
     var c = frm.elements[i].type;
         if (c == 'checkbox')
          {
            if(frm.elements[i].id=="ctl00_ContentHolder_ShopCart_ctl01_CheckALL")
            {
               continue;
            }
            if(frm.elements[i].checked == true)
            {
               return "1"
            }
         }
 }
 return "0";
}

            
function deltetcar()
{
  if(ishref == "")
  {
      var checkValue=isCheckBox();
      if(checkValue=="1")
      {
        document.getElementById("ctl00_ContentHolder_btnUpdata").click(); 
      }
      else
      {
         alert("请先选择你要删除的商品！")
      }
  }
}
