﻿// JScript 檔

 function ChannelVote(channel,kind,cls,id)
 {
     writeCookie("hkstockTestCookie", "1234");
     if (readCookie("hkstockTestCookie") == null || readCookie("hkstockTestCookie") == "")
     {
        alert("請開啟 cookie 功能！");
        return;
     }
     
     if(readCookie(kind) == null || readCookie(kind) !="YES")
     {

        var pd = "channel="+channel+"&kind="+kind+"&cls="+cls+"&id="+id+"&rnd="+Rnd();
        $.post("Ajax/HKStockVote.aspx", 
                pd, 
                function(result)
                {
                  //alert(result);
                  
                  //if(result.split("|")[0] == 1)
                  if(result.split("|").length > 3)
                  {
                      
                     var bullPercent = parseInt(result.split('|')[0]);
                     var bearPercent = parseInt(result.split('|')[1]);
                     var consolidationPercent = parseInt(result.split('|')[2]);
                   
                     $("span[class='bar_r']").css({width: bullPercent + "%"});
                     $("span[class='bar_g']").css({width: bearPercent + "%"});
                     $("span[class='bar_y']").css({width: consolidationPercent + "%"});
                     
                     $("#percent_r").text(bullPercent + "%");
                     $("#percent_g").text(bearPercent + "%");
                     $("#percent_y").text(consolidationPercent + "%");
                     
                     //投票成功寫入Cookie
                     writeCookie(kind,  "YES",  24);
                     
                     alert("多空調查投票成功！");
                     window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
                  
                  }
                  else
                  {
                     alert("不得重複投票，每人一天限投一票！");
                     window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
                  
                  }
                   
                }
        );
     }
     else
     {
       
        alert("不得重複投票，每人一天限投一票！");
        window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
     }
 
   } 
   
   
   
   
   function WarrantCaculate(channel,kind,cls,id)
   {
     writeCookie("hkstockTestCookie", "1234");
     if (readCookie("hkstockTestCookie") == null || readCookie("hkstockTestCookie") == "")
     {
        alert("請開啟 cookie 功能！");
        return;
     }
     
     if(readCookie(kind) == null || readCookie(kind) !="YES")
     {

        var pd = "channel="+channel+"&kind="+kind+"&cls="+cls+"&id="+id+"&rnd="+Rnd();
        $.post("Ajax/HKStockVote.aspx", 
                pd, 
                function(result)
                {
                  //alert(result);
                  
                  if(result.split("|")[0] == 1)
                  {
                      
                     var bullPercent = parseInt(result.split('|')[1]);
                     var bearPercent = parseInt(result.split('|')[2]);
                     var consolidationPercent = parseInt(result.split('|')[3]);
                   
                     $("span[class='bar_r']").css({width: bullPercent + "%"});
                     $("span[class='bar_g']").css({width: bearPercent + "%"});
                     $("span[class='bar_y']").css({width: consolidationPercent + "%"});
                     
                     $("#percent_r").text(bullPercent + "%");
                     $("#percent_g").text(bearPercent + "%");
                     $("#percent_y").text(consolidationPercent + "%");
                     
                     //投票成功寫入Cookie
                     writeCookie(kind,  "YES",  24);
                     
                     alert("多空調查投票成功！");
                     window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
                  
                  }
                  else
                  {
                     alert("不得重複投票，每人一天限投一票！");
                     window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
                  
                  }
                   
                }
        );
     }
     else
     {
       
        alert("不得重複投票，每人一天限投一票！");
        window.open('http://www.cnyes.com/hkstock/hkvote.aspx');
     }
 
   } 
   
   
   
   
   
