var vote={Init:function(){var t=$.cookie("ListVoteItemID");null!=t&&$(".box-vote ul li").each((function(){var e=$(this).find(".inp_radio"),i=$(e).attr("data-voteitemid");-1!=t.search("_"+i+"_")&&$(e).prop("checked",!0)}));var e=$("#voteID").val();vote.IsVoted(e)&&vote.DrawVote(),$("input[type=radio][name=vote-item]").change((function(){var t=$("#voteID").val();vote.IsVoted(t)?alert("Bạn đã vote rồi !"):$("#myModal").show()})),$(".my-modal").on("click",".close",(function(){$("#myModal").hide(),$("input[name='vote-item']:checked").prop("checked",!1)})),$(document).click((function(t){$target=$(t.target),!$target.closest(".my-modal-content").length&&$(".my-modal-content").is(":visible")&&($("#myModal").hide(),$("input[name='vote-item']:checked").prop("checked",!1))})),$("#txtImgVerifyVote").blur((function(){return $("#txtImgVerifyVote_validate").length>0&&$("#txtImgVerifyVote_validate").remove(),""!=$("#txtImgVerifyVote").val().trim()||($("#txtImgVerifyVote").parent().after('<div id="txtImgVerifyVote_validate" class="errorcaptcha">Vui lòng nhập mã xác nhận</div>'),$("#txtImgVerifyVote").focus(),!1)})),$("#btnSubmitVote").click((function(){return!!vote.ValidateProcessing()&&vote.Submit()}))},ValidateProcessing:function(){return $("#txtImgVerifyVote").trigger("blur")},AddCookie:function(t,e){var i,o,a=$.cookie("ListVoteItemID"),n=$.cookie("ListVoteID");(o=new Date).setTime(o.getTime()+2592e6),null!=a?-1==a.search("_"+e+"_")&&$.cookie("ListVoteItemID","_"+e+"_,"+a,{path:"/",expires:o}):$.cookie("ListVoteItemID","_"+e+"_",{path:"/",expires:o}),(i=new Date).setTime(i.getTime()+2592e6),null!=n?-1==n.search("_"+t+"_")&&$.cookie("ListVoteID","_"+t+"_,"+n,{path:"/",expires:i}):$.cookie("ListVoteID","_"+t+"_",{path:"/",expires:i})},IsVoted:function(t){var e=$.cookie("ListVoteID");return null!=e&&-1!=e.search("_"+t+"_")},DrawVote:function(){$(".box-vote .txt_number_ketqua").removeClass("display-none");var t=parseInt($("#totalVote").val())+1,e=1,i=$(".box-vote ul li").length,o=100;$(".box-vote ul li").each((function(){if(e==i)$(this).find(".bg_center_scroll").attr("style","width:"+o+"%"),$(this).find(".txt_number_ketqua").text(o+"%");else{var a;if($(this).find("input[name='vote-item']").is(":checked")){var n=parseInt($(this).find(".option_value").val())+1;a=parseInt(100*n/t),$(this).find(".bg_center_scroll").attr("style","width:"+a+"%"),$(this).find(".txt_number_ketqua").text(a+"%")}else{n=parseInt($(this).find(".option_value").val());a=parseInt(100*n/t),$(this).find(".bg_center_scroll").attr("style","width:"+a+"%"),$(this).find(".txt_number_ketqua").text(a+"%")}o-=a}e++}))},Submit:function(){var t=$("#voteID").val(),e=$("input[name='vote-item']:checked").attr("data-voteitemid"),i=$("#txtImgVerifyVote").val();$.ajax({type:"GET",url:websiteDomain+"/member/votecount",data:{voteItemID:e,captcha:i},dataType:"jsonp",jsonp:"callback",success:function(o){"true"==o?($("#txtImgVerifyVote").val(""),$("#myModal").hide(),vote.AddCookie(t,e),vote.DrawVote()):"captchafalse"==o&&($(".verifyCodeVote").attr("src","/member/captcha/"+Math.random()),$("#txtImgVerifyVote_validate").length>0?""==i&&0==i.length?$("#txtImgVerifyVote_validate").html("Mã captcha không được để trống"):$("#txtImgVerifyVote_validate").html("Mã captcha không đúng, Vui lòng thử lại"):$("#txtImgVerifyVote").parent().after('<div id="txtImgVerifyVote_validate" class="errorcaptcha">Mã captcha không đúng, Vui lòng thử lại.</div>'),$("#txtImgVerifyVote").focus())},error:function(t,e,i){}})}};