function promot(key){
    if(key == 1){
        $(".pin").addClass("hidden");
        $(".goods").addClass("hidden");
        $(".fen").removeClass("hidden");
        $("#brand_id").removeAttr("datatype");
        $("#goods_id").removeAttr("datatype");
    }else if(key == 2){
        $(".fen").addClass("hidden");
        $(".pin").removeClass("hidden");
        $(".goods").addClass("hidden");
        $("#brand_id").attr("datatype",'*');
        $("#goods_id").removeAttr("datatype");
        $("#cat_id").removeAttr("datatype");
    }else if(key == 3){
        $(".fen").addClass("hidden");
        $(".pin").addClass("hidden");
        $(".goods").removeClass("hidden");
        $("#brand_id").removeAttr("datatype");
        $("#goods_id").attr("datatype",'*');
        $("#cat_id").removeAttr("datatype");
    }
    //var lists  = $("#act_type_ext").html();

}
function searchgoods(){
  var query= new Object();
  query.keyword =$('#keyword').val();
  $.ajax({
     type: "GET",
     url: APP+"PromotAct/ajaxgetgoods.html",
     data: query,
     success: function(data){
       $("#goods_id").html(data.list);
  }
  });
}
function searchshopgoods(){
  var query= new Object();
  query.keyword =$('#keyword').val();
  query.shop_id =$('#shop_id').val();
  query.is_pt =$('#is_pt').val();
  $.ajax({
     type: "GET",
     url: APP+"PromotAct/ajaxgetshopgoods.html",
     data: query,
     success: function(data){
       $("#goods_id").html(data.list);
  }
  });
}
function addRang(val){
    var rang = $("#"+val).val();
    var lists  = document.getElementById("act_range_ext");
    var rang_val = document.forms['myform'].elements[val];
    if (rang > 0){
        rangId = rang;
        rangName = rang_val.options[rang_val.selectedIndex].text;
    }else{
        return;
    }
    // 检查该地区是否已经存在
    exists = false;
    for (i = 0; i < document.forms['myform'].elements.length; i++){
      if (document.forms['myform'].elements[i].type=="checkbox"){
        if (document.forms['myform'].elements[i].value == rangId){
          exists = true;
		      $.showConfirm('选定的选项已经存在','','hc')
        }
      }
    }
    // 创建checkbox
    if (!exists){
      lists.innerHTML += "<label class='checkbox-inline'><input type='checkbox' name='act_rang_ext[]' value='" + rangId + "' checked='true' /> " + rangName + "</label>&nbsp;&nbsp;";
    }
}
function addRow(obj){//阶梯价格+
	var html = $(obj).parent().html();
	html = html.replace("addRow", "delRow");
	html = html.replace("+", "-");
  $("<div class='mt5 clearfix'>"+html+"</div>").insertAfter($(obj).parent());
}
function delRow(obj){//阶梯价格-
	$(obj).parent().remove();
}
function show_type(){//优惠方式
	var type = $("#act_type").val();
	if(type == 1 || type == 2 || type==4){
		$('#act_type_ext').removeClass('hidden');
		$('#goods_show').addClass('hidden');
        if( type==4){
            $('#goods_show').removeClass('hidden');
        }
	}else{
		$('#act_type_ext').addClass('hidden');
		$('#goods_show').removeClass('hidden');
	}
}
