﻿//商品打分
function mark(theform)
{
	if (document.forms[theform].myscore[0].checked==false&&document.forms[theform].myscore[1].checked==false&&document.forms[theform].myscore[2].checked==false&&document.forms[theform].myscore[3].checked==false&&document.forms[theform].myscore[4].checked==false)
	{
		alert("请选择分数！");
		document.forms[theform].myscore[4].focus();
	}
	else
	{
		var sValue = "";
		var tmpels = document.getElementsByName('myscore');
        for(var i=0;i<tmpels.length;i++)
         {
            if(tmpels[i].checked)
            {
               sValue += tmpels[i].value;
            }
        }
		ajaxchangecontentbypost(this,'userscoretabel','UserScoreForm');
	}
}
//商品打分


//教练推荐商品
function nominate(pointid,pointid1)
{	
	alert('推荐成功,您的名字将会在右侧"推荐此商品用户"中显示');
	ajaxchangecontent(this,'nominateproductuser',
		'/submit/action=product_nominate_ex&myid='+pointid1+'&pointid='+pointid);
}
//教练推荐商品


//添加商品TAG
function ShopTagAdd()
{
	
	ajaxchangecontentbypost(this,'ShopTagAndSomeList','ShopTagForm');
	ajaxchangecontentbypost(this,'AllShopTagList','AllShopTagForm');
}
//添加商品TAG


//添加商品评论
function ProductCommentAddSubmit(thefrom)
{
	if (document.ProductCommentAdd.mycommenttype[0].checked==false&&document.ProductCommentAdd.mycommenttype[1].checked==false&&document.ProductCommentAdd.mycommenttype[2].checked==false&&document.ProductCommentAdd.mycommenttype[3].checked==false&&document.ProductCommentAdd.mycommenttype[4].checked==false)
	{
		alert('请选择评价');
		document.ProductCommentAdd.mycommenttype[0].focus();
		return false;
	}
	if (document.getElementById("mydescriptions").value=='')
	{
		alert('请输入评语');
		document.getElementById("mydescriptions").focus();
		return false;
	}
	if (document.getElementById("mydescriptions").value.length>200)
	{
		alert('评语字数不能超过200字');
		document.getElementById("mydescriptions").focus();
		return false;
	}
	else
	{ 
		alert("评论添加成功,感谢您的参与！");
		ajaxchangecontentbypost(this,'ProductPresentationAndCommentTabel','ProductCommentAdd');
		
	}
}
//添加商品评论


//评价商品
function Appraise(thevalue,pointid)
{
	document.getElementById("pointvalue").value = thevalue;
	ajaxchangecontentbypost(this,'CommunityShopAppraiseTable','CommunityShopAppraiseForm');
}
//评价商品


//检测二手商品搜索表单
function CheckSearchCommunitySecondProductFormValue(theform)
{
	if (document.getElementById("mystartprice").value!='')
	{
		if ((isNaN(document.getElementById("mystartprice").value)))
		{
			alert("请输入一个有效的正整数作为价格范围起始价！");
			document.getElementById("mystartprice").focus();
			return false;
		}
	}
	if (document.getElementById("myendprict").value!='')
	{
		if ((isNaN(document.getElementById("myendprict").value)))
		{
			alert("请输入一个有效的正整数作为价格范围结束价！");
			document.getElementById("myendprict").focus();
			return false;
		}
		if ((document.getElementById("myendprict").value-document.getElementById("mystartprice").value)<0)
		{
			alert("价格范围结束价不能小于起始价！");
			document.getElementById("myendprict").focus();
			return false;
		}
	}
	
}
//检测二手商品搜索表单


//添加社区商品TAG
function CommunityShopTagAdd()
{
	ajaxchangecontentbypost(this,'ShopTagAndSomeList','ShopTagForm');
	ajaxchangecontentbypost(this,'AllShopTagList','AllShopTagForm');
	ajaxchangecontentbypost(this,'BrowseAndBuyAndTagListTable','BrowseAndBuyAndTagListForm');
}
//添加社区商品TAG


//添加社区二手商品TAG
function CommunitySecondProductTagAdd()
{
	ajaxchangecontentbypost(this,'CommunitySecondProductInfo','CommunitySecondProductTagForm');
	ajaxchangecontentbypost(this,'AllSecondProductTagList','AllSecondProductTagForm');
}
//添加社区二手商品TAG

