function duowan_canvote(id){
   var setcookie=function(sName,sValue){
    var d=new Date();
    var year=d.getYear()+1;
    var end=Date.parse(((year<1900)?(1900+year):year)+"/"+(d.getMonth()+1)+"/"+d.getDate()+" 23:59:59");
    var t_date = new Date(end);
    var expiresDate = t_date.toUTCString();
    document.cookie=sName+"="+escape(sValue)+";expires="+expiresDate;
  };
    var getcookie=function(sName){  
    var aCookie = document.cookie.toString().split(";");  
    for(var i=0; i < aCookie.length; i++){
      var aCrumb = aCookie[i].split("=");
      if (sName == aCrumb[0].replace(/\s/ig,"")) return unescape(aCrumb[1]);  
    }
  };
  if(getcookie(id)!="1"){
    setcookie(id,"1");
    return true;
  }
  return false;
} 

function $(o){
	 if(typeof(o) == "string")
	 return document.getElementById(o);
	 return o;
}

function addpot(channelid,voteid)
 {  
  var duowan_vote_chktype=1;
  var subjectid=$("vote_subjectid").value;
  var id="duowanvote"+channelid+voteid+subjectid;
  var endtime=$("vote_endtime_"+channelid+"_"+voteid).value;
  var checks=document.getElementsByName("op");
  var itemid;
  var b=false;
  var othervote;
  for(var i=0;i<checks.length;i++){
              if(checks[i].checked==true){
                b=true;
                itemid=checks[i].value;
                break;
              }
   }
    if(b==true)
    {
     if(!duowan_canvote(id)){
       alert("对不起你已经投过票了^O^!");
       return;
     }
      var f=$("dw_vote");
      if(!f){
      f=document.createElement("iframe");
      f.id="dw_vote";
      f.height="0px";
      f.width="0px";
      f.style.display="none";
      document.body.appendChild(f);
     }
     var href="http://comment2.duowan.com/vote/voting.jsp?channelid="+channelid+"&voteid="+voteid+"&subjectid="+subjectid+"&itemid="+itemid+"&endtime="+endtime+"&duowan_vote_chktype="+duowan_vote_chktype+"&isclick=1";
     f.src=href;
    }else{
      alert("对不起,选项不能为空!");
     return;
    }
 }
