﻿var moreLinks = new Array();
moreLinks['tab_gonggao'] = "http://gongfu.xunlei.com/c/0000070003_1.html";
moreLinks['tab_xinwen'] = "http://gongfu.xunlei.com/c/0000070001-0000070002-0000070003_1.html";
moreLinks['tab_huodong'] = "http://gongfu.xunlei.com/c/0000070002_1.html";

moreLinks['tab_xszn'] = "http://gongfu.xunlei.com/website/info/index.html";
moreLinks['tab_zldq'] = "http://gongfu.xunlei.com/website/info/index.html";


function toTab(o){
	if(!o) return ;
	var id = o.getAttribute('id');
	var ids = id.split('_');
	var div = document.getElementById('div_'+ids[1]);
	displayNoneSiblings(div);
	alterClassSiblings(o,'up');
	alertMoreLinks(o);
	_tabClass = 'up';
}

function displayNoneSiblings(o){
	if(!o) return ;
	var parent = o.parentNode;
	if(!parent) return ;
	var children = parent.childNodes;
	for(var i=0;i<children.length;i++){
		var tagName = children[i].tagName;
		var className = children[i].className;
		if(tagName == o.tagName && className == o.className){
			children[i].style.display = 'none';
		}
	}
	o.style.display = '';
}

function alterClassSiblings(o,classname){
	if(!o) return ;
	var parent = o.parentNode;
	if(!parent) return ;
	var children = parent.childNodes;
	for(var i=0;i<children.length;i++){
		var tagName = children[i].tagName;
		if(tagName == o.tagName){
			children[i].className = '';
		}
	}
	o.className = classname;
}

function alertMoreLinks(o){
	if(!o) return ;
	var morelink = document.getElementById("more_link")
	if(morelink){
		if(morelink.getAttribute('onclick')){
			if(document.all){
				morelink.onclick = function(){
					window.location.href = moreLinks[o.getAttribute('id')]+getSearch();
					return false;
				}
			}
			else{
				morelink.setAttribute("onclick","javascript:location.href='"+moreLinks[o.getAttribute('id')]+getSearch()+"';return false;");
			}
		}
		else{
			morelink.href = moreLinks[o.getAttribute('id')]+getSearch();
		}
	}
	else{
		var parent = o.parentNode;
		if(!parent) return ;
		parent = parent.parentNode;
		if(!parent) return ;
		var childnodes = parent.childNodes;
		for(var i=0; i<childnodes.length; i++){
			if(childnodes[i].tagName && childnodes[i].tagName.toLowerCase() == 'h3'){
				var cns = childnodes[i].childNodes;
				for(var j = 0; j < cns.length; j++){
					if(cns[j].tagName && cns[j].tagName.toLowerCase() == 'a' && cns[j].className == 'more'){
						cns[j].href = moreLinks[o.getAttribute('id')]+getSearch();
						break;
					}
				}
			}
		}
	}
}

var _tabClass = '';
function moveInTab(o){
	if(!o) return ;
	_tabClass = o.className;
	o.className = 'up';
}

function moveOutTab(o){
	if(!o) return ;
	o.className = _tabClass;
}
function getSearch(){
	var loc = location.search;
	return loc;
}


var speed_1=30
var demo_1,demo1_1,demo2_1;
function Marquee_1(){
	if(demo1_1.offsetHeight-demo_1.scrollTop<=0){
		demo_1.scrollTop=0;
	}
	else{
		demo_1.scrollTop++;
	}
}

var speed_2=30
var demo_2,demo1_2,demo2_2;
function Marquee_2(){
	if(demo1_2.offsetHeight-demo_2.scrollTop<=0){
		demo_2.scrollTop=0;
	}
	else{
		demo_2.scrollTop++;
	}
}

