﻿// 滚动游戏条
var mydomain="/";
var game = new Array();

var picpath="";
var tpic="http://www.88yx.com/newimages/transparent.gif";

game[1] = ["0", "/game/dongzuo/monitezhongbing.shtml", "/newimages23/topjsimg/monitezhongbing.jpg", "模拟特种兵"];
game[2] = ["0", "/game/dongzuo/dongmanmingxingdaluandou1.0.shtml", "/newimages23/topjsimg/dongmanmingxingdaluandou1.0.jpg", "动漫明星大乱斗"];
game[3] = ["0", "/game/zhuangban/renzaomeinv.shtml", "/newimages23/topjsimg/renzaomeinv.jpg", "人造美女"];
game[4] = ["0", "/game/zhuangban/meimeiqiangnanyou.shtml", "/newimages23/topjsimg/meimeiqiangnanyou.jpg", "美眉抢男友"];
game[5] = ["0", "/game/zhuangban/aSuedeyichu.shtml", "/newimages23/topjsimg/aSuedeyichu.jpg", "阿Sue的衣橱"];
game[6] = ["0", "/game/dongzuo/yuansezhandui.shtml", "/newimages23/topjsimg/yuansezhandui.jpg", "原色战队"];
game[7] = ["0", "/game/zhuangban/asuefalangdian2.shtml", "/newimages23/topjsimg/asuefalangdian2.jpg", "阿sue发廊店2"];
game[8] = ["0", "/game/mingjie/Qbanpaopaotang.shtml", "/newimages23/topjsimg/Qbanpaopaotang.jpg", "Q版泡泡堂"];
game[9] = ["0", "/game/dongzuo/baodaxiaopengyou.shtml", "/newimages23/topjsimg/baodaxiaopengyou.jpg", "暴打小朋友"];
game[10] = ["0", "/game/celue/xiaoxiaomaoxiandao.shtml", "/newimages23/topjsimg/xiaoxiaomaoxiandao3.jpg", "小小冒险岛"];
game[11] = ["0", "/game/yizhi/chongwulianliankan.shtml", "/newimages23/topjsimg/chongwulianliankan.jpg", "宠物连连看"];
game[12] = ["0", "/game/dongzuo/shankekuaida3zhongwenban.shtml", "/newimages23/topjsimg/shankekuaida3zhongwenban.jpg", "闪客快打3"];
game[13] = ["0", "/game/dongzuo/quanhuangmenghuanzhizhan.shtml", "/newimages23/topjsimg/quanhuangmenghuanzhizhan.jpg", "拳皇梦幻之战"];
game[14] = ["0", "/game/yizhi/mengniangduiduipeng.shtml", "/newimages23/topjsimg/mengniangduiduipeng.jpg", "萌娘对对碰"];
game[15] = ["0", "/game/tiyu/fengkuangyueyemotuo.shtml", "/newimages23/topjsimg/fengkuangyueyemotuo.jpg", "疯狂越野摩托"];
game[16] = ["0", "/game/yizhi/gaobinglianliankan.shtml", "/newimages23/topjsimg/gaobinglianliankan.jpg", "糕饼连连看"];
game[17] = ["0", "/game/yizhi/qichelianliankan.shtml", "/newimages23/topjsimg/qichelianliankan.jpg", "汽车连连看"];
game[18] = ["0", "/game/faxie/zhenggudiaoximeinv.shtml", "/newimages23/topjsimg/zhenggudiaoximeinv.jpg", "整蛊调戏美女"];
game[19] = ["0", "/game/dongzuo/binghuozhanshi.shtml", "/newimages23/topjsimg/binghuozhanshi.jpg", "冰火战士"];
game[20] = ["0", "/game/tiyu/tejimotuo.shtml", "/newimages23/topjsimg/tejimotuo.jpg", "特技摩托"];
game[21] = ["0", "/game/dongzuo/sishenVSmingren.shtml", "/newimages23/topjsimg/sishenVSmingren.jpg", "死神VS火影0.6"];
game[22] = ["0", "/game/dongzuo/quanhuangwing1.2wanzhengban.shtml", "/newimages23/topjsimg/quanhuangwing1.2wanzhengban.jpg", "拳皇wing1.2完整版"];
game[23] = ["0", "http://www.88yx.com/game/mingjie/shenqixiaoyaoguai.shtml", "/newimages23/topjsimg/shenqixiaoyaoguai.jpg", "神奇小妖怪"];
game[24] = ["0", "/game/dongzuo/huoyinggedou.shtml", "/newimages23/topjsimg/huoyinggedou.jpg", "火影格斗"];
game[25] = ["0", "/game/tiyu/paopaokadingche.shtml", "/newimages23/topjsimg/paopaokadingche.jpg", "泡泡卡丁车"];
game[26] = ["0", "/game/sheji/hejindantou2-kangriwanzhengban.shtml", "/newimages23/topjsimg/hejindantou2-kangriwanzheng.jpg", "合金弹头2-抗日完整版"];
var special_game = new Array();
//special_game[1] = ["0", "http://g.91sanguo.cn/letou/4/index.html?agent_id=17164", "/newimages23/topjsimg/ggimg/91wan.gif", "乐土"];
//special_game[1] = ["0", "http://g.91ivr.com/click_full.php?tid=1&uid=17164&aid=13&sid=1", "/newimages23/topjsimg/ggimg/68x45_plsm.gif", "盘龙神墓"];
//special_game[2] = ["0", "http://u.molidao.com/zzygg/index.php?m=adregister&a=toregisterpage&siteid=358&othername=88yx", "/newimages23/topjsimg/ggimg/yxzc_68_45.jpg", "英雄之城"];
//special_game[3] = ["0", "http://www.xxp001.com/game/zztx.html?site=151&i=151&h=151", "/newimages23/topjsimg/ggimg/zztx_68x45.gif", "征战天下"];
//special_game[0] = ["0", "http://p.yiqifa.com/c?s=5b325c8c&w=68900&c=3640&i=3082&l=0&e=3gm&t=http://home.3gm.com.cn/do.php?ac=ddt", "/newimages23/topjsimg/ggimg/ddt.gif", "弹弹堂"];
//special_game[2] = ["0", "/game/dongzuo/hejindantou4.shtml", "/newimages23/topjsimg/hejindantou4.jpg", "合金弹头4"];
special_game[3] = ["0", "/game/dongzuo/quanhuangmenghuanzhizhan.shtml", "/newimages23/topjsimg/quanhuanggedouquanji.jpg", "拳皇梦幻之战"];
//special_game[0] = ["0", "http://rd.cnzz.com/rd.htm?id=3329&r=http%3A%2F%2Fd.5ding.com%2Freg%2F201004047.htm", "/newimages23/topjsimg/ggimg/game5.gif", "明珠三国"];
special_game[2] = ["0", "http://www.88yx.com/special/caihong/", "/newimages23/topjsimg/ggimg/hbchc.jpg", "88yx彩虹城"];
special_game[0] = ["0", "http://rd.cnzz.com/rd.htm?id=3329&r=http%3A%2F%2Fwww.unionli.com%2Ftxlink.php%3Falid%3D12498", "http://uimg.unionli.com/pic/minimg/mm_wmnc.gif", "完美农场"];
special_game[1] = ["0", "/game/zhonghe/zhiwudazhanjiangshi.shtml", "/newimages23/topjsimg/zhiwudazhanjiangshi.gif", "植物大战僵尸"];
//special_game[4] = ["0", "http://rd.cnzz.com/rd.htm?id=3329&r=http%3A%2F%2Fwww.youxijidi.com%2Fgame%2F156.html", "/newimages23/topjsimg/ggimg/youxijidi.gif", "极品飞车13"];

