﻿function SearchForum(event){
    var e = event || window.event;
    var key = event.charCode || event.keyCode;
    if (document.getElementById("searchForumTxt").value == ""){
            alert("עלייך להזין טקסט על מנת לחפש");
            document.getElementById("searchForumTxt").blur();
            return false;
    }
    else{
         if ((key == 13) || (document.getElementById("searchForumTxt").value != "")){
            var elementVal = document.getElementById('searchForum').value;
            if (elementVal == 'forum'){window.location = "ForumsList.aspx?Display=3&Search=" + document.getElementById("searchForumTxt").value;};
            if (elementVal == 'topic'){window.location = "TopicList.aspx?Order=3&Search=" + document.getElementById("searchForumTxt").value;};
        }
}
}

var MainPoll = {
    Vote: function(pollId, voteBtn, options, answers, width) {

        if (!IsLogin) {
            window.location = "../Login.aspx";
            return;
        }

        selectedAnswerId = this.CheckVoteForPoll(pollId);
        var data = { PollId: pollId, SelectedAnswerId: selectedAnswerId, OptionWidth: width };
        $.json('AnswerMainPoll', { url: 'Json/JsonMain.aspx?action=', postBody: data, onSuccess: function(json, state) {
            if (state) {
                $(options).hide();
                $(voteBtn).hide();
                $(answers).innerHTML = json.MainPollAnswersDisplay;
                $(answers).show();
            }
        }
        });
    },
    CheckVoteForPoll: function(pollId) {
        var Name = "ctl00$ctl00$BasicMasterPage$cphForumsMasterPage$MainPollDisplay$MainPoll_" + pollId;
        var Options = document.getElementsByName(Name);
        for (var i = 0; i < Options.length; i++) {
            if (Options[i].checked) return Options[i].value;
        }
        $('dvNoAnswer').show();
        Effect.Pulsate('dvNoAnswer', { duration: 1.5, afterFinish: function() { $('dvNoAnswer').hide(); } });
        return false;
    }
};