function initMarquee(){
	demo_1 = document.getElementById('shopts_1');
	if(demo_1){
		demo_1.innerHTML = '<ul id="shopts_11" ></ul><ul id="shopts_12"></ul>';
		demo1_1 = document.getElementById('shopts_11');
		demo1_1.innerHTML = '<li><a href="http://gongfu.xunlei.com/website/info/sys/nine/qiang.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/qiang.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/qiang.html" target="_blank">英雄之枪</a></dt><dd>枪者，英雄豪杰</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/gun.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/gun.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/gun.html" target="_blank">王道之棍</a></dt><dd>棍者，沉着稳定</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/fu.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/fu.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/fu.html" target="_blank">霸王之斧</a></dt><dd>斧者，霸气逼人</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/gong.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/gong.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/gong.html" target="_blank">坚毅之弓</a></dt><dd>弓者，坚韧不拔</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/quan.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/quan.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/quan.html" target="_blank">勇者之拳</a></dt><dd>拳者，锐勇无惧</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/dao.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/dao.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/dao.html" target="_blank">侠义之刀</a></dt><dd>刀者，侠肝义胆</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/jian.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/jian.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/jian.html" target="_blank">君子之剑</a></dt><dd>剑者，飘逸洒脱</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/shan.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/shan.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/shan.html" target="_blank">智者之扇</a></dt><dd>扇者，慎密心细</dd></dl></li><li><a href="http://gongfu.xunlei.com/website/info/sys/nine/gou.html" target="_blank"><img src="http://img.gongfu.xunlei.com/img_v2/wuqi/gou.jpg" alt="" /></a><dl><dt><a href="http://gongfu.xunlei.com/website/info/sys/nine/gou.html" target="_blank">无情之钩</a></dt><dd>钩者，果敢无情</dd></dl></li>';
		demo2_1 = document.getElementById('shopts_12');
		demo2_1.innerHTML = demo1_1.innerHTML;
		var MyMar_1=setInterval(Marquee_1,speed_1)
		demo_1.onmouseover=function() {clearInterval(MyMar_1)}
		demo_1.onmouseout=function() {MyMar_1=setInterval(Marquee_1,speed_1)} 
	}

	demo_2 = document.getElementById('shopts_2');
	if(demo_2){
		demo_2.innerHTML = '<ul id="shopts_21" ></ul><ul id="shopts_22"></ul>';
		demo1_2 = document.getElementById('shopts_21');
		demo1_2.innerHTML = '<li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/cwd.jpg" alt="" />宠物蛋</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/hhs.jpg" alt="" />黑虎煞</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/hybx.jpg" alt="" />混元宝箱</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/jhjz.jpg" alt="" />结婚戒指</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/jdy.jpg" alt="" />筋斗云</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/jybz.jpg" alt="" />经验宝珠</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/jlh.jpg" alt="" />九黎壶</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/kxw.jpg" alt="" />开心丸</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/lhs.jpg" alt="" />轮回石</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/ql.jpg" alt="" />青龙</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/tny.jpg" alt="" />胎暖玉</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/wxjz.jpg" alt="" />悟性卷轴</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/xyh.jpg" alt="" />小丫鬟</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/xlhw.jpg" alt="" />玄灵虎王</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/xlz.jpg" alt="" />玄灵珠</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/xw.jpg" alt="" />玄武</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/xn.jpg" alt="" />雪女</li><li><img src="http://img.gongfu.xunlei.com/img_v2/djsc/zq.jpg" alt="" />朱雀</li>';
		demo2_2 = document.getElementById('shopts_22');
		demo2_2.innerHTML = demo1_2.innerHTML;
		var MyMar_2=setInterval(Marquee_2,speed_2)
		demo_2.onmouseover=function() {clearInterval(MyMar_2)}
		demo_2.onmouseout=function() {MyMar_2=setInterval(Marquee_2,speed_2)} 
	}
}

function initRankOfPay(){
	var ropdiv = document.getElementById('rankofpaydiv');
	if(ropdiv && payrank){
		var ropc = '<table><thead><tr><th width="40">排名|</th><th width="93">帐号</th><th>|雷点数</th></tr></thead><tbody>';
		for(var i = 0; i < payrank.length && i < 10; i++){
			ropc += '<tr><td><span>'+(i+1)+'</span>';
			if(i < 3){
				ropc += '<img src="http://img.gongfu.xunlei.com/img_v2/'+i+'_ico.jpg" alt="" />';
			}
			ropc +='</td><td>'+payrank[i]['customer']+'</td><td>'+payrank[i]['qty']+'</td></tr>';
		}
		ropc += '</tbody></table>';
		ropdiv.innerHTML = ropc;
	}
}