//检测添加社区商品
function CheckCommunityShopAddFormValues(theform)
{
	if (trim(document.getElementById("mytitle").value)=='')
	{
		alert("请输入商品名称！");
		document.getElementById("mytitle").focus();
		return false;
	}
	if (document.getElementById("mytitle").value.length>50)
	{
		alert("商品名称字数不能超过50个字符！");
		document.getElementById("mytitle").focus();
		return false;
	}
	if (trim(document.getElementById("myprice").value)=='')
	{
		alert("请输入商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (isNaN(document.getElementById("myprice").value))
	{
		alert("请输入一个有效的正整数作为商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (trim(document.getElementById("mydescriptions").value)=='')
	{
		alert("请输入商品描述！");
		document.getElementById("mydescriptions").focus();
		return false;
	}
	if (document.getElementById("myfile").value!='')
	{
		if(!CheckExt(document.getElementById("myfile")))
		{
			alert("请选择JPG或JPGE格式的图片作为商品图片！");
			document.getElementById("myfile").focus();
			return false;
		}
	}
}
//检测添加社区商品


//二手商品状态更新
function SecondProductSale(pointid,pointstate,pointarea)
{	
	
	if (pointarea=='LeftNav')
	{
		document.getElementById("state").value = pointstate;
		document.getElementById("pointid").value = pointid;
		ajaxchangecontentbypost(this,'AllMyAddSecondProductList','AllMyAddSecondProductForm');
		ajaxchangecontentbypost(this,'CommunitySecondProductListTable','CommunitySecondProductListForm');
	}
	if (pointarea=='MoreList')
	{
		document.getElementById("state").value = pointstate;
		document.getElementById("pointid1").value = pointid;
		ajaxchangecontentbypost(this,'MoreMyAddSecondProductListTable','MoreMyAddSecondProductListForm');
	}
	
}
//二手商品状态更新

//检测重新发布二手表单
function CheckUpdateCommunitySecondProductFormValues(theform)
{
	if (document.getElementById("myquality").value=='')
	{
		alert("请选择新旧程度！");
		document.getElementById("myquality").focus();
		return false;
	}
	if (trim(document.getElementById("myprice").value)=='')
	{
		alert("请输入商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (isNaN(document.getElementById("myprice").value))
	{
		alert("请输入一个有效的正整数作为商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (trim(document.getElementById("mydescriptions").value)=='')
	{
		alert("请输入商品描述！");
		document.getElementById("mydescriptions").focus();
		return false;
	}
}
//检测重新发布二手表单



//刷新表单
function FormReset(theform)
{
	document.getElementById(theform).reset();
}
//刷新表单

//发布二手商品商品搜索
function SearchProduct()
{
	ajaxchangecontentbypost(this,'ProductListTable','SearchProductInSecondAdd');
}
//发布二手商品商品搜索


//添加一个商品为要转让的二手商品
function SecondProductAddToForm(thevalue)
{
	document.getElementById("pointproductid").value = thevalue;
	ajaxchangecontentbypost(this,'SecondProductAddFormShowArae','SecondProductAddForm');
	
}
//添加一个商品为要转让的二手商品


//
function DelProduct()
{
	ajaxchangecontentbypost(this,'SecondProductAddFormShowArae','HiddenSecondProductForm');
}
//

//检测发布二手表单
function CheckCommunitySecondProductAddFormValues()
{
	if (document.getElementById("myquality").value=='')
	{
		alert("请选择新旧程度！");
		document.getElementById("myquality").focus();
		return false;
	}
	if (trim(document.getElementById("myprice").value)=='')
	{
		alert("请输入商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (isNaN(document.getElementById("myprice").value))
	{
		alert("请输入一个有效的正整数作为商品价格！");
		document.getElementById("myprice").focus();
		return false;
	}
	if (document.getElementById("myfile").value!='')
	{
		if(!CheckExt(document.getElementById("myfile")))
		{
			alert("请选择JPG或JPGE格式的图片作为商品图片！");
			document.getElementById("myfile").focus();
			return false;
		}
	}
	if (document.getElementById("myfile1").value!='')
	{
		if(!CheckExt(document.getElementById("myfile1")))
		{
			alert("请选择JPG或JPGE格式的图片作为商品图片！");
			document.getElementById("myfile1").focus();
			return false;
		}
	}
	if (document.getElementById("myfile2").value!='')
	{
		if(!CheckExt(document.getElementById("myfile2")))
		{
			alert("请选择JPG或JPGE格式的图片作为商品图片！");
			document.getElementById("myfile2").focus();
			return false;
		}
	}
	if (trim(document.getElementById("mydescriptions").value)=='')
	{
		alert("请输入商品描述！");
		document.getElementById("mydescriptions").focus();
		return false;
	}
}
//检测发布二手表单


//添加知识TAG

function LoreTagAdd()

{

         ajaxchangecontentbypost(this,'LoreTagAndSomeList','LoreTagForm');

}

//添加知识TAG
function NewsTagAdd()

{


         ajaxchangecontentbypost(this,'NewsTagAndSomeList','NewsTagForm');

}
