$(document).ready(function(){
						   
$('#yes').click(function() {             
            var tempTitle = escape($("#txtTitle").val());
            var tempText = escape($("#txaAddText").html());
			var tepmInputcode=escape($("#Code").val());
			var tempName = escape($("#NickName").val());
			var tempEmail = escape($("#Email").val());
			var UpStr = "UserName="+tempName;
				UpStr += "&Email="+tempEmail;
				UpStr += "&Title="+tempTitle;
				UpStr += "&Content="+tempText;
				UpStr += "&Code="+tepmInputcode;
            $.ajax({ 
				type: "post",  
				url : "/guestbook_ok.php?Action=feedback&"+UpStr, 
				dataType:'json',
				cache: false,
				success: function(json){
                $.blockUI({ message: "<h3>"+json.msg+"</h3><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>",css:{padding:	'10px',
		margin:		0,
		width:		'30%',
		top:		'40%',
		left:		'35%',
		textAlign:	'center',
		color:		'#000',
		border:		'3px solid #aaa',
		backgroundColor:'#fff'} }); 
				
		if(json.icon=='n'){
				$("#NickName").val("");
				$("#Email").val("");
				$("#txtTitle").html("");
				$("#txaAddText").html("");
				$("#Code").val("");
			}
				         
                          }  
            }); 
        }); 
});


function MessageRe(newsid,doAction){
$('#newsRe').click(function() {             
            var tempText = escape($("#txaAddText").html());
			var tepmInputcode=escape($("#Code").val());
			var tempName = escape($("#NickName").val());
			var tempEmail = escape($("#Email").val());
			var UpStr = "UserName="+tempName;
				UpStr += "&Email="+tempEmail;
				UpStr += "&newsid="+newsid;	
				UpStr += "&Content="+tempText;
				UpStr += "&Code="+tepmInputcode;
               $.ajax({ 
				type: "post",  
				url : "/guestbook_ok.php?Action="+doAction+"&"+UpStr, 
				dataType:'json',
				cache: false,
				success: function(date){
                $.blockUI({ message: "<h4>"+date.message+"</h4><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>",css:{padding:'10px',
		margin:		0,
		width:		'30%',
		top:		'40%',
		left:		'35%',
		textAlign:	'center',
		color:		'#000',
		border:		'3px solid #aaa',
		backgroundColor:'#fff'} }); 
				
		reloadCode();
		$("#txaAddText").html("");
		$("#Code").val("");
			
				         
                          }  
            });  
        }); 	
	}
	
function chklogin(){
$('#login').click(function() {             
            var tempName = escape($("#UserName").val());
			var tempPws = escape($("#Password").val());
			var tepmInputcode=escape($("#Code").val());
            
			var UpStr = "Password="+escape(tempPws);            
            UpStr += "&UserName="+tempName;
			UpStr += "&Code="+tepmInputcode;
            $.ajax({ 
				type: "post",  
				url : "/CheckLogin.php?"+UpStr, 
				dataType:'json',
				cache: false,
				success: function(data){
                $.blockUI({ message: "<h3>"+data.msg+"</h3><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>",css:{padding:	'10px',
		margin:		0,
		width:		'30%',
		top:		'40%',
		left:		'35%',
		textAlign:	'center',
		color:		'#000',
		border:		'3px solid #aaa',
		backgroundColor:'#fff'}
		}); 
			if(data.msg=='登录成功'){	
			$("#UserName").val("");
            $("#Password").val("");
		    $("#Code").val("");
			window.location.href="/my_info.php/index.html"}		
				}
            }); 
        }); 	
	}	


function register(){
$('#reg').click(function() { 
			var ac=$("#RegName").val();
			var pwd=$("#RegPwd").val();
			
			//var rule=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
//			if (!rule.test(ac)){
//			alert("用户名必须为有效邮箱!");
//			return false();
//			}
//			
			
			if(pwd==''){
			alert("密码不能为空");
			return false();
				}
				
			if(pwd.length<6 || pwd.length>18)
			{
			alert("密码介于6-18个字符间");
			return false();
			}	
			if($("#RegPwd").val()!=$("#RegPwd2").val()){
				alert("两次密码不一致"); 
				return false();
				}			 
            var tempName = escape($("#RegName").val());
			var tempPws = escape($("#RegPwd").val());
			var tepmInputcode=escape($("#RegCode").val());
            
			var UpStr = "RegPwd="+escape(tempPws);            
            UpStr += "&RegName="+tempName;
			UpStr += "&Code="+tepmInputcode;
            $.ajax({ 
				type: "post",  
				url : "/guestbook_ok.php?Action=register&"+UpStr, 
				dataType:'json',
				cache: false,
				success: function(data){
                $.blockUI({ message: "<h3>"+data.msg+"</h3><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>",css:{padding:	'10px',
		margin:		0,
		width:		'30%',
		top:		'40%',
		left:		'35%',
		textAlign:	'center',
		color:		'#000',
		border:		'3px solid #aaa',
		backgroundColor:'#fff'}
		}); 
				
		$("#RegName").val("");
		$("#RegPwd").val("");
		$("#RegPwd2").val("");
		$("#RegCode").val("");
					
                  }  
            }); 
        }); 	
	}		
function ToBuy(pid){
            
        var r = /^[1-9]*[1-9][0-9]*$/
		var _values = document.getElementById("buyNum").value;
		if(_values=="")
		{
			alert("请输入购买的数量！");
			return false();
		}
		
		if(_values.indexOf(".")>=0)
		{
			alert("不能输入小数点!");
			return false();
		}
		if(!r.test(_values)){ 
			alert("请输入正整数!");
			return false(); 
		} 
            
		window.location.href="/cart.php?Action=Add&VID="+pid+"&buyNum="+_values;	
                            
	
}
function numReduce(){
	var cc=document.getElementById("buyNum").value;
	if(cc>1){
		document.getElementById("buyNum").value--;
	}else{
		alert("数值不能低于1");
	}
}
function numAdd(){
	document.getElementById("buyNum").value++;
}

