//打开商品预订窗口
function buyproduct(pointid,pointid1)
{
	var a=showModalDialog('/windowopen/action=buyproductframe&pointid='+pointid+'&pointid1='+pointid1,window,'dialogWidth:700px; dialogHeight:400px;help:0;status:0;resizeable:1;scrolling:1;');
}
//打开商品预订窗口

//计算商品总价
function AccountPrice(theform,pointid)
{
	if (document.forms[theform].myamount.value=='')
	{
		alert("请填写购买数量！");
		document.getElementById('myamount').focus();
		return false;
	}
	if (isNaN(document.forms[theform].myamount.value))
	{
		alert("请填写有效的数字！");
		document.getElementById('myamount').focus();
		return false;
	}
	if (document.forms[theform].myamount.value==0)
	{
		alert("请填写有效的数字作为购买数量！");
		document.getElementById('myamount').focus();
		return false;
	}
	if(Math.floor(document.getElementById('myamount').value)!=Math.ceil(document.getElementById('myamount').value))
	{
		alert("请填写有效的数字作为购买数量！");
		document.getElementById('myamount').focus();
		return false;
	}
	else
	{	
		var sValue = document.forms[theform].myamount.value;
		ajaxchangecontentforaccountproductprice(this,'TotalPrices',
			'/buyproduct/action=account_price_ex&myamount='+sValue+'&pointid='+pointid);
	}
}
//计算商品总价


//AJAX
function ajaxchangecontentforaccountproductprice(sendobj,div,geturl) {
	gsendobj=sendobj;
	gsendobj.disabled=true;
	var ajax=new AJAXRequest;
	ajax.get(
		geturl+'&a=Math.Random()',
		function(obj) {
		if (obj.responseText==1)
		{
			alert('对不起,您购买的商品数量超过了我们的商品库存,请您重新填写购买数量！');
			document.getElementById('submits').style.cursor="default";
			document.getElementById('submits').disabled=true;
			document.getElementById('myamount').focus();
		}
		else
		{
		document.getElementById('submits').style.cursor="pointer";
		document.getElementById('submits').disabled=false;
		document.getElementById(div).innerHTML=obj.responseText;
		}
		}
	);
}
//AJAX


//检测购买商品表单
function CheckFormValues(theform)
{
	if (theform.myamount.value=='')
	{
		alert("请填写购买数量！");
		theform.myamount.focus();
		return false;
	}
	if (isNaN(theform.myamount.value))
	{
		alert("请填写有效的数字作为购买数量！");
		theform.myamount.focus();
		return false;
	}
	if (theform.myamount.value==0)
	{
		alert("请填写有效的数字作为购买数量！");
		theform.myamount.focus();
		return false;
	}
	if(Math.floor(document.getElementById('myamount').value)!=Math.ceil(document.getElementById('myamount').value))
	{
		alert("请填写有效的数字作为购买数量！");
		document.getElementById('myamount').focus();
		return false;
	}
	if (theform.myusername.value=='')
	{
		alert("请填写购买人姓名！");
		theform.myusername.focus();
		return false;
	}
	if (theform.mylinkphone.value=='')
	{
		alert("请填写联系电话！");
		theform.mylinkphone.focus();
		return false;
	}
	if(!NoahWebJsExpTest(theform.mylinkphone.value,/^(\d{2,4}-)?(\(\d{3,4}\)|\d{3,4}-)?(\d{7,8}|\d{11,11})(-\d{2,4})?$/)) 
	{ 
		alert('请填写有效的联系电话！'); 
		theform.mylinkphone.focus(); 
		return false;
	 }
	if (theform.mypaymode.value=='')
	{
		alert("请选择送货方式！");
		theform.mypaymode.focus();
		return false;
	}
	if (theform.mydelivermode.value=='')
	{
		alert("请选择付款方式！");
		theform.mydelivermode.focus();
		return false;
	}
	if (theform.mylink_address.value=='')
	{
		alert("请填写送货地点！");
		theform.mylink_address.focus();
		return false;
	}
	if (theform.mylink_address.value.length>200)
	{
		alert("送货地点不能超过200字！");
		theform.mylink_address.focus();
		return false;
	}
}
function NoahWebJsExpTest(str,strm)
{
	var re = strm;
	if(str=='' || str==null)
		return true;
	if (!re.test(str))
	{
		return false;
	}
return true;
}
//检测购买商品表单