﻿

/*ppp add*/
var B=BigNews={
 current:0,
 next:0,
 scrollInterval:0,
 autoScroller:0
};
BigNews.turn=function(index){
 clearInterval(BigNews.autoScroller);
 BigNews.scroll(index);
}
BigNews.scroll=function(index){
 if(!$('ul_big_news_item')){
  clearInterval(BigNews.autoScroller);
  return;
 }
 var count=0;
 var step=395;
 var duration=16;
 var b=BigNews;
 b.next=index;
 if(index!=b.current&&count>duration/8){
  return;
 }
 clearInterval(b.scrollInterval);
 var items=$('ul_big_news_item').getElementsByTagName('li');
 for(var i=0;i<5;i++){
  items[i].className='';
 }
 items[index].className='up';
 var span=index-b.current;
 var begin_value=$('div_big_news_img').scrollTop;
 var chang_in_value=span*step+(b.current*step-begin_value);
 b.scrollInterval=setInterval(function(){doit(begin_value,chang_in_value)},10);
 function doit(b,c){
  $('div_big_news_img').scrollTop=cpu(count,b,c,duration);
  count++;
  if(count==duration){
   clearInterval(BigNews.scrollInterval);
   scrollInterval=0;
   count=0;
   $('div_big_news_img').scrollTop=b+c;
   BigNews.current=index;
  }
 }
 function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}
BigNews.auto=function(){
 clearInterval(BigNews.autoScroller);
 BigNews.autoScroller=setInterval(function(){
  BigNews.scroll(BigNews.current==4?0:BigNews.current+1);
 },5000);
}
window.attachEvent('onload',BigNews.auto);

function print_probs(){
 var tmp='';
 var default_link='http://helpbbs.xunlei.com/read.php?tid=2&toread=1';
 for(var i=0;i<g_probs_text.length-1;i++){
  tmp+='<li><a onclick="logForClick(\'A1010;\')" href="'+(g_probs_text[i].link||default_link)+'" target="_blank">'+g_probs_text[i].txt+'</a></li>';
 }
 tmp+='<li><a onclick="logForClick(\'A1010;\')" href="'+(g_probs_text[0].link||default_link)+'" target="_blank">'+g_probs_text[0].txt+'</a></li>';
 setInterval(scroll_probs,5000);
 $('div_probs').style.display='block';
 document.write(tmp);
}//document.domain='xunlei.com';
function $(s){return document.getElementById(s);}function $P(child,parent){return parent?parent.appendChild(child):document.body.appendChild(child);}function $C(s){return document.createElement(s);};function $R(child,parent){return parent?parent.removeChild(child):document.body.removeChild(child);};var E=new Object;E.add=function(o,t,f){if(o.addEventListener){o.addEventListener(t,f,false)}else if(o.attachEvent){o.attachEvent("on"+t,f)}else{o["on"+t]=f}};E.remove=function(o,t,f){if(o.removeEventListener){o.removeEventListener(t,f,false)}else if(o.detachEvent){o.detachEvent("on"+t,f)}else{o["on"+t]=null}};E.formatEvent=function(e){if(isIE&&isWin){e.charCode=(e.type=="keypress")?e.keyCode:0;e.eventPhase=2;e.isChar=(e.charCode>0);e.pageX=e.clientX+document.body.scrollLeft;e.pageY=e.clientY+document.body.scrollTop;e.preventDefault=function(){this.returnValue=false};if(e.type=="mouseout"){e.relatedTarget=e.toElement}else if(e.type=="mouseover"){e.relatedTarget=e.fromElement}e.stopPropagation=function(){this.cancelBubble=true};e.target=e.srcElement;e.time=(new Date).getTime()}return e};E.get=function(){if(window.event){return this.formatEvent(window.event)}else{return E.get.caller.arguments[0]}};function GetDataByIframe(url,cbf,err,para){if((cbf[0]&&typeof(cbf[0])!='function')||typeof(cbf)!='function'){return alert('cbf function is in error!')}if(url instanceof Array){for(var i=0;i<arr_url.length;i++){doWork(url[i],cbf[i],para[i])}}else if(typeof(url)=='string'){doWork(url,cbf,para)}function doWork(u,cb,p){var idp=$C('iframe');idp.style.display='none';idp.src=u;E.add(idp,'load',icb);function icb(){E.remove(idp,'load',icb);var json=idp.contentWindow.jsonObj;if(!json){if(typeof(err)=='function'){$R(idp);return err();}else{$R(idp);return;}}$R(idp);cb(json,p)}$P(idp)}};

var HotPlay={built:[1,0,0],current:0,step:743,done:true,a:'a_hp_',div:'div_hot_play_content',ul:''}
var Movie={built:[1,0,0],current:0,step:376,done:true,a:'a_m_',div:'div_movie_content',ul:'movie'}
var TV={built:[1,0,0],current:0,step:376,done:true,a:'a_tv_',div:'div_tv_content',ul:'tv'}
var Fun={built:[1,0,0],current:0,step:376,done:true,a:'a_f_',div:'div_fun_content',ul:'fun'}
var Cartoon={built:[1,0,0],current:0,step:376,done:true,a:'a_c_',div:'div_cartoon_content',ul:'cartoon'}

var Turn={}
Turn.pre=function(obj){
 if(obj.current==0){
  return;
 }else{
  Turn.go(obj,obj.current-1);
 }
}
Turn.next=function(obj){
 if(obj.current==2){
  return;
 }else{
  Turn.go(obj,obj.current+1);
 }
}
Turn.go=function(obj,index){
 if(obj.current==index||!obj.done){return;}
 for(var i=0;i<3;i++){
  if(obj.built[i]==0){
   imgSrc(i,obj.ul);
   obj.built[i]=1;
  }
 }
 obj.done=false;
 var span=-index+obj.current;
 KK.scrollCross.scroll($(obj.div),obj.step,span,parseInt($(obj.div).style.marginLeft)||0,cb,10);
 function imgSrc(index,id){
  var arr_img=$('ul_'+id+'_'+index).getElementsByTagName('img');
  for(var i=0;i<6;i++){
   arr_img[i].src=obj.imgs[index-1][i];
  }
 }
 function cb(){
  obj.current=index;
  obj.done=true;
  for(var i=0;i<3;i++){
   $(obj.a+i).className='';
  }
  $(obj.a+index).className='now';
 }
}
