	function BuyEnter_Submit(e) {
		var c = 0;
		if (navigator.appName == "Microsoft Internet Explorer"){
			c = event.keyCode;
		}else{
			c = e.keyCode;
		}
		if (c == 13) {
			check_url();
		}
	}
 
	function check_url(){
		var textfield = $.trim($("#textfield").val());
		if((textfield.length <= 0)||(textfield == "http://") ){
			$("#head_buy h1").removeClass("tips_word").addClass("error_word").text("您没有输入任何信息。");
			$("#textfield").focus();
		}else{
			var j=new RegExp("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?");
			if((textfield.indexOf("http://") < 0)&&(textfield.indexOf("https://")<0)){
				textfield="http://"+textfield;
			}
			if(j.test(textfield)){
				check_login(); //判断是否登录
			}else{
				$("#head_buy h1").removeClass("tips_word").addClass("error_word").text("呀！链接地址不准确，请您核实后填写哦。");
				$("#textfield").val("");
				$("#textfield").focus();
			}
		}
	}
	
	function check_login(){
		$.ajax({
			type: "post",
			dataType: "text",
			data: null,
			url: "/ajax_login.php?act=check_login",
			success: function(data){
				//alert(data);
				if(data == "1"){
					$float({width:800,height:550,showClose:true,iframe:'/quick_buy/index.php?act=quick_login',title:'快速登录',fix:true,cover:true});
				}else{
					$float({width:800,height:550,showClose:true,iframe:'/quick_buy/index.php?act=buy',title:'快速代购',fix:true,cover:true});
				}
			},
			error: function(msg){
				alert('对不起,请求服务器失败');
			}
		});
	}
	
	function clear_value(){
		$("#tips_buybox").show();
	}
	
	function return_value(){
		$("#tips_buybox").hide();
	}
    

	function my_daigou(urlid){
		$.ajax({
			type: "post",
			dataType: "text",
			data: null,
			url: "/ajax_login.php?act=check_login",
			success: function(data){
				//alert(data);
				if(data == "1"){
					$float({width:800,height:550,showClose:true,iframe:'/click_buy/index.php?act=quick_login&urlid='+urlid,title:'快速登录',fix:true,cover:true});
				}else{
					$float({width:800,height:550,showClose:true,iframe:'/click_buy/index.php?act=buy&urlid='+urlid,title:'快速代购',fix:true,cover:true});
				}
			},
			error: function(msg){
				alert('对不起,请求服务器失败');
			}
		});
	}
    // Check Buy
function check_buy(e)
{
	var msg;
	var text_cart_p_url="";
	var text_cart_p_name="";
	var text_cart_p_price="";
	var text_cart_p_shipping_fee="";
	var text_cart_p_num="";
	var text_cart_p_note="";
	var text_cart_p_saler='';
	var fg=1;

	var show_saler_style = document.getElementById('show_saler_input').style.display;

	if ((e.cart_p_url.value == null) || (e.cart_p_url.value == "") || isblank(e.cart_p_url.value)) { text_cart_p_url = "请填写商品页网址.\n"; fg=0;}
	if ((e.cart_p_name.value == null) || (e.cart_p_name.value == "") || isblank(e.cart_p_name.value)) { text_cart_p_name = "请填写商品名称.\n"; }
	if ((e.cart_p_price.value == null) || (e.cart_p_price.value == "") || isblank(e.cart_p_price.value) || e.cart_p_price.value < 0.01) { text_cart_p_price = "请填写商品价格.\n"; }
	if ((e.cart_p_shipping_fee.value == null) || (e.cart_p_shipping_fee.value == "") || isblank(e.cart_p_shipping_fee.value)) { text_cart_p_shipping_fee = "请填写国内运费.\n"; }
	if ((e.cart_p_num.value == null) || (e.cart_p_num.value == "") || isblank(e.cart_p_num.value) || e.cart_p_num.value < 1) { text_cart_p_num = "请填写商品数量.\n"; }
	//if ((e.cart_p_note.value == null) || (e.cart_p_note.value == "") || isblank(e.cart_p_note.value)) { text_cart_p_note = "请填写您的备注.\n"; }

	if (e.cart_p_url.style) e.cart_p_url.style.backgroundColor = text_cart_p_url != "" ? '#ffffcc':'#FFFFFF'; 
	if (e.cart_p_name.style) e.cart_p_name.style.backgroundColor = text_cart_p_name != "" ? '#ffffcc':'#FFFFFF';
	if (e.cart_p_price.style) e.cart_p_price.style.backgroundColor = text_cart_p_price != "" ? '#ffffcc':'#FFFFFF';
	if (e.cart_p_shipping_fee.style) e.cart_p_shipping_fee.style.backgroundColor = text_cart_p_shipping_fee != "" ? '#ffffcc':'#FFFFFF';
	if (e.cart_p_num.style) e.cart_p_num.style.backgroundColor = text_cart_p_num != "" ? '#ffffcc':'#FFFFFF';
	//if (e.cart_p_note.style) e.cart_p_note.style.backgroundColor = text_cart_p_note != "" ? '#ffffcc':'#FFFFFF';

	if(show_saler_style != 'none')
	{
		if ((e.cart_p_saler.value == null) || (e.cart_p_saler.value == "") || isblank(e.cart_p_saler.value) || e.cart_p_saler.value == '0') { text_cart_p_saler = "请填写卖家名称.\n"; }
		if (e.cart_p_saler.style) e.cart_p_saler.style.backgroundColor = text_cart_p_saler != "" ? '#ffffcc':'#FFFFFF';
	}

	
	if (text_cart_p_url == "" && text_cart_p_name == "" && text_cart_p_price == "" && text_cart_p_shipping_fee == "" && text_cart_p_num == "" && text_cart_p_saler == "") 
	{ 
		e.submit(); 
        return true; 
	}
	else { msg = text_cart_p_url+text_cart_p_saler+text_cart_p_name+text_cart_p_price+text_cart_p_shipping_fee+text_cart_p_num;	} 
	
	alert(msg);
	return false;
}
function isblank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

