var txt = '<ul style="float: left;display: block;" class="ull">';
		txt += '<li style="float: left;display: block;">';
		txt += '<dl>';
		txt += '<dd >';
		txt += '<p style="font-size: 12px;font-weight: normal; "> * 您对该产品的评论 (1000字以内)</p>';
		txt += '</dd>'
		txt += '</dl>';
		txt += '<div class="c"></div>';
		txt += '</li>';
		txt += '<li>';
		txt += '<textarea name="content" id="content" style="width:600px;height:200px;"></textarea>';
		txt += '</li>';
		txt += '<li>';
		txt += '<dl id="pinglun_grade" style="width:600px;">';
		txt += '<dd style="float: left;display: block;">';
		txt += '<p>* 请您对产品进行评分: </p>';
			txt += '<table class="tab">';
				txt += '<tr><td style="width:70px;">综合</td><td>';
					txt += '<select name="zonghegrade" id="zonghegrade" style="width:100px;">';
						txt += '<option value="5">5 星</option>';
						txt += '<option value="4">4 星</option>';
						txt += '<option value="3">3 星</option>'; 
						txt += '<option value="2">2 星</option>';
						txt += '<option value="1">1 星</option>';
					txt += '</select>';
				txt += '</td></tr>';
				txt += '<tr><td>时尚度</td><td>';
					txt += '<select name="shushidugrade" id="shushidugrade" style="width:100px;">';
						txt += '<option value="5">5 星</option>';
						txt += '<option value="4">4 星</option>';
						txt += '<option value="3">3 星</option>'; 
						txt += '<option value="2">2 星</option>';
						txt += '<option value="1">1 星</option>';
					txt += '</select>';
				txt += '</td></tr>';
				txt += '<tr><td>民族味</td><td>';
					txt += '<select name="yangshigrade" id="yangshigrade" style="width:100px;">';
						txt += '<option value="5">5 星</option>';
						txt += '<option value="4">4 星</option>';
						txt += '<option value="3">3 星</option>';
						txt += '<option value="2">2 星</option>';
						txt += '<option value="1">1 星</option>';
					txt += '</select>';
				txt += '</td></tr>';
			txt += '</table>';
		txt += '</dd>';
		txt += '<dd style="float: left;display: block;margin-right: 40px;margin-left: 40px;width:150px;">';
		txt += '<p>* 您觉得这款商品质量</p>';
		txt += '<table >';
			txt += '<tr><td class="radio"><input type="radio" name="quality" value="很满意" /></td>';
				txt += '<td class="descrp">很满意</td></tr>';
			txt += '<tr><td class="radio" ><input type="radio" name="quality" value="不错" /></td>';
				txt += '<td class="descrp">不错</td></tr>';
			txt += '<tr><td class="radio"><input type="radio" name="quality" value="一般" /></td>';
				txt += '<td class="descrp">一般</td></tr>';
			txt += '<tr><td class="radio"><input type="radio" name="quality" value="不太满意" /></td>';
				txt += '<td class="descrp">不太满意</td></tr>';
		txt += '</table>';
		txt += '</dd>';
		
		txt += '<dd style="float: left;display: block;width:150px;">';
		txt += '<p>* 您觉得店家的服务</p>';
		txt += '<table>';
			txt += '<tr><td class="radio"><input type="radio" name="serve" value="非常满意" /></td>';
				txt += '<td class="descrp">非常满意</td></tr>';
			txt += '<tr><td class="radio"><input type="radio" name="serve" value="满意" /></td>';
				txt += '<td class="descrp">满意</td></tr>';
			txt += '<tr><td class="radio"><input type="radio" name="serve" value="一般" /></td>';
				txt += '<td class="descrp">一般</td></tr>';
			txt += '<tr><td class="radio"><input type="radio" name="serve" value="差" /></td>';
				txt += '<td class="descrp">差</td></tr>';
		txt += '</table>';
		txt += '</dd>';
		txt += '</dl>';
		txt += '<div class="c"></div>';
		txt += '</li>';
		txt += '</ul>';	
		
		
		var login = '<div >';
	   	    login += '<div >';
	   	    login += '<dl>';
	   		login += '<dd >';
	   		login += '<img src="/images/car_signin.gif" />';
	   		login += '</dd>';
	   		login += '<dd >';
	   		login += '</dd>';
	   		login += '</dl>';
	   		login += '</div> ';
	   		login += '<div></div>';
	   		login += '<div ></div>';
			login += '<form name="login_f" method="post" onsubmit="return loginClick()">';
			login += '<p style="padding:5px 0 0 10px;" id="login_msg"></p>';
	   		login += '<table  align="center">';
	   		login += '<tr><td >用户名或Email：</td><td class="td_con"><input type="text" name="loginName" id="loginName" size="26" style="width:170px;height:15px"></td></tr>';
	   		login += '<tr><td >密　码：</td><td class="td_con"><input type="password" name="pwd" id="pwd" size="26" style="width:170px;height:15px"></td></tr>';
	   		login += '<tr><td colspan="2" align="center"><input type="image" src="/images/button_dl.gif"/ style="margin-top:10px;margin-bottom:10px;"></td></tr>';
	   		login += '<tr><td colspan="2" align="center">有任何疑问请点击 <a class="carlink" href="">帮助中心</a> 或  联系客服 0871-8369663</td></tr>';
			login += '</table><input name="criticism" id="criticism"  type="hidden"/>';
			login += '</form>';
			login += '</div>';
	
	
	
	
	function loginClick(){
		var username = $.trim($('#loginName').val());
        var password = $.trim($('#pwd').val());
        
        if(username == ''){
        	alert("请输入登陆用户名或Email");
        	return false;
        }
         if(password == ''){
        	alert("请输入登陆密码");
        	return false;
        }
        
        $.ajax({
			type: "POST",
			url: "/member.shtml?method=ajaxLogin&username="+encodeURI(encodeURI(username))+"&password="+encodeURI(encodeURI(password))+"&time="+new Date().getTime(),
			dataType:"text",
			async:false,
			success: function(data){ 
				if("suc" == data) {
					alert("登陆本站成功!");
					$(".jqidefaultbutton").click();
					document.location.reload();
				} else {
					alert("密码不正确!");
					$('#pwd').attr("value","");
				}
			} 
		});
        return false;
	}
	
	/**
	* 产品回答
	**/
	function proMessage(){
		var msg = $.trim($('#msg').val());
	    var title = $.trim($('#title').val());
	    var memberid = $("#memberid").val();
	    var productid = $("#productid").val();
	    if(title == ''){
	    	alert("标题不能为空！");
	    	$('#title').focus();
	    	return false
	    }
	    if(msg == ''){
	    	alert("评论内容不能为空！");
	    	$('#msg').focus();
	    	return false;
	    }
	    
	    $.ajax({
			type: "POST",
				url: "/index.shtml?method=productMessage"+"&time="+new Date().getTime(),
				data:"productid="+productid+"&memberid="+memberid+"&title="+encodeURI(encodeURI(title))+"&msg="+encodeURI(encodeURI(msg)),
				async:false,
					success: function(msg){ 						
						if(msg != '谢谢您的题问,管理员会尽快给你回复'){
						alert(msg);
					}else{
						alert(msg);
						$('#title').attr("value","");
						$('#msg').attr("value","");
					}							
				 	} 
		});
	}
	
	
	
	function customPropertyInit(groupId,propertylist){
		//按选择标签组ID 加载到页面中
		$.ajax({
				type: "POST",
					url: "/group.shtml?method=updateInitProperty"+"&time="+new Date().getTime(),
					data:"groupId="+groupId+"&propertylist="+propertylist,
					dataType:"json",
					async:false,
						success: function(msg){ 						
							if(msg == '请选择商品自定义属性!'){
							alert(msg);
						}else{								
							var showNode = $("#show");	
							//根据返回的json 添加到HTML中
							for(var i=0; i<msg.length; i++) {
							    var value = msg[i].defaultValue;
								if(value != ''){
									showNode.append("<strong>"+msg[i].name+"：</strong>").append(value+"&nbsp;&nbsp;&nbsp;&nbsp;<br>");
								}
							}	
													
							}
					 	} 
			});
		}
		
		
		
		//产品评论
		function mysubmitfunc(v,m,f){
	      var content = $.trim($('#content').val());
	      var quality=$("input[name='quality']:checked").val();
		  var serve= $("input[name='serve']:checked").val();
		  var member = $("#memberid").val();
		  var productid = $("#productid").val();
	      if(content==''){
	      	alert('请输入评论内容!')
	      	return false;
	      }
	      if(quality==undefined || quality == ''){
			alert("请评论一下商品量质信息");
			return false;
		  }
		  if(serve==undefined  || serve == ''){
			alert("请评论一下店家的服务");
			return false;
		  }
		  if(member == ''){
		  	$.prompt(login,{submit: loginsubmitfunc, buttons:{'关 闭':false}});
		  	$(".jqi").css("width","400");
		  }else{
		  	//验证此用户是否 购买过产品
		  	$.ajax({
				type: "POST",
				url: "/index.shtml?method=productIsMember&time="+new Date().getTime(),
				data:"productid="+productid+"&memberid="+member,
				dataType:"text",
				async:false,
				success: function(data){ 
					if("false" == data) {
						$.prompt("对不起你没购买过此商品或此商品订单还未［完成］,暂时不能为些商品添加评论",{submit: loginsubmitfunc, buttons:{'关 闭':false}});
					}else{
						var synthesis = $("#zonghegrade");   //综合
						var comfort = $("#shushidugrade"); 	//舒适度shushidugrade
						var styles = $("#yangshigrade"); 	//样式yangshigrade
						$.ajax({
								type: "POST",
								url: "/index.shtml?method=productScore&time="+new Date().getTime(),
								data:"productid="+productid+"&content="+encodeURI(encodeURI(content))+"&quality="+encodeURI(encodeURI(quality))
								+"&memberid="+member+"&serve="+encodeURI(encodeURI(serve))+"&synthesis="+synthesis.val()+"&comfort="+comfort.val()+"&styles="+styles.val(),
								dataType:"text",
								async:false,
								success: function(data){ 
									alert(data);
								} 
							});
						
						
					}
				} 
			});
		  } 	     
	      return true;
		}
		
		//加入收藏夹
		function AddFavorite(sURL, sTitle)
		{
		    try
		    {
		        window.external.addFavorite(sURL, sTitle);
		    }
		    catch (e)
		    {
		        try
		        {
		            window.sidebar.addPanel(sTitle, sURL, "");
		        }
		        catch (e)
		        {
		            alert("加入收藏失败，请使用Ctrl+D进行添加");
		        }
		    }
		}
		
		
		//购物车
		//提交到购物车
		function submit_cat(productid,integral,num){
			var numNode; //购买数量
			if(num != '' && num != undefined){
				numNode = num;
			}else{
				numNode = $("#comnum").val();
			}
			
			//判断购买数量是否为数字
			if(isNaN(numNode)){
				alert('购买数量请填写数值型数据');
				return;
			}else{
				if(numNode.charAt(0)=='-' || numNode==0){
					alert('购买数量必需要大于0');
					return;
				}
				
				
				//检查库存数
				$.ajax({
					type: "POST",
					url: "/index.shtml?method=productIsQuantity&time="+new Date().getTime(),
					data:"productid="+productid+"&count="+numNode,
					dataType:"text",
					async:false,
					success: function(data){ 
						if(data != ''){
							alert(data);
							return;
						}else{
							//var url = 
							//判断商品是不是积分商城来的
							//if(integral>0){
							//	window.location.href = '/order.shtml?method=integral_buy&productId='+productid+'&count='+numNode;
							//}else{
								window.location.href = '/order.shtml?method=buy&productId='+productid+'&count='+numNode;
							//}
						}
					} 
				});
			}
			
		}
		
		
		function submit_diy(productid,num){
			var numNode; //购买数量
			var claimNode = $("#claim");
			
			if(claimNode.val() == '' || claimNode.val() == undefined){
				alert('请填写您的制作要求及添加其他DIY商品');
				claimNode.focus();
				return ;
			}
			
			if(num != '' && num != undefined){
				numNode = num;
			}else{
				numNode = $("#comnum").val();
			}
			
			//判断购买数量是否为数字
			if(isNaN(numNode)){
				alert('购买数量请填写数值型数据');
				return;
			}else{
				if(numNode.charAt(0)=='-' || numNode==0){
					alert('购买数量必需要大于0');
					return;
				}
				
				var fromNode = $("#diy_from");
				fromNode.attr("action",'/order.shtml?method=buy&productId='+productid+'&count='+numNode);
				fromNode.submit();
			}
			
		}
		
		//分出文件名
		function getExtName(fileName){
		    if(fileName.lastIndexOf(".")<0) return "";
		    return fileName.substring(fileName.lastIndexOf(".")+1,fileName.length).toLowerCase();
		}
		
		//判断文件是否为jpg
		function previewPic(upfilename){
		
		  var upfile = document.getElementById(upfilename);
		  if (upfile != "") {
		    var extname = getExtName(upfile.value);
		    if(extname != "jpg" && extname != "gif" && extname != "jpeg"){
		      upfile.value = "";
		      alert("请选择jpg/gif类型的图片");
		    }else{
		      document.getElementById('faceImg').setAttribute("src",upfile.value);
		    }
		  }
		}
		
		function fixTo(s,i){   
		  if   (s==null   ||   s==""   ||   isNaN(s)   ||   Math.round(s)==0)  return   '0';   
		  i   =   Math.round(i);   
		  if   (i==0)   return   Math.round(s);   
		  if   (i==null   ||   isNaN(i)   ||   i<0)   i=2;   
		  var   v   =   Math.round(s*Math.pow(10,i)).toString();   
		  if   (/e/i.test(v))   return   s;   
		  return   v.substr(0,v.length-i)+"."+v.substr(v.length-i);   
		} 
		
		//邮件订阅
		function subscibeEmail(){
			var emailNode = $("#subscibe_email");
			var emailValue = emailNode.val();
			if(emailValue == '' || emailValue == '请输入E-mail地址'){
				alert('请输入E-mail地址');
				return false;
			}else{
				var emailPat=/^(.+)@(.+)$/;
				var matchArray=emailValue.match(emailPat);
				
				if (matchArray==null){
				   alert('请输入正确的E-mail地址');
				   return false;
				}else{
					$.ajax({
					type: "POST",
					url: "/member.shtml?method=subscibeEmail&time="+new Date().getTime(),
					data:"subscibe_email="+encodeURI(encodeURI(emailValue)),
					dataType:"text",
					async:false,
					success: function(data){ 
						if(data != ''){
							alert(data);
							emailNode.attr("value","请输入E-mail地址");
							return;
						}
					} 
				});
				}
			}
			
		}
		
		//找回密码
		function getPwdbyEmail(){
			var emailValue = $("#email2").val();
			if(emailValue != '' && emailValue != undefined){
				$.ajax({
					type: "POST",
					url: "/member.shtml?method=getQuestionByEmail&time="+new Date().getTime(),
					data:"email="+encodeURI(encodeURI(emailValue)),
					dataType:"text",
					async:false,
					success: function(data){ 
						if(data != 'false'){
							ChkSelected(document.getElementById('question'),data);
							return;
						}
					} 
				});
			}
		}
		function ChkSelected(Obj,Val)
		{
			if (Obj)
			{
				for (i=0;i<Obj.length;i++){
					if (Obj.options[i].value==Val){
					Obj.options[i].selected=true;
					break;
					}
				}
			}
		}
		
		function tab(type){
			var menu=document.getElementById(type);
			menu.className="hover";
		}
		
		function nav(type){
			var menu=document.getElementById(type);
			menu.className="hover";
		}
		