if(typeof(psortid)=="undefined")psortid=0;
game=game.sort(function(){return Math.random()*new Date%3-1});
game=game.sort(function(a,b){
	oc=a[0].indexOf(","+psortid)!=-1?3:0;
	oc+=a[0].indexOf(",0")!=-1?1:0;
	oc+=a[0].indexOf("top")!=-1?2:0;
	od=b[0].indexOf(","+psortid)!=-1?3:0;
	od+=b[0].indexOf(",0")!=-1?1:0;
	od+=b[0].indexOf("top")!=-1?2:0;
	return od-oc
});
var gamehtml="";
var ndomain;
var i=0;
for(key in game){
	if(typeof(game[key][3])=="undefined") {
		continue;
	}
	if (i < 4) {
		game[key] = special_game[i];
	}
	if(i>10){
		gamehtml+='<li><a href="'+game[key][1]+'" target="_blank"><img pic="'+picpath+game[key][2]+'" src="'+tpic+'" /></a><br /><a href="'+game[key][1]+'" target="_blank">'+game[key][3]+'</a></li>'
	}else{
		gamehtml+='<li><a href="'+game[key][1]+'" target="_blank"><img pic="" src="'+picpath+game[key][2]+'" /></a><br /><a href="'+game[key][1]+'" target="_blank">'+game[key][3]+'</a></li>'
	}
	gamehtml+='\n';
	i++
}


