/*
**Name:dsc-common.js
**Author:ecmoban Team sunle
**Description:Commonly used JS
**Date:2017-02-06 15:30:30
*/
 
/* 全局变量 */ 
var user_id = $("input[name='user_id']").val(), //会员ID
	goods_id = 0,	//商品ID
	ru_id = 0,		//商家ID
	store_id = 0,	//门店ID
	hoverTimer = '',
	outTimer = '',
	doc = $(document);
	
$(function(){
	/************************************** 通用内容start ****************************************/
	// 顶部快捷栏 地区切换 and 网站导航
	$("*[data-ectype='dorpdown']").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	//顶部快捷栏 地区选择
	$("*[data-ectype='dorpdown'] *[ectype='dsc-choie']").on("mouseenter",function(){
		$("*[ectype='dsc-choie-content']").html(load_cart_info);
		$.jqueryAjax('get_ajax_content.php', 'act=insert_header_region', function(data){
			if(data.content){
				$("*[ectype='dsc-choie-content']").html(data.content);
			}
		});
	});
	
	// 面包屑
	$(".crumbs-nav-item .menu-drop").hover(function(){
		$(this).addClass("menu-drop-open");
	},function(){
		$(this).removeClass("menu-drop-open");
	});
	
	//返回顶部
	doc.on("click","[ectype='returnTop']",function(){
		$("body,html").animate({scrollTop:0});
	});
	
	//top_banner关闭
	$("*[ectype='close']").click(function(){
		$(this).parents(".top-banner").hide();
	});
	
	//底部二维码切换
	$(".help-scan .tabs li").hover(function(){
		var t = $(this);
		var index = t.index();
		t.addClass("curr").siblings().removeClass("curr");
		$(".code").find(".code_tp").eq(index).show().siblings().hide();
	});
	
	//价格筛选
	$(".fP-box input").click(function(){
		$('.fP-expand').show();
	});
	
	//价格筛选提交
	$('.ui-btn-submit').click(function(){
		var min_price = Number($(".price-min").val());
		var max_price = Number($(".price-max").val());
		
		if(min_price == '' && max_price == ''){
			pbDialog(json_languages.screen_price,"",0);
			return false;
		}else if(min_price == ''){
			pbDialog(json_languages.screen_price_left,"",0);
			return false;
		}else if(max_price == ''){
			pbDialog(json_languages.screen_price_right,"",0);
			return false;
		}else if(min_price > max_price || min_price == max_price){
			pbDialog(json_languages.screen_price_dy,"",0,"","",70);
			return false;
		}
		$("form[name='listform']").submit();
	});
	
	$('.ui-btn-clear').click(function(){
		$("input[name='price_min']").val('');
		$("input[name='price_max']").val('');
	});
	
	//优惠活动价格筛选提交(团购、夺宝奇兵等)
	$('.ui-btn-submit').click(function(){
		$("form[name='listform']").submit();
	});
	//头部搜索
	$.inputPrompt("#keyword",true,$('#keyword').val());
	$.inputPrompt("#keyword2",true,$('#keyword2').val());
	
	//导航栏全部分类展开
	$("*[ectype='cateItem']").on('mouseenter',function(){
		var T = $(this),
			cat_id = T.data('id'),
			eveval = T.data('eveval'),
			layer = T.find("*[ectype='cateLayer']");
		
		if(eveval != 1){
			T.data('eveval', '1');
			/*加载中by wu*/
			layer.find("*[ectype='cateLayerCon_" + cat_id + "']").html(' ');
			$.ajax({
			   type: "GET",
			   url: "ajax_dialog.php",
			   data: "act=getCategoryCallback&cat_id=" + cat_id,
			   dataType:'json',
			   success: function(data){
			   		if(data.has_child == 0){
			   			T.find("*[ectype='cateLayer']").addClass("cateLayer_items_all");
			   		}else{
						T.find("*[ectype='cateLayer']").removeClass("cateLayer_items_all");
			   		}
					var channels = $("*[ectype='cateLayerCon_" + data.cat_id + "']");
					channels.html(data.cat_content);
			   }
			});
		}
		T.addClass("selected");
		layer.show();
	}).on("mouseleave",function(){
		var T = $(this),layer = T.parent().find("*[ectype='cateLayer']");
		T.removeClass("selected");
		layer.hide();
	});
	
	//顶级分类展开(女装模板)
	$("*[ectype='items'] *[ectype='item']").on('mouseenter',function(){
		var T = $(this),
			cat_id = T.data('catid'),
			eveval = T.data('eveval'),
			layer = T.find("*[ectype='cateLayer']"),
            defa = '';
		if(T.data('defa')){
			defa = T.data('defa');
		}
		if(eveval != 1){
			T.data('eveval', '1');
			/*加载中by wu*/
			layer.find("*[ectype='subitems_" + cat_id + "']").html('
');
			$.ajax({
			   type: "GET",
			   url: "ajax_dialog.php",
			   data: "act=getCategoryCallback&cat_id=" + cat_id,
			   dataType:'json',
			   success: function(data){
			   		if(data.has_child == 0){
			   			T.find("*[ectype='cateLayer']").addClass("cateLayer_items_all");
			   		}else{
						T.find("*[ectype='cateLayer']").removeClass("cateLayer_items_all");
			   		}
					var channels = $("*[ectype='cateLayerCon_" + data.cat_id + "']");
					channels.html(data.cat_content);
			   }
			});
		}
		T.addClass("selected");
		layer.show();
	}).on("mouseleave",function(){
		var T = $(this),layer = T.parent().find("*[ectype='cateLayer']");
		T.removeClass("selected");
		layer.hide();
	});
	
	//顶级分类展开(女装模板)
	$("*[ectype='items'] *[ectype='item']").on('mouseenter',function(){
		var T = $(this),
			cat_id = T.data('catid'),
			eveval = T.data('eveval'),
			layer = T.find("*[ectype='cateLayer']"),
            defa = '';
		if(T.data('defa')){
			defa = T.data('defa');
		}
		if(eveval != 1){
			T.data('eveval', '1');
			/*加载中by wu*/
			layer.find("*[ectype='subitems_" + cat_id + "']").html(' ');
			$.ajax({
			   type: "GET",
			   url: "get_ajax_content.php",
			   data: "act=getCategotyParentTree&cat_id=" + cat_id + "&defa=" + defa,
			   dataType:'json',
			   success: function(data){
				 $("*[ectype='subitems_" + data.cat_id + "']").html(data.brands_content);
			   }
			});
		}
		T.addClass("selected");
		layer.show();
	}).on("mouseleave",function(){
		var T = $(this),layer = T.parent().find("*[ectype='cateLayer']");
		T.removeClass("selected");
		layer.hide();
	});	
	
	//b2b二级导航展开
	$(".b2b-categorys-content li").hover(function(){
		var T = $(this),layer = T.find("*[ectype='cateLayer']");
		layer.show();
	},function(){
		var T = $(this),layer = T.find("*[ectype='cateLayer']");
		layer.hide();
	});
	
	//点击空白处隐藏展开框	
	$(document).click(function(e){
		//购物车更多促销活动
		if(e.target.className !='sales-promotion' && !$(e.target).parents("div").is("[ectype='promInfo']")){
			$("[ectype='promInfo']").removeClass("prom-hover");
		}
		
		if(e.target.id !='price-min' && e.target.id !='price-max'){
			$('.fP-expand').hide();
		}
		
		//仿select
		if(e.target.className !='cite' && !$(e.target).parents("div").is(".imitate_select")){
			$('.imitate_select ul').hide();
		}
		
		if(e.target.id !='btn-anchor' && !$(e.target).parents("div").is(".tb-popsku")){
			$('.tb-popsku').hide();
		}
		
		//首页弹出广告
		if(e.target.className == 'ejectAdvbg' && !$(e.target).parents("div").is(".ejectAdvimg")){
			$("*[ectype='ejectAdv']").hide();
		}
	});
	
	$(".value-item").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");
	});
	
	//div仿select下拉选框 start
	$(document).on("click",".imitate_select .cite",function(){
		$(".imitate_select ul").hide();
		$(this).parents(".imitate_select").find("ul").show();
		$(this).siblings("ul").perfectScrollbar("destroy");
		$(this).siblings("ul").perfectScrollbar();
	});
	
	$(document).on("click",".imitate_select li  a",function(){
		var _this = $(this);
		var val = _this.data('value');
		var text = _this.html();
		_this.parents(".imitate_select").find(".cite span").html(text).css("color","#707070");
		_this.parents(".imitate_select").find("input[type=hidden]").val(val);
		_this.parents(".imitate_select").find("ul").hide();
	});
	//div仿select下拉选框 end
	
	//input获得焦点加样式
	$("input.text").focus(function(){
		$(this).parents(".item").addClass("item-focus");
	});
	
	$("input.text").blur(function(){
		$(this).parents(".item").removeClass("item-focus");
	});
	
	/*****************************右侧黑色悬浮栏内容点击触发事件start***************************************/
	//移动图标出现文字提示
	$(".quick_links_panel li").hover(function(){
		$(this).find(".mp_tooltip").stop().animate({left:-92,queue:true});
		$(this).find(".mp_tooltip").css("visibility","visible");
		$(this).find(".ibar_login_box").show();
	},function(){
		$(this).find(".mp_tooltip").css("visibility","hidden");
		$(this).find(".mp_tooltip").stop().animate({left:-121,queue:true});
		$(this).find(".ibar_login_box").hide();
	});
	
	//点击图标判断用户是否登录
	$(".quick_links li").find("a").click(function(){
		var $this = $(this),
			user_id = $this.parents(".quick_link_mian").data("userid");
		
		if(user_id < 1 && !$this.hasClass('cart_list') && !$this.hasClass('mpbtn_history') && !$this.hasClass('mpbtn_email')){
			$.notLogin("get_ajax_content.php?act=get_login_dialog",'');
			return false;
		}
	});
	
	//点击展开邮箱订阅
	$(".mpbtn_email").click(function(){
		var obj = $(".email_sub");
		if(obj.hasClass("show")){
			obj.removeClass("show");
		}else{
			obj.addClass("show");
		}
	});
	
	//判断浏览器下滚还是上滚,向上滚动邮箱验证隐藏
	$(document).ready(function(){
		var p=0,t=0;
		var obj = $(".email_sub");
		$(window).scroll(function(e){
			p = $(this).scrollTop();
			if(t<=p){
				if(obj.hasClass("show")){
					obj.addClass("show");
				}
			}else{
				obj.removeClass("show");
			}
			setTimeout(function(){t = p;},0);		
		});
	});
	/*****************************右侧黑色悬浮栏内容点击触发事件end***************************************/
	
	//关注品牌
	$(document).on("click","*[ectype='coll_brand']",function(){
		var user_id = $("input[name=user_id]").val();
		if(user_id > 0){
			var brand_id = $(this).data('bid');
			if($(this).find("i").hasClass("icon-zan-alts")){
				$(this).find("i").removeClass("icon-zan-alts").addClass("icon-zan-alt");
				$(this).find("*[ectype='follow_span']").html("关注");
				Ajax.call('brandn.php', 'act=cancel&id=' + brand_id +'&user_id='+user_id, collect_brandResponse, 'POST', 'JSON');
			}else{
				$(this).find("i").removeClass("icon-zan-alt").addClass("icon-zan-alts");
				$(this).find("*[ectype='follow_span']").html("已关注");
				Ajax.call('brandn.php', 'act=collect&id=' + brand_id, collect_brandResponse, 'POST', 'JSON');
			}
		}else{
            var back_url = "brand.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);	
		}
	});
	
	//关注品牌回调函数
	function collect_brandResponse(result)
	{
        $("#collect_count").html(result.collect_count);
		$("#collect_count_"+result.brand_id).html(result.collect_count);;
	}
    
	//秒杀商品设置提醒
	$(document).on("click","*[ectype='collSecGoods']",function(){
		var user_id = $("input[name=user_id]").val();
		if(user_id > 0){
			var sid = $(this).data('id');
			if($(this).hasClass("sc-greenBg-btn")){
				$(this).removeClass("sc-greenBg-btn").addClass("sc-redBg-btn");
				$(this).html("取消提醒");
                Ajax.call('seckill.php', 'act=collect&sid=' + sid +'&user_id='+user_id, colSecGoodsResponse, 'POST', 'JSON');
			}
            else{
				$(this).removeClass("sc-redBg-btn").addClass("sc-greenBg-btn");
				$(this).html("提醒我");
				Ajax.call('seckill.php', 'act=cancel&sid=' + sid +'&user_id='+user_id, colSecGoodsResponse, 'POST', 'JSON');
			}
		}else{
            var back_url = "seckill.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);	
		}
	});
	
	//秒杀商品设置提醒回调函数
	function colSecGoodsResponse(result)
	{
        pbDialog(result.message,"",1,300,"80",50);
	} 	
	/****会员领取优惠券 start***/
	$(document).on("click",".get-coupon",function(){
		var cou_id = $(this).attr('cou_id');
                var coupon = '';
                if($(this).data('coupon')){
                    coupon = $(this).data('coupon');
                }
		receiveCoupon(cou_id,coupon);
	});
	
	function receiveCoupon(cou_id,coupon){
		if(user_id > 0){
			$.post('coupons.php?act=coupons_receive',{'cou_id':cou_id},function(data){
				if(data.status=='ok'){
                    $(".item-fore h3").html(data.msg);
                    $(".success-icon").removeClass("i-icon").addClass("m-icon");
					var content =$("#pd_coupons").html();
					pb({
						id:"coupons_dialog",
						title:json_languages.receive_coupons,
						width:550,
						height:140,
						ok_title:json_languages.Immediate_use, 	//按钮名称
						cl_title:json_languages.close, 	//按钮名称
						content:content, 	//调取内容
						drag:false,
						foot:true,
						onOk:function(){
							location.href="search.php?cou_id="+cou_id
						},
						onCancel:function(){
							$(".cou-data").html(data.content);
							$(".cou-seckill").html(data.content_kill);
                                                        $(".cou_shipping").html(data.content_shipping);
						},
					});
					
					$(".pb-ok").addClass("color_df3134");
				}else{
					$(".success-icon").removeClass("m-icon").addClass("i-icon");
					$(".item-fore h3").addClass("red");
					$(".item-fore h3").html(data.msg);
					var content =$("#pd_coupons").html();
					pb({
						id:"coupons_dialog",
						title:json_languages.receive_coupons,
						width:550,
						height:140,
						ok_title:json_languages.close, 	//按钮名称
						content:content, 	//调取内容
						cl_cBtn:false,
						onOk:function(){}
					});
				}
			},'json');
		}else{
			var back_url = "coupons.php?act=coupons_index";
			if(coupon == 1){
				back_url = 'coupons.php?act=coupons_info&id=' + cou_id;
			}
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
        	return false;
		}
	}
	/****会员领取优惠券 end***/
	
	
	/* 商品收藏 品牌关注 店铺关注 */
	$(document).on('click',"*[data-dialog='goods_collect_dialog']",function(){
		var url = $(this).data('url'),
			id = $(this).data('goodsid'),
			divId = $(this).data("divid"),
			width = 455,
			height = 58,
			content = "",
			goods_url = "",
			type = $(this).data("type");
		
		if(user_id == 0 && type == "goods"){
			goods_url = "goods.php?id=" + id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog", goods_url);
			return false;
		}
		
		if(id > 0){
			Ajax.call(url, 'id=' + id, function(data){
				if(data.error > 0){
					if(data.error == 2){
						$.notLogin("get_ajax_content.php?act=get_login_dialog", data.url);
						return false;
					}
					
					pbDialog(data.message,"",0,width,height,65,true,function(){
						location.href = "user.php?act=collection_list";
					},"会员中心");
					
				}else{
					$(".choose-btn-coll").addClass('selected');
					$(".choose-btn-icon").addClass('icon-collection-alt').removeClass('icon-collection');
					$("#collect_count").html(data.collect_count);
					
					pbDialog("您已成功收藏该商品!","",1,width,height,95,false,function(){
						location.href = "user.php?act=collection_list";
					},json_languages.My_collection);
				}
				
			}, 'GET', 'JSON');
		}else{
			if(divId == 'delete_goods_collect'){
				content = "您确定要取消收藏该商品吗?"; 
			}else if(divId == "delete_brand_collect"){
				content = "您确定要取消关注该品牌吗?"; 
			}else if(divId == "user_attention"){
				content = $(this).data("confirmtitle"); 
			}
			
			pbDialog(content,"",0,width,height,95,true,function(){
				location.href = url;
			});
		}		
	});
	
	/* 对比框隐藏 */
	$("[ectype='db_hide']").on("click",function(){
		$("#slideTxtBox").hide();
	});
	
	/* 对比 */
	var db_winWidth = $(window).width();
	var db_left = (db_winWidth-1200)/2;
	$("#slideTxtBox").css({"left":db_left});
	
	$(window).resize(function(){
		db_winWidth = $(this).width();
		if(db_winWidth>1200){
			db_left = (db_winWidth-1200)/2;
			$("#slideTxtBox").css({"left":db_left});
		}else{
			$("#slideTxtBox").css({"left":0});
		}
	});
	
	
	//商品名称title设置了颜色 前台处理title html代码
	$(".p-name a").each(function(){
		if($(this).prop("title") != ""){
			var title = $(this).attr('title');
			var newTitle = title.replace(/<\/?[^>]*>/g,'');
			
			$(this).attr('title',newTitle);
		}
	});
	
	/*var brand_select = $(".brand_select_more");
	if(brand_select.length>0){
		brand_select.hover(function(e){
            $(".brand_select_more").perfectScrollbar("destroy");
			$(".brand_select_more").perfectScrollbar();
        });
	}*/
	
	
	
	/************************************** 通用内容end ******************************************/
	
	/************************************** 批发市场 start ******************************************/
	$(document).on(" click","*[ectype='lieMore']",function(){
		var t = $(this);
		var parent = t.parents("*[ectype='lieItems']");
		if(t.hasClass("lie-down")){
			t.removeClass("lie-down");
			t.find("i").addClass("icon-down").removeClass("icon-up");
			parent.find("*[ectype='lieItem']").addClass("hide").eq(0).removeClass("hide");
		}else{
			t.addClass("lie-down");
			t.find("i").removeClass("icon-down").addClass("icon-up");
			parent.find("*[ectype='lieItem']").removeClass("hide");
			
		}
	});
	
	$(document).on('click',"[ectype='invPayee']",function(){
		var val = $(this).val();
		if(val == 0){
			$('#inv_payee').hide();
			$('#tax_id').hide();
		}else{
			$('#inv_payee').show();
			$('#tax_id').show();
		}
	});
	/************************************** 批发市场 end ******************************************/
	
	/************************************** 首页 start ******************************************/
	
	//首页楼层鼠标移动分类触发事件
	$(document).on("mouseenter","li[ectype='floor_cat_content']",function(){
		get_homefloor_cat_content(this);
	});
	
	//首页品牌 换一批切换
	doc.on('click',"*[ectype='changeBrand']",function(){
		var temp = '';
		if($("input[name='temp']").length > 0){
			temp = $("input[name='temp']").val();
		}
		
		Ajax.call("get_ajax_content.php","act=ajax_change_brands&temp="+temp,changeBrandResponse,'GET','JSON');
	});	
	
	function changeBrandResponse(result){
		$("#recommend_brands").html(result.content);
	}
	
	//首页弹出全屏广告
	doc.on('click',"*[ectype='ejectClose']",function(){
		$("*[ectype='ejectAdv']").hide();
	});
	
	/************************************** 首页 end ******************************************/
	
	/************************************** 商品列表页start ***************************************/
	$("a[ectype='gstop']").on("click",function(){
		var parent = $(this).parents(".goods-spread");
		var ico = $(this).find("i");
		var goodslist = parent.siblings(".goods-list");
		var right = 0;
		
		var winWidth = $(window).width();
		
		var minWidth = 1160;
		var maxWidth = 1392;
		
		if(winWidth < 1450){
			minWidth = 978;
			maxWidth = 1200;
		}
		
		if(parent.hasClass("goods-spread-fix")){
			goodslist.stop().animate({"width":minWidth},startAnimate);
			goodslist.removeClass("goods-list-w1390");
		}else{
			goodslist.stop().animate({"width":maxWidth});
			
			right = ($(window).width() - maxWidth)/2;
			parent.css("right",right-60);
			
			goodslist.addClass("goods-list-w1390");
			
			parent.addClass("goods-spread-fix");
			ico.removeClass("icon-right").addClass("icon-left");
		}
		
		function startAnimate(){
			parent.removeClass("goods-spread-fix");	
			ico.removeClass("icon-left").addClass("icon-right");
		}
	});
	
	$("*[ectype='fsortTab'] .item").on("click",function(){
		var Item = $(this);
		var type = Item.data("type");
		var main = $("*[ectype='gMain']");
		
		Item.addClass("current").siblings(".item").removeClass("current");
		if(type == "large"){
			main.find(".gl-warp-large").show();
			main.find(".gl-warp-samll").hide();
		}else{
			main.find(".gl-warp-large").hide();
			main.find(".gl-warp-samll").show();
		}
	});
	
	//列表页 相册切换
    $(".sider li").hover(function(){
		var src = $(this).find('img').attr("src");
		$(this).parents(".sider").prev().find("img").attr("src",src);
		$(this).addClass("curr").siblings().removeClass("curr");
	});
	
    //产品列表筛选
    $(".fcheckbox .checkbox_item label").click(function(){
		var check = $(this).prev();
		if(check.prop("checked") == true){
			var input_url = ($(this).nextAll('#input-i2').attr('rev'));
			check.addClass("checkbox-checked");
		}else{
			var input_url = ($(this).nextAll("#input-i1").attr('rev'));
			check.addClass("checkbox-checked");
		}
		location.href = input_url;
    });
	/************************************** 商品列表页(goods_list)end ***************************************/
	
	
	/************************************** 商品详情页(goods_info)start ***************************************/
        //商品评论标签点击筛选
        $("*[ectype='comment_tag']").on("click",function(){
            var type = $(this).data('type');//操作类型  1表示全部
            //点击高亮处理
            $(this).find('span').addClass('red');
            $(this).siblings().find('span').removeClass('red');
            var tag_obj = $("#ECS_COMMENT").find('.com-list-item');
            if (type == 1) {
                tag_obj.show();
            } else {
                var tag = $(this).find('span').html();
                var i = 0;//评论中出现次数
                if (tag_obj) {
                    tag_obj.each(function () {
                        var _this = $(this);
                        var j = 0;//单条评论中出现次数
                        _this.find('.ciw-actor-info span e').each(function () {
                            var c_tag = $(this).html();
                            if (c_tag == tag) {
                                j++;
                                $(this).addClass('red');
                            }else{
                                $(this).removeClass('red');
                            }
                        });
                        if (j == 0) {
                            _this.hide();
                        } else {
                            _this.show();
                            i++;
                        }
                    })
                    //预留入口
                    if (i == 0) {
                    }
                }
            }
        })
	//多个促销活动展开
	$("*[ectype='view-prom']").hover(function(){
		var $this = $(this);
		var s_wrap = $this.parents(".summary-price-wrap");
		var w_wrap = $this.parents(".s-p-w-wrap");
		var height = w_wrap.outerHeight();
		
		s_wrap.css("height",height);
		w_wrap.addClass("z-promotions-all-show");
		
	},function(){
		var $this = $(this);
		var w_wrap = $this.parents(".s-p-w-wrap");
		w_wrap.removeClass("z-promotions-all-show");
	});
	
	//配送地区选择展开效果
	doc.on("mouseenter","*[ectype='areaSelect']",function(){
		var $this = $(this);
		$this.find("*[ectype='areaWarp']").show();
		$this.addClass("hover");
		$this.find(".iconfont").removeClass("icon-down").addClass("icon-up");
	});
	
	doc.on("mouseleave","*[ectype='areaSelect']",function(){
		var $this = $(this);
		$this.find("*[ectype='areaWarp']").hide();
		$this.removeClass("hover");
		$this.find(".iconfont").removeClass("icon-up").addClass("icon-down");
	});
	
	
	//商品属性选择切换
	$("*[ectype='is-attr'] .item").on("click",function(){
		var $this = $(this),
			parent = $this.parents("*[ectype='is-attr']"),
			type = parent.data("type"),
			name = $this.data("name"),
			spec_value = 0;
			
			spec_value = $this.find("input").val();
			Ajax.call('ajax_dialog.php', 'act=getInfo&goods_id=' + goodsId + '&attr_id=' + spec_value, getImgUrl, 'GET', 'JSON');
		if(type == "radio"){
			$this.find("input[type='radio']").prop("checked",true);
			$this.addClass("selected").siblings().removeClass("selected");
			
			$("[data-name="+name+"]").find("input[type='radio']").prop("checked",true);
			$("[data-name="+name+"]").addClass("selected").siblings().removeClass("selected");
		}else if(type == "checkbox"){
			var len = parent.find(".selected").length;
			
			if($this.hasClass("selected")){
				if(len<=1)return;
				$this.removeClass("selected");
				$this.find("input[type='checkbox']").prop("checked",false);
				
				$("[data-name="+name+"]").removeClass("selected");
				$("[data-name="+name+"]").find("input[type='checkbox']").prop("checked",false);
			}else{
				$this.addClass("selected");
				$this.find("input[type='checkbox']").prop("checked",true);		
				
				$("[data-name="+name+"]").addClass("selected");
				$("[data-name="+name+"]").find("input[type='checkbox']").prop("checked",true);
			}
		}else{}
		
		changePrice();
	});
	
	//商品降价通知
	$("*[ectype='priceNotify']").on("click",function(){
		var $this = $(this),
			user_id = $this.data("userid"),
			goods_id = $this.data("goodsid"),
			content = $("#notify_box").html();
		
		//判断是否登录
		if(user_id == 0){
			var back_url = "goods.php?id=" + goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
			return false;
		}else{
			pb({
				id:"notifyBox",
				title:json_languages.pb_title,
				width:500,
				height:210,
				content:content,
				ok_title:json_languages.determine,
				cl_title:json_languages.cancel,
				drag:false,
				foot:true,
				onOk:function(){
					notifyBox(user_id,goods_id,"#notifyBox");
				}
			});
		}
	});
	
	//白条分期
	$("*[ectype='is-ious'] .item").on("click",function(){
		var $this = $(this),
			val = $this.data("value");
		if($this.hasClass("selected")){
			$this.removeClass("selected");
			$this.siblings("input[name='stages_qishu']").val('');
		}else{
			$this.addClass("selected").siblings().removeClass("selected");
			$this.siblings("input[name='stages_qishu']").val(val);
		}
	});
	
	//分期提交表单
	$("*[ectype='byStages']").on("click",function(){
		var val = $("input[name='stages_qishu']").val();
		var goods_id = $("input[name='good_id']").val();
		var user_id = $("input[name='user_id']").val();
		if(user_id > 0){
			if(val > 0){
				window.location.href ="javascript:bool=1;addToCartStages(goods_id);";
			}else{
				get_goods_prompt_message(json_languages.select_stages_number);
			}
		}else{
			var back_url = "goods.php?id="+ goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	/*门店取货*/
	function goodsStorePick(){
		var goods_id = $("input[name='goods_id']").val(),
			user_id = $("input[name='user_id']").val(),
			back_url = "goods.php?id="+ goods_id,
			formBuy  = document.forms['ECS_FORMBUY'],
			spec_arr = "",
			divId = "";
		//门店服务-门店取货弹窗口
		/*未登录 跳转登陆,登陆选择门店*/
		$("*[ectype='seller_store']").on("click",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "storeDialogBody";
			if(user_id > 0){
				Ajax.call("get_ajax_content.php?act=get_store_list&goods_id="+goods_id+ '&spec_arr=' + spec_arr,'back_act='+ back_url, function(data){
					pb({
						id:divId,
						title:json_languages.see_store,
						width:670,
						height:320,
						content:data.content,
						drag:false,
						foot:false
					});
					
					$.levelLink(1);
					
				}, 'POST','JSON');
			}else{
				$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
				return false;
			}
		});
		
		//到店取货弹框
		$("*[ectype='btn-store-pick']").on("click",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "storePick";
			ru_id = $("input[name='merchantId']").val();
			/*未登录 跳转登陆,登陆选择门店*/
			if(user_id == 0){
				$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
				return false;
			}
			Ajax.call("get_ajax_content.php?act=storePick",'ru_id='+ ru_id + "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(data){
				pb({
					id:divId,
					title:json_languages.store_subscribe,
					width:450,
					height:240,
					ok_title:json_languages.submit_subscribe,
					cl_title:json_languages.cancel,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var store_id = $("input[name='store_id']").val(),
							end_time = $("input[name='end_time']").val(),
							store_mobile = $("input[name='store_mobile']").val();
						if(store_id > 0){
							if(store_mobile == ""){
								pbDialog(json_languages.login_phone_packup_one,"",0);
								$("input[name='store_mobile']").focus();
								return false;
							}else if(!Utils.isTel(store_mobile) || store_mobile.length != 11){
								pbDialog(json_languages.msg_phone_not,"",0);
								$("input[name='store_mobile']").focus();
								return false; 
							}else{
								bool=2;
								addToCart(goods_id,0,0,'','',store_id,end_time,store_mobile);
								return true;
							}
						}else{
							pbDialog(json_languages.select_store,"",0);
							return false;
						}
					}
				});
			}, 'POST','JSON');
		});
	
		/*更换选择门店*/
		$(document).on("click","*[ectype='storeSelect']",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "latelStorePick";
			ru_id = $("input[name='merchantId']").val();
			
			Ajax.call("get_ajax_content.php?act=storeSelect",'ru_id='+ ru_id +  "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(data){
				pb({
					id:divId,
					title:json_languages.store_lately,
					width:900,
					height:410,
					ok_title:json_languages.determine,
					cl_title:json_languages.cancel,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk: function () {
						store_id = $("#"+divId).find(".active input[name='store_id']").val();
						if(store_id > 0){
							Ajax.call("get_ajax_content.php?act=replaceStore",'store_id='+ store_id + "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(result){
								$(".replaceStore").html(result.content);
							}, 'POST','JSON')
						}
					}
				});
				//$(".select-shop").perfectScrollbar("destroy");
				//$(".select-shop").perfectScrollbar();
			},'POST','JSON');
			
			//筛选城市门店
			regionSelect(ru_id,goods_id);
		});
	}
	
	//门店取货方法调用
	goodsStorePick();
	
	//商品详情页价格阶梯 start
	$("*[ectype='view_priceLadder']").hover(function(){
		/*clearTimeout(outTimer);
		var priceLadder = $(this).siblings("*[ectype='priceLadder']");
		hoverTimer = setTimeout(function(){priceLadder.show()},200);*/
		
		$(this).siblings("*[ectype='priceLadder']").show();
	},function(){
		$(this).siblings("*[ectype='priceLadder']").hide();
	});
	
	/*$("*[ectype='priceLadder']").hover(function(){
		clearTimeout(outTimer);
		$(this).show();
	},function(){
		$(this).hide();
	});*/
	//商品详情页价格阶梯 end
	
	//配送地区 start
	function areaAddress(){
		var $this = $("#area_address");
		var width=0;
		$this.hover(function(){
			width = $(this).outerWidth();
			$(this).find('.area-warp').show();
		},function(){
			$(this).find('.area-warp').hide();
		});
	}
	areaAddress();
	//配送地区 end
	
	//商品举报
	$("*[ectype='report']").on("click", function () {
		var goods_id = $("input[name='good_id']").val(),
			user_id = $("input[name='user_id']").val(),
			back_url = "user.php?act=goods_report&goods_id="+goods_id;
			
		if(user_id > 0) {
		   location.href = back_url;
		}else{
			$.notLogin("get_ajax_content.php?act=get_login_dialog", back_url);
			return false;
		}
	});
	
	//后台购买流程设置点击确定立即购买,并且没有登录会员弹出登录框(后台设置购物流程为一步购物)
	$("*[ectype='btn-buynow']").click(function(){
		var one_step_buy = $(this).data("type"),
			goods_id = $("input[name='good_id']").val();
			
		if(user_id <= 0 && one_step_buy == 1){
			var back_url = "goods.php?id=" + goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
			return false;
		}
	});
	
	
	//预售详情 预售规则
	$(".sp-rule").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	//商品详情页悬浮栏加入购物车 商品规格
	$("*[ectype='tb-tab-anchor']").on("click",function(){
		var t = $(this);
		$(this).siblings(".tb-popsku").show();
	});
	
	$("*[ectype='tb-cancel']").on("click",function(){
		var t = $(this);
		$(this).parents(".tb-popsku").hide();
	});
	
	//商品详情页店铺展开收起
	$(".arrow-show-more").click(function(){
		$(".seller-pop-box,.seller-address").stop(true,false).slideToggle();
	});
	
	//店内分类展开收起
	$("*[ectype='cateOpen'] dt").click(function(){
		var $this = $(this);
		var dl = $this.parent("dl");
		if(dl.hasClass("hover")){
			dl.removeClass("hover");
		}else{
			dl.addClass("hover");
		}
	});
	
	//商品详情页 详情左侧 店铺商品热销、新品、精品排行
	var rankmcli_length = $("*[ectype='rankMcTab']").find("li").length;
	if(rankmcli_length == 1){
		$("*[ectype='rankMcTab']").addClass("mcOne");
	}else if(rankmcli_length == 2){
		$("*[ectype='rankMcTab']").addClass("mcTwo");
	}else if(rankmcli_length == 3){
		$("*[ectype='rankMcTab']").addClass("mcThree");
	}
	
	//评论筛选
	$("*[ectype='gmf-tab'] li").click(function(){
		var rev = $(this).attr("rev");
		var comment = "";
		var goods_id = $("input[name='good_id']").val()
		$(this).addClass("curr").siblings().removeClass("curr");
		
		if(rev == 1){
			comment = 'comment_good';	
		}else if(rev == 2){
			comment = 'comment_middle';
		}else if(rev == 3){
			comment = 'comment_short';
		}else{
			comment = 'comment_all';
		}
		
		goods_id = goods_id + "|" + rev;
		
		Ajax.call('comment.php?act=' + comment, 'id=' + goods_id, get_commentResponse, 'GET', 'JSON');
	});
	
	$("*[ectype='reply']").click(function(){
		if($(this).parents(".com-operate").next().hasClass("hide")){
			$(this).parents(".com-operate").next().removeClass("hide");
		}else{
			$(this).parents(".com-operate").next().addClass("hide");
		}
	});
	
	function get_commentResponse(result){
		$("#ECS_COMMENT").html(result.content);
	}
	
	//网友讨论圈
	$('.dis_type').click(function(){
		var T = $(this);
		var rev = T.attr('rev');
		var dis_sort = T.attr('sort');
		var revType = T.attr('revType');
		var goods_id = $("input[name='good_id']").val();
		
		$(this).addClass('curr').siblings().removeClass('curr');
		
		if(!revType){
			revType = 0; //加载模板
		}
		
		if(dis_sort){
			dis_sort = "|" + dis_sort;
			rev = $("input[name='dis_class']").val();
		}else{
			dis_sort = '';
			$("input[name='dis_class']").val(rev);
		}
		
		goods_id = goods_id + "|" + rev + "|" + revType + dis_sort;
		
		Ajax.call('comment_discuss.php?act=discuss', 'id=' + goods_id, comment_discussResponse, 'GET', 'JSON');
	});
	
	$('.dis_type').eq(0).click();
	function comment_discussResponse(result){
		$("#discuss_list_ECS_COMMENT").html(result.content);
	}
	
	/*评论图片展开 start */
	$(document).on("click",".p-thumb-img li",function(){
		var $this = $(this);
		var imgUrl = $this.data("src");
		var viewImg = $this.parents(".p-imgs-warp").find(".p-view-img");
		var length = $this.siblings("li").length + 1;
		var fale = false;
		if($this.hasClass("curr")){
			$this.removeClass("curr");
			fale = false;
		}else{
			$this.addClass("curr").siblings().removeClass("curr");	
			fale = true;
		}
		
		if(fale == true){
			viewImg.show();
			viewImg.find("img").attr("src",imgUrl);
		}else{
			viewImg.hide();
		}
	});
	
	$(document).on("click",".p-view-img img",function(){
		var $this = $(this);
		var viewImg = $this.parents(".p-view-img");
		viewImg.hide();
		viewImg.siblings(".p-thumb-img").find("li").removeClass("curr");
	});
	
	$(document).on("click",".p-view-img a",function(){
		var $this = $(this);
		var imgs = $this.parents(".p-imgs-warp");
		var length = imgs.find("li").length;
		var count = imgs.find(".curr").data("count");
		
		if($this.hasClass("p-prev")){
			if(count>1){
				imgs.find("*[data-count="+(count-1)+"]").click();
			}
		}else{
			if(count != length){
				imgs.find("*[data-count="+(count+1)+"]").click();
			}
		}
	});
	/*评论图片展开end*/
	
	/************************************** 商品详情页(goods_list)end ***************************************/
	
	/************************************** 品牌专区(brand)start *******************************************/
	//品牌专区首页分类筛选
	$(document).on("click", "*[ectype='brandCate'] *[ectype='cateItem']", function(){
		var cat_id = $(this).data('catid');
		
		$(this).addClass('curr').siblings("*[ectype='cateItem']").removeClass('curr');
		
		$.jqueryAjax('brand.php', 'act=filter_category&cat_id='+cat_id, function(data){
			$("*[ectype='brandList'] *[ectype='items']").html(data.content);
		});
	});
	
	//品牌专区 品牌详情页 点击分类展示商品
	$(document).on("click","*[ectype='brandcat'] a",function(){
		var brand_id = $("input[name=brand_id]").val();
		var cat_id = $(this).data("catid");
		
		$(this).addClass("curr").siblings().removeClass("curr");
		$.jqueryAjax('brandn.php', 'act=get_brand_cat_goods&id='+brand_id+'&cat='+cat_id, function(data){
			if(data.content){
				$("*[ectype='goodslist']").html(data.content);
			}
		});
	});
	/************************************** 品牌专区(brand)end *********************************************/
	
	/********************************************* 购物车(cart)start ***************************************/
	$("*[ectype='c-promotion']").on("click",function(){
		var $this = $(this);
		var parent = $this.parent();
		var height = parent.find("*[ectype='promTips'] ul").height();
		$(".promotion-info").removeClass("prom-hover");
		$(".promotion-info").find("*[ectype='promTips']").css("height",0);
		if(parent.hasClass("prom-hover")){
			parent.removeClass("prom-hover");
			parent.find("*[ectype='promTips']").css("height",0);
		}else{
			parent.addClass("prom-hover");
			parent.find("*[ectype='promTips']").css("height",height);
		}
	});
	
	//购物车删除和移到收藏弹框
	$(document).on("click", "*[ectype='cartOperation']", function(){
		var user_id = $("#user_id").val();
		
		var ok_title, cl_title, content;
		var obj = $(this).data("value");
		if (obj.divId == 'cart_remove') {
			ok_title = json_languages.remove;
			cl_title = json_languages.move_collection;
			content = $("#dialog_remove").html();
		} else if (obj.divId == 'cart_collect') {
			ok_title = json_languages.follow;
			cl_title = json_languages.cancel;
			content = $("#dialog_collect").html();
		}
		
		if (user_id > 0 || obj.divId == 'cart_remove') {
			pb({
				id: obj.divId,
				title: obj.title,
				width: 455,
				height: 58,
				ok_title: ok_title, //按钮名称
				cl_title: cl_title, //按钮名称
				content: content, //调取内容
				drag: false,
				foot: true,
				onOk: function () {
					location.href = obj.url;
				},
				onCancel: function () {
					if (obj.divId == 'cart_remove') {
						location.href = obj.cancelUrl;
					}
				}
			});
		}else{
			var back_url = "flow.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	//购物车批量删除
	$("*[data-dialog='remove_collect_dialog']").click(function(){
		var user_id = $("#user_id").val();
		if(user_id > 0){
			var remove_url = $(this).data('removeurl');
			var collect_url = $(this).data('collecturl');
			var divId = $(this).data('divid');
			var cart_value = $('#cart_value').val();
			var goods_ru = $('#goods_ru').val();
			var url;
			
			if(divId == 'cart-remove-batch'){
				var content = json_languages.drop_goods;
				url = remove_url;
			}else if(divId == 'cart-collect-batch'){
				var content = json_languages.confirm_Move_collection;
				url = collect_url;
			}
			
			pbDialog(content,"",0,450,50,"",true,function(){
				Ajax.call(url, 'cart_value=' + cart_value, function(data){
						location.href = "flow.php";
				}, 'POST','JSON');
			});
		}else{
			var back_url = "flow.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	
	//购物车未登录结算弹出登录框
	$("#go_pay").click(function(){
		var back_url=$(this).data("url");
		$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		return false;
	});
	/********************************************* 购物车(cart)end ***************************************/
	
	/********************************************* 结算页(flow)start ***************************************/
	
	//收货人信息切换
	$(document).on("click","*[ectype='cs-w-item']",function(){
		var $this = $(this);
		var address_id = $this.data('addressid');
		var store_id = 0;
		var shipping_id = get_cart_shipping_id();
		
		if($(":input[name='uc_id']").length > 0){
			var uc_id = $(":input[name='uc_id']").val();
		}else{
			var uc_id = 0;
		}
		
		$this.addClass("cs-selected").siblings().removeClass("cs-selected");
		
		if(document.getElementById('store_id')){
			store_id = document.getElementById('store_id').value;
			(store_id > 0) ? store_id : 0;
		}
		uc_id
		Ajax.call('flow.php?step=edit_consignee_checked', 'address_id=' + address_id + '&store_id=' +store_id + '&uc_id=' + uc_id + '&shipping_id=' + $.toJSON(shipping_id), function (result) {
			if(result.error > 0){
				if(result.error == 1){
					var back_url = "flow.php";
					$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
					return false;
				}else{
					alert(result.msg);
					return false;
				}
			}else{
				$('#consignee-addr').html(result.content);
				$('#goods_inventory').html(result.goods_list);//送货清单
				$('#ECS_ORDERTOTAL').html(result.order_total);//费用汇总
				
                                //优惠券 处理
                                $("[ectype='order_coupoms_list']").html(result.order_coupoms_list);
				$('#not_freightfree').val(result.not_freightfree);
			}
		}, 'POST','JSON');
	});
        
	/* 结算页面 用户收货地址 start */
	$(document).on("click","*[ectype='dialog_checkout']",function(){
		var obj = $(this).data("value");
		var parent = $(this).parents(".cs-w-item");
		var length = parent.siblings(".cs-w-item").length;
		if(obj.divId == 'new_address'){
			if((length+1) >= 11){
				pbDialog(json_languages.add_address_10,"",0);
				return false;
			}
		}
		
		if(obj.divId == 'new_address' || obj.divId == 'edit_address'){
			//添加收货地址信息
			Ajax.call(obj.url, 'address_id=' + obj.id, function(data){
				pb({
					id:obj.divId,
					title:obj.title,
					width:obj.width,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					ok_title:json_languages.con_Preservation,
					cl_title:json_languages.cancel,
					onOk:function(){
						var form = $("#" + obj.divId).find("form").attr("name");
						if(addUpdate_Consignee(form)== false){
							return false;
						}else{
							return true;
						};
					}
				});
				
				if(obj.divId == 'new_address'){
					//新增地区初始化
					$.levelLink(1);
				}else{
					//编辑地区初始化
					$.levelLink(0);
				}
				
			}, 'POST','JSON');
				            
		}else if(obj.divId == 'del_address'){
			//删除收货地址信息
			var content = $('#del_address').html();
			
			pbDialog(json_languages.confirm_drop_address,"",0,'','','',true,function(){
				Ajax.call('flow.php?step=delete_Consignee', 'address_id=' + obj.id + "&temtype=1&type=1", function(data){
					if(data.error == 2){
						$('#consignee-addr').html(data.content);
					}else{
						$('#consignee-addr').html(data.content);
					}
					
					$('#goods_inventory').html(data.goods_list);//送货清单
					$('#ECS_ORDERTOTAL').html(data.order_total);//费用汇总
					
					$('#not_freightfree').val(0);
				}, 'POST','JSON');
			});
		}
	});
	/* 结算页面 用户收货地址 end */
	
	/* 门店自提结算页面 修改门店选择 start*/
	$("*[ectype='storeBtn']").on("click",function(){
		$("*[ectype='seller_address']").addClass("hide")
		$("*[ectype='get_seller_sotre']").addClass("show");
	});
	
	/* 门店自提结算页面 修改门店选择 end*/
	
	function paymet(){
		var payment_method = $("*[ectype='paymentType']"),			//结算页面支付方式
			payInput = $("input[name='pay_pwd_error']"),			//结算页面其他信息 支付密码隐藏域
			length = payInput.length,								//结算页面其他信息 支付密码隐藏域 大于0表示开启
			balance = $("#qt_balance"),                             //结算页面其他信息 使用余额
			payPw = $("#qt_onlinepay"),								//结束页面其他信息 支付密码
			integObj = $("#qt_integral"),							//结算页面其他信息 使用积分
			sueplus = balance.find("input[name='surplus']"),		//余额input
			user_sueplus = sueplus.data("yoursurplus"),				//用户可用余额
			integral = integObj.find("input[name='integral']"),		//积分input
			integral_max = integral.data("maxinteg");				//此订单可用积分
		
			//余额和积分初始化方法
			initialize = function(){
			//积分input是否大于0
			if(integral.val() > 0){
				//初始化积分
				integral.val(0);
				//初始化积分为0,总价去除积分抵扣价格
				changeIntegral(0);
			}
			
			//余额input是否大于0
			if(sueplus.val() > 0){
				//初始化余额
				sueplus.val(0);
				//初始化余额为0,总价去除余额抵扣价格
				changeSurplus(0);
			}
		}
		
		payPassword = function(){
			var pay_length = payment_method.find(".item-selected").length;
			if(length > 0 && pay_length > 0){
				var paymet_curr_val = payment_method.find(".item-selected").data("value"),  //结算页面支付方式 默认选中的支付方式value
					paymet_curr_type = paymet_curr_val.type;								//结算页面支付方式 默认选中的支付方式类型
				
				//初始化
				initialize();
				
				if(paymet_curr_type == "balance"){
					//余额支付状态,余额填写区域隐藏
					balance.hide();
					
					//支付状态为在线支付,并且设置了支付密码
					if(payPw.length > 0){
						payPw.show();    //支付密码显示
						payInput.val(1); //支付密码隐藏域值赋值为1
					}
				}else{
					//非余额支付状态,余额填写区域显示
					balance.show();
					
					//用户余额大于0,余额显示
					if(user_sueplus > 0){
						balance.show();
					}else{
						balance.hide();
					}
					
					//此订单可以使用积分,积分显示
					if(integral_max > 0){
						//integObj.show();
					}else{
						//integObj.hide();
					}
					
					payPw.hide();  //支付密码隐藏
					payInput.val(0); //支付密码隐藏域值赋值为0
				}
			}
		}
		
		initialize(); //初始化方法默认调用
		payPassword();
		
		//支付方式切换
		payment_method.find(".p-radio-item").on("click",function(){
			var t = $(this),
				paymet_curr_val = t.data("value"),			//选中支付方式的value
				paymet_curr_type = paymet_curr_val.type,	//选中支付方式的type
				paymet_curr_id = paymet_curr_val.payid,     //选中支付方式的id
				paymet_curr_allow = paymet_curr_val.allow;  //选中支付方式的allow
			
			//初始化方法调用
			initialize();
			
			//支付方式选中
			t.addClass("item-selected").siblings().removeClass("item-selected");
			t.find('input').prop("checked",true);
			
			if(paymet_curr_type == "balance"){
				//余额支付状态,余额填写区域隐藏
				balance.hide();
				
				//支付状态为在线支付,并且设置了支付密码
				if(payPw.length > 0){
					payPw.show();    //支付密码显示
					payInput.val(1); //支付密码隐藏域值赋值为1
				}
			}else{
				
				//非余额支付状态,余额填写区域显示
				balance.show();
				
				if(paymet_curr_allow == 1){
					//判断会员是否有余额
					changeSurplus(0);
				}
				
				/* 是否存在储值卡和是否选择储值卡 */
				if(document.getElementById('value_card_psd') && $("#value_card_psd").prop('disabled') == true){
					
					//支付密码显示
					payPw.show();
					
					//初始化支付密码
					payPw.find("input[name='pay_pwd']").val("");
					
					payInput.val(1); //支付密码隐藏域值赋值为1
			
				}else{
					payPw.hide();  //支付密码隐藏
					
					//初始化支付密码
					payPw.find("input[name='pay_pwd']").val("");
					
					payInput.val(0); //支付密码隐藏域值赋值为0
				}
			}
			
			//改变支付方式
			selectPayment(paymet_curr_id);
		});
	}
	paymet();
	
	//发票修改
	$(document).on("click","*[ectype='invEdit']",function(){
		var obj = $(this).data("value");
		var invoice_type = $("#inv_content").find("input[name='invoice_type']").val();
		Ajax.call(obj.url,'invoice_type=' + invoice_type ,invoiceResponse, 'POST', 'JSON');
		function invoiceResponse(data){
			if(data.error == 0){
				pb({
					id:obj.divid,
					title:obj.title,
					width:675,
					height:278,
					ok_title:json_languages.invoice_ok, 	//按钮名称
					cl_title:json_languages.cancel, 		//按钮名称
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var invoice_val  = $("#edit_invoice .selected").find("input[name='invoice_id']").val();
						var inv_content  = $("#edit_invoice .radio-list .item-selected").find("input[name='inv_content']").val();
						var invoice_type = $("#edit_invoice .tab-nav").find(".item-selected").data('value');
						var store_id 	 = $("#store_id").val();
						var tax_id = $("#tax_id").val();
						var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
						var area_id = $(".checkout-foot").find("input[name='area_id']").val();
						var cfrom = $("#inv_content").find("input[name='from']").val();
						var shipping_id = get_cart_shipping_id();
						
						if(typeof invoice_val == 'undefined' || invoice_val == ""){
							pbDialog(json_languages.invoice_packup,"",0);
							return false;
						}
						if(!$("*[ectype='tax']").is(":hidden") && tax_id == ""){
							pbDialog(json_languages.invoice_tax_null,"",0);
							return false;
						}
						
						Ajax.call('ajax_dialog.php?act=gotoInvoice','inv_content='+encodeURIComponent(inv_content)+'&invoice_id='+invoice_val + '&from='+ cfrom +'&warehouse_id='+warehouse_id +'&area_id='+area_id +'&store_id='+store_id +'&invoice_type='+invoice_type + '&tax_id=' + tax_id + '&shipping_id=' + $.toJSON(shipping_id),gotoInvoiceResponse, 'POST', 'JSON');
									  	
						function gotoInvoiceResponse(result){
							if(result.error != ""){
								pbDialog(result.error,"",0);
								return false;
							}else{
								if(result.type){
									$("#inv_content .inv_payee").html('');
									$("#inv_content .inv_content").html('');
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val('');
									$("#inv_content").find("input[name=inv_content]").val('');	
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);	
                                    
                                    $("#ECS_ORDERTOTAL").html(result.content);	
								}else{
									$("#inv_content .inv_payee").html(result.inv_payee);
									$("#inv_content .inv_content").html(result.inv_content);
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val(result.inv_payee);
									$("#inv_content").find("input[name=inv_content]").val(result.inv_content);
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);
									$("#inv_content").find("input[name=tax_id]").val(result.tax_id);
									
									
									$("#common_button").find("input[name=inv_payee]").val(result.inv_payee);
									$("#common_button").find("input[name=inv_content]").val(result.inv_content);
									$("#common_button").find("input[name=invoice_type]").val(invoice_type);
									$("#common_button").find("input[name=tax_id]").val(result.tax_id);
									$("#ECS_ORDERTOTAL").html(result.content);									
								}
							}
						}
					}
				});
				
				//选中效果 by wu start
				var inv_payee = $("#inv_content").find("input[name=inv_payee]").val();
				var inv_content = $("#inv_content").find("input[name=inv_content]").val();
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").parents(".invoice-item").addClass("selected").siblings().removeClass("selected");
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").siblings("input[name='invoice_id']").prop("checked",true);
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").parents("li").addClass("item-selected").siblings().removeClass("item-selected");
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").prop("checked",true);
				//选中效果 by wu end
				
				invoice();	
			}else if(data.error == 1){
				pbDialog(data.content,"",0,"","",50);
			}
		}
		
		//跳转手机端
		browserRedirect();
	});
//批发-发票修改
	$(document).on("click","*[ectype='wholesale_invEdit']",function(){
		var obj = $(this).data("value");
		var invoice_type = $("#inv_content").find("input[name='invoice_type']").val();
		Ajax.call(obj.url,'invoice_type=' + invoice_type ,invoiceResponse, 'POST', 'JSON');
		function invoiceResponse(data){
			if(data.error == 0){
				pb({
					id:obj.divid,
					title:obj.title,
					width:675,
					height:278,
					ok_title:json_languages.invoice_ok, 	//按钮名称
					cl_title:json_languages.cancel, 		//按钮名称
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var invoice_val  = $("#edit_invoice .selected").find("input[name='invoice_id']").val();
						var inv_content  = $("#edit_invoice .radio-list .item-selected").find("input[name='inv_content']").val();
						var invoice_type = $("#edit_invoice .tab-nav").find(".item-selected").data('value');
						var store_id 	 = $("#store_id").val();
						var tax_id = $("#tax_id").val();
						var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
						var area_id = $(".checkout-foot").find("input[name='area_id']").val();
						var cfrom = $("#inv_content").find("input[name='from']").val();
						var shipping_id = get_cart_shipping_id();
						
						if(typeof invoice_val == 'undefined' || invoice_val == ""){
							pbDialog(json_languages.invoice_packup,"",0);
							return false;
						}
						if(!$("*[ectype='tax']").is(":hidden") && tax_id == ""){
							pbDialog(json_languages.invoice_tax_null,"",0);
							return false;
						}
						
						Ajax.call('ajax_dialog.php?act=wholesale_gotoInvoice','inv_content='+encodeURIComponent(inv_content)+'&invoice_id='+invoice_val + '&from='+ cfrom +'&warehouse_id='+warehouse_id +'&area_id='+area_id +'&store_id='+store_id +'&invoice_type='+invoice_type + '&tax_id=' + tax_id + '&shipping_id=' + $.toJSON(shipping_id),gotoInvoiceResponse, 'POST', 'JSON');
									  	
						function gotoInvoiceResponse(result){
							if(result.error != ""){
								pbDialog(result.error,"",0);
								return false;
							}else{
								if(result.type){
									$("#inv_content .inv_payee").html('');
									$("#inv_content .inv_content").html('');
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val('');
									$("#inv_content").find("input[name=inv_content]").val('');	
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);									
								}else{
									$("#inv_content .inv_payee").html(result.inv_payee);
									$("#inv_content .inv_content").html(result.inv_content);
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val(result.inv_payee);
									$("#inv_content").find("input[name=inv_content]").val(result.inv_content);
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);
									$("#inv_content").find("input[name=tax_id]").val(result.tax_id);
									
									
									$("#common_button").find("input[name=inv_payee]").val(result.inv_payee);
									$("#common_button").find("input[name=inv_content]").val(result.inv_content);
									$("#common_button").find("input[name=invoice_type]").val(invoice_type);
									$("#common_button").find("input[name=tax_id]").val(result.tax_id);
									$("#ECS_ORDERTOTAL").html(result.content);									
								}
							}
						}
					}
				});
				
				//选中效果 by wu start
				var inv_payee = $("#inv_content").find("input[name=inv_payee]").val();
				var inv_content = $("#inv_content").find("input[name=inv_content]").val();
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").parents(".invoice-item").addClass("selected").siblings().removeClass("selected");
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").siblings("input[name='invoice_id']").prop("checked",true);
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").parents("li").addClass("item-selected").siblings().removeClass("item-selected");
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").prop("checked",true);
				//选中效果 by wu end
				
				invoice();	
			}else if(data.error == 1){
				pbDialog(data.content,"",0,"","",50);
			}
		}
		
		//跳转手机端
		browserRedirect();
	});
	
	/* 跳转手机端 start */
	function browserRedirect() {
		var sUserAgent = navigator.userAgent.toLowerCase();
		var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
		var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
		var bIsMidp = sUserAgent.match(/midp/i) == "midp";
		var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
		var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
		var bIsAndroid = sUserAgent.match(/android/i) == "android";
		var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
		var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
		
		if ((bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) == true ){
			window.location.href="/mobile";
		}
	}
	/* 跳转手机端 end */
	
	//编辑发票弹窗内容
	function invoice(){
		var invoice = "#edit_invoice",
			invoiceItem = ".invoice-item",
			addBtn = ".add-invoice-btn",
			editBtn = ".edit-tit",
			updateBtn = ".update-tit",
			delBtn = ".del-tit",
			radioList = $(invoice).find(".radio-list");
			
		if($(".invoice-item").hasClass("selected")){
			
			var invoiceid = $(".invoice-thickbox .selected").data('invoiceid');
			
			var tax_id = $(":input[name='invoice_tax_" + invoiceid + "']").val();
			
			$("#tax_id").val(tax_id);
		}
		$(".invoice-list").on("click",invoiceItem,function(){
			$(this).addClass("selected").siblings().removeClass("selected");
			$(this).find("input[name='invoice_id']").prop("checked", true); 
			
			var invoice_id = $(this).find(":input[name='invoice_id']").val();
			if(invoice_id > 0){
				var tax_id = $(this).find('[ectype=taxId]').val();
			}else{
				var tax_id = $("#tax_id").val();
			}
			
			$("#tax_id").val(tax_id);
			checked(invoice_id);
		});
		
		function checked(invoice_id){
			if($(invoiceItem).length <= 1 || invoice_id == 0){
				$("*[ectype='tax']").hide();
				$("#tax_id").val('');
			}else{
				$("*[ectype='tax']").show();
			}
		}
		checked($(invoiceItem).find("input[name='invoice_id']:checked").val());
		
		//新增公司发票
		$(invoice).find(addBtn).on("click",function(){
			var $this = $(this),
				f_item = "";
			$this.addClass("hide");
			$(invoiceItem).removeClass("selected");
			
			f_item = $(invoiceItem).length;
		
			if(f_item < 4){
				var div = "
');
			$.ajax({
			   type: "GET",
			   url: "get_ajax_content.php",
			   data: "act=getCategotyParentTree&cat_id=" + cat_id + "&defa=" + defa,
			   dataType:'json',
			   success: function(data){
				 $("*[ectype='subitems_" + data.cat_id + "']").html(data.brands_content);
			   }
			});
		}
		T.addClass("selected");
		layer.show();
	}).on("mouseleave",function(){
		var T = $(this),layer = T.parent().find("*[ectype='cateLayer']");
		T.removeClass("selected");
		layer.hide();
	});	
	
	//b2b二级导航展开
	$(".b2b-categorys-content li").hover(function(){
		var T = $(this),layer = T.find("*[ectype='cateLayer']");
		layer.show();
	},function(){
		var T = $(this),layer = T.find("*[ectype='cateLayer']");
		layer.hide();
	});
	
	//点击空白处隐藏展开框	
	$(document).click(function(e){
		//购物车更多促销活动
		if(e.target.className !='sales-promotion' && !$(e.target).parents("div").is("[ectype='promInfo']")){
			$("[ectype='promInfo']").removeClass("prom-hover");
		}
		
		if(e.target.id !='price-min' && e.target.id !='price-max'){
			$('.fP-expand').hide();
		}
		
		//仿select
		if(e.target.className !='cite' && !$(e.target).parents("div").is(".imitate_select")){
			$('.imitate_select ul').hide();
		}
		
		if(e.target.id !='btn-anchor' && !$(e.target).parents("div").is(".tb-popsku")){
			$('.tb-popsku').hide();
		}
		
		//首页弹出广告
		if(e.target.className == 'ejectAdvbg' && !$(e.target).parents("div").is(".ejectAdvimg")){
			$("*[ectype='ejectAdv']").hide();
		}
	});
	
	$(".value-item").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");
	});
	
	//div仿select下拉选框 start
	$(document).on("click",".imitate_select .cite",function(){
		$(".imitate_select ul").hide();
		$(this).parents(".imitate_select").find("ul").show();
		$(this).siblings("ul").perfectScrollbar("destroy");
		$(this).siblings("ul").perfectScrollbar();
	});
	
	$(document).on("click",".imitate_select li  a",function(){
		var _this = $(this);
		var val = _this.data('value');
		var text = _this.html();
		_this.parents(".imitate_select").find(".cite span").html(text).css("color","#707070");
		_this.parents(".imitate_select").find("input[type=hidden]").val(val);
		_this.parents(".imitate_select").find("ul").hide();
	});
	//div仿select下拉选框 end
	
	//input获得焦点加样式
	$("input.text").focus(function(){
		$(this).parents(".item").addClass("item-focus");
	});
	
	$("input.text").blur(function(){
		$(this).parents(".item").removeClass("item-focus");
	});
	
	/*****************************右侧黑色悬浮栏内容点击触发事件start***************************************/
	//移动图标出现文字提示
	$(".quick_links_panel li").hover(function(){
		$(this).find(".mp_tooltip").stop().animate({left:-92,queue:true});
		$(this).find(".mp_tooltip").css("visibility","visible");
		$(this).find(".ibar_login_box").show();
	},function(){
		$(this).find(".mp_tooltip").css("visibility","hidden");
		$(this).find(".mp_tooltip").stop().animate({left:-121,queue:true});
		$(this).find(".ibar_login_box").hide();
	});
	
	//点击图标判断用户是否登录
	$(".quick_links li").find("a").click(function(){
		var $this = $(this),
			user_id = $this.parents(".quick_link_mian").data("userid");
		
		if(user_id < 1 && !$this.hasClass('cart_list') && !$this.hasClass('mpbtn_history') && !$this.hasClass('mpbtn_email')){
			$.notLogin("get_ajax_content.php?act=get_login_dialog",'');
			return false;
		}
	});
	
	//点击展开邮箱订阅
	$(".mpbtn_email").click(function(){
		var obj = $(".email_sub");
		if(obj.hasClass("show")){
			obj.removeClass("show");
		}else{
			obj.addClass("show");
		}
	});
	
	//判断浏览器下滚还是上滚,向上滚动邮箱验证隐藏
	$(document).ready(function(){
		var p=0,t=0;
		var obj = $(".email_sub");
		$(window).scroll(function(e){
			p = $(this).scrollTop();
			if(t<=p){
				if(obj.hasClass("show")){
					obj.addClass("show");
				}
			}else{
				obj.removeClass("show");
			}
			setTimeout(function(){t = p;},0);		
		});
	});
	/*****************************右侧黑色悬浮栏内容点击触发事件end***************************************/
	
	//关注品牌
	$(document).on("click","*[ectype='coll_brand']",function(){
		var user_id = $("input[name=user_id]").val();
		if(user_id > 0){
			var brand_id = $(this).data('bid');
			if($(this).find("i").hasClass("icon-zan-alts")){
				$(this).find("i").removeClass("icon-zan-alts").addClass("icon-zan-alt");
				$(this).find("*[ectype='follow_span']").html("关注");
				Ajax.call('brandn.php', 'act=cancel&id=' + brand_id +'&user_id='+user_id, collect_brandResponse, 'POST', 'JSON');
			}else{
				$(this).find("i").removeClass("icon-zan-alt").addClass("icon-zan-alts");
				$(this).find("*[ectype='follow_span']").html("已关注");
				Ajax.call('brandn.php', 'act=collect&id=' + brand_id, collect_brandResponse, 'POST', 'JSON');
			}
		}else{
            var back_url = "brand.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);	
		}
	});
	
	//关注品牌回调函数
	function collect_brandResponse(result)
	{
        $("#collect_count").html(result.collect_count);
		$("#collect_count_"+result.brand_id).html(result.collect_count);;
	}
    
	//秒杀商品设置提醒
	$(document).on("click","*[ectype='collSecGoods']",function(){
		var user_id = $("input[name=user_id]").val();
		if(user_id > 0){
			var sid = $(this).data('id');
			if($(this).hasClass("sc-greenBg-btn")){
				$(this).removeClass("sc-greenBg-btn").addClass("sc-redBg-btn");
				$(this).html("取消提醒");
                Ajax.call('seckill.php', 'act=collect&sid=' + sid +'&user_id='+user_id, colSecGoodsResponse, 'POST', 'JSON');
			}
            else{
				$(this).removeClass("sc-redBg-btn").addClass("sc-greenBg-btn");
				$(this).html("提醒我");
				Ajax.call('seckill.php', 'act=cancel&sid=' + sid +'&user_id='+user_id, colSecGoodsResponse, 'POST', 'JSON');
			}
		}else{
            var back_url = "seckill.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);	
		}
	});
	
	//秒杀商品设置提醒回调函数
	function colSecGoodsResponse(result)
	{
        pbDialog(result.message,"",1,300,"80",50);
	} 	
	/****会员领取优惠券 start***/
	$(document).on("click",".get-coupon",function(){
		var cou_id = $(this).attr('cou_id');
                var coupon = '';
                if($(this).data('coupon')){
                    coupon = $(this).data('coupon');
                }
		receiveCoupon(cou_id,coupon);
	});
	
	function receiveCoupon(cou_id,coupon){
		if(user_id > 0){
			$.post('coupons.php?act=coupons_receive',{'cou_id':cou_id},function(data){
				if(data.status=='ok'){
                    $(".item-fore h3").html(data.msg);
                    $(".success-icon").removeClass("i-icon").addClass("m-icon");
					var content =$("#pd_coupons").html();
					pb({
						id:"coupons_dialog",
						title:json_languages.receive_coupons,
						width:550,
						height:140,
						ok_title:json_languages.Immediate_use, 	//按钮名称
						cl_title:json_languages.close, 	//按钮名称
						content:content, 	//调取内容
						drag:false,
						foot:true,
						onOk:function(){
							location.href="search.php?cou_id="+cou_id
						},
						onCancel:function(){
							$(".cou-data").html(data.content);
							$(".cou-seckill").html(data.content_kill);
                                                        $(".cou_shipping").html(data.content_shipping);
						},
					});
					
					$(".pb-ok").addClass("color_df3134");
				}else{
					$(".success-icon").removeClass("m-icon").addClass("i-icon");
					$(".item-fore h3").addClass("red");
					$(".item-fore h3").html(data.msg);
					var content =$("#pd_coupons").html();
					pb({
						id:"coupons_dialog",
						title:json_languages.receive_coupons,
						width:550,
						height:140,
						ok_title:json_languages.close, 	//按钮名称
						content:content, 	//调取内容
						cl_cBtn:false,
						onOk:function(){}
					});
				}
			},'json');
		}else{
			var back_url = "coupons.php?act=coupons_index";
			if(coupon == 1){
				back_url = 'coupons.php?act=coupons_info&id=' + cou_id;
			}
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
        	return false;
		}
	}
	/****会员领取优惠券 end***/
	
	
	/* 商品收藏 品牌关注 店铺关注 */
	$(document).on('click',"*[data-dialog='goods_collect_dialog']",function(){
		var url = $(this).data('url'),
			id = $(this).data('goodsid'),
			divId = $(this).data("divid"),
			width = 455,
			height = 58,
			content = "",
			goods_url = "",
			type = $(this).data("type");
		
		if(user_id == 0 && type == "goods"){
			goods_url = "goods.php?id=" + id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog", goods_url);
			return false;
		}
		
		if(id > 0){
			Ajax.call(url, 'id=' + id, function(data){
				if(data.error > 0){
					if(data.error == 2){
						$.notLogin("get_ajax_content.php?act=get_login_dialog", data.url);
						return false;
					}
					
					pbDialog(data.message,"",0,width,height,65,true,function(){
						location.href = "user.php?act=collection_list";
					},"会员中心");
					
				}else{
					$(".choose-btn-coll").addClass('selected');
					$(".choose-btn-icon").addClass('icon-collection-alt').removeClass('icon-collection');
					$("#collect_count").html(data.collect_count);
					
					pbDialog("您已成功收藏该商品!","",1,width,height,95,false,function(){
						location.href = "user.php?act=collection_list";
					},json_languages.My_collection);
				}
				
			}, 'GET', 'JSON');
		}else{
			if(divId == 'delete_goods_collect'){
				content = "您确定要取消收藏该商品吗?"; 
			}else if(divId == "delete_brand_collect"){
				content = "您确定要取消关注该品牌吗?"; 
			}else if(divId == "user_attention"){
				content = $(this).data("confirmtitle"); 
			}
			
			pbDialog(content,"",0,width,height,95,true,function(){
				location.href = url;
			});
		}		
	});
	
	/* 对比框隐藏 */
	$("[ectype='db_hide']").on("click",function(){
		$("#slideTxtBox").hide();
	});
	
	/* 对比 */
	var db_winWidth = $(window).width();
	var db_left = (db_winWidth-1200)/2;
	$("#slideTxtBox").css({"left":db_left});
	
	$(window).resize(function(){
		db_winWidth = $(this).width();
		if(db_winWidth>1200){
			db_left = (db_winWidth-1200)/2;
			$("#slideTxtBox").css({"left":db_left});
		}else{
			$("#slideTxtBox").css({"left":0});
		}
	});
	
	
	//商品名称title设置了颜色 前台处理title html代码
	$(".p-name a").each(function(){
		if($(this).prop("title") != ""){
			var title = $(this).attr('title');
			var newTitle = title.replace(/<\/?[^>]*>/g,'');
			
			$(this).attr('title',newTitle);
		}
	});
	
	/*var brand_select = $(".brand_select_more");
	if(brand_select.length>0){
		brand_select.hover(function(e){
            $(".brand_select_more").perfectScrollbar("destroy");
			$(".brand_select_more").perfectScrollbar();
        });
	}*/
	
	
	
	/************************************** 通用内容end ******************************************/
	
	/************************************** 批发市场 start ******************************************/
	$(document).on(" click","*[ectype='lieMore']",function(){
		var t = $(this);
		var parent = t.parents("*[ectype='lieItems']");
		if(t.hasClass("lie-down")){
			t.removeClass("lie-down");
			t.find("i").addClass("icon-down").removeClass("icon-up");
			parent.find("*[ectype='lieItem']").addClass("hide").eq(0).removeClass("hide");
		}else{
			t.addClass("lie-down");
			t.find("i").removeClass("icon-down").addClass("icon-up");
			parent.find("*[ectype='lieItem']").removeClass("hide");
			
		}
	});
	
	$(document).on('click',"[ectype='invPayee']",function(){
		var val = $(this).val();
		if(val == 0){
			$('#inv_payee').hide();
			$('#tax_id').hide();
		}else{
			$('#inv_payee').show();
			$('#tax_id').show();
		}
	});
	/************************************** 批发市场 end ******************************************/
	
	/************************************** 首页 start ******************************************/
	
	//首页楼层鼠标移动分类触发事件
	$(document).on("mouseenter","li[ectype='floor_cat_content']",function(){
		get_homefloor_cat_content(this);
	});
	
	//首页品牌 换一批切换
	doc.on('click',"*[ectype='changeBrand']",function(){
		var temp = '';
		if($("input[name='temp']").length > 0){
			temp = $("input[name='temp']").val();
		}
		
		Ajax.call("get_ajax_content.php","act=ajax_change_brands&temp="+temp,changeBrandResponse,'GET','JSON');
	});	
	
	function changeBrandResponse(result){
		$("#recommend_brands").html(result.content);
	}
	
	//首页弹出全屏广告
	doc.on('click',"*[ectype='ejectClose']",function(){
		$("*[ectype='ejectAdv']").hide();
	});
	
	/************************************** 首页 end ******************************************/
	
	/************************************** 商品列表页start ***************************************/
	$("a[ectype='gstop']").on("click",function(){
		var parent = $(this).parents(".goods-spread");
		var ico = $(this).find("i");
		var goodslist = parent.siblings(".goods-list");
		var right = 0;
		
		var winWidth = $(window).width();
		
		var minWidth = 1160;
		var maxWidth = 1392;
		
		if(winWidth < 1450){
			minWidth = 978;
			maxWidth = 1200;
		}
		
		if(parent.hasClass("goods-spread-fix")){
			goodslist.stop().animate({"width":minWidth},startAnimate);
			goodslist.removeClass("goods-list-w1390");
		}else{
			goodslist.stop().animate({"width":maxWidth});
			
			right = ($(window).width() - maxWidth)/2;
			parent.css("right",right-60);
			
			goodslist.addClass("goods-list-w1390");
			
			parent.addClass("goods-spread-fix");
			ico.removeClass("icon-right").addClass("icon-left");
		}
		
		function startAnimate(){
			parent.removeClass("goods-spread-fix");	
			ico.removeClass("icon-left").addClass("icon-right");
		}
	});
	
	$("*[ectype='fsortTab'] .item").on("click",function(){
		var Item = $(this);
		var type = Item.data("type");
		var main = $("*[ectype='gMain']");
		
		Item.addClass("current").siblings(".item").removeClass("current");
		if(type == "large"){
			main.find(".gl-warp-large").show();
			main.find(".gl-warp-samll").hide();
		}else{
			main.find(".gl-warp-large").hide();
			main.find(".gl-warp-samll").show();
		}
	});
	
	//列表页 相册切换
    $(".sider li").hover(function(){
		var src = $(this).find('img').attr("src");
		$(this).parents(".sider").prev().find("img").attr("src",src);
		$(this).addClass("curr").siblings().removeClass("curr");
	});
	
    //产品列表筛选
    $(".fcheckbox .checkbox_item label").click(function(){
		var check = $(this).prev();
		if(check.prop("checked") == true){
			var input_url = ($(this).nextAll('#input-i2').attr('rev'));
			check.addClass("checkbox-checked");
		}else{
			var input_url = ($(this).nextAll("#input-i1").attr('rev'));
			check.addClass("checkbox-checked");
		}
		location.href = input_url;
    });
	/************************************** 商品列表页(goods_list)end ***************************************/
	
	
	/************************************** 商品详情页(goods_info)start ***************************************/
        //商品评论标签点击筛选
        $("*[ectype='comment_tag']").on("click",function(){
            var type = $(this).data('type');//操作类型  1表示全部
            //点击高亮处理
            $(this).find('span').addClass('red');
            $(this).siblings().find('span').removeClass('red');
            var tag_obj = $("#ECS_COMMENT").find('.com-list-item');
            if (type == 1) {
                tag_obj.show();
            } else {
                var tag = $(this).find('span').html();
                var i = 0;//评论中出现次数
                if (tag_obj) {
                    tag_obj.each(function () {
                        var _this = $(this);
                        var j = 0;//单条评论中出现次数
                        _this.find('.ciw-actor-info span e').each(function () {
                            var c_tag = $(this).html();
                            if (c_tag == tag) {
                                j++;
                                $(this).addClass('red');
                            }else{
                                $(this).removeClass('red');
                            }
                        });
                        if (j == 0) {
                            _this.hide();
                        } else {
                            _this.show();
                            i++;
                        }
                    })
                    //预留入口
                    if (i == 0) {
                    }
                }
            }
        })
	//多个促销活动展开
	$("*[ectype='view-prom']").hover(function(){
		var $this = $(this);
		var s_wrap = $this.parents(".summary-price-wrap");
		var w_wrap = $this.parents(".s-p-w-wrap");
		var height = w_wrap.outerHeight();
		
		s_wrap.css("height",height);
		w_wrap.addClass("z-promotions-all-show");
		
	},function(){
		var $this = $(this);
		var w_wrap = $this.parents(".s-p-w-wrap");
		w_wrap.removeClass("z-promotions-all-show");
	});
	
	//配送地区选择展开效果
	doc.on("mouseenter","*[ectype='areaSelect']",function(){
		var $this = $(this);
		$this.find("*[ectype='areaWarp']").show();
		$this.addClass("hover");
		$this.find(".iconfont").removeClass("icon-down").addClass("icon-up");
	});
	
	doc.on("mouseleave","*[ectype='areaSelect']",function(){
		var $this = $(this);
		$this.find("*[ectype='areaWarp']").hide();
		$this.removeClass("hover");
		$this.find(".iconfont").removeClass("icon-up").addClass("icon-down");
	});
	
	
	//商品属性选择切换
	$("*[ectype='is-attr'] .item").on("click",function(){
		var $this = $(this),
			parent = $this.parents("*[ectype='is-attr']"),
			type = parent.data("type"),
			name = $this.data("name"),
			spec_value = 0;
			
			spec_value = $this.find("input").val();
			Ajax.call('ajax_dialog.php', 'act=getInfo&goods_id=' + goodsId + '&attr_id=' + spec_value, getImgUrl, 'GET', 'JSON');
		if(type == "radio"){
			$this.find("input[type='radio']").prop("checked",true);
			$this.addClass("selected").siblings().removeClass("selected");
			
			$("[data-name="+name+"]").find("input[type='radio']").prop("checked",true);
			$("[data-name="+name+"]").addClass("selected").siblings().removeClass("selected");
		}else if(type == "checkbox"){
			var len = parent.find(".selected").length;
			
			if($this.hasClass("selected")){
				if(len<=1)return;
				$this.removeClass("selected");
				$this.find("input[type='checkbox']").prop("checked",false);
				
				$("[data-name="+name+"]").removeClass("selected");
				$("[data-name="+name+"]").find("input[type='checkbox']").prop("checked",false);
			}else{
				$this.addClass("selected");
				$this.find("input[type='checkbox']").prop("checked",true);		
				
				$("[data-name="+name+"]").addClass("selected");
				$("[data-name="+name+"]").find("input[type='checkbox']").prop("checked",true);
			}
		}else{}
		
		changePrice();
	});
	
	//商品降价通知
	$("*[ectype='priceNotify']").on("click",function(){
		var $this = $(this),
			user_id = $this.data("userid"),
			goods_id = $this.data("goodsid"),
			content = $("#notify_box").html();
		
		//判断是否登录
		if(user_id == 0){
			var back_url = "goods.php?id=" + goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
			return false;
		}else{
			pb({
				id:"notifyBox",
				title:json_languages.pb_title,
				width:500,
				height:210,
				content:content,
				ok_title:json_languages.determine,
				cl_title:json_languages.cancel,
				drag:false,
				foot:true,
				onOk:function(){
					notifyBox(user_id,goods_id,"#notifyBox");
				}
			});
		}
	});
	
	//白条分期
	$("*[ectype='is-ious'] .item").on("click",function(){
		var $this = $(this),
			val = $this.data("value");
		if($this.hasClass("selected")){
			$this.removeClass("selected");
			$this.siblings("input[name='stages_qishu']").val('');
		}else{
			$this.addClass("selected").siblings().removeClass("selected");
			$this.siblings("input[name='stages_qishu']").val(val);
		}
	});
	
	//分期提交表单
	$("*[ectype='byStages']").on("click",function(){
		var val = $("input[name='stages_qishu']").val();
		var goods_id = $("input[name='good_id']").val();
		var user_id = $("input[name='user_id']").val();
		if(user_id > 0){
			if(val > 0){
				window.location.href ="javascript:bool=1;addToCartStages(goods_id);";
			}else{
				get_goods_prompt_message(json_languages.select_stages_number);
			}
		}else{
			var back_url = "goods.php?id="+ goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	/*门店取货*/
	function goodsStorePick(){
		var goods_id = $("input[name='goods_id']").val(),
			user_id = $("input[name='user_id']").val(),
			back_url = "goods.php?id="+ goods_id,
			formBuy  = document.forms['ECS_FORMBUY'],
			spec_arr = "",
			divId = "";
		//门店服务-门店取货弹窗口
		/*未登录 跳转登陆,登陆选择门店*/
		$("*[ectype='seller_store']").on("click",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "storeDialogBody";
			if(user_id > 0){
				Ajax.call("get_ajax_content.php?act=get_store_list&goods_id="+goods_id+ '&spec_arr=' + spec_arr,'back_act='+ back_url, function(data){
					pb({
						id:divId,
						title:json_languages.see_store,
						width:670,
						height:320,
						content:data.content,
						drag:false,
						foot:false
					});
					
					$.levelLink(1);
					
				}, 'POST','JSON');
			}else{
				$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
				return false;
			}
		});
		
		//到店取货弹框
		$("*[ectype='btn-store-pick']").on("click",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "storePick";
			ru_id = $("input[name='merchantId']").val();
			/*未登录 跳转登陆,登陆选择门店*/
			if(user_id == 0){
				$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
				return false;
			}
			Ajax.call("get_ajax_content.php?act=storePick",'ru_id='+ ru_id + "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(data){
				pb({
					id:divId,
					title:json_languages.store_subscribe,
					width:450,
					height:240,
					ok_title:json_languages.submit_subscribe,
					cl_title:json_languages.cancel,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var store_id = $("input[name='store_id']").val(),
							end_time = $("input[name='end_time']").val(),
							store_mobile = $("input[name='store_mobile']").val();
						if(store_id > 0){
							if(store_mobile == ""){
								pbDialog(json_languages.login_phone_packup_one,"",0);
								$("input[name='store_mobile']").focus();
								return false;
							}else if(!Utils.isTel(store_mobile) || store_mobile.length != 11){
								pbDialog(json_languages.msg_phone_not,"",0);
								$("input[name='store_mobile']").focus();
								return false; 
							}else{
								bool=2;
								addToCart(goods_id,0,0,'','',store_id,end_time,store_mobile);
								return true;
							}
						}else{
							pbDialog(json_languages.select_store,"",0);
							return false;
						}
					}
				});
			}, 'POST','JSON');
		});
	
		/*更换选择门店*/
		$(document).on("click","*[ectype='storeSelect']",function(){
			//商品属性
			if(formBuy){
				spec_arr = getSelectedAttributes(formBuy);
			}
			
			divId = "latelStorePick";
			ru_id = $("input[name='merchantId']").val();
			
			Ajax.call("get_ajax_content.php?act=storeSelect",'ru_id='+ ru_id +  "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(data){
				pb({
					id:divId,
					title:json_languages.store_lately,
					width:900,
					height:410,
					ok_title:json_languages.determine,
					cl_title:json_languages.cancel,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk: function () {
						store_id = $("#"+divId).find(".active input[name='store_id']").val();
						if(store_id > 0){
							Ajax.call("get_ajax_content.php?act=replaceStore",'store_id='+ store_id + "&spec_arr=" + spec_arr +"&goods_id=" + goods_id, function(result){
								$(".replaceStore").html(result.content);
							}, 'POST','JSON')
						}
					}
				});
				//$(".select-shop").perfectScrollbar("destroy");
				//$(".select-shop").perfectScrollbar();
			},'POST','JSON');
			
			//筛选城市门店
			regionSelect(ru_id,goods_id);
		});
	}
	
	//门店取货方法调用
	goodsStorePick();
	
	//商品详情页价格阶梯 start
	$("*[ectype='view_priceLadder']").hover(function(){
		/*clearTimeout(outTimer);
		var priceLadder = $(this).siblings("*[ectype='priceLadder']");
		hoverTimer = setTimeout(function(){priceLadder.show()},200);*/
		
		$(this).siblings("*[ectype='priceLadder']").show();
	},function(){
		$(this).siblings("*[ectype='priceLadder']").hide();
	});
	
	/*$("*[ectype='priceLadder']").hover(function(){
		clearTimeout(outTimer);
		$(this).show();
	},function(){
		$(this).hide();
	});*/
	//商品详情页价格阶梯 end
	
	//配送地区 start
	function areaAddress(){
		var $this = $("#area_address");
		var width=0;
		$this.hover(function(){
			width = $(this).outerWidth();
			$(this).find('.area-warp').show();
		},function(){
			$(this).find('.area-warp').hide();
		});
	}
	areaAddress();
	//配送地区 end
	
	//商品举报
	$("*[ectype='report']").on("click", function () {
		var goods_id = $("input[name='good_id']").val(),
			user_id = $("input[name='user_id']").val(),
			back_url = "user.php?act=goods_report&goods_id="+goods_id;
			
		if(user_id > 0) {
		   location.href = back_url;
		}else{
			$.notLogin("get_ajax_content.php?act=get_login_dialog", back_url);
			return false;
		}
	});
	
	//后台购买流程设置点击确定立即购买,并且没有登录会员弹出登录框(后台设置购物流程为一步购物)
	$("*[ectype='btn-buynow']").click(function(){
		var one_step_buy = $(this).data("type"),
			goods_id = $("input[name='good_id']").val();
			
		if(user_id <= 0 && one_step_buy == 1){
			var back_url = "goods.php?id=" + goods_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
			return false;
		}
	});
	
	
	//预售详情 预售规则
	$(".sp-rule").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	//商品详情页悬浮栏加入购物车 商品规格
	$("*[ectype='tb-tab-anchor']").on("click",function(){
		var t = $(this);
		$(this).siblings(".tb-popsku").show();
	});
	
	$("*[ectype='tb-cancel']").on("click",function(){
		var t = $(this);
		$(this).parents(".tb-popsku").hide();
	});
	
	//商品详情页店铺展开收起
	$(".arrow-show-more").click(function(){
		$(".seller-pop-box,.seller-address").stop(true,false).slideToggle();
	});
	
	//店内分类展开收起
	$("*[ectype='cateOpen'] dt").click(function(){
		var $this = $(this);
		var dl = $this.parent("dl");
		if(dl.hasClass("hover")){
			dl.removeClass("hover");
		}else{
			dl.addClass("hover");
		}
	});
	
	//商品详情页 详情左侧 店铺商品热销、新品、精品排行
	var rankmcli_length = $("*[ectype='rankMcTab']").find("li").length;
	if(rankmcli_length == 1){
		$("*[ectype='rankMcTab']").addClass("mcOne");
	}else if(rankmcli_length == 2){
		$("*[ectype='rankMcTab']").addClass("mcTwo");
	}else if(rankmcli_length == 3){
		$("*[ectype='rankMcTab']").addClass("mcThree");
	}
	
	//评论筛选
	$("*[ectype='gmf-tab'] li").click(function(){
		var rev = $(this).attr("rev");
		var comment = "";
		var goods_id = $("input[name='good_id']").val()
		$(this).addClass("curr").siblings().removeClass("curr");
		
		if(rev == 1){
			comment = 'comment_good';	
		}else if(rev == 2){
			comment = 'comment_middle';
		}else if(rev == 3){
			comment = 'comment_short';
		}else{
			comment = 'comment_all';
		}
		
		goods_id = goods_id + "|" + rev;
		
		Ajax.call('comment.php?act=' + comment, 'id=' + goods_id, get_commentResponse, 'GET', 'JSON');
	});
	
	$("*[ectype='reply']").click(function(){
		if($(this).parents(".com-operate").next().hasClass("hide")){
			$(this).parents(".com-operate").next().removeClass("hide");
		}else{
			$(this).parents(".com-operate").next().addClass("hide");
		}
	});
	
	function get_commentResponse(result){
		$("#ECS_COMMENT").html(result.content);
	}
	
	//网友讨论圈
	$('.dis_type').click(function(){
		var T = $(this);
		var rev = T.attr('rev');
		var dis_sort = T.attr('sort');
		var revType = T.attr('revType');
		var goods_id = $("input[name='good_id']").val();
		
		$(this).addClass('curr').siblings().removeClass('curr');
		
		if(!revType){
			revType = 0; //加载模板
		}
		
		if(dis_sort){
			dis_sort = "|" + dis_sort;
			rev = $("input[name='dis_class']").val();
		}else{
			dis_sort = '';
			$("input[name='dis_class']").val(rev);
		}
		
		goods_id = goods_id + "|" + rev + "|" + revType + dis_sort;
		
		Ajax.call('comment_discuss.php?act=discuss', 'id=' + goods_id, comment_discussResponse, 'GET', 'JSON');
	});
	
	$('.dis_type').eq(0).click();
	function comment_discussResponse(result){
		$("#discuss_list_ECS_COMMENT").html(result.content);
	}
	
	/*评论图片展开 start */
	$(document).on("click",".p-thumb-img li",function(){
		var $this = $(this);
		var imgUrl = $this.data("src");
		var viewImg = $this.parents(".p-imgs-warp").find(".p-view-img");
		var length = $this.siblings("li").length + 1;
		var fale = false;
		if($this.hasClass("curr")){
			$this.removeClass("curr");
			fale = false;
		}else{
			$this.addClass("curr").siblings().removeClass("curr");	
			fale = true;
		}
		
		if(fale == true){
			viewImg.show();
			viewImg.find("img").attr("src",imgUrl);
		}else{
			viewImg.hide();
		}
	});
	
	$(document).on("click",".p-view-img img",function(){
		var $this = $(this);
		var viewImg = $this.parents(".p-view-img");
		viewImg.hide();
		viewImg.siblings(".p-thumb-img").find("li").removeClass("curr");
	});
	
	$(document).on("click",".p-view-img a",function(){
		var $this = $(this);
		var imgs = $this.parents(".p-imgs-warp");
		var length = imgs.find("li").length;
		var count = imgs.find(".curr").data("count");
		
		if($this.hasClass("p-prev")){
			if(count>1){
				imgs.find("*[data-count="+(count-1)+"]").click();
			}
		}else{
			if(count != length){
				imgs.find("*[data-count="+(count+1)+"]").click();
			}
		}
	});
	/*评论图片展开end*/
	
	/************************************** 商品详情页(goods_list)end ***************************************/
	
	/************************************** 品牌专区(brand)start *******************************************/
	//品牌专区首页分类筛选
	$(document).on("click", "*[ectype='brandCate'] *[ectype='cateItem']", function(){
		var cat_id = $(this).data('catid');
		
		$(this).addClass('curr').siblings("*[ectype='cateItem']").removeClass('curr');
		
		$.jqueryAjax('brand.php', 'act=filter_category&cat_id='+cat_id, function(data){
			$("*[ectype='brandList'] *[ectype='items']").html(data.content);
		});
	});
	
	//品牌专区 品牌详情页 点击分类展示商品
	$(document).on("click","*[ectype='brandcat'] a",function(){
		var brand_id = $("input[name=brand_id]").val();
		var cat_id = $(this).data("catid");
		
		$(this).addClass("curr").siblings().removeClass("curr");
		$.jqueryAjax('brandn.php', 'act=get_brand_cat_goods&id='+brand_id+'&cat='+cat_id, function(data){
			if(data.content){
				$("*[ectype='goodslist']").html(data.content);
			}
		});
	});
	/************************************** 品牌专区(brand)end *********************************************/
	
	/********************************************* 购物车(cart)start ***************************************/
	$("*[ectype='c-promotion']").on("click",function(){
		var $this = $(this);
		var parent = $this.parent();
		var height = parent.find("*[ectype='promTips'] ul").height();
		$(".promotion-info").removeClass("prom-hover");
		$(".promotion-info").find("*[ectype='promTips']").css("height",0);
		if(parent.hasClass("prom-hover")){
			parent.removeClass("prom-hover");
			parent.find("*[ectype='promTips']").css("height",0);
		}else{
			parent.addClass("prom-hover");
			parent.find("*[ectype='promTips']").css("height",height);
		}
	});
	
	//购物车删除和移到收藏弹框
	$(document).on("click", "*[ectype='cartOperation']", function(){
		var user_id = $("#user_id").val();
		
		var ok_title, cl_title, content;
		var obj = $(this).data("value");
		if (obj.divId == 'cart_remove') {
			ok_title = json_languages.remove;
			cl_title = json_languages.move_collection;
			content = $("#dialog_remove").html();
		} else if (obj.divId == 'cart_collect') {
			ok_title = json_languages.follow;
			cl_title = json_languages.cancel;
			content = $("#dialog_collect").html();
		}
		
		if (user_id > 0 || obj.divId == 'cart_remove') {
			pb({
				id: obj.divId,
				title: obj.title,
				width: 455,
				height: 58,
				ok_title: ok_title, //按钮名称
				cl_title: cl_title, //按钮名称
				content: content, //调取内容
				drag: false,
				foot: true,
				onOk: function () {
					location.href = obj.url;
				},
				onCancel: function () {
					if (obj.divId == 'cart_remove') {
						location.href = obj.cancelUrl;
					}
				}
			});
		}else{
			var back_url = "flow.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	//购物车批量删除
	$("*[data-dialog='remove_collect_dialog']").click(function(){
		var user_id = $("#user_id").val();
		if(user_id > 0){
			var remove_url = $(this).data('removeurl');
			var collect_url = $(this).data('collecturl');
			var divId = $(this).data('divid');
			var cart_value = $('#cart_value').val();
			var goods_ru = $('#goods_ru').val();
			var url;
			
			if(divId == 'cart-remove-batch'){
				var content = json_languages.drop_goods;
				url = remove_url;
			}else if(divId == 'cart-collect-batch'){
				var content = json_languages.confirm_Move_collection;
				url = collect_url;
			}
			
			pbDialog(content,"",0,450,50,"",true,function(){
				Ajax.call(url, 'cart_value=' + cart_value, function(data){
						location.href = "flow.php";
				}, 'POST','JSON');
			});
		}else{
			var back_url = "flow.php";
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		}
	});
	
	
	//购物车未登录结算弹出登录框
	$("#go_pay").click(function(){
		var back_url=$(this).data("url");
		$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
		return false;
	});
	/********************************************* 购物车(cart)end ***************************************/
	
	/********************************************* 结算页(flow)start ***************************************/
	
	//收货人信息切换
	$(document).on("click","*[ectype='cs-w-item']",function(){
		var $this = $(this);
		var address_id = $this.data('addressid');
		var store_id = 0;
		var shipping_id = get_cart_shipping_id();
		
		if($(":input[name='uc_id']").length > 0){
			var uc_id = $(":input[name='uc_id']").val();
		}else{
			var uc_id = 0;
		}
		
		$this.addClass("cs-selected").siblings().removeClass("cs-selected");
		
		if(document.getElementById('store_id')){
			store_id = document.getElementById('store_id').value;
			(store_id > 0) ? store_id : 0;
		}
		uc_id
		Ajax.call('flow.php?step=edit_consignee_checked', 'address_id=' + address_id + '&store_id=' +store_id + '&uc_id=' + uc_id + '&shipping_id=' + $.toJSON(shipping_id), function (result) {
			if(result.error > 0){
				if(result.error == 1){
					var back_url = "flow.php";
					$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
					return false;
				}else{
					alert(result.msg);
					return false;
				}
			}else{
				$('#consignee-addr').html(result.content);
				$('#goods_inventory').html(result.goods_list);//送货清单
				$('#ECS_ORDERTOTAL').html(result.order_total);//费用汇总
				
                                //优惠券 处理
                                $("[ectype='order_coupoms_list']").html(result.order_coupoms_list);
				$('#not_freightfree').val(result.not_freightfree);
			}
		}, 'POST','JSON');
	});
        
	/* 结算页面 用户收货地址 start */
	$(document).on("click","*[ectype='dialog_checkout']",function(){
		var obj = $(this).data("value");
		var parent = $(this).parents(".cs-w-item");
		var length = parent.siblings(".cs-w-item").length;
		if(obj.divId == 'new_address'){
			if((length+1) >= 11){
				pbDialog(json_languages.add_address_10,"",0);
				return false;
			}
		}
		
		if(obj.divId == 'new_address' || obj.divId == 'edit_address'){
			//添加收货地址信息
			Ajax.call(obj.url, 'address_id=' + obj.id, function(data){
				pb({
					id:obj.divId,
					title:obj.title,
					width:obj.width,
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					ok_title:json_languages.con_Preservation,
					cl_title:json_languages.cancel,
					onOk:function(){
						var form = $("#" + obj.divId).find("form").attr("name");
						if(addUpdate_Consignee(form)== false){
							return false;
						}else{
							return true;
						};
					}
				});
				
				if(obj.divId == 'new_address'){
					//新增地区初始化
					$.levelLink(1);
				}else{
					//编辑地区初始化
					$.levelLink(0);
				}
				
			}, 'POST','JSON');
				            
		}else if(obj.divId == 'del_address'){
			//删除收货地址信息
			var content = $('#del_address').html();
			
			pbDialog(json_languages.confirm_drop_address,"",0,'','','',true,function(){
				Ajax.call('flow.php?step=delete_Consignee', 'address_id=' + obj.id + "&temtype=1&type=1", function(data){
					if(data.error == 2){
						$('#consignee-addr').html(data.content);
					}else{
						$('#consignee-addr').html(data.content);
					}
					
					$('#goods_inventory').html(data.goods_list);//送货清单
					$('#ECS_ORDERTOTAL').html(data.order_total);//费用汇总
					
					$('#not_freightfree').val(0);
				}, 'POST','JSON');
			});
		}
	});
	/* 结算页面 用户收货地址 end */
	
	/* 门店自提结算页面 修改门店选择 start*/
	$("*[ectype='storeBtn']").on("click",function(){
		$("*[ectype='seller_address']").addClass("hide")
		$("*[ectype='get_seller_sotre']").addClass("show");
	});
	
	/* 门店自提结算页面 修改门店选择 end*/
	
	function paymet(){
		var payment_method = $("*[ectype='paymentType']"),			//结算页面支付方式
			payInput = $("input[name='pay_pwd_error']"),			//结算页面其他信息 支付密码隐藏域
			length = payInput.length,								//结算页面其他信息 支付密码隐藏域 大于0表示开启
			balance = $("#qt_balance"),                             //结算页面其他信息 使用余额
			payPw = $("#qt_onlinepay"),								//结束页面其他信息 支付密码
			integObj = $("#qt_integral"),							//结算页面其他信息 使用积分
			sueplus = balance.find("input[name='surplus']"),		//余额input
			user_sueplus = sueplus.data("yoursurplus"),				//用户可用余额
			integral = integObj.find("input[name='integral']"),		//积分input
			integral_max = integral.data("maxinteg");				//此订单可用积分
		
			//余额和积分初始化方法
			initialize = function(){
			//积分input是否大于0
			if(integral.val() > 0){
				//初始化积分
				integral.val(0);
				//初始化积分为0,总价去除积分抵扣价格
				changeIntegral(0);
			}
			
			//余额input是否大于0
			if(sueplus.val() > 0){
				//初始化余额
				sueplus.val(0);
				//初始化余额为0,总价去除余额抵扣价格
				changeSurplus(0);
			}
		}
		
		payPassword = function(){
			var pay_length = payment_method.find(".item-selected").length;
			if(length > 0 && pay_length > 0){
				var paymet_curr_val = payment_method.find(".item-selected").data("value"),  //结算页面支付方式 默认选中的支付方式value
					paymet_curr_type = paymet_curr_val.type;								//结算页面支付方式 默认选中的支付方式类型
				
				//初始化
				initialize();
				
				if(paymet_curr_type == "balance"){
					//余额支付状态,余额填写区域隐藏
					balance.hide();
					
					//支付状态为在线支付,并且设置了支付密码
					if(payPw.length > 0){
						payPw.show();    //支付密码显示
						payInput.val(1); //支付密码隐藏域值赋值为1
					}
				}else{
					//非余额支付状态,余额填写区域显示
					balance.show();
					
					//用户余额大于0,余额显示
					if(user_sueplus > 0){
						balance.show();
					}else{
						balance.hide();
					}
					
					//此订单可以使用积分,积分显示
					if(integral_max > 0){
						//integObj.show();
					}else{
						//integObj.hide();
					}
					
					payPw.hide();  //支付密码隐藏
					payInput.val(0); //支付密码隐藏域值赋值为0
				}
			}
		}
		
		initialize(); //初始化方法默认调用
		payPassword();
		
		//支付方式切换
		payment_method.find(".p-radio-item").on("click",function(){
			var t = $(this),
				paymet_curr_val = t.data("value"),			//选中支付方式的value
				paymet_curr_type = paymet_curr_val.type,	//选中支付方式的type
				paymet_curr_id = paymet_curr_val.payid,     //选中支付方式的id
				paymet_curr_allow = paymet_curr_val.allow;  //选中支付方式的allow
			
			//初始化方法调用
			initialize();
			
			//支付方式选中
			t.addClass("item-selected").siblings().removeClass("item-selected");
			t.find('input').prop("checked",true);
			
			if(paymet_curr_type == "balance"){
				//余额支付状态,余额填写区域隐藏
				balance.hide();
				
				//支付状态为在线支付,并且设置了支付密码
				if(payPw.length > 0){
					payPw.show();    //支付密码显示
					payInput.val(1); //支付密码隐藏域值赋值为1
				}
			}else{
				
				//非余额支付状态,余额填写区域显示
				balance.show();
				
				if(paymet_curr_allow == 1){
					//判断会员是否有余额
					changeSurplus(0);
				}
				
				/* 是否存在储值卡和是否选择储值卡 */
				if(document.getElementById('value_card_psd') && $("#value_card_psd").prop('disabled') == true){
					
					//支付密码显示
					payPw.show();
					
					//初始化支付密码
					payPw.find("input[name='pay_pwd']").val("");
					
					payInput.val(1); //支付密码隐藏域值赋值为1
			
				}else{
					payPw.hide();  //支付密码隐藏
					
					//初始化支付密码
					payPw.find("input[name='pay_pwd']").val("");
					
					payInput.val(0); //支付密码隐藏域值赋值为0
				}
			}
			
			//改变支付方式
			selectPayment(paymet_curr_id);
		});
	}
	paymet();
	
	//发票修改
	$(document).on("click","*[ectype='invEdit']",function(){
		var obj = $(this).data("value");
		var invoice_type = $("#inv_content").find("input[name='invoice_type']").val();
		Ajax.call(obj.url,'invoice_type=' + invoice_type ,invoiceResponse, 'POST', 'JSON');
		function invoiceResponse(data){
			if(data.error == 0){
				pb({
					id:obj.divid,
					title:obj.title,
					width:675,
					height:278,
					ok_title:json_languages.invoice_ok, 	//按钮名称
					cl_title:json_languages.cancel, 		//按钮名称
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var invoice_val  = $("#edit_invoice .selected").find("input[name='invoice_id']").val();
						var inv_content  = $("#edit_invoice .radio-list .item-selected").find("input[name='inv_content']").val();
						var invoice_type = $("#edit_invoice .tab-nav").find(".item-selected").data('value');
						var store_id 	 = $("#store_id").val();
						var tax_id = $("#tax_id").val();
						var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
						var area_id = $(".checkout-foot").find("input[name='area_id']").val();
						var cfrom = $("#inv_content").find("input[name='from']").val();
						var shipping_id = get_cart_shipping_id();
						
						if(typeof invoice_val == 'undefined' || invoice_val == ""){
							pbDialog(json_languages.invoice_packup,"",0);
							return false;
						}
						if(!$("*[ectype='tax']").is(":hidden") && tax_id == ""){
							pbDialog(json_languages.invoice_tax_null,"",0);
							return false;
						}
						
						Ajax.call('ajax_dialog.php?act=gotoInvoice','inv_content='+encodeURIComponent(inv_content)+'&invoice_id='+invoice_val + '&from='+ cfrom +'&warehouse_id='+warehouse_id +'&area_id='+area_id +'&store_id='+store_id +'&invoice_type='+invoice_type + '&tax_id=' + tax_id + '&shipping_id=' + $.toJSON(shipping_id),gotoInvoiceResponse, 'POST', 'JSON');
									  	
						function gotoInvoiceResponse(result){
							if(result.error != ""){
								pbDialog(result.error,"",0);
								return false;
							}else{
								if(result.type){
									$("#inv_content .inv_payee").html('');
									$("#inv_content .inv_content").html('');
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val('');
									$("#inv_content").find("input[name=inv_content]").val('');	
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);	
                                    
                                    $("#ECS_ORDERTOTAL").html(result.content);	
								}else{
									$("#inv_content .inv_payee").html(result.inv_payee);
									$("#inv_content .inv_content").html(result.inv_content);
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val(result.inv_payee);
									$("#inv_content").find("input[name=inv_content]").val(result.inv_content);
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);
									$("#inv_content").find("input[name=tax_id]").val(result.tax_id);
									
									
									$("#common_button").find("input[name=inv_payee]").val(result.inv_payee);
									$("#common_button").find("input[name=inv_content]").val(result.inv_content);
									$("#common_button").find("input[name=invoice_type]").val(invoice_type);
									$("#common_button").find("input[name=tax_id]").val(result.tax_id);
									$("#ECS_ORDERTOTAL").html(result.content);									
								}
							}
						}
					}
				});
				
				//选中效果 by wu start
				var inv_payee = $("#inv_content").find("input[name=inv_payee]").val();
				var inv_content = $("#inv_content").find("input[name=inv_content]").val();
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").parents(".invoice-item").addClass("selected").siblings().removeClass("selected");
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").siblings("input[name='invoice_id']").prop("checked",true);
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").parents("li").addClass("item-selected").siblings().removeClass("item-selected");
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").prop("checked",true);
				//选中效果 by wu end
				
				invoice();	
			}else if(data.error == 1){
				pbDialog(data.content,"",0,"","",50);
			}
		}
		
		//跳转手机端
		browserRedirect();
	});
