﻿// JScript 文件
function do_vote(vid,vtitle,Msg)
    {
        var oArgs = document.getElementsByName('vote_option');
        var vcom = document.getElementById('vote_comment').value;
        var oid_str = '';
       
        for(var i=0;i<oArgs.length;i++)
        {
            if(oArgs[i].checked == true)
            {
                oid_str += ','+oArgs[i].value;
            }
        }
        
        if(oid_str == '')
        {
            return;
        }
        
         var option={
        parameters:'ot=addvoteoption&vid='+vid+'&oids='+oid_str+'&vcomment='+vcom,
        method:'post',
        onSuccess:function(transport){
            var rp = transport.responseText;
            if(rp == 'true')
            {     
//                    alert(Msg);
                  document.getElementById('Div_vote1').innerHTML="<b>"+Msg+"<b>";
                  document.getElementById('div_vote').style.display="none";      
//                    document.location.href = '/vote/vote.aspx?vid='+vid;
            }
            else
            {
                return;
            }
            return;
        },
        onFailure:function(transport){
            alert('Exception error');
            return;
        }
    }
    var request=new Ajax.Request("/ajax.aspx",option); 
    }
    
//cesc add 
function addvote(divlistStr)
{
    var divlist = divlistStr.split('|');
    var tempcontrolname = '';
    var allstr = '';
    for(i = 0;i < divlist.length;i++)
    { 
        var tempid = divlist[i]; 
        if(tempid != '')
        {
            tempcontrolname = 'vote_option_'+tempid;
            var oArgs = document.getElementsByName(tempcontrolname);
            var oid_str = '';
            
        
            for(j=0;j<oArgs.length;j++)
            {
                if(oArgs[j].checked == true)
                { 
                    oid_str += ',' + oArgs[j].value;
                }
                
            }
            allstr += '|' + tempid + '-' + oid_str;
            
        }
        
    }
    //alert(allstr);
    if(allstr == '')
    {
        return;
    }
    
     var option={
        parameters:'ot=addparticipation&allstr='+allstr,
        method:'post',
        onSuccess:function(transport)
        {
            var rp = transport.responseText;
                if(rp == 'true')
                {     
                        alert("Vote Success!");
                        window.location.replace('../Customer/Regist.html');
        //                    alert(Msg);
                      //document.getElementById('Div_vote1').innerHTML="<b>"+Msg+"<b>";
                      //document.getElementById('div_vote').style.display="none";      
        //                    document.location.href = '/vote/vote.aspx?vid='+vid;
                }
                else
                {
                    alert("Vote Success!");
                    window.location.replace('../Customer/Regist.html');
                    return;
                }
                return;
        },
        onFailure:function(transport){
            //alert('Exception error');
            alert("Vote Success!");
            window.location.replace('../Customer/Regist.html');
            return;
        }
    }
    var request=new Ajax.Request("/ajax.aspx",option); 
    
}



function participate(vid)
{

    var tempcontrolname = 'vote_option_'+vid
    var oArgs = document.getElementsByName(tempcontrolname);
    var vcom = '';
    //var vcom = document.getElementById('vote_comment').value;
    var oid_str = '';
   
    for(var i=0;i<oArgs.length;i++)
    {
        if(oArgs[i].checked == true)
        {
            
            oid_str += ',' + oArgs[i].value;
        }
    }
    
    if(oid_str == '')
    {
        return;
    }
    
     var option={
        parameters:'ot=addparticipation&vid='+vid+'&oids='+oid_str+'&vcomment='+vcom,
        method:'post',
        onSuccess:function(transport)
        {
            var rp = transport.responseText;
                if(rp == 'true')
                {     
                        alert("true");
        //                    alert(Msg);
                      document.getElementById('Div_vote1').innerHTML="<b>"+Msg+"<b>";
                      document.getElementById('div_vote').style.display="none";      
        //                    document.location.href = '/vote/vote.aspx?vid='+vid;
                }
                else
                {
                    alert("false");
                    return;
                }
           //return;
        },
        onFailure:function(transport){
            alert('Exception error');
            //return;
        }
    }
    var request=new Ajax.Request("/ajax.aspx",option); 
}
