﻿ var L;
 $(document).ready(function() {
     $.ajaxSetup({
         type: "POST",
         cache: false
     });

      L = new Gift();
    L.checkLogin();
 })
 
function Gift()
 {
  var self=this;
  this.dv_lout=$("#dv_lout");
  this.rezult={};
  this.bnt= $("#a_bnt");
  this.a_out = $("#a_out");
  
   this.checkLogin=function()
   {
      $.post("ajax/luck.ashx","act=checkLogin",function(d){
        if(d!=""){ self.dv_lout.css("display","block");$("#dv_msg").html("您好，欢迎您 "+d);}
        else{ self.dv_lout.css("display","none");$("#dv_msg").html("");}
      })
   }
   self.bnt.click(function(){
     $.getJSON("ajax/luck.ashx","act=gift",function(d){
        self.rezult=d ;
        var ack=self.rezult["ack"];
        if(ack=="notlogin"){ window.showPopWin('', 'login.html', 250, 250, null, true, true);}
        else if(ack=="notrank"){window.showPopWin('', 'error.html', 250, 130, null, true, true);}
        else if(ack=="hadward"){window.showPopWin('', 'msg.html', 250,120, null, true, true);}
        else if(ack=="ok"){window.showPopWin('', 'giftbox.html?gift='+self.rezult["msg"], 590,505, null, true, true);}
     })
   })
   self.a_out.click(function(){
      $.post("ajax/luck.ashx","act=out",function(d){
        if(d=="ok"){ self.dv_lout.css("display","none");$("#dv_msg").html("");}
      })
   })
   $("#a_online").click(function(){
        window.open("zhan.html");
   })
 }
