﻿//设置cookies
        function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
        {
            var exp  = new Date(); 
            exp.setTime(exp.getTime() + 12*60*60*1000);//有效期为12个小时
            document.cookie = name + "="+ encodeURI (value) + ";expires=" + exp.toGMTString();
        }
        /*关闭网页就可以关闭cookies*/
        function SetCookie1(name,value)//两个参数，一个是cookie的名子，一个是值
        {
            var exp  = new Date(); 
            document.cookie = name + "="+ encodeURI (value) ;
        }
        
        //读取cookies的技术,为空返回null
        function getCookie(name)//取cookies函数        
        {
             var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
             if(arr != null)
                return decodeURI(arr[2]); 
             return null;
        }
        
        
        //删除cookie
        function delCookie(name)//删除cookie
        {
            var exp = new Date();
            exp.setTime(exp.getTime() - 1);
            var cval=getCookie(name);
            if(cval!=null) 
            document.cookie= name + "="+cval+";expires="+exp.toGMTString();
        }
        
        function submit()
        {
           var v_id = $("#submit").val();
           var ss= getCookie(v_id);
             
           if(ss!=null)
             alert("您已经投过票了，谢谢！");
           else
           {
              var ss = "";
              $(".myclass ").each(function(){
                 if($(this).attr("checked"))
                    ss+=$(this).val()+",";
              });
              if(ss==""){
                 alert("您没有选择");
                 return;
              }
              $.get("/js/vote.aspx",{vote:ss,voteid:v_id,num:Math.round(Math.random()*10000)},
                function(data){
                   if(data.re=="1")
                   {
                      SetCookie(v_id,"1");
                      alert("投票成功！");
                      window.open("/other/VoteShow.aspx", "", "");
                      $(".myclass :checked").each(function(){
                        window.setTimeout( function(){$(this).attr("checked",false);},3);
                      });
                    }
                    else
                    { 
                      alert("投票失败");
                    }
                },
               "json");
           }
        }
        
        /*时间扩展*/
         Date.prototype.toMyDate = function() { 
             var day = this.getDay();
             var xq ;
             if(day==0)
                 xq="星期日";
             else if(day==1) 
                xq="星期一"; 
             else if(day==2)
                xq="星期二"; 
             else if(day==3)
                xq="星期三"; 
             else if(day==4)
                xq="星期四"; 
             else if(day==5)
                xq="星期五"; 
             else
                xq="星期六"; 
            
             return this.toLocaleDateString()+"&nbsp;"+ xq +this.toLocaleTimeString();
         };  
         
         //市民邮箱登陆部分
        function MailLogin()
        {
           var action =document.form1.action;
           if(document.form1.F_domain.value=="dongying.gov.cn")
           {
               document.form1.action="http://mail.dongying.gov.cn/index.php";
	           document.form1.name = "login";
	           document.form1.F_email.value;
	           document.form1.F_password.value;
	           document.form1.cmd.value;
	           document.form1.target= "_blank ";
	           document.form1.submit();
           }
           else if(document.loginmail.F_domain.value=="dongying.cn")
           {
               document.form1.action="http://mail.dongying.cn/index.php";
	           document.form1.name = "login";
	           document.form1.cmd.value;
	           document.form1.F_email.value;
	           document.form1.F_password.value;
	           document.form1.target= "_blank ";
	           document.form1.submit();
           }
           else
           {
               document.form1.action="http://mail.dongying.gov.cn/index.php";
	           document.form1.name = "login";
	           document.form1.F_email.value;
	           document.form1.F_password.value;
	           document.form1.cmd.value;
	           document.form1.target= "_blank ";
	           document.form1.submit();
           }
           window.setTimeout(function(){
               document.form1.action=action;
           },200);
        }
        
$(document).ready(function(){
   $("#jian").html("简体");
   $("#jian").attr("title","简体");
});
