﻿// 信息检索文本框的键盘事件(回车)
function SearchKeyPress(e,isOpenWin){
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    if (keyCode == 13){
        Searching(isOpenWin);
        return false;
    }
}

// 信息检索操作函数
function Searching(isOpenWin){
    var $textCxnr = $("#txtSearch");
    if($.trim($textCxnr.val()) == ""){
        alert("请您输入要查询的内容！");
        $textCxnr.focus();
        return false;
    }
    else{
        if(Boolean(isOpenWin)){
            window.open("/Page/Search.aspx?key=" + escape($.trim($textCxnr.val())));
            $textCxnr.val('');
        }
        else{
            window.location.href="/Page/Search.aspx?key=" + escape($.trim($textCxnr.val()));
        }
    }
}

// 首页异步提交投票
function UpdateVote(){
    var $chkOptions = $('#tabVote :checkbox:checked');
    var $rdoOptions = $('#tabVote :radio:checked');
    if(($chkOptions.length == 0) && ($rdoOptions.length == 0)){
        alert("请您选择投票选项！");
        return false;
    }
    else{
        var voteid = $('#hfVoteId').val();
        var options = "";
        var $lx = $('#hfLx');
        if($lx.val() == "1"){  //单选
            options = $rdoOptions.eq(0).val();
        }
        else{//多选
            $chkOptions.each(function(i){
                options += $(this).parent("span").attr('tag') + ",";
            });
            options = options.substr(0 , options.length-1);
        }
        $.ajax({
            type : "POST",
            url : "/Page/OnlineVoteHandler.ashx",
            data : "voteid=" + voteid + "&options=" + options,
            success : function(msg){
                 if(Boolean(msg)){
                    $chkOptions.attr('checked' , false);
                    $rdoOptions.attr('checked' , false);
                    alert("投票成功，感谢您的参与！");
                    window.open("/OnlineVote/Vote_" + voteid + ".html", "_blank", "width = 500, height = 300, resizable = yes");
                 }
                 else{
                    alert("投票失败，您可以稍候再试！");
                 }
            },
            error : function(){
                alert("投票失败，您可以稍候再试！");
            }
        });
    }
}

//查看投票
function ShowVote(){
    var voteid = $('#hfVoteId').val();
    window.open("/OnlineVote/Vote_" + voteid + ".html", "_blank", "width = 500, height = 300, resizable = yes");
}

//搜索
function clickinput(n)
{ 
    var serachId = document.getElementById("serach");
    if (n == 0 && serachId.value == "请输入办事事项关键字"){serachId.value="";}
    if (n == 1 && serachId.value == ""){serachId.value = "请输入办事事项关键字";}
}
