/*  设置点击切换行样式*/
$(document).ready(function(){ 
	$("div[@name='item']").click(function(){ //在点击后切换div_bs_的class
   	$(this).toggleClass("div_bs__");});
	$("input[@name='gms'],span[@name='ljhz']").click(function(){  //阻止点击input和获知商家也切换class
	return false;});
	
	
	$('img[@name="log"]').click(function() {
   	     //
		 if(confirm("您需要登录后才能购买！点击“确定”打开登陆页面进行登陆。点击“取消”继续浏览。")){
		 	open("logon.asp");
		 };
	}); 



});

function gms_err(huohao)
{
	$("#err_"+huohao+"").html("请填写正确的商品数量");
	setTimeout(function(){$("#err_"+huohao+"").html("");},2000);
}
function gms_err2(huohao)
{
	$("#err_"+huohao+"").html("不能大于库存数量");
	setTimeout(function(){$("#err_"+huohao+"").html("");},2000);
}


function edi_sl(user_id,huohao,sl,cp_id,cp_jg,biaoqs)  //实时修改数量  用户ID，货号，购买数量，产品ID，产品价格
{
	$("#g_"+huohao+"").html("<img src='img/g.gif'>");
	//alert(user_id+huohao+sl)
	if(sl == "" || sl == 0){
		sl = 0;
		$("input[@name='xg_biaoqian_"+huohao+"']").attr('checked',0); //如果数量变成0，就取消标签的勾勾
	}
	var biaoqians = $("#biaoqian_num_"+huohao+"").html();
	$.post('edi_sl.asp',{
		user_id: user_id,
		huohao: huohao,
		sl: sl,
		cp_id: cp_id,
		cp_jg: cp_jg,
		biaoqians: biaoqians},
		function(data){
		//alert(data);//返回echo $_POST['a']+$_POST['b'];
		$(".lay2").html(""+data+"");
		$("#g_"+huohao+"").html("<img src='img/gg.gif'>");
		//根据返回的数量来修改标签选购数
		$("#biaoqian_num_"+huohao+"").html(""+parseInt(biaoqs)*parseInt(sl)+"");
		$("#biaoqian_"+huohao+"").attr("class","biaoqian_ts2").html("恭喜！您选购的"+parseInt(biaoqs)*parseInt(sl)+"枚中文标签已经放进了购物车。");
	});
}

//选购中文标签
function biaoqian_xg(user_id,huohao){
	//先查看此人购物车里是否已经至少已经有一盒了
	if($("input[@name='xg_biaoqian_"+huohao+"']").attr('checked')) //如果是勾上选购框
	{
		if($("input[@name='gms_"+huohao+"']").val() == "" || $("input[@name='gms_"+huohao+"']").val() < 1)  //如果当前还没有买
		{
			$("input[@name='xg_biaoqian_"+huohao+"']").attr("checked",0);
			$("#biaoqian_"+huohao+"").attr("class","biaoqian_ts3").html("抱歉！须先购买本品后，才能订购中文标签。").show();
		}else{
			var biaoqians = $("#biaoqian_num_"+huohao+"").html();
			$.post('biaoqian_xg.asp',{user_id: user_id,huohao: huohao,xg: "1",biaoqians: biaoqians},function(data){
				$("#biaoqian_"+huohao+"").show();
			});
		}
	}else{  //如果是取消选购框
		var biaoqians = $("#biaoqian_num_"+huohao+"").html();
		$.post('biaoqian_xg.asp',{user_id: user_id,huohao: huohao,xg: "0",biaoqians: biaoqians},function(data){
			//$("#biaoqian_"+huohao+"").show();
		});

		$("#biaoqian_qx_"+huohao+"").show();
		setTimeout(function(){$("#biaoqian_qx_"+huohao+"").fadeOut("slow");},2000);
	}
	setTimeout(function(){$("#biaoqian_"+huohao+"").fadeOut("slow");},3000);
}

function huiche(huohao)  //截获回车键并模拟Tab键
{
		if (window.event.keyCode==13) window.event.keyCode=9;
}

function jihuo(huohao)  //数量框获得焦点
{
	$("#g_"+huohao+"").html("<input style='height:20px;' type='button' value='提交'>");
}

//立即查看批发价
document.onclick = eVclick;
function eVclick(event)
{  
	event = (event == null)?window.event:event;  
	var srcelement= event.target?event.target:event.srcElement;  
	if(srcelement.getAttribute("Author")==null){closeFloatobj(document.getElementById("floatObj"));}
}
function openFloatobj(obj,thi)
{
    var x = thi.offsetLeft;    
    var y = thi.offsetTop;    
    while(thi = thi.offsetParent)
	{
        x += thi.offsetLeft;    
        y += thi.offsetTop;    
    }
	obj.style.display = 'block';
	obj.style.left=(x+65)+"px";
	obj.style.top=(y-45)+"px";
}
function closeFloatobj(obj){obj.style.display = 'none';} 