//批发-发票修改
	$(document).on("click","*[ectype='wholesale_invEdit']",function(){
		var obj = $(this).data("value");
		var invoice_type = $("#inv_content").find("input[name='invoice_type']").val();
		Ajax.call(obj.url,'invoice_type=' + invoice_type ,invoiceResponse, 'POST', 'JSON');
		function invoiceResponse(data){
			if(data.error == 0){
				pb({
					id:obj.divid,
					title:obj.title,
					width:675,
					height:278,
					ok_title:json_languages.invoice_ok, 	//按钮名称
					cl_title:json_languages.cancel, 		//按钮名称
					content:data.content, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){
						var invoice_val  = $("#edit_invoice .selected").find("input[name='invoice_id']").val();
						var inv_content  = $("#edit_invoice .radio-list .item-selected").find("input[name='inv_content']").val();
						var invoice_type = $("#edit_invoice .tab-nav").find(".item-selected").data('value');
						var store_id 	 = $("#store_id").val();
						var tax_id = $("#tax_id").val();
						var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
						var area_id = $(".checkout-foot").find("input[name='area_id']").val();
						var cfrom = $("#inv_content").find("input[name='from']").val();
						var shipping_id = get_cart_shipping_id();
						
						if(typeof invoice_val == 'undefined' || invoice_val == ""){
							pbDialog(json_languages.invoice_packup,"",0);
							return false;
						}
						if(!$("*[ectype='tax']").is(":hidden") && tax_id == ""){
							pbDialog(json_languages.invoice_tax_null,"",0);
							return false;
						}
						
						Ajax.call('ajax_dialog.php?act=wholesale_gotoInvoice','inv_content='+encodeURIComponent(inv_content)+'&invoice_id='+invoice_val + '&from='+ cfrom +'&warehouse_id='+warehouse_id +'&area_id='+area_id +'&store_id='+store_id +'&invoice_type='+invoice_type + '&tax_id=' + tax_id + '&shipping_id=' + $.toJSON(shipping_id),gotoInvoiceResponse, 'POST', 'JSON');
									  	
						function gotoInvoiceResponse(result){
							if(result.error != ""){
								pbDialog(result.error,"",0);
								return false;
							}else{
								if(result.type){
									$("#inv_content .inv_payee").html('');
									$("#inv_content .inv_content").html('');
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val('');
									$("#inv_content").find("input[name=inv_content]").val('');	
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);									
								}else{
									$("#inv_content .inv_payee").html(result.inv_payee);
									$("#inv_content .inv_content").html(result.inv_content);
									$("#inv_content .invoice_type").html(result.invoice_type);
									$("#inv_content").find("input[name=inv_payee]").val(result.inv_payee);
									$("#inv_content").find("input[name=inv_content]").val(result.inv_content);
									$("#inv_content").find("input[name=invoice_type]").val(invoice_type);
									$("#inv_content").find("input[name=tax_id]").val(result.tax_id);
									
									
									$("#common_button").find("input[name=inv_payee]").val(result.inv_payee);
									$("#common_button").find("input[name=inv_content]").val(result.inv_content);
									$("#common_button").find("input[name=invoice_type]").val(invoice_type);
									$("#common_button").find("input[name=tax_id]").val(result.tax_id);
									$("#ECS_ORDERTOTAL").html(result.content);									
								}
							}
						}
					}
				});
				
				//选中效果 by wu start
				var inv_payee = $("#inv_content").find("input[name=inv_payee]").val();
				var inv_content = $("#inv_content").find("input[name=inv_content]").val();
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").parents(".invoice-item").addClass("selected").siblings().removeClass("selected");
				$("#edit_invoice .invoice-list").find("input[value='"+inv_payee+"']").siblings("input[name='invoice_id']").prop("checked",true);
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").parents("li").addClass("item-selected").siblings().removeClass("item-selected");
				$("#edit_invoice .radio-list").find("input[value='"+inv_content+"']").prop("checked",true);
				//选中效果 by wu end
				
				invoice();	
			}else if(data.error == 1){
				pbDialog(data.content,"",0,"","",50);
			}
		}
		
		//跳转手机端
		browserRedirect();
	});
	
	/* 跳转手机端 start */
	function browserRedirect() {
		var sUserAgent = navigator.userAgent.toLowerCase();
		var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
		var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
		var bIsMidp = sUserAgent.match(/midp/i) == "midp";
		var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
		var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
		var bIsAndroid = sUserAgent.match(/android/i) == "android";
		var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
		var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
		
		if ((bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) == true ){
			window.location.href="/mobile";
		}
	}
	/* 跳转手机端 end */
	
	//编辑发票弹窗内容
	function invoice(){
		var invoice = "#edit_invoice",
			invoiceItem = ".invoice-item",
			addBtn = ".add-invoice-btn",
			editBtn = ".edit-tit",
			updateBtn = ".update-tit",
			delBtn = ".del-tit",
			radioList = $(invoice).find(".radio-list");
			
		if($(".invoice-item").hasClass("selected")){
			
			var invoiceid = $(".invoice-thickbox .selected").data('invoiceid');
			
			var tax_id = $(":input[name='invoice_tax_" + invoiceid + "']").val();
			
			$("#tax_id").val(tax_id);
		}
		$(".invoice-list").on("click",invoiceItem,function(){
			$(this).addClass("selected").siblings().removeClass("selected");
			$(this).find("input[name='invoice_id']").prop("checked", true); 
			
			var invoice_id = $(this).find(":input[name='invoice_id']").val();
			if(invoice_id > 0){
				var tax_id = $(this).find('[ectype=taxId]').val();
			}else{
				var tax_id = $("#tax_id").val();
			}
			
			$("#tax_id").val(tax_id);
			checked(invoice_id);
		});
		
		function checked(invoice_id){
			if($(invoiceItem).length <= 1 || invoice_id == 0){
				$("*[ectype='tax']").hide();
				$("#tax_id").val('');
			}else{
				$("*[ectype='tax']").show();
			}
		}
		checked($(invoiceItem).find("input[name='invoice_id']:checked").val());
		
		//新增公司发票
		$(invoice).find(addBtn).on("click",function(){
			var $this = $(this),
				f_item = "";
			$this.addClass("hide");
			$(invoiceItem).removeClass("selected");
			
			f_item = $(invoiceItem).length;
		
			if(f_item < 4){
				var div = "
";
				$this.parent().prev().append(div);
				
				$(invoiceItem).eq(f_item).find("input.inv_payee").focus();
				
				$("div[ectype='tax']").hide();
				$("div[ectype='tax']").find("input[name='tax_id']").val('');
			}else{
				pbDialog(json_languages.invoice_desc_number,"",0);
				
				$(invoiceItem).eq(0).addClass("selected");
				$this.removeClass("hide");
			}
		});
		
		//编辑公司名称
		$(".invoice-list").on('click',editBtn,function(){
			var $this = $(this),
				obj = $this.parent().prev(),
				val = 0;
			
			obj.find("input").removeAttr("readonly");
			obj.find("input").focus();
			
			$this.addClass("hide").next().removeClass("hide");
			val = obj.find("input[name='invoice_id']").val();
		});
		
		$(".invoice-list").on('click',updateBtn,function(){
			var $this = $(this),
				obj = $this.parent().prev(),
				inv_payee = obj.find("input[name=inv_payee]").val(),
				invoice_id = obj.find("input[name=invoice_id]").val(),
				tax_id = $("#tax_id").val();
				
			if(inv_payee==""){
				
				pbDialog(json_languages.invoice_desc_null,"",0);
				return false;
				
			}else{
				Ajax.call('ajax_dialog.php?act=update_invoicename', 'inv_payee=' + encodeURIComponent(inv_payee) + '&invoice_id=' + invoice_id + '&tax_id=' + tax_id, function (result) {
					if(result.error == 0){
						obj.find("input[name=invoice_id]").val(result.invoice_id);
					
						$("#tax_id").val(result.tax_id);
						
						checked(result.invoice_id);
					}else{	
						pbDialog(result.msg,"",0);
						
					}
				},'POST','JSON');
				obj.find("input").attr("readonly", true);
				
				$this.addClass("hide").siblings().removeClass("hide");
				
				$(addBtn).removeClass("hide");
				
				$this.find("input[name='invoice_id']").prop("checked", true);
			}
		});
		
		$(".invoice-list").on("click",delBtn,function(){
			var $this = $(this),
				obj = $this.parents(invoiceItem),
				invoice_id = obj.find("input[name=invoice_id]").val(),
				length = 0;
			if (invoice_id == 0) {
				obj.remove();
				
				length = $(invoice).find(invoiceItem).length;
				if(length == 1) {
					$(invoice).find(invoiceItem).addClass("selected");
					$(invoice).find(invoiceItem).find("input[name=invoice_id]").prop("checked", true);
				}
			
			}else{
				Ajax.call('ajax_dialog.php?act=del_invoicename', 'invoice_id=' + invoice_id, function (result) {
					if(result.error == 1) {
						
						pbDialog(result.msg,"",0);
						return false;
						
					}else{
						obj.remove();
						$(invoice).find(invoiceItem).eq(0).addClass("selected");
						$(invoice).find(invoiceItem).eq(0).find("input[name=invoice_id]").click();
						$("#tax_id").val('');
					}
				},'POST', 'JSON');
			}
		});
		
		radioList.find("li").click(function(){
			$(this).addClass("item-selected").siblings().removeClass("item-selected");
			$(this).find('input').prop("checked", true);
		});
		/*发票切换*/
		$(".invoice-dialog").slide({titCell:".tab-nav li",mainCell:".invoice-thickbox",titOnClassName:"item-selected",trigger:"click"});
		
		/*下一步*/
		$("*[ectype='nextStep']").on("click",function(){
			var type = $(this).data("type"),				
				steps = $(this).parents(".steps"),
				fald = true,
				frm = $(this).parents("form[name='inv_form']"),
				act = frm.find("input[name='action']").val(),
				msg = new Object;
				
				msg.company_name = frm.find("input[name='company_name']").val();
				msg.tax_id = frm.find("input[name='tax_id']").val();
				msg.company_address = frm.find("input[name='company_address']").val();
				msg.company_telephone = frm.find("input[name='company_telephone']").val();
				msg.bank_of_deposit = frm.find("input[name='bank_of_deposit']").val();
				msg.bank_account = frm.find("input[name='bank_account']").val();
				msg.consignee_name = frm.find("input[name='consignee_name']").val();
				msg.consignee_mobile_phone = frm.find("input[name='consignee_mobile_phone']").val();
				msg.country = frm.find("input[name='country']").val();
				msg.province = frm.find("input[name='province']").val();
				msg.city = frm.find("input[name='city']").val();
				msg.district = frm.find("input[name='district']").val();
				msg.consignee_address = frm.find("input[name='consignee_address']").val();
				console.log(msg);
			if(type != 1){
				var step = steps.find(".step").eq(type-1);
				
				step.find("input[type='text']").each(function(v,k){
					if($(this).val() == ""){
						iValid($(this).attr("name"),$(this).val(),type);
						fald = false;
					}else{
						fald = true;
					}
				});
			}else{
				fald = true;
			}
			
			if(fald == true){
				steps.find(".step").eq(type).show().siblings().hide();	
				
			if(type == 3){
					Ajax.call('user.php?act=' + act, 'msg=' + $.toJSON(msg),function(data){
						var icon = 1;
						if(data.error == 1){
							icon = 3;
						}
						
						var html = '
';
						
						$("*[ectype='invReturn']").html(html);	
					},'POST','JSON');
				}
			}
		});
		/*返回*/
		$("*[ectype='backStep']").on("click",function(){
			var type = $(this).data("type"),				
				steps = $(this).parents(".steps");
			steps.find(".step").eq((type-2)).show().siblings().hide();	
		});
		
		function iValid(name,val,type){
			if(val == "" && type == 2){
				switch(name){
					case 'company_name':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写增值发票单位名称");
					break;
					
					case 'tax_id':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写纳税人识别码");
					break;
					
					case 'company_address':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写注册地址");
					break;
					
					case 'company_telephone':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写联系电话");
					break;
					
					case 'bank_of_deposit':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写开户行名称");
					break;
					
					case 'bank_account':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写银行卡卡号");
					break;
					
					default:
					return true;
				}
			}else if(val == "" && type == 3){
				switch(name){
					case 'consignee_name':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写收发票人名称");
					break;
					
					case 'consignee_mobile_phone':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写收票人手机号码");
					break;
					
					case 'consignee_province':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写收票人地址");
					break;
					
					case 'consignee_address':
					$("input[name='"+ name +"']").siblings(".form_prompt").html("请填写收票人详细地址");
					break;
					
					default:
					return true;
				}	
			}
		}
	}
	
	//优惠券/储值卡/红包
	$("*[ectype='ck-toggle']").on("click",function(){
		var $this = $(this);
		$this.siblings(".ck-step-cont").slideToggle(300,function(){
			if($this.hasClass("ck-toggle-off")){
				$this.removeClass("ck-toggle-off")
					 .addClass("ck-toggle-on")
					 .find(".iconfont")
					 .removeClass(".icon-down")
					 .addClass("icon-up");
			}else{
				$this.removeClass("ck-toggle-on")
					 .addClass("ck-toggle-off")
					 .find(".iconfont")
					 .removeClass("icon-up")
					 .addClass("icon-down");
			}
		});
	});
	
	//优惠券/储值卡/红包 选择切换
	$(document).on("click","*[ectype='panlItem']",function(){
		var $this = $(this);
		var shipping_id = get_cart_shipping_id();
		var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
		var area_id = $(".checkout-foot").find("input[name='area_id']").val();
						
		//没填收货地址不允许选择
		var uc_id = $this.data('ucid');
		var type = $this.data("type");
	   
		if ($('#consignee-addr').length == 0) {
			pbDialog(json_languages.checked_address,"",0);
			return false;
		}
		if ($this.hasClass("selected")) {
			$this.removeClass("selected").siblings().removeClass("selected");
			//优惠券
			if(type == 'coupons'){
				$.getJSON("flow.php?step=change_coupons&uc_id=0", '&warehouse_id=' + warehouse_id + '&area_id=' + area_id + '&shipping_id=' + $.toJSON(shipping_id),function(data){
					orderSelectedResponse(data);
					$('#uc_id').val(0);
					$('#not_freightfree').val(0);
				},'json');
			}
			//红包
			else if(type == 'bonus'){
			   $('#bonus_id').val(0);
				changeBonus(0);
			}
			//储值卡
			else if(type == 'value_card'){
				$('#ECS_VALUE_CARD').val(0);
				changeVcard(0);
			}
		} else {
			$this.addClass("selected").siblings().removeClass("selected");
			//优惠券
			 if(type == 'coupons'){
				$.getJSON("flow.php?step=change_coupons&uc_id=" + uc_id, '&warehouse_id=' + warehouse_id + '&area_id=' + area_id + '&shipping_id=' + $.toJSON(shipping_id), function (data) {
					$('#uc_id').val(uc_id);
					$('#not_freightfree').val(data.not_freightfree);
					
					orderSelectedResponse(data);
				}, 'json')
			}
			//红包
			else if(type == 'bonus'){
				$('#bonus_id').val(uc_id);
				changeBonus(uc_id);
			}
			//储值卡
			else if(type == 'value_card'){
				$('#ECS_VALUE_CARD').val(uc_id);
				changeVcard(uc_id);
			}
		}
	});
	
	//配送方式选择
	function logistics(){
		var t = "", 
			parents = "",
			_html = "",
			index = 0,
			ru_id = 0,
			type = 0,
			shipping = "",
			shipping_id = 0,
			shipping_code = "",
			text = "";
		
		//展开配送方式
		doc.on('mouseenter','.mode-tab-item',function(){
			clearTimeout(outTimer);
			var width = 0;
			t = $(this);
			width = t.parents("ul").outerWidth();
			
			shipping_code = t.data('shippingcode');
			parents = t.parents("[ectype='disInfo']");
			
			hoverTimer = setTimeout(function(){
				if(shipping_code == "cac"){
					parents.find("*[ectype='since']").show();
					parents.find("*[ectype='logistics']").hide();
				}else{
					parents.find("*[ectype='logistics']").css("right",width-t.outerWidth());
					parents.find("*[ectype='logistics']").show();
					parents.find("*[ectype='since']").hide();
				}
			},200);
		})
		.on('mouseleave','.mode-tab-item',function(){
			clearTimeout(hoverTimer);
			t = $(this);
			
			shipping_code = t.data('shippingcode');
			parents = t.parents();
			
			outTimer = setTimeout(function(){
				parents.find("*[ectype='since']").hide();
				parents.find("*[ectype='logistics']").hide();
			},100);	
		})
		.on('mouseenter','.mwapper',function(){
			clearTimeout(outTimer);
		})
		.on('mouseleave','.mwapper',function(){
			$(this).hide();
		});
		
		//展开配送方式end
		//切换配送方式 start
		$(document).on("click",".logistics_li",function(){
			t = $(this);
			index = t.index();
			ru_id = t.data('ruid');
			type = t.data('type');
			shipping_id = t.data('shipping');
			shipping_code = t.data('shippingcode');
			parents = t.parents("*[ectype='disInfo']");
			shipping = "";
			var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
			var area_id = $(".checkout-foot").find("input[name='area_id']").val();
			
			if(shipping_code != 'cac')
			{
				_html = t.data("text");
				parents.find("*[ectype='tabLog']").addClass("item-selected").siblings().removeClass("item-selected");
			}
			
			//console.log(index,ru_id,type,shipping_id,shipping_code,_html);
			
			t.addClass("item-selected").siblings().removeClass("item-selected");
			
			$(".shipping_" + ru_id).val(shipping_id);
			$(".shipping_code_" + ru_id).val(shipping_code);
			
			if(_html != "")
			{
				parents.find("*[ectype='tabLog'] span").html(_html);
				parents.find("*[ectype='tabLog']").attr("data-shipping",shipping_id).attr("data-shippingcode", shipping_code).attr("data-ruid", ru_id).attr("data-type", type);
			}
			
			t.parents("*[ectype='logistics']").hide();
			
			/* 选择配送方式 start */
			$("*[ectype='shoppingList']").each(function(index, element) {
				var li_shinpping_id = $(element).find("*[ectype='disInfo'] li.item-selected").attr("data-shipping");
				var seller_shipping = Number(li_shinpping_id);
				if(index > 0){
					shipping += ",";
				}
				
				shipping += li_shinpping_id;
			});
			/* 选择配送方式 end */
			
			Ajax.call('ajax_dialog.php?act=shipping_type', 'ru_id=' + ru_id + '&shipping_id='+ shipping_id + '&warehouse_id='+ warehouse_id + '&area_id='+ area_id +'&type=' + type +'&shipping=' + shipping, changeShippingResponse, 'POST','JSON');
		});
		//切换配送方式 end
		
		doc.on("click",".mode-tab-item",function(){
			t = $(this);
			index = t.index();
			shippingcode = t.data("shippingcode");
			shipping = "";
			var warehouse_id = $(".checkout-foot").find("input[name='warehouse_id']").val();
			var area_id = $(".checkout-foot").find("input[name='area_id']").val();
			
			t.addClass('item-selected').siblings().removeClass('item-selected');
			
			/* 选择配送方式 start */
			$("*[ectype='shoppingList']").each(function(index, element) {
				var li_shinpping_id = $(element).find("*[ectype='disInfo'] li.item-selected").attr("data-shipping");
				var seller_shipping = Number(li_shinpping_id);
				
				if(index > 0){
					shipping += ",";
				}
				
				shipping += seller_shipping;
			});
			/* 选择配送方式 end */	
			
			if(shippingcode == 'cac'){
				ru_id = t.data('ruid');
				type = t.data('type');
				shipping_id = t.data('shipping');
				
				Ajax.call('ajax_dialog.php?act=shipping_type', 'ru_id=' + ru_id + '&shipping_id='+ shipping_id + '&warehouse_id='+ warehouse_id + '&area_id='+ area_id +'&type=' + type +'&shipping=' + shipping, changeShippingResponse, 'POST','JSON');		
			}else{
				parents = t.parents("[ectype='disInfo']");
				parents.find(".logistics_li").each(function(index, element) {
					var $this = $(this);
					if($this.hasClass("item-selected")){
						ru_id = $this.data("ruid");
						type = $this.data("type");
						shipping_id = $this.data("shipping");
						
						Ajax.call('ajax_dialog.php?act=shipping_type', 'ru_id=' + ru_id + '&shipping_id='+ shipping_id + '&warehouse_id='+ warehouse_id + '&area_id='+ area_id +'&type=' + type +'&shipping=' + shipping, changeShippingResponse, 'POST','JSON');		
					}
				});
			}
	
		});
		
		//自提点
		doc.on("click","*[ectype='flow_dialog']",function(){
			var value,ok_title,cl_title,url,title,width,height,divId,mark,ajax_picksite;
			
			value = $(this).data("value");
			
			url = value.url; //删除连接地址
			title = value.title;
			width = value.width;
			height = value.height;
			divId = value.divid;
			mark = value.mark; //区分提货站与日期修改
			
			ok_title = json_languages.save;
			cl_title = json_languages.cancel;
			
			$("*[ectype='tabCac']").click();
			
			Ajax.call(url,'',shopResponse, 'POST', 'JSON');
			function shopResponse(result){
				pb({
					id:divId,
					title:title,
					width:width,
					height:height,
					ok_title:ok_title, 	//按钮名称
					cl_title:cl_title, 	//按钮名称
					content:result.result, 	//调取内容
					drag:false,
					foot:true,
					onOk:function(){ //保存回调函数
						if(mark == 0){
							var district = $("#pickRegion_select").val();
							var picksite_id = $("input[name='picksite_radio']:checked").val();
							ajax_picksite = 'district='+ district +'&picksite_id='+ picksite_id + 'mark=' + mark ;
	
							if(typeof(picksite_id) == "undefined"){
								pbDialog(json_languages.delivery_Prompt,"",0);
								return false;
							}
						}else{
							var shipping_date = $("input[name='shipping_date']:checked").attr('data-shippingDate');
							var time_range = $("input[name='shipping_date']:checked").attr('data-range');
		
							if(typeof(shipping_date) == "undefined"){
								pbDialog(json_languages.delivery_Prompt_two,"",0);
								return false;
							}
							ajax_picksite = 'shipping_date='+ shipping_date + '&time_range='+ time_range +'&mark=' + mark ;
						}
						
						Ajax.call('flow.php?step=select_picksite', ajax_picksite, selectPicksiteResponse, 'POST', 'JSON');
					},
					onCancel:function(){ //取消回调函数
					}
				});
			}
		});
	}
	//配送方式方法
	logistics();
	
	
	/* 支付订单页 */
	$("*[ectype='opened']").on("click",function(){
		var $this = $(this);
		var div = $this.parents(".o-list-info").next();
		if(div.is(":hidden")){
			$this.html(json_languages.down_detail+"
");
		}else{
			$this.html(json_languages.order_detail+"
");
		}
		div.slideToggle();
	});
	
	//银行卡切换
	$("*[ectype='bankList'] li").on("click",function(){
		var $this = $(this);
		var parent = $(this).parents("*[ectype='bankList']");
		$this.addClass("selected").siblings().removeClass("selected");
		
		if(parent.find(".selected").length>0){
			$("#alipay_bank").find(".noBtn").hide();
			$("#alipay_bank").find("input").show().css({"background-color":"#f42424"});
		}
	});
	
	//移除到order_total.lbi
	// $(document).on("click",".no_goods", function(){
	// 	var rec_number = $("input[name='rec_number_str']").val();
	// 	var url = $(this).data('url');
	// 	if(rec_number != ''){
	// 		url = url + "&rec_number=" + rec_number;
	// 	}
	// 	Ajax.call(url,'',noGoods, 'POST', 'JSON');
	// 	function noGoods(result){
	// 		if(result.error == 1){
	// 			pb({
	// 				id:'noGoods',
	// 				title:json_languages.No_goods,
	// 				width:670,
	// 				ok_title:json_languages.go_up, 	//按钮名称
	// 				cl_title:json_languages.back_cart, 	//按钮名称
	// 				content:result.content, 	//调取内容
	// 				drag:false,
	// 				foot:true,
	// 				onOk:function(){
	// 					$("form[name='stockFormCart']").submit();
	// 				},
	// 				onCancel:function(){
	// 					location.href = "flow.php";
	// 				}
	// 			});
	// 			$('.pb-ok').addClass('color_df3134');
	// 		}else{
	// 			$("form[name='doneTheForm']").submit();
	// 		}
	// 	}
	// });
	
	// $(document).on("click",".no_shipping", function(){
	// 	var shipping_prompt = $("input[name='shipping_prompt_str']").val();
	// 	var url = $(this).data('url');
	// 	if(shipping_prompt != ''){
	// 		url = url + "&shipping_prompt=" + shipping_prompt;
	// 	}
		
	// 	Ajax.call(url,'',noShipping, 'POST', 'JSON');
	// 	function noShipping(result){
	// 		if(result.error == 1){
	// 			pb({
	// 				id:'noGoods',
	// 				title:json_languages.No_shipping,
	// 				width:670,
	// 				ok_title:json_languages.go_up, 	//按钮名称
	// 				cl_title:json_languages.back_cart, 	//按钮名称
	// 				content:result.content, 	//调取内容
	// 				drag:false,
	// 				foot:true,
	// 				onOk:function(){
	// 					$("form[name='stockFormCart']").submit();
	// 				},
	// 				onCancel:function(){
	// 					location.href = "flow.php";
	// 				}
	// 			});
	// 			$('.pb-ok').addClass('color_df3134');
	// 		}else{
	// 			$("form[name='doneTheForm']").submit();
	// 		}}
	// });
    
	/********************************************* 结算页(flow)end ***************************************/
	
	/********************************************* 促销模块(团购,优惠,夺宝,礼包等)start************************/
	//优惠活动
	$(document).on('click', "*[ectype='actFilter'] a", function(){
		var actType = $(this).data('acttype');
		var i = 0;
		
		$(this).addClass('curr').siblings().removeClass('curr');
		
		$("*[ectype='actList'] li").each(function(){
			var li_acttype = $(this).data('acttype');
			if(li_acttype == actType || actType == -1){
				i++;
				$(this).show();
			}else{
				$(this).hide();
			}
		});
		
		if(i == 0){
			$(".no_records").show()
		}else{
			$(".no_records").hide()
		}
	});
	
	
	//团购详情页 立即团购
    $("*[ectype='btn-group-buy']").on('click',function(){
		var quantity = Number($("*[ectype='quantity']").val()),
			perNumber =Number($("*[ectype='perNumber']").val()),
			restrictShop = Number($("*[ectype='restrictShop']").val()),
			ogNumber = Number($("*[ectype='orderGNumber']").data("value")),
			minamount = Number($(this).data('minamount'));
		
		if(user_id > 0){
			if(perNumber == 0 || quantity > perNumber){
                            
				pbDialog(json_languages.Stock_goods_null,"",0,450,80,50);
				return false;
			}else if((quantity+ogNumber) > restrictShop  && restrictShop > 0){
				pbDialog(json_languages.purchasing_prompt_two,"",0,500,80,50);
				return false;
			}else if(minamount > 0 && quantity < minamount){
				pbDialog(json_languages.purchasing_minamount,"",0,500,80,50);
				return false;
			}
			else{
				Ajax.call('group_buy.php?act=checked_certification', 'user_id=' + user_id, function(data){
					if(data.error > 0){
						pbDialog(json_languages.emailInfo_incompleted,"",0,500,80,50);
						return false;					
					}else{
						$("form[name='ECS_FORMBUY']").submit();
					}
				}, 'POST', 'JSON');	
			}
		}else{
			var group_buy_id = $("input[name='group_buy_id']").val();
			var back_url = "group_buy.php?act=view&id=" + group_buy_id;
			$.notLogin("get_ajax_content.php?act=get_login_dialog",back_url);
			return false;
		}
    });
	/********************************************* 促销模块(团购,优惠,夺宝,礼包等)end************************/
	
	/********************************************* 文章页start ***************************************/
	$(".menu-item div.item-hd").on("click",function(){
		var t = $(this);
		$(this).siblings("ul").slideToggle(500,function(){
			if($(this).is(":hidden")){
				t.find(".iconfont").removeClass("icon-down").addClass("icon-up");
			}else{
				t.find(".iconfont").addClass("icon-down").removeClass("icon-up");
			}
		});
	});
	/********************************************* 文章页end ***************************************/
	
	/********************************************* 用户中心页(user) start *********************************/
	//用户中心右侧最小高度和左侧栏高度一样
	$(window).ready(function(e) {
        var height = $("*[ectype='userSide']").height(),
			action = $("*[ectype='userMain']").data("action");
		
		if(action == "default"){
			$("*[ectype='userMain'] .user-mod").css({"min-height":height-298});
		}else{
			$("*[ectype='userMain'] .user-mod").css({"min-height":height-70});
		}
    });
	
	//点击其他地方关闭选择列表模块
	$("body").on('click', function(e){
		var target = $(e.target);
		var opened = $(".mod-select.mod-select-open");
		if(opened.length > 0){
			if(target.parents(".mod-select").length == 0){
				opened.removeClass("mod-select-open");
			}
		}
	});
	// 用户菜单展开效果
	$(".user-side .side-menu dt .square").click(function(){
		var $this = $(this);
		var dd = $this.parent("dt").siblings("dd");
		$this.toggleClass("square-plus");
		dd.slideToggle();
	});
	
	//订单多个产品展开
	$(document).on("click","[ectype='opm']",function(){
		$(this).prevAll("[ectype='c-goods']").show();
		$(this).prev().hide();
		$(this).hide();
	});
	
	/* 跟踪包裹start */
	var hoverTimer, outTimer,hoverTimer2;
	$(document).on('mouseenter',"*[ectype='track-packages-btn']",function(){
		clearTimeout(outTimer);
		var $this = $(this);
		hoverTimer = setTimeout(function(){
			$this.find("*[ectype='track-packages-info']").show();
		},50);
	});
	
	$(document).on('mouseleave',"*[ectype='track-packages-btn']",function(){
		clearTimeout(hoverTimer);
		var $this = $(this);
		outTimer = setTimeout(function(){
			$this.find("*[ectype='track-packages-info']").hide();
		},50); 
	});
	$(document).on('mouseenter',"*[ectype='track-packages-info']",function(){
		clearTimeout(outTimer);
		hoverTimer2 = setTimeout(function(){
			$(this).show();
		});
	});
	$(document).on('mouseleave',"*[ectype='track-packages-info']",function(){
		$(this).hide();
	});
	/* 虚拟商品卡密end*/
	
	/* 评论晒单 start */
	function userComment(){
		var t = "",
		parent = "",
		divId = "commentDialog";
		
		//点击评论弹出框
		doc.on("click","a[ectype='btn-comment']",function(){
			var rec_id = $(this).data('recid');
			var sign = $(this).data('sign');
			var size = $(this).data('size');
			var start = $(this).data('start');
			var foot = $(this).data('foot');
			
			Ajax.call('ajax_user.php?act=comments_form', 'rec_id=' + rec_id + '&sign=' + sign + '&start=' + start + '&size=' + size, commentsFormResponse, 'POST', 'JSON');
			
			function commentsFormResponse(data){
				var content = data.content;
				pb({
					id:divId,
					title:json_languages.comment_goods,
					content:content,
					ok_title:json_languages.determine,
					cl_title:json_languages.cancel,
					drag:false,
					foot:foot,
					onOk:function(){
						if(commentForm(divId) == false){
							return false
						}else{
							return true
						}
					}
				});
			}
		});
		
		//评价星级
		doc.on("click","*[ectype='p_rate'] a",function(){
			t = $(this);
			parent = t.parents("*[ectype='rates']");
			val = t.data("value");
			
			parent.find(".error").hide();
			t.addClass("selected").siblings().removeClass("selected");
			
			parent.find("input[type='hidden']").val(val);
			
			if(parent.find(".degree-text").length>0){
				parent.find(".degree-text").show();
				parent.find(".comt-error").hide();
				parent.find("*[ectype='number']").html(val);
			}
		});
		
		//买家印象标签切换
		doc.on("click","*[ectype='itemTab']",function(){
			var val = "",recid = "";
			t = $(this);
			
			if(t.hasClass("selected")){
				t.removeClass("selected");
			}else{
				t.addClass("selected");
			}
			
			t.parent().find(".selected").each(function(){
				var tag_val = $(this).data('val');
				var tag_recid = $(this).data('recid');
				
				val += tag_val +",";
				recid += tag_recid +",";
			});
	
			val = val.substring(0,val.length-1);
			recid = recid.substring(0,recid.length-1);
			
			$("input[name='impression']").val(val);
		});
		
		//删除图片
		doc.on("click","*[ectype='cimg-remove']",function(){
			var $this = $(this);
			var cur_imgId = $this.data("imgid");
			var order_id = $("input[name='order_id']").val();
			var goods_id = $("input[name='goods_id']").val();
			var ul = $this.parents(".img-list-ul");
			var num = ul.parents(".img-lists").find("*[ectype='num']").text();
			var num1 = ul.parents(".img-lists").find("*[ectype='ima_number']").text();
			
			if(cur_imgId == ""){
				pbDialog(json_languages.parameter_error,"",0);
				return false;
			}
			Ajax.call('comment.php?act=del_pictures', 'cur_imgId=' + cur_imgId+'&order_id='+order_id+'&goods_id='+goods_id, delCommentImgResponse, 'POST', 'JSON');
			function delCommentImgResponse(data){
				ul.html(data.content);
				ul.parents(".img-lists").find("*[ectype='num']").html(Number(num)-1);
				ul.parents(".img-lists").find("*[ectype='ima_number']").html(Number(num1)+1);
				 
			}
		});
	}
	userComment();
	
	//用户评论提交方法
	function commentForm(obj){
		var obj = $("#"+obj),
			comment_id = "",
			comment_rank = "",
			content = "",
			impression = "",
			is_impression = "",
      captcha = "",
			cmt = new Object;
			
		comment_id = obj.find("input[name='comment_id']").val();
		comment_rank = obj.find("input[name='comment_rank']").val();
		content = obj.find("textarea[name='content']").val();
		impression = obj.find("input[name='impression']").val();
		is_impression = obj.find("input[name='is_impression']").val();
		captcha = obj.find("input[name='captcha']").val();
                
		cmt.comment_rank = (typeof(comment_rank) == "undefined") ? 0 : comment_rank ;
		cmt.comment_id = (typeof(comment_id) == "undefined") ? 0 : comment_id ;
		cmt.impression = (typeof(impression) == "undefined") ? '' : impression ;
		cmt.content = (typeof(content) == "undefined") ? '' : content ;
    cmt.captcha = (typeof(captcha) == "undefined") ? '' : captcha ;
                
		cmt.order_id = obj.find("input[name='order_id']").val();
		cmt.goods_id = obj.find("input[name='goods_id']").val();
		cmt.rec_id = obj.find("input[name='rec_id']").val();
		cmt.sign = obj.find("input[name='sign']").val();
		
		if(cmt.comment_rank == 0 && cmt.sign == 0){
			pbDialog(json_languages.select_pf,"",0);
			return false;
		}else if(cmt.impression == '' && cmt.sign == 0 && is_impression == 1){
			pbDialog(json_languages.Label_number_null,"",0);
			return false;
		}else if((cmt.content == '' || cmt.content.length > 500) && cmt.sign == 0){
			if(cmt.content == ''){
				pbDialog(json_languages.content_not,"",0);
			}else{
				pbDialog(json_languages.word_number,"",0);
			}
			return false;
		}else if(cmt.captcha == '' && typeof(captcha) != "undefined"){
			pbDialog(json_languages.null_captcha_login,"",0);
			return false;
		}else{	
			Ajax.call('comment.php?act=comm_order_goods', 'cmt=' + $.toJSON(cmt), commentSignOneResponse, 'POST', 'JSON');
		}
	}
	
	//回调函数
	function commentSignOneResponse(result){
		var sign = '';
		var left = 0;
		if(result.sign > 0){
			sign = "&sign=" + result.sign;
		}
		
		if(result.sign > 0){
			left = 100;
		}else{
			left = 60;
		}
		
		var hrefCont = "user.php?act=comment_list" + sign;
		if(result.error > 0){
			pbDialog(result.message,"",0);
		}else{
			pbDialog(result.message,json_languages.comments_Other,1,"","",left,false,function commentOk(){location.href = hrefCont});
		}
	}
	
	//店铺满意度提交
	$("[ectype='storeRateBtn']").on("click",function(){
		var rank = new Object;
			
		rank.order_id = $(this).data('orderid');
		rank.desc_rank = $(this).parents(".score").find("input[name=desc_rank]").val();
		rank.service_rank = $(this).parents(".score").find("input[name=service_rank]").val();
		rank.delivery_rank = $(this).parents(".score").find("input[name=delivery_rank]").val();
		rank.sender_rank = $(this).parents(".score").find("input[name=sender_rank]").val();
		
		if(rank.desc_rank == 0){
			$("input[name=desc_rank]").nextAll(".comt-error").show();
			return false;
		}else if(rank.desc_ran==0){
			$("input[name=desc_ran]").nextAll(".comt-error").show();
			return false;
		}else if(rank.service_rank==0){
			$("input[name=service_rank]").nextAll(".comt-error").show();
			return false;
		}else if(rank.delivery_rank==0){
			$("input[name=delivery_rank]").nextAll(".comt-error").show();
			return false;
		}else if(rank.sender_rank==0){
			$("input[name=sender_rank]").nextAll(".comt-error").show();
			return false;
		}else{
			Ajax.call('comment.php?act=satisfaction_degree', 'rank=' + $.toJSON(rank), SatisfactionDegreeResponse, 'POST', 'JSON');
		}
	});
	
	function SatisfactionDegreeResponse(result)
	{
		if(result.error > 0){
			pbDialog(result.msg,"",0);
			return false;
		}else{
			var _html = '
';
			$(".votelist-content").find(".service-rcol").html(_html);
		}
	}
	/* 评论晒单 end */
	
	
	/* 虚拟商品卡密start */
	var hoverTimer, outTimer,hoverTimer2;
	$(document).on('mouseenter','.virtual_title',function(){
		clearTimeout(outTimer);
		var parents = $(this).parents('.virtual_div');
		hoverTimer = setTimeout(function(){
			parents.find(".virtual_info").show();
		},200);
	});
	
	$(document).on('mouseleave','.virtual_title',function(){
		clearTimeout(hoverTimer);
		var parents = $(this).parents('.virtual_div');
		outTimer = setTimeout(function(){
			parents.find(".virtual_info").hide();
		},100); 
	});
	$(document).on('mouseenter','.virtual_info',function(){
		clearTimeout(outTimer);
		hoverTimer2 = setTimeout(function(){
			$(this).show();
		});
	});
	$(document).on('mouseleave','.virtual_info',function(){
		$(this).hide();
	});
	/* 虚拟商品卡密end*/
	
	
	/* 银行卡号每隔4位空格 by yanxin start */
	/*var bank_card = $("*[ectype='bank_card']");
	if(bank_card.length > 0){
		//默认加载银行卡号 4位数后空格隔开
		var card = bank_card.val();		
		var ncard = "";
		
		card = card.replace(/\D/g,'');
		
		for(var i = 0; i < card.length; i = i+4){
			ncard += card.substring(i,i+4)+" ";
		}
		
		bank_card.val(ncard.replace(/(\s*$)/g,""));
		
		//银行卡输入后4位数后空格隔开
		bank_card.keyup(function(e){
			var obj = e , bankVal;
			if(obj.keyCode != 8){             				//判断是否为Backspace键,若不是执行函数;
				bankVal = $(this).val();   					//定义变量input  value值
				bankVal = bankVal.replace(/[^\d\s]/g,"");   //正则表达式:如果输入框中输入的不是数字或者空格,将不会显示;
				$(this).val(bankVal);       				//把新得到得value值赋值给输入框;
				for(n=1;n<=4;n++){
					if(bankVal.length <= 5*n-2 || bankVal.length>5*n-1){   //判断是否是该加空格的时候,若不会,还是原来的值;
						bankVal = bankVal;
					}else{
						bankVal += " ";                         //给value添加一个空格;
						$(this).val(bankVal);  					//赋值给输入框新的value
					}
				}
			}
		});
		
		bank_card.blur(function(e){
			var $this = $(this).parents("div.value");
            bankCard = bank_card.val();
			bankCard = bankCard.replace(/\s+/g, "");
			$.getJSON("./data/bankData.json", {}, function (data) { 
				var bankBin = 0; 
				var isFind = false; 
				for (var key = 10; key >= 2; key--) { 
					bankCard = bankCard.toString();
					bankBin = bankCard.substring(0, key); 
					$.each(data, function (i, item) { 
						if (item.bin == bankBin) { 
							isFind = true; 
							bName = item.bankName; 
							$this.find(".notic").hide();
							$this.find("*[ectype='bname']").html(bName).show();
						} 
					}); 
					if (isFind) { 
						break; 
					} 
				} 
				if (!isFind) { 
					$this.find(".notic").hide();
					$this.find("*[ectype='bname']").html("请填写正确卡号").show();
				} 
			}); 
        });
	}*/
	/* 银行卡号每隔4位空格 by yanxin end */
	
	/* 举报start */
    $(document).on("click", "*[ectype='cancel_report']", function(){
        var _this = $(this);
        var id = _this.data("id");
        var type = _this.data("type");
        var state = _this.data("state");
        var back_href = '';
        if(type == 1 || state == 3){
            back_href = 'user.php?act=illegal_report';
        }else{
            back_href = "user.php?act=goods_report&report_id=" + id;
        }
        if(confirm("确定执行此操作吗?执行后数据将不能找回!请谨慎操作!")){
            Ajax.call('ajax_user.php?act=check_report_state', 'report_id=' + id + "&state=" + state , function(data){
                if(data.error > 0){
                    pbDialog(data.message,"",0);
                }else{
                    location.href = back_href;
                }
             }, 'POST', 'JSON');
        }
    });
	/* 举报end */
	
	/* 缺货登记 取消 */
	$("*[ectype='goods_del_booking']").on("click",function(){
		var url = $(this).data("url");
		
		pbDialog("您确定要取消订购信息?","",0,455,58,"",true,function(){
			location.href = url;
		});
	});
	
	/* 提现手续费 */
	$("*[ectype='deposit_amout']").blur(function(){
		var val = $(this).val();
		var deposit_fee = $(this).parents('form').find("input[name='deposit_fee']").val();
		var deposit_money = 0;
		var input = '';
		//parseInt(val);
		if(deposit_fee > 0 && val > 0 && !isNaN(val)){
			deposit_money = parseInt(val)*parseInt(deposit_fee)/100;
			if(deposit_money > 0){
				input = '
';
				$("*[ectype='deposit_fee']").find("*[ectype='deposit_fee_value']").html(deposit_money+input);
				$("*[ectype='deposit_fee']").removeClass('hide');
			}else{
				$("*[ectype='deposit_fee']").find("*[ectype='deposit_fee_value']").html('');
				$("*[ectype='deposit_fee']").addClass('hide');
			}
		}else{
			$("*[ectype='deposit_fee']").find("*[ectype='deposit_fee_value']").html('');
				$("*[ectype='deposit_fee']").addClass('hide');
		}
	});
	
	$(".user-purchase .item").each(function(){
		var height_l = $(this).find(".itemc-left").height();
		var height_r = $(this).find(".itemc-right").height();
		
		
		if(height_l < height_r){
			$(this).find(".itemc-right").addClass("borderLeft");
		}else if(height_l > height_r){
			$(this).find(".itemc-left").addClass("borderRight");
		}else{
			$(this).find(".itemc-left").addClass("borderRight");
		}
	});
	
	//会员中心储值卡
    $("*[ectype='value_see']").hover(function(){
        $("[ectype='value_shop']").show();
    },function(){
		$("[ectype='value_shop']").hide();
	});
	//会员中心延迟收货
        $(document).on("click", "#sbumit_order_delay", function(){
            var rquest_url = "user.php?act=apply_delivery";
            var order_id = $(this).data('id');
            $.ajax({
                type: 'post',
                cache: false,
                async: false,
                dataType: 'json',
                data: {order_id: order_id},
                url: rquest_url,
                success: function (result) {
                    alert(result.err_msg);
                },
                error: function () {
                }
            });
        }); 
	//全选
	$("input[name='all_list']").click(function(){
		if($(this).prop("checked") == true){
			$("input[name='checkboxes[]']").prop("checked",true);
		}else{
			$("input[name='checkboxes[]']").prop("checked",false);
		}
	});
	
	/********************************************* 用户中心页(user) end ***********************************/
	
	
	/********************************************* 入驻切换头部导航start ***********************************/
	$("*[ ectype='merchants_article']").on("click",function(){
		var _this = $(this);
		var title = _this.html();
		Ajax.call('ajax_dialog.php?act=merchants_article','title='+title, function(data){
			if(data.error == 1){
				_this.parents('li').addClass("curr").siblings().removeClass("curr");;
				$(".container").html(data.content);
			}else{
				pbDialog(data.message,"",0,"","",50);
			}
		}, 'POST', 'JSON');
	})
	/********************************************* 入驻切换头部导航end *************************************/
	
	
	/********************************************* 促销活动页面 start *************************************/
	$("*[ectype='snatchType']").on("click",function(){
		$("#detail-slide").find(".hd li:eq(1)").click();
	});
	/********************************************* 促销活动页面 end***************************************/
	
	/********************************************* 众筹页面 start ****************************************/
	$("#parent_catagory li a").on("click",function(){
		var textTypeIndex = $(this).parent().index();
		var vsecondlist = $(".v-second-list");
		$(this).parent().addClass("current").siblings().removeClass("current");
		$(this).parents(".v-fold").next().show();
		var index = textTypeIndex-1;
		if(index >= 0){
			vsecondlist.show();
			vsecondlist.children(".s-list").eq(index).show().siblings().hide();
		}else{
			vsecondlist.hide();
			vsecondlist.children(".s-list").hide();
		}
	});
	
	$("#sort li").click(function(){
		$(this).addClass("current").siblings().removeClass("current");
	});
	
	$(".v-option").click(function(){
		if($(this).hasClass('slidedown')){
			$(this).removeClass('slidedown').addClass('v-close');
			$(this).html("
"+json_languages.Pack_up+"");
			$(this).next().css("height","auto");
		}else{
			$(this).removeClass('v-close').addClass('slidedown');
			$(this).html("
"+json_languages.more+"");
			$(this).next().css("height","26px");
		}
	});
	/********************************************* 众筹页面 end ****************************************/
	
	/***********************************************秒杀 start*****************************************/
	$(document).on("mouseenter","*[ectype='skmuMove']",function(){
		clearTimeout(outTimer);
		hoverTimer = setTimeout(function(){
			$("[ectype='skmuMcate']").addClass("skmu-mcate-active");
		},200);
	});
	
	$(document).on("mouseleave","*[ectype='skmuMove']",function(){
		clearTimeout(hoverTimer);
		outTimer = setTimeout(function(){
			$("[ectype='skmuMcate']").removeClass("skmu-mcate-active");
		},100); 
	});
	$(document).on("mouseenter","[ectype='skmuMcate']",function(){
		clearTimeout(outTimer);
		hoverTimer2 = setTimeout(function(){
			$(this).addClass("skmu-mcate-active");
		});
	});
	$(document).on("mouseleave","[ectype='skmuMcate']",function(){
		$(this).removeClass("skmu-mcate-active");
	});
});
/****************************************** js通用方法start *************************************************/
/* 商品详情信息 详情、评论、讨论圈滚动悬浮栏 start */
(function($){
	$.fn.jfloor = function(itemHeight,bHeight){
		if(itemHeight == null){
			var itemHeight = 0;
		}
		if(bHeight == null){
			var bHeight = 0;
		}
		return this.each(function(){
			var winHeight = $(window).width();
				floors = $(this).find("*[ectype='gm-floors']"),
				flooritem = floors.find("*[ectype='gm-item']"),
				axis = $(this).find("*[ectype='gm-tabs']"),
				layer = axis.find("*[ectype='gm-tab-item']"),
				bor = axis.find("*[ectype='qp-bort']"),
				floorsTop =  parseInt(floors.offset().top-itemHeight);
			
			layer.click(function(){
				var index = layer.index(this);
				var top = parseInt(flooritem.eq(index).offset().top-itemHeight);
				$("body,html").stop().animate({scrollTop:top});
			});
			
			$(window).scroll(function(){
				var top = $(document).scrollTop();
				
				if(top >= floorsTop-itemHeight){
					axis.addClass("detail-hd-fixed");
					
					if(bor.length>0){
						bor.css({"width":winHeight,"left":-((winHeight-1200)/2 + floors.position().left)});
					}
				}else{
					axis.removeClass("detail-hd-fixed");
				}
				
				for(var i=0;i
= flooritemTop-bHeight){
						layer.eq(i).addClass("curr").siblings().removeClass("curr");
					}
				}
			});
		});
	}
})(jQuery);
/* 商品详情描述 规格参数切换 */
function goods_desc_floor(){
	var winHeight = $(window).width(),
		floors = $("*[ectype='gm-floors']"),
		flooritem = floors.find("*[ectype='gm-item']"),
		axis = $("*[ectype='gm-tabs']"),
		layer = axis.find("*[ectype='gm-tab-item']"),
		bor = axis.find("*[ectype='qp-bort']"),
		floorsTop =  parseInt(floors.offset().top);
	
	$("*[ectype='gm-tabs'] .gm-tab li").on("click",function(){
		var t = $(this),
			index = t.index();
		
		t.addClass("curr").siblings().removeClass("curr");
		
		for(var i = 0;i= index){
					flooritem.eq(i).show();
				}else{
					flooritem.eq(i).hide();
				}
			}
		}
		$("body,html").stop().animate({scrollTop:(floorsTop-100)});
	});
	
	$("*[ectype='product-detail']").on("click",function(){
		$("*[ectype='gm-tabs'] li").eq(1).click();
	});
	
	$(window).scroll(function(){
		var top = $(document).scrollTop();
		
		if(top >= floorsTop){
			axis.addClass("detail-hd-fixed");
			
			if(bor.length>0){
				bor.css({"width":winHeight,"left":-((winHeight-1200)/2 + floors.position().left)});
			}
		}else{
			axis.removeClass("detail-hd-fixed");
		}
	});
}
/* 商品详情信息 详情、评论、讨论圈滚动悬浮栏 end */
/* 商品详情页 清空浏览历史记录 */
function clear_history(){
	Ajax.call('user.php', 'act=clear_history',function(){
		$("*[ectype='history_mian']").html(''+json_languages.no_history+'
'+json_languages.go_shoping+'' + 
							'
' +
								'
' + 
								'
' +
									'
' + no_keywords + '
' +
								'' +
							'
' +
						'
"+load_icon+"
");
		Ajax.call('flow.php', 'step=insert_Consignee&csg=' + $.toJSON(csg) + '&shipping_id=' + $.toJSON(shipping_id) + '&uc_id=' + uc_id, addUpdate_ConsigneeResponse, 'POST', 'JSON');
		
		fale = true;
	}
	
	return fale;
}
//回调
function addUpdate_ConsigneeResponse(result){
	if(result.error > 0){
		if(result.error == 2){
			pbDialog(result.message,"",0);
			location.href = "user.php";
		}
		
		if(result.error == 4){
			$('#consignee-addr').html(result.content);
		}
	}else{
		$('#consignee-addr').html(result.content);
		$('#goods_inventory').html(result.goods_list);//送货清单
		$('#ECS_ORDERTOTAL').html(result.order_total);//费用汇总
        $("[ectype='order_coupoms_list']").html(result.order_coupoms_list);//优惠券
	}
	
	if(result.error == 4){
		var ok_title,cl_title;
		var width = 455; 
		var height = 58;
		var divId = "address_div_id";
		
		ok_title = json_languages.determine;
		cl_title = json_languages.cancel;
		
		var content = '' + 
							'
' +
								'
' + 
								'
' +
									'
' + result.message + '
' +
								'' +
							'
' +
						'
"+ msgTitle +"
";
		}else{
			msgTit = ""+ msgTitle +"
";
		}
	}
	
	if(msg != ""){
		msgSpan = ""+ msg +"";
	}
	
	if(width == null || width == ""){
		width = 450;
	}
	
	if(height == null || height == ""){
		height = 80;
	}
	if(left == null || left == ""){
		left = 100;
		leftCss = "padding:0 0 0 100px";
	}else{
		leftCss = "padding:0 " + left +"px;";
	}
	
	if(onOk == null || onOk ==""){
		foot = false;
	}
	
	if(ok_title == null || ok_title == ""){
		ok_title = json_languages.determine;
	}
	
	if(cl_title == null || cl_title == ""){
		cl_title = json_languages.cancel;
	}
	
	if(pb_title == null || pb_title ==""){
		pb_title = json_languages.pb_title;
	}
	
	if(typeof(height) == "string"){
		content = '';
	}else{
		content = '';
	}
	pb({
		id:"pbDialog",
		title:pb_title,
		width:width,
		height:height,
		content:content,
		drag:false,
		foot:foot,
		ok_title:ok_title,
		cl_title:cl_title,
		cl_cBtn:cBtn,
		onOk:onOk
	});
	
	var tipbox = $('#pbDialog .tip-box'),
		item_height = tipbox.find(".item-fore").height();
	
	if(item_height > 48){
		tipbox.find('h3').css({"line-height":"30px"});
	}
	
	if(typeof(height) == "string"){
		tipbox.parents(".pb-ct").css({"height":"auto","min-height":height});
	}
 	tipbox.css({"padding-left":left});
}
/* 首页楼层分类切换函数 */
function get_homefloor_cat_content(f_this){
	var obj = $(f_this).data('value');
	var eveval = $(f_this).data("flooreveval");
	var visualhome = $(f_this).data("visualhome");//可视化模板标识
	var visualItme = $(f_this).parents("*[ectype='visualItme']");
	var identi = $(f_this).data("identi");
	
	var cat_id = '',
		floor_num = '',
		goods_ids = '',
		warehouse_id = '',
		floorcat = 0,
		seller_id = 0,
		area_id = '';
		
	if(visualhome == 1){
		cat_id = $(f_this).data('id');
		floor_num = $(f_this).data('floornum');
		warehouse_id = $("input[name='warehouse_id']").val();
		area_id = $("input[name='area_id']").val();
		area_city = $("input[name='area_city']").val();
		goods_ids = $(f_this).data("catgoods");
		floorcat = $(f_this).data("floorcat");
		seller_id = $("input[name='merchantId']").val();
	}else{
		cat_id = obj.id;
		floor_num = obj.floornum;
		warehouse_id = obj.warehouse;
		area_id =obj.area;
		area_city = obj.city;
	}
	
	if(floorcat == 2){
		eveval = 0;
	}
	
	if(eveval == 0){
		$.ajax({
			type: "POST",
			url: "get_ajax_content.php",
			data: "act=floor_cat_content&cat_id=" + cat_id + "&floor_num=" + floor_num + "&warehouse_id=" + warehouse_id + "&area_id=" + area_id + "&area_city=" + area_city + "&goods_ids=" + goods_ids + "&floorcat=" + floorcat + "&seller_id=" + seller_id,
			dataType:'json',
			success: function(data){
				if(visualItme.length > 0){
					if(floorcat == 2){
						var goods = data.content;
						var implement = visualItme.find("*[ectype='pList'] .li");
						if(identi == 1){
							implement = $(f_this).find("li");
						}
						
						for(var i = 0; i < goods.length; i++){
							var html = '';
							var goods_price = '';
							
							if(goods[i].promote_price != ''){
								goods_price = goods[i].promote_price;
							}else{
								goods_price = goods[i].shop_price;
							}
							if(identi == 1){
								html = '

"+json_languages.loading+"
"+load_icon+"
");
		
		Ajax.call('wholesale_flow.php', 'step=insert_Consignee&csg=' + $.toJSON(csg) + '&shipping_id=' + $.toJSON(shipping_id) + '&uc_id=' + uc_id, wholesale_addUpdate_ConsigneeResponse, 'POST', 'JSON');
		
		fale = true;
	}
	
	return fale;
}
//回调
function wholesale_addUpdate_ConsigneeResponse(result){
	if(result.error > 0){
		if(result.error == 2){
			pbDialog(result.message,"",0);
			location.href = "user.php";
		}
		
		if(result.error == 4){
			$('#consignee-addr').html(result.content);
		}
	}else{
		$('#consignee-addr').html(result.content);
		$('#goods_inventory').html(result.goods_list);//送货清单
		$('#ECS_ORDERTOTAL').html(result.order_total);//费用汇总
	}
	
	if(result.error == 4){
		var ok_title,cl_title;
		var width = 455; 
		var height = 58;
		var divId = "address_div_id";
		
		ok_title = json_languages.determine;
		cl_title = json_languages.cancel;
		
		var content = '' + 
							'
' +
								'
' + 
								'
' +
									'
' + result.message + '
' +
								'' +
							'
' +
						'