var twidth=720;
var alldown=false;
var mnow=false;
var as=80;
var asm=20;
var spd=as;
var asx=4;
function setmove(){
	if(getObj('games').offsetWidth<=twidth)return;
	var a=document.createElement("UL");
	a.innerHTML=getObj('games').innerHTML;getObj('gamesdiv').appendChild(a);
	getObj('tumbleleft').onclick=function(){
		if(!mnow){
			downpic("r");
			movegame(twidth,"r")}
	};
	getObj('tumbleright').onclick=function(){
		if(!mnow){
			downpic("l");
			movegame(twidth,"l")
		}
	}
}
function movegame(n,f){
	mnow=true;
	if(f=="l"&&getObj('tumbletext').scrollLeft>=getObj('games').offsetWidth)
		getObj('tumbletext').scrollLeft=0;
	if(f=="r"&&getObj('tumbletext').scrollLeft==0) 
		getObj('tumbletext').scrollLeft=getObj('games').offsetWidth;
	if(f=="l") 
		getObj('tumbletext').scrollLeft+=spd;
	if(f=="r")
		getObj('tumbletext').scrollLeft-=spd;
	n=n-spd;
	if(n==0) spd=20;
	if(n+as==0){
		mnow=false;
		clearTimeout(mto);
		f=f=="l"?"r":"l";
		spd=as;
		var a=window.setTimeout(function(){movegamex(as,f)},10)
	}else{
		var mto=window.setTimeout(function(){movegame(n,f)},10)
	}
}
function movegamex(n,f){
	mnow=true;
	if(f=="l"&&getObj('tumbletext').scrollLeft>=getObj('games').offsetWidth)
		getObj('tumbletext').scrollLeft=0;
	if(f=="r"&&getObj('tumbletext').scrollLeft==0)
		getObj('tumbletext').scrollLeft=getObj('games').offsetWidth;
	if(f=="l")
		getObj('tumbletext').scrollLeft+=asx;
	if(f=="r")
		getObj('tumbletext').scrollLeft-=asx;
	n=n-asx;
	if(n==0){
		mnow=false;
		clearTimeout(a)
	}else{
		var a=window.setTimeout(function(){movegamex(n,f)},10)
	}
}
function getdownnum(o){
	if(alldown)return false;
	for(i=0;i<o.length;i++) {
		if(o[i].getAttribute("pic")!="")
			return o.length;
	}
	alldown=true
}
function downpic(t){
	var a=getObj('games').getElementsByTagName("IMG");
	var b=getdownnum(a);
	if(!b)return;
	var c=(t=="l")?getObj('tumbletext').scrollLeft+twidth+80:getObj('tumbletext').scrollLeft-80-twidth;
	if(!t)c=0;
	var f=c/80;
	if(f<0)f=a.length+f;
	if(f>a.length-1)f=f-a.length;
	var t=f+9;
	if(t>a.length-1) t=a.length-1;
	for(i=f;i<=t;i++){
		if(a[i].getAttribute("pic")!="")
			a[i].src=a[i].getAttribute("pic");
		a[i].setAttribute("pic","")
	}
}

tumble_html = '<div id="tumble" class="tumble"><div class="tumbleleft" id="tumbleleft" alt="往左"></div><div id="tumbletext" class="tumbletext" style="overflow:hidden"><div id="gamesdiv"><ul id="games">'+gamehtml+'</ul></div></div><div class="tumbleright" id="tumbleright" alt="往右"></div></div>';
getObj('mgame_div').innerHTML = tumble_html;
setmove();