﻿
    $(document).ready(function () {

           if ($("[id$=btnVote]").attr("disabled") == "disabled" || $("[id$=btnVote]").attr("disabled") == true)
            $("[id$=btnVote]").addClass("btnNotEable");

        $("[id$=btnVote]").click(function () {

            // alert($("[id$=rbChoice]:checked").val());
            var choiceId = $("[name=choice]:checked").val();

            if (choiceId == undefined) {
                if (!$("[id$=btnVote]").hasClass("btnNotEable"))
                    alert("الرجاء اختيار احد الخيارات");
                return false;
            }
            $("#PollLoading").show();
            choiceId = choiceId.toString().split('_');
            var id = choiceId[choiceId.length - 1].toLowerCase();

            //alert("id: " + $(this).attr("voteId") + " vote:" + id);
            $.get(
                'PollResult.aspx',
                { 'rand': Math.random(), id: $(this).attr("voteId"), vote: id },
                function (data) {
                    //alert("success");
                    //                setInterval(function() {
                    //                $(".chall").load(location.href + " .chall>*", "");
                    //                }, 5000);
                    //
                    // $("[id$=btnVote]").attr("disabled", "disabled");
                    $("[id$=btnVote]").addClass("btnNotEable");
                    $("#result").html(data);
                    $("#PollLoading").hide();
                    $("[name=choice]").each(function () {
                        $(this).attr("disabled", "disabled");
                    });
                    //alert(data);
                }
            );

            return false;
        });
    });
  
   	








