/*
-------------------------------------------------------------
*****************  乐度网店系统(lodoeshop)  *****************

作者：福州市好格网络技术有限公司
网站：http://www.lodoeshop.com
版权：版权属于福州市好格网络技术有限公司，不得拷贝、修改，侵权必究。

*************************************************************
-------------------------------------------------------------
*/
function Goods_cal(sum1,sum2)
{
var temptext=document.getElementById('req_good_num'+sum1);
if (eval(temptext.value)+sum2>0)
{
  temptext.value=eval(temptext.value)+sum2;
}
}
function Save(str1)
{
var temptext=document.getElementById("req_good_num"+str1);	
var newstr="";
var str3=document.getElementById("FOA"+str1).value;
//alert(str3);
if(str3!="No")
	{
	var tempstr=str3.split("|");
		for(var i=0;i<tempstr.length-1;i++)
		{
		  var Tstr=tempstr[i].split(":");
		  if(Tstr[1].split("/").length-1>0)
			{
			newstr=newstr+Tstr[0]+":"+document.getElementById("sel"+str1+"OA"+i).value+"|";}
			
		}
	}
	else
	{newstr="No";}
	
var hp_year=jQuery("select#hp_year_"+str1).val();
var hp_month=jQuery("select#hp_month_"+str1).val();
var hp_day=jQuery("select#hp_day_"+str1).val();
location.href="cart1.asp?addr=cart1&editstr="+newstr+"&editsum="+temptext.value+"&hp_year="+hp_year+"&hp_month="+hp_month+"&hp_day="+hp_day+"&Cid="+str1+"";
}
function nextcart()
{
Upform.submit();
}
function isnumber(e)
{
var patrn=/^[0-9]{1,20}$/;
if (!patrn.exec(e.value)) {alert("只能由整数组成!");e.value=1;return false;}
return true;

}

function chGiftnum(chid,tempe)
{
var tempGiveWay=jQuery("#GiveWay"+chid).val();

var tempk=jQuery("form[name='GWform_"+chid+"'] input:checkbox:checked[name='Giftch"+chid+"']").size();

if(eval(tempGiveWay)==0)
{
	if(tempk<=0)
	{
	alert('此优惠活动至少要有一个礼品才能享受!');
	return false;
	}
}
else
{
	if(eval(tempk)>eval(tempGiveWay))
	{
	alert('此优惠活动你最多只能选择'+tempGiveWay+'个礼品');
	return false;
	}
}

}

function chknumber(num)
{
var patrn=/^[0-9]{1,20}$/;
if (!patrn.exec(num))
	{
		return false;
	}
 return true;	
} 
function chkDozen(e,lv)
{
if(!chknumber(e.value)){
		alert("购买数量只能由整数组成！");
		e.value=lv;
		e.focus();
		return false;
}

if ( e.value<=0 || (e.value % lv) != 0)
	{
		alert("购买数量只能是一手的整数倍！");
		e.value=lv;
		e.focus();
		return false;
	}
}

//跳转到订单信息输入页面
function gotocart2(url)
{
	var cart_goods_list=$("#cart_goods_list>table>tbody>tr.cart_goods_info");
	if(cart_goods_list.size()<=0){alert("您的购物车内暂无商品，无法继续！");return false;}
	var tmp_h=jQuery("input:hidden[name='lodo_goods_qno'][value=1]");
	if(tmp_h.size()>0)
	{	var tmp_str="";
		tmp_h.each(function(){
								if(tmp_str!=""){tmp_str+=","}
								tmp_str+="["+this.gname+"]"
							});
		alert("您购物车内的商品["+tmp_str+"]的库存不足，无法做下一步操作！请去掉这些商品或与商家联系！");
		return false;
		}
	
	//判断配送日期是否过期
	var nextno=true;
/*	$(cart_goods_list).each(function(){
									   var DeliveryDate=$(this).attr("DeliveryDate");
									   var nowDate=$(this).attr("nowDate");
									   var goodsname=$(this).attr("gname");
									   if(DeliveryDate<nowDate){
										   alert("购物车内的商品["+goodsname+"]的配送日期已过期，暂时无法下单，请重新选择配送日期！");
										   nextno=false;
										   return false;
										   }
									 })*/
	if(nextno){location.href=url;}
		
	//判断是否达到最低购买金额
/*	jQuery.getJSON("/ajax_data.asp?action=chmm",function(data){
														 if(data.ch){
															 location.href=url;
															 }
														 else
														 {
															 alert("您的购物车内的总金额只有["+data.carsum+"]元,未达到最低的购买金额["+data.mm+"元],无法下单！");
															  return false;
															 }
														 });*/
}