﻿
window.onload=function()
{
    //fnGetPostFileScript("FeedBack");
    fnInit();
    var objVoteOK = document.getElementById("bt_vote_ok");
    var objVoteView = document.getElementById("bt_vote_view");
    if(objVoteOK)
    {
        if(Browser.isIE)
        objVoteOK.attachEvent("onclick",fnSumbitVote);
        else
        objVoteOK.addEventListener("click",fnSumbitVote,false);
    }
    if(objVoteView)
    {
        if(Browser.isIE)
        objVoteView.attachEvent("onclick",fnViewVote);
        else
        objVoteView.addEventListener("click",fnViewVote,false);
    }
}


function fnSumbitVote()
 {
    var ulList = $("ul_vote_list");
    var strChecked = "";
    if(ulList)
    {
        var inputCollect = ulList.getElementsByTagName("input");
        for(var index=0;index<inputCollect.length;index++)
        {
            var inputItem = inputCollect[index];
            if(inputItem.type.toString()=="radio" || inputItem.type.toString()=="checkbox" )
            {//单选或者复选
                if(inputItem.checked)
                {
                    strChecked += inputItem.id + "|";
                }
            }
        }
        if(strChecked.length<1) //没有选择任何选项
        {
            alert("你没有选择任何选项!");
            return;
        }
        else
        {
            
            var arrParams = new Array();
            arrParams = pushParam(arrParams,"strVoteList",strChecked);
            fnCreateXmlDoc("Vote",arrParams,true); 
        }     
    }
 }
 function fnViewVote()
 {
    window.open("/ViewBallot.Html",'result','toolbar=no,menu=no,width=400,height=350');
 }
 
function cb_fnVote()
 {
     if(xmlhttp.readyState== 4 && xmlhttp.status == 200)
    {
        if(Browser.isIE)
        {
            var err = xmlDoc.parseError;
		    if (err.errorCode != 0)	
		    {
		        alert("xmlDoc出错：\n" + err.reason);
		        return;
		    }	
            var result = xmlhttp.responseXML.selectSingleNode("//VoteResult").nodeTypedValue;          
        }
        else
        {
            var result = GetNodeValue(xmlhttp.responseXML.childNodes[0].childNodes[0].childNodes[0].childNodes[0]);  
        }

        if(result.toLowerCase()=="ok")
        {
            alert("投票完成,感谢你的参与！");
        }
        else
        {
            alert("投票失败" + result);
        }
    }
 }

