function gw_ps(n){if($("#gw_b"+n).css("display")=="none"){$("#gw_b"+n).show();}else{$("#gw_b"+n).hide();}}
function gw_mkreview(n,name,brand_id,cat_id,bc_id,open,have_support,campaign_end,default_choose,have_pro,now_campaign,select_num){if(default_choose==1){hide_pro();}
if(roundselect==select_num-need_scorenum_for_chance){$("#goon_button").hide();$("#submit_button").show();}
var vv=0;for(s=1;s<=(select_num-need_scorenum_for_chance);s++){if($("#brand_idf"+s).val()!=''){vv++;}}
var chk=false;if(vv==(select_num-need_scorenum_for_chance)){for(s=1;s<=vv;s++){if($("#brand_idf"+s).val()==brand_id){chk=true;break;}}
if(!chk){var brand1=window.document.getElementById("brand");if(brand1){if(have_pro==1){if(default_choose==1){$('input[@name=brand]').get(0).checked=true;$('input[@name=brand]').get(1).checked=false;}else{$('input[@name=brand]').get(0).checked=false;$('input[@name=brand]').get(1).checked=true;display_pro(brand_id,cat_id);}}else{$('input[@name=brand]').get(0).checked=true;}}
$('input[@name=pro_id]').checked=false;var used1=window.document.getElementById("used");if(used1){$("input[@name=used]").get(0).checked=false;$("input[@name=used]").get(1).checked=false;}
var will_buy1=window.document.getElementById("will_buy");if(will_buy1){$("input[@name=will_buy]").get(0).checked=false;$("input[@name=will_buy]").get(1).checked=false;}
var used_pass_six1=window.document.getElementById("used_pass_six");if(used_pass_six1){$("input[@name=used_pass_six]").get(0).checked=false;$("input[@name=used_pass_six]").get(1).checked=false;}
$("#comment_score0").val('');$("#comment").val('');$("#support_msg").show();$("#com_msg").hide();hide_pro();return false;}}
$('input[@name=pro_id]').checked=false;$("#change_score_id").val(0);$('#mkh_textarea').hide();$('#mkh_vinfo').show();$('#plk_review').hide();$('#plk_review_edit').hide();$('#plk_info').show();display_pro(brand_id,cat_id);$(".mk_score > ul >li >a").removeClass("bok");$("#score_confirm").hide();$("#score_confirm").html('');for(i=1;i<4;i++){$("#gw_brand"+i).removeClass("bwh_unit_b");$("#gw_brand"+i).addClass("bwh_unit");$("#bwh_anum"+i).removeClass().addClass("bwh_rknum");$("#gw_stat").removeClass();}
$("#gw_stat").addClass("bwh_bfocus"+n).show();$("#bwh_anum"+n).removeClass().addClass("bwh_rknuma");$("#gw_brand"+n).removeClass("bwh_unit").addClass("bwh_unit_b");$("#support_msg").hide();$("#com_msg").show();$('.bwh_comment').show();$("#brand_idf").val(brand_id);$("#brand_namef").val(name);$("#cat_idf").val(cat_id);$("#n_idc").val(n);$("#bc_idf").val(bc_id);$("#brand_namespan").html(name);$("#probrand_namespan").html(name);$("#pro_mtb").html('');$("#pro_mtb").hide();var brand1=window.document.getElementById("brand");if(brand1){if(have_pro==1){if(default_choose==1){$('input[@name=brand]').get(0).checked=true;$('input[@name=brand]').get(1).checked=false;}else{$('input[@name=brand]').get(0).checked=false;$('input[@name=brand]').get(1).checked=true;display_pro(brand_id,cat_id);}}else{$('input[@name=brand]').get(0).checked=true;}}
$('input[@name=pro_id]').checked=false;var used1=window.document.getElementById("used");if(used1){$("input[@name=used]").get(0).checked=false;$("input[@name=used]").get(1).checked=false;}
var will_buy1=window.document.getElementById("will_buy");if(will_buy1){$("input[@name=will_buy]").get(0).checked=false;$("input[@name=will_buy]").get(1).checked=false;}
var used_pass_six1=window.document.getElementById("used_pass_six");if(used_pass_six1){$("input[@name=used_pass_six]").get(0).checked=false;$("input[@name=used_pass_six]").get(1).checked=false;}
$('#brand_use').hide();$('#brand_buy').hide();$('#comment').val('用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。');$("#file_brand").val('');if(campaign_end==0){if(open==1&&bc_id!=undefined&&have_support==1){tb_show('','/users/popup_havesuport?now_campaign='+now_campaign+'&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}
$.ajax({type:'GET',url:"/users/check_scored_brand&now_campaign="+now_campaign+"&brandid="+brand_id+"",data:"",success:function(flag){if(flag==1){alert("你已经为该品牌或其产品打分。");return false;}}});}
for(a=1;a<=select_num-need_scorenum_for_chance;a++){if($("#bc_idf"+a).val()&&$("#bc_idf"+a).val()==bc_id){if(a<select_num-need_scorenum_for_chance){$("#goon_button").show();$("#submit_button").hide();}
if($("#pk_round").html()==0){$("#goon_button").hide();$("#submit_button").show();}
$("#change_score_id").val(a);if($("#comment"+a).val()!=''&&$("#comment"+a).val()!='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。'){$("#comment_edit").val($("#comment"+a).val());$("#plk_review_edit").show();$("#plk_info").hide();}
if($("#pro_idf"+a).val()==''){if(have_pro==1){if(default_choose==1){$('input[@name=brand]').get(0).checked=true;$('input[@name=brand]').get(1).checked=false;}else{$('input[@name=brand]').get(0).checked=false;$('input[@name=brand]').get(1).checked=true;display_pro(brand_id,cat_id);}}else{$('input[@name=brand]').get(0).checked=true;}}else{$('input[@name=brand]').get(0).checked=false;if(have_pro==1){$('input[@name=brand]').get(1).checked=true;}
display_pro(brand_id,cat_id);}
if($("#used"+a).val()==1){$('#brand_use').show();$('#brand_buy').hide();$("input[@name=used]").get(0).checked=true;$("input[@name=used]").get(1).checked=false;if($("#used_pass_six"+a).val()==5){$("input[@name=used_pass_six]").get(0).checked=true;$("input[@name=used_pass_six]").get(1).checked=false;}else{$("input[@name=used_pass_six]").get(1).checked=true;$("input[@name=used_pass_six]").get(0).checked=false;}}else{$("input[@name=used]").get(1).checked=true;$("input[@name=used]").get(0).checked=false;$('#brand_buy').show();$('#brand_use').hide();if($("#will_buy"+a).val()==3){$("input[@name=will_buy]").get(0).checked=true;$("input[@name=will_buy]").get(1).checked=false;}else{$("input[@name=will_buy]").get(1).checked=true;$("input[@name=will_buy]").get(0).checked=false;}}
break;}}
if($("#pro_idf"+$("#change_score_id").val()).val()==''){hide_pro();}
$("input[@name=pro_id][@checked]").val('');}
function checkF(){if($("input[@name=brand][@checked]").val()==2){$.ajax({type:'GET',url:"/products/getdata?c=isbidpidok&bid="+$("#brand_idf").val()+"&pid="+$("#pro_id").val(),data:"",success:function(str){if(str!=1){alert("数据错误，请重新选择。");return false;}else{ncheckF();}}});}else{ncheckF();}}
function ncheckF(){$("#plk_review_edit").hide();$("#plk_review").hide();$("#plk_info").show();if($.trim($('#bc_idf').val())==''){malert("请从以上品牌中选择六个，逐一打分。");return false;}
var brand1=window.document.getElementById("brand");if(brand1){var brand=$("input[@name=brand][@checked]").val();if(brand==undefined){malert("请选择您要评价的对象。");return false;}}
var pro_id=$("input[@name=pro_id][@checked]").val();if(brand==2){if(pro_id==undefined){malert("请选择您要评价的对象。");return false;}}
var used1=window.document.getElementById("used");if(used1){used=$("input[@name=used][@checked]").val();if(used==undefined){malert("请选择您是否使用过该品牌？");return false;}else{if(used==1){used_pass_six=$("input[@name=used_pass_six][@checked]").val();if(used_pass_six==undefined){malert("请选择您过去6个月是否使用过？");return false;}}
if(used==2){will_buy=$("input[@name=will_buy][@checked]").val();if(will_buy==undefined){malert("您未来6个月是否准备购买？");return false;}}}}
var comment=$('#comment').val();if(comment==""||$.trim(comment)=='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。')
{}else if($.trim(comment).length>800||$.trim(comment).length<20){$("#plk_review_edit").hide();$("#plk_review").show();$("#plk_info").hide();malert("评论内容字数须在20和800之间。");$('#comment').focus();return false;}
if($("#change_score_id").val()!=0){var y=$("#change_score_id").val();var comment_score_edit=$("#comment_score"+y).val();if($("#comment_score0").val()==''){$("#comment_score0").val(comment_score_edit);}
$("#list_score"+comment_score_edit).html('<a class="" id=link_'+comment_score_edit+' href="javascript:void(0);" onclick=brand_warsetscore('+comment_score_edit+',0,this);return false;>'+comment_score_edit+'</a>');$("#brand_namef"+y).val($("#brand_namef").val());$("#n_idc"+y).val($("#n_idc").val());$("#brand_idf"+y).val($("#brand_idf").val());$("#pro_idf"+y).val(pro_id);$("#cat_idf"+y).val($("#cat_idf").val());$("#bc_idf"+y).val($("#bc_idf").val());$("#brand"+y).val($("#brand").val());$("#used"+y).val($("input[@name=used][@checked]").val());$("#used_pass_six"+y).val($("input[@name=used_pass_six][@checked]").val());$("#will_buy"+y).val($("input[@name=will_buy][@checked]").val());if($("#comment"+y).val()!=''&&$("#comment"+y).val()!='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。'){if($.trim($("#comment_edit").val())!=''&&$.trim($("#comment_edit").val())!='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。'){if($.trim($("#comment_edit").val()).length>800||$.trim($("#comment_edit").val()).length<20){malert("评论内容字数须在20和800之间。");$("#plk_review_edit").show();$("#plk_review").hide();$("#plk_info").hide();$("#comment_edit").focus();return false;}}
$("#comment"+y).val($.trim($("#comment_edit").val()));}else{$("#comment"+y).val($("#comment").val());}
$("#comment_score"+y).val($("#comment_score0").val());$("#list_score"+$("#comment_score0").val()).html($("#comment_score0").val());$("#display_img"+$("#n_idc").val()).html('<img height="18" width="18" alt="" src="/img/bw3_have.jpg"/>');$("#me_score"+($("#n_idc").val()-1)).html("我打"+$("#comment_score0").val()+"分");}else{var vv=0;for(s=1;s<=(select_num-need_scorenum_for_chance);s++){if($("#brand_idf"+s).val()!=''){vv++;}}
if($('#comment_score0').val()==""&&vv!=(select_num-need_scorenum_for_chance)){malert("请选择对品牌推荐程度的评分。");return false;}
for(var b=1;b<=select_num-need_scorenum_for_chance;b++){if($("#bc_idf"+b).val()==''){$("#brand_namef"+b).val($("#brand_namef").val());$("#n_idc"+b).val($("#n_idc").val());$("#brand_idf"+b).val($("#brand_idf").val());$("#pro_idf"+b).val(pro_id);$("#cat_idf"+b).val($("#cat_idf").val());$("#bc_idf"+b).val($("#bc_idf").val());$("#brand"+b).val($("#brand").val());$("#used"+b).val($("input[@name=used][@checked]").val());$("#used_pass_six"+b).val($("input[@name=used_pass_six][@checked]").val());$("#will_buy"+b).val($("input[@name=will_buy][@checked]").val());$("#comment"+b).val($("#comment").val());$("#comment_score"+b).val($("#comment_score0").val());}}
if(vv<select_num){$("#list_score"+$("#comment_score0").val()).html($("#comment_score0").val());$("#display_img"+$("#n_idc").val()).html('<img height="18" width="18" alt="" src="/img/bw3_have.jpg"/>');$("#me_score"+($("#n_idc").val()-1)).html("我打"+$("#comment_score0").val()+"分");$("#pk_round").html('0');}}
$("#comment_score0").val('');$("#comment").val('');$("#comment_edit").val('');$.ajax({type:'GET',url:"/users/ajax_islogin",data:"",success:function(str){if(!str){tb_show('','/users/popup_brandwar?&now_campaign='+now_campaign+'&username='+username+'&type=postcomment&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}else{$.ajax({type:'GET',url:"/users/checkbcamp&now_campaign="+now_campaign,data:"",success:function(msg){if(msg.replace(/<.*?>/g,"")==1){malert("您已经参加活动，不能重复参加。");return false;}else{tb_show('','/users/popup_newpostbrandwar?now_campaign='+now_campaign+'&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}}});}}});}
function goonF(){if($("input[@name=brand][@checked]").val()==2){$.ajax({type:'GET',url:"/products/getdata?c=isbidpidok&bid="+$("#brand_idf").val()+"&pid="+$("#pro_id").val(),data:"",success:function(str){if(str!=1){alert("数据错误，请重新选择。");return false;}else{ngoonF();}}});}else{ngoonF();}}
function ngoonF(){$("#plk_review_edit").hide();$("#plk_review").hide();$("#plk_info").show();select_num=$.trim($('#select_num').val());if($.trim($('#bc_idf').val())==''){malert("请从以上品牌中选择"+select_num+"个，逐一打分。");return false;}
var brand1=window.document.getElementById("brand");if(brand1){var brand=$("input[@name=brand][@checked]").val();if(brand==undefined){malert("请选择您要评价的对象。");return false;}}
var pro_id=$("input[@name=pro_id][@checked]").val();if(brand==2){if(pro_id==undefined){malert("请选择您要评价的对象。");return false;}}
var used=window.document.getElementById("used");if(used){used=$("input[@name=used][@checked]").val();if(used==undefined){malert("请选择您是否尝试过该品牌？");return false;}else{if(used==1){used_pass_six=$("input[@name=used_pass_six][@checked]").val();if(used_pass_six==undefined){malert("请选择您过去6个月是否尝试过？");return false;}}
if(used==2){will_buy=$("input[@name=will_buy][@checked]").val();if(will_buy==undefined){malert("请选择您未来6个月是否准备尝试？");return false;}}}}
var comment=$('#comment').val();if(comment==""||$.trim(comment)=='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。')
{}else if($.trim(comment).length>800||$.trim(comment).length<20){malert("评论内容字数须在20和800之间。");$("#plk_review_edit").hide();$("#plk_review").show();$("#plk_info").hide();$('#comment').focus();return false;}
if($("#change_score_id").val()!=0){edit_score($("#change_score_id").val());}else{var vv=0;for(s=1;s<=(select_num-need_scorenum_for_chance);s++){if($("#brand_idf"+s).val()!=''){vv++;}}
if($('#comment_score0').val()==""&&vv!=(select_num-need_scorenum_for_chance)){malert("请选择对品牌推荐程度的评分。");return false;}
for(var b=1;b<=roundselect;b++){if($("#bc_idf"+b)&&$("#bc_idf"+b).val()==''){$("#brand_namef"+b).val($("#brand_namef").val());$("#n_idc"+b).val($("#n_idc").val());$("#brand_idf"+b).val($("#brand_idf").val());$("#pro_idf"+b).val(pro_id);$("#cat_idf"+b).val($("#cat_idf").val());$("#bc_idf"+b).val($("#bc_idf").val());$("#brand"+b).val($("#brand").val());$("#used"+b).val($("input[@name=used][@checked]").val());$("#used_pass_six"+b).val($("input[@name=used_pass_six][@checked]").val());$("#will_buy"+b).val($("input[@name=will_buy][@checked]").val());$("#comment"+b).val($("#comment").val());$("#comment_score"+b).val($("#comment_score0").val());}}
$("#list_score"+$("#comment_score0").val()).html($("#comment_score0").val());$("input[@name=brand]").get(0).checked=false;if(have_pro==1){$('input[@name=brand]').get(1).checked=false;}
$("input[@name=used]").get(0).checked=false;$("input[@name=used]").get(1).checked=false;$("input[@name=will_buy]").get(0).checked=false;$("input[@name=will_buy]").get(1).checked=false;$("input[@name=used_pass_six]").get(0).checked=false;$("input[@name=used_pass_six]").get(1).checked=false;$("#display_img"+$("#n_idc").val()).html('<img height="18" width="18" alt="" src="/img/bw3_have.jpg"/>');$("#me_score"+($("#n_idc").val()-1)).html("我打"+$("#comment_score0").val()+"分");$('#change_score_id').val(roundselect);roundselect++;$("#pk_round").html(select_num-roundselect-need_scorenum_for_chance+1);}
$("#comment_score0").val('');$("#comment").val('');$("#support_msg").show();$("#com_msg").hide();$(".gw_brand .bw3_brand").removeClass("bw3_b_focus");hide_pro();}
function display_pro(brand_id,cat_id){$("#pro1532").css("height","auto");$("#pro1532").show();$("#pro1532").html("正在处理数据...");var change_score_id=$("#change_score_id").val();var pro_did=$("#pro_idf"+change_score_id).val();var pro_html="";var pro_title;$.getJSON("/users/ajax_getpro?brand_id="+brand_id+"&cat_id="+cat_id+"",function(data){$("#pro1532").show();pro_html+='<table width="705" border="0" cellspacing="0" cellpadding="0" id="pro_mtb"><tr>';$.each(data,function(i,pro){if(pro.products.pro_name.length>14){if(pro_did&&pro_did==pro.products.id){pro_html+='<td class="protd"><p style="text-align:left;" title="'+pro.products.pro_name+'"><input type="radio" id="pro_id" name="pro_id" value="'+pro.products.id+'" checked="checked" >'+pro.products.pro_name.substring(0,14)+'...</p></td>';}else{pro_html+='<td class="protd"><p style="text-align:left;" title="'+pro.products.pro_name+'"><input type="radio" id="pro_id" name="pro_id" value="'+pro.products.id+'" >'+pro.products.pro_name.substring(0,14)+'...</p></td>';}}else{if(pro_did&&pro_did==pro.products.id){pro_html+='<td class="protd"><p style="text-align:left;"><input type="radio" id="pro_id" name="pro_id"  value="'+pro.products.id+'" checked="checked"  >'+pro.products.pro_name+'</p></td>';}else{pro_html+='<td class="protd"><p style="text-align:left;"><input type="radio" id="pro_id" name="pro_id" value="'+pro.products.id+'">'+pro.products.pro_name+'</p></td>';}}
if((i+1)%4==0){pro_html+="</tr><tr>";}
pro_title="#pro"+pro.products.brand_id;});pro_html+='</tr></table>';$("#pro1532").html(pro_html);$("#pro1532").css("height","auto");if($("#pro_mtb tr").length>3){$("#pro1532").css("height","80px");}else{$("#pro1532").css("height","auto");}});}
function dis_pro(obj){$("#pro1532").show();}
function closecomment(){$("#pro1532").hide();$('#pro_mtb').html('');$("#pro_mtb").hide();$("#gw_stat").hide();$('.bwh_comment1').hide();}
function hide_pro(obj){$("#pro1532").hide();}
function checkV(bc_id){if(userid&&!phone){tb_show('','/users/popup_phone_remind?now_campaign='+now_campaign+'&type=award_result&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}
$.ajax({type:'GET',url:"/users/ajax_islogin",data:"",success:function(str){if(!str){tb_show('','/users/popup_brandwar?username='+username+'&type=popaward&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}else{tb_show('','/users/popup_award/'+bc_id+'?now_campaign='+now_campaign+'&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}}});}
function display_lastaward(){tb_show('','/users/popup_lastaward?now_campaign='+now_campaign+'&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}
function display_inviteflist(){tb_show('','/users/popup_inviteflist?now_campaign='+now_campaign+'&TB_iframe=true&height=450px&width=600px',"thickbox");return false;}
function display_reward_result(step){tb_show('','/users/popup_award_result?now_campaign='+now_campaign+'&step='+step+'&TB_iframe=true&height=600px&width=600px',"thickbox");return false;}
function edit_score(n){var comment_score_edit=$("#comment_score"+n).val();if($("#comment_score0").val()==''){$("#comment_score0").val(comment_score_edit);}
$("#list_score"+comment_score_edit).html('<a class="" id=link_'+comment_score_edit+' href="javascript:void(0);" onclick=brand_warsetscore('+comment_score_edit+',0,this);return false;>'+comment_score_edit+'</a>');$("#brand_namef"+n).val($("#brand_namef").val());$("#n_idc"+n).val($("#n_idc").val());$("#brand_idf"+n).val($("#brand_idf").val());$("#pro_idf"+n).val($("input[@name=pro_id][@checked]").val());$("#cat_idf"+n).val($("#cat_idf").val());$("#bc_idf"+n).val($("#bc_idf").val());$("#brand"+n).val($("#brand").val());$("#used"+n).val($("input[@name=used][@checked]").val());$("#used_pass_six"+n).val($("input[@name=used_pass_six][@checked]").val());$("#will_buy"+n).val($("input[@name=will_buy][@checked]").val());if($("#comment"+n).val()!=''&&$("#comment"+n).val()!='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。'){if($.trim($("#comment_edit").val())!=''&&$.trim($("#comment_edit").val())!='用户首先选择'+select_num+'个品牌完成对其推荐程度的评分，然后更新个人信息或写一条评论。'){if($.trim($("#comment_edit").val()).length>800||$.trim($("#comment_edit").val()).length<20){malert("评论内容字数须在20和800之间。");$("#plk_review_edit").show();$("#plk_review").hide();$("#plk_info").hide();$("#comment_edit").focus();return false;}}
$("#comment"+n).val($.trim($("#comment_edit").val()));}else{$("#comment"+n).val($("#comment").val());}
$("#comment_score"+n).val($("#comment_score0").val());$("#list_score"+$("#comment_score0").val()).html($("#comment_score0").val());$("#display_img"+$("#n_idc").val()).html('<img height="18" width="18" alt="" src="/img/bw3_have.jpg"/>');$("#me_score"+($("#n_idc").val()-1)).html("我打"+$("#comment_score0").val()+"分");$("input[@name=brand]").get(0).checked=false;if(have_pro==1){$('input[@name=brand]').get(1).checked=false;}
$("input[@name=used]").get(0).checked=false;$("input[@name=used]").get(1).checked=false;$("input[@name=will_buy]").get(0).checked=false;$("input[@name=will_buy]").get(1).checked=false;$("input[@name=used_pass_six]").get(0).checked=false;$("input[@name=used_pass_six]").get(1).checked=false;$("#comment_score0").val('');$("#comment").val('');$("#comment_edit").val('');if(roundselect>5-need_scorenum_for_chance&&roundselect<select_num-need_scorenum_for_chance){$("#goon_button").hide();$("#submit_button").show();}}
function bwfocusthis(n){$(".gw_brand .bw3_brand").removeClass("bw3_b_focus");$(".gw_brand .bw3_brand:eq("+n+")").addClass("bw3_b_focus");}
