// JavaScript Document
function chk_usern(){
		if (document.getElementById("usern").value=='匿名用户')
		{document.getElementById("usern").value='';}
		}
function chk_blur(){
		if (document.getElementById("usern").value=='')
		{document.getElementById("usern").value='匿名用户';}
		}
function submitComment(){
		if (document.getElementById("usern").value=='')
		{alert("请填写用户名称");return false;}
		if (document.getElementById("check_code_comments").value=='')
		{alert("请填写验证码！");return false;}
		if ((document.getElementById("pl_content").value).length<10)
		{alert("评论内容不能少于10个字");return false;}
		
		$("btnp").disabled=true;
		$("btnp").value="正在提交中...";
		var usern,pl_content,yanzhengma,proid;
		usern=document.getElementById("usern").value;
		pl_content=document.getElementById("pl_content").value;
		yanzhengma=document.getElementById("check_code_comments").value;
		proid=document.getElementById("proid").value;
			var option={
			parameters:"oper=addcomment&usern="+usern+"&pl_content="+pl_content+"&proid="+proid+"&yanzhengma="+yanzhengma+"&time="+Date(),
			method:"post",
			onSuccess:function(transport){
				var rp=transport.responseText;
				if(rp=="yes"){ 
					alert("评论成功！");
					document.getElementById("check_code_comments").value='';
					document.getElementById("pl_content").value='';
					document.getElementById("ImgCheckCode_comments").src='/inc/VerifyCode.asp?id="<%=GetRndFileName()%>"&time='+Date();
					gotoPage(1,proid);
				} 
				if(rp=="yes2"){ 
					alert("评论成功，请等待管理员审核！");;
					document.getElementById("check_code_comments").value='';
					document.getElementById("pl_content").value='';
					document.getElementById("ImgCheckCode_comments").src='/inc/VerifyCode.asp?id="<%=GetRndFileName()%>"&time='+Date();
					//gotoPage(1,proid);
				} 
				if(rp=="check1"){ 
					alert("用户名称或者评论内容不能为空！");
				} 
				if(rp=="checkall"){ 
					alert("该网站的评论数目超过限制！");
				} 
				if(rp=="check2"){ 
					document.getElementById("ImgCheckCode_comments").src='/inc/VerifyCode.asp?id="<%=GetRndFileName()%>"&time='+Date();
					alert("验证码错误！");
				} 
			},
			onFailure:function(transport){
				alert("网络错误，请联系管理员");
			}
		}
		var request=new Ajax.Request("Pro_Comments.asp",option);
		$("btnp").value="提交评论";
		$("btnp").disabled=false;
		return;
	 } 

function gotoPage(page_num,proid)
{
	var page_nums,proids
	var option={
			parameters:"oper=comment_page&page_nums="+page_num+"&proids="+proid+"&time="+Date(),
			method:"post",
			onSuccess:function(transport){
				var rp=transport.responseText;
				if(rp=="no"||rp=="no2"){ 
					return;
				} 
				else
				{ 
					products_comment_con.innerHTML=rp;
				} 
			},
			onFailure:function(transport){
				alert("网络错误，请联系管理员");
			}
		}
		var request=new Ajax.Request("Pro_Comments.asp",option);
		return;
	}

function collect(proid)
{
	var page_nums,proids
	var option={
			parameters:"oper=addcar&proids="+proid+"&time="+Date(),
			method:"post",
			onSuccess:function(transport){
				var rp=transport.responseText;
				if(rp=="no"){ 
					alert("由于您还没有登录，因此不能使用此功能！");
				} 
				if(rp=="no2")
				{ 
					alert("该商品已经存在您的收藏夹了！");
				} 
				if(rp=="OK")
				{ 
					alert("该商品已经成功加入您的收藏夹了！");
				} 
			},
			onFailure:function(transport){
				alert("网络错误，请联系管理员");
			}
		}
		var request=new Ajax.Request("Pro_Comments.asp",option);
		return;
	}

  function addtocar(proid)
{
	var pro_nums,proids;
	var peisongfeiValue,shuxingzhis,sxsm;
	shuxingzhis="";
	if(document.getElementById("attr_list")==null)
	{sxsm=0;}
	else
	{
		sxsm=document.getElementById("attr_list").value;
		for (var j=1;j<=sxsm;j++)
		{
			for (var k=0;k<document.getElementsByName("attr"+j).length;k++)
			{
            if (document.getElementsByName("attr"+j)[k].checked)
				{
					shuxingzhis = shuxingzhis + document.getElementsByName("attr"+j)[k].value + ",";
					break;
				}
			}
		}
	}
	//alert(shuxingzhis);return;
	
	if (document.getElementById("pro_num")==null) 
	{pro_nums=1;}
	else
	{pro_nums=document.getElementById("pro_num").value;}
	
	if (document.getElementById("peisongfei")==null) 
	{peisongfeiValue=0;}
	else {
	var peisongfeis=document.getElementsByName("peisongfei");
	for (var k=0;k<peisongfeis.length;k++){
            if (peisongfeis[k].checked){
                peisongfeiValue = peisongfeis[k].value;
                break;
            }
	}
	}
	
	if(pro_nums=="")
	{pro_nums=1;}
	var option={
			parameters:"oper=addtocar&pro_nums="+pro_nums+"&proids="+proid+"&peisongfei="+peisongfeiValue+"&sx_value="+shuxingzhis+"&time="+Date(),
			method:"post",
			onSuccess:function(transport){
				var rp=transport.responseText;
				//alert(rp);return;
				if(rp=="no"){ 
					alert("参数错误！");return;
				} 
				if(rp=="sxok"){ 
					if(confirm("您加入的购物车有不同型号可选，你是否立即跳转到商品详情选择型号！"))
					{location.href="/Product_Show.asp?id="+proid+"";}
				} 
				if(rp=="no2")
				{ 
					alert("该商品可能刚被商家删除，请联系商家！");return;
				} 
				if(rp=="no3")
				{ 
					alert("库存数量不足，请联系商家！");return;
				} 
				if(rp=="OK")
				{ 
					location.href='Product_Car.asp';
				} 
			},
			onFailure:function(transport){
				alert("网络错误，请联系管理员");
			}
		}
		var request=new Ajax.Request("Pro_Comments.asp",option);
		return;
	}