﻿ var L;
 $(document).ready(function() {
     $.ajaxSetup({
         type: "POST",
         cache: false
     });

    L = new PtGift();
    L.checkLogin();
 })
 function PtGift()
 {
  var self=this;
  this.dv_lout=$("#mess");
  this.rezult={};
  this.a_out = $("#a_out");
  this.a_login=$("#a_login");
    this.img_logout = $("#img_logout");
    this.dv_lout=$("#dv_lout");
   this.checkLogin=function()
   {
      $.getJSON("ajax/PtGifts.ashx","act=checkLogin",function(d){
           if(d.user!="")
           { self.dv_lout.css("display","block"); $("#mess").css("display","block");$("#a_login").css("display","none");$("#td_out").css("display","block");
                             $("#str_name").html(d.user);
                              if(d.qs!="")
                              {
                              $("#f_qs").html("已开通");
                              }
                              if(d.email!="")
                              {
                                $("#f_email").html("已开通");
                              }
            }
        else{ self.dv_lout.css("display","none");$("#td_out").css("display","none");}
      })
   }
   this.bnt=$(".bnt");
   $.each(this.bnt,function(i,n){  
           $(n).click(function(){
             $.post("ajax/PtGifts.ashx","act=gift&rank="+i,function(d){
                 if(d=="notlogin"){ window.showPopWin('', 'Ptlogin.html', 250, 250, null, true, true);}
                 else{alert(d);return ;}
//                var ack=d.ack;
//                if(ack=="notlogin"){ window.showPopWin('', 'Ptlogin.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");
   })
   
  $("#a_login").click(function(){
  
     window.showPopWin('', 'Ptlogin.html', 250, 250, null, true, true);
  })
   self.img_logout.click(function(){
      $.post("ajax/luck.ashx","act=out",function(d){
        if(d=="ok"){window.location.href="PtGifts.html"}
      })
   })
 }