function AddDVRCard(Id){
	dynamicGetDate("/Inc/checkuser.asp","show=0&time="+getTimeValue(),"AddToCart("+Id+",'DVRCard')",1,getLoginContent(),"LogIn","en");
}

function AddDVR(Id){
	dynamicGetDate("/Inc/checkuser.asp","show=0&time="+getTimeValue(),"AddToCart("+Id+",'DVR')",1,getLoginContent(),"LogIn","en");
}

function AddCamera(Id){
	dynamicGetDate("/Inc/checkuser.asp","show=0&time="+getTimeValue(),"AddToCart("+Id+",'Camera')",1,getLoginContent(),"LogIn","en");
}

function AddToCart(Id,table){
	dynamicGetDate("/Member/AddToCart.asp","Type="+table+"&Id="+Id+"&time="+getTimeValue(),"showCart(showDate)",1,getLoginContent(),"LogIn","en");
}

function getContent(page){	
	dynamicGetDate("/Member/ShowCart.asp","page="+page,"renewContent(showDate)",1,"","","en");
}

function renewContent(str){
	if(document.all.msgTxt) 	document.all.msgTxt.innerHTML=str;
}

function showCart(str){
	showModalWindows("Shoping Cart",str,600,500);
}

function changeFee(){
	var bankFee=document.all.O_BankFee.value;
	var freightFee=document.all.O_FreightFee.value;
	var totalPrice=document.all.totalPrice.innerHTML;
	var total=bankFee*1+freightFee*1+totalPrice*1;
	document.all["totalCost"].innerHTML="<strong>$"+bankFee+" + $"+totalPrice+" + $"+freightFee+" = $"+total+"</strong>";
}

function updateOrder(defaultValue,obj,id,tag){
	var O_BankFee=document.all["O_BankFee"].value*1;
	var O_FreightFee=document.all["O_FreightFee"].value*1
	if(tag==1){   //价格改变
		var totalPrice=document.all["totalPrice"].innerText*1+(obj.innerText*1-defaultValue*1)*document.all["B_Num"+id].value;
		totalPrice=Math.round(totalPrice*100)/100;
		var total=O_BankFee+totalPrice+O_FreightFee;
		document.all["countPrice"+id].innerText=Math.round(obj.innerText*document.all["B_Num"+id].value*100)/100;
		document.all["totalPrice"].innerText=totalPrice;
		//document.all["totalCost"].innerHTML="<strong>$"+O_BankFee+" + $"+O_FreightFee+" + $"+totalPrice+" = $"+total+"</strong>";
	}else{   //数量改变
		var totalPrice=document.all["totalPrice"].innerText*1+(obj.value*1-defaultValue*1)*document.all["B_Price"+id].innerText;
		totalPrice=Math.round(totalPrice*100)/100;
		var total=O_BankFee+totalPrice+O_FreightFee;
		document.all["countWeight"+id].innerText=Math.round(obj.value*document.all["Weight"+id].innerText*100)/100;
		document.all["countPrice"+id].innerText=Math.round(obj.value*document.all["B_Price"+id].innerText*100)/100;
		document.all["totalPrice"].innerText=totalPrice;
		document.all["totalNumber"].innerText=(document.all["totalNumber"].innerText*1+(obj.value*1-defaultValue))
		document.all["totalWeight"].innerText=Math.round((document.all["totalWeight"].innerText*1+(obj.value*1-defaultValue)*document.all["Weight"+id].innerText)*100)/100;
		//document.all["totalCost"].innerHTML="<strong>$"+O_BankFee+" + $"+O_FreightFee+" + $"+totalPrice+" = $"+total+"</strong>";
	}
}

function userUpdate(table,defaultValue,checkField,checkValue,changeField,changeValue,valueType,obj,dealWithFunction,updateMethod){
	//document.all.result.innerText=changeValue;
	//document.all.result.innerText=table+"&"+defaultValue+"&"+checkField+"&"+checkValue+"&"+changeField+"&"+changeValue+"&"+valueType+"&"+obj+"&"+method;
	urlStr="/inc/userupdate.asp";
	parameterStr="time="+getTimeValue()+"&table="+table+"&checkField="+checkField+"&checkValue="+checkValue+"&changeField="+changeField+"&changeValue="+URLEncode(changeValue)+"&valueType="+valueType;
	dynamicGetDate(urlStr,parameterStr,dealWithFunction,updateMethod,defaultValue,obj,"en");
}

//updateMethod: 1:重新刷新整个页面  0:更新整个页面
function delProduct(Id,updateMethod){
	if(!Id){
		alert("Error\nYou don't select any item.");
		return;
	}
	if(confirm("The opetion will not be comeback,are you sure to do it?"))
		dynamicGetDate("/Member/delCart.asp","id="+Id,"checkDel(showDate,"+updateMethod+")",1,"","","en")
}

function checkDel(returnValue,updateMethod){
	if(returnValue=="OK")
		if(updateMethod==0) getContent(0);
		else document.location.reload();
	else
		alert("error!!!!");
}

checked=false;
function CheckAll(form,selectId){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
     e.checked = selectId.checked;
  }
}

function ConfirmDel(form,updateMethod){
	var id;
	for (var i=0;i<form.elements.length;i++){
		if(form.elements[i].id=="Id"&&form.elements[i].checked){
			if(id)	id+=","+form.elements[i].value;
			else 	id=form.elements[i].value;
		}
 	}
	delProduct(id,updateMethod);
}
