﻿
var index={
   onInit:function(){
     this.onNewsItems();
     this.loadnews("action=gonggao");
     this.loadInfo("action=petlevel");
   },
   $:function(_id){
      return document.getElementById(_id);
   },
   newsmenus:[["m_n_t_1","action=all"],["m_n_t_2","action=tuiguan"],["m_n_t_3","action=gonggao"],["m_n_t_4","action=huodong"]],
   url:"handle/contest/activitylistHandler.ashx",
   infolurl:"handle/Top10Handler.ashx",
   onNewsItems:function(){
      for(var j=0;j<this.newsmenus.length;j++){
        var _element=index.$(this.newsmenus[j][0]);
        _element.action=this.newsmenus[j][1];
        _element.onclick=function(){
            index.loadnews(this.action);
           for(var i=0;i<index.newsmenus.length;i++){
              index.$(index.newsmenus[i][0]).style.backgroundImage="url(images/"+index.newsmenus[i][0]+"_2.gif)";
           }
           this.style.backgroundImage="url(images/"+this.id+"_1.gif)";
        }
      }
   },
   loadnews:function(pars){
        $.ajax({
         type: "POST",
         url:  index.url,
         data: pars,
         success: function(msg){
           $('#m_news_list').html(msg);
         }
       });
   },
   loadInfo:function(pars){
      $.ajax({
         type: "POST",
         url:  index.infolurl,
         data: pars,
         success: function(msg){
           $('#r_top_l').html(msg);
         }
       });
   },
   profiles:["账号","密码","验证码"],
   joinParamers:function(width,height,textwidth){
     var pics,links,texts,pars;
       for(var i=0;i<_flashImages.length;i++){
        if(i==0){
           pics=_flashImages[i][0]; 
           texts=encodeURIComponent(_flashImages[i][1]); 
           links=encodeURIComponent(_flashImages[i][2]);
        }else{
           pics+='|'+_flashImages[i][0];
           texts+='|'+encodeURIComponent(_flashImages[i][1]);
           links+='|'+encodeURIComponent(_flashImages[i][2]);
        }
     } 
     pars='pics='+pics;
     pars+='&links='+links;
     pars+='&texts='+texts;
     pars+='&borderwidth='+width;
     pars+='&borderheight='+height;
     pars+='&textheight='+textwidth;
     return pars;
   },
   renderFlash:function(width,height){
        var textwidth=0;
        var pars=this.joinParamers(width,height,textwidth);
		var l=[];
		l.push('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+(height+textwidth)+'" title="谜奇国度">');
		l.push('<param name="allowScriptAccess" value="sameDomain" />');
        l.push('<param name="movie" value="images/kad_2.swf" />');
        l.push('<param name="quality" value="high" />');
        l.push('<param name="bgcolor" value="#F0F0F0" />');
        l.push('<param name="menu" value="false" />');
        l.push('<param name="wmode" value="opaque" />');
        l.push('<param name="FlashVars" value="'+pars+'" />');
        l.push('<embed src="images/kad_2.swf" quality="high" wmode="opaque" allowScriptAccess="sameDomain" FlashVars="'+pars+'"   pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+(height+textwidth)+'"></embed>');
        l.push('</object>');
        document.write(l.join(''));
   },
   renderServerlist:function(){
     var ils=[];
     ils.push("<ul>");
     for(var i=0;i<_indexServers.length;i++){
         ils.push("<li><span>"+_indexServers[i][0]+"</span>"+_indexServers[i][1]+"</li>");
     }
     ils.push("</ul>");
     document.write(ils.join(''));
   },
   renderadvslefttop:function(i){
      document.write("<a href=\""+_indexadvs[i][1]+"\"><img  src=\""+_indexadvs[i][0]+"\" /></a>");
   }
}

var gamePic={
  currentPageIndex:0,
  onInit:function(){
    this.renderGamePic();
  },
  renderGamePic:function(){
    var gl=[];
    gl.push("<tr>");
    for(var i=0;i<4;i++){
      var _arr=_gamePicArr[this.currentPageIndex*4+i];
      gl.push("<td>");
      gl.push("<div class='m_g_p_img'>");
      gl.push(" <a href='"+_arr[1]+"' target='_blank'><img src='"+_arr[0]+"' /></a></div>");
      gl.push("</td>");
    }
    gl.push("</tr>");
    $("#m_g_p_list").html(gl.join(''));
  },
  nextPage:function(){
     this.currentPageIndex++;
     if(this.currentPageIndex>=3) 
         this.currentPageIndex=0;
     this.renderGamePic();
  },
  prvPage:function(){
    this.currentPageIndex--;
    if(this.currentPageIndex<0)
        this.currentPageIndex=2;
    this.renderGamePic();
  }
}

var Player={
   currentPageIndex:0,
   onInit:function(){
     this.renderPlayer();
   },
   renderPlayer:function(){
      var  pl=[];
      pl.push("<tr>");
      pl.push("<td colspan='2' class='title'><img src='images/player_b_left.gif' style='cursor:pointer;'  onclick='Player.prvPage();' /><img src='images/player_b_right.gif' style='cursor:pointer;'  onclick='Player.nextPage();' /></td>");
      pl.push("</tr>");
      var p1="",p2="",p3="";
      for(var i=0;i<2;i++){
         var _arr=_PlayerArr[this.currentPageIndex*2+i];
         p1+="<td><div class='m_re_img'><a href='"+_arr[2]+"' target='_blank'><img src='"+_arr[0]+"' /></a></div></td>";
         p2+="<td>"+_arr[1]+"</td>";
         p3+="<td>所在区："+this.getServer(_arr[3])+"</td>";
      }
      pl.push("<tr>"+p1+"</tr>");
      pl.push("<tr>");
      pl.push("<td>玩家昵称：</td>");
      pl.push("<td>玩家昵称：</td>");
      pl.push("</tr>");
      pl.push("<tr>"+p2+"</tr>");
      pl.push("<tr>"+p3+"</tr>");
      $("#m_re_r_list").html(pl.join(''));
   },  
   nextPage:function(){
    this.currentPageIndex++;
     if(this.currentPageIndex>=3) 
         this.currentPageIndex=0;
     this.renderPlayer();
   },
   prvPage:function(){
       this.currentPageIndex--;
       if(this.currentPageIndex<0)
        this.currentPageIndex=2;
       this.renderPlayer();
   },
   getServer:function(serverID){
     switch(serverID){
       case "1":
         return "北京区";
       case "2":
         return "上海区";
       case "3":
         return  "Hers区";
       case "4":
         return "广东区";
       case "5":
         return "蓝草莓";
       case "6":
         return "人人区";
      }
   }
}


var advIMG={
  currentPageIndex:0,
  onInit:function(){
     this.renderadvIMG();
   },
  renderadvIMG:function(){
     var advI=[];
     advI.push("<tr>");
     advI.push("<td class='l'><img src='images/m_nis_list_l.gif' style='cursor: pointer;' onclick='advIMG.prvPage();' /></td>");
     for(var i=0;i<4;i++){
      var _arr=_advIMGArr[this.currentPageIndex*4+i];
        var k= _arr[1].length>7?_arr[1].substring(0,7):_arr[1];
        advI.push("<td><div class='m_n_img'><img src='"+_arr[0]+"' /></div><h1>"+k+"</h1></td>");
     }
     advI.push("<td class='l'><img src='images/m_nis_list_r.gif' style='cursor: pointer;' onclick='advIMG.nextPage();' /></td>");
     advI.push("</tr>");
     $("#m_nis_list").html(advI.join(''));
  },
  nextPage:function(){
     this.currentPageIndex++;
     if(this.currentPageIndex>=3) 
         this.currentPageIndex=0;
     this.renderadvIMG();
  },
  prvPage:function(){
    this.currentPageIndex--;
    if(this.currentPageIndex<0)
    this.currentPageIndex=2;
    this.renderadvIMG();
  }
}
