

var MultiplayHash=new Hash("{\"col\":5,\"datas\":{\"286\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/78\\/22\\/95\\/small_thumb_286.jpg\",\"name\":\"Mahjongg 3D\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/logikai-jatekok\\/mahjongg-3-d-win\"},\"598\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/92\\/79\\/81\\/small_thumb_598.jpg\",\"name\":\"Dress Up Emo Girl \",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/tini-jatekok\\/dress-up-emo-girl\"},\"608\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/69\\/26\\/47\\/small_thumb_608.jpg\",\"name\":\"Monkey GO Happy\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/monkey-go-happy\"},\"757\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/73\\/93\\/65\\/small_thumb_757.jpg\",\"name\":\"Tower Blaster\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/logikai-jatekok\\/tower-blaster\"},\"2772\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/21\\/87\\/36\\/small_thumb_2772.jpg\",\"name\":\"After Glow\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/after-glow\"},\"2773\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/85\\/66\\/26\\/small_thumb_2773.jpg\",\"name\":\"JadaBug\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/jada-bug\"},\"2774\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/59\\/35\\/47\\/small_thumb_2774.jpg\",\"name\":\"Go Home Ball 2\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/go-home-ball-2\"},\"2775\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/43\\/93\\/42\\/small_thumb_2775.jpg\",\"name\":\"Sift Heads World 5\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/akcio-jatekok\\/sift-heads-world-5\"},\"2776\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/76\\/44\\/24\\/small_thumb_2776.jpg\",\"name\":\"Recoil\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/recoil\"},\"2778\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/56\\/97\\/77\\/small_thumb_2778.jpg\",\"name\":\"Rock n Risk Blitz 2\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/rock-n-risk-blitz-2\"},\"2777\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/82\\/85\\/77\\/small_thumb_2777.jpg\",\"name\":\"Running Man 2\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/running-man-2\"},\"2779\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/33\\/17\\/32\\/small_thumb_2779.jpg\",\"name\":\"Vertical Drop Heroes\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/vertical-drop-heroes\"},\"2780\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/66\\/34\\/22\\/small_thumb_2780.jpg\",\"name\":\"Block Knocker\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/block-knocker\"},\"2781\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/97\\/66\\/59\\/small_thumb_2781.jpg\",\"name\":\"Reincarnation 4\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/kaland-jatekok\\/reincarnation-4\"},\"2782\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/84\\/42\\/19\\/small_thumb_2782.jpg\",\"name\":\"Wingmen\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/strategiai-jatekok\\/wingmen\"}},\"timer\":1,\"last\":false,\"thumb\":\"<div style=\\\"float:left;width:#{thumb[width]}px; height:86px;text-align:center; cursor:pointer; margin-right:#{thumb[right]}px;\\\">\\n\\t<div style=\\\"width:#{thumb[width]}px; height:#{thumb[height]}px;overflow:hidden\\\">\\n\\t\\t<a id=\\\"#{domimagelinkid}\\\" href=\\\"#{url}\\\" target=\\\"_blank\\\">\\n\\t\\t\\t<img src=\\\"#{src}\\\" style=\\\"width:#{thumb[width]}px; height:#{thumb[height]}px;\\\" id=\\\"#{domid}\\\" border=\\\"0\\\">\\n\\t\\t<\\/a>\\n\\t<\\/div>\\n\\t<a style=\\\"margin-top:7px;display:block;color:#c1edff!important;\\\" id=\\\"#{domlinkid}\\\" href=\\\"#{url}\\\">#{name}<\\/a>\\n<\\/div>\",\"frame\":\"<div  style=\\\"font-size:11px!important;color:#c1edff!important;width:#{frame[width]}px; height:#{frame[height]}px; background:transparent url(\'#{frame[bg]}\') top left no-repeat; overflow:hidden;\\\">\\n\\t<div style=\\\"width:#{frame[width]}px; height:#{frame[title_height]}px; background:transparent url(\'#{frame[bg]}\') top left no-repeat;\\\">\\n\\t\\t<a href=\\\"http:\\/\\/multiplay.hu\\\" target=\\\"_blank\\\">\\n\\t\\t\\t<div style=\\\"width:#{frame[width]}px; height:#{frame[title_height]}px;\\\"><\\/div>\\n\\t\\t<\\/a>\\n\\t<\\/div>\\n\\t<div class=\\\"cf\\\"  style=\\\"margin-left:#{frame[left]}px;\\\">\\n\\t\\t#{thumbs}\\n\\t<\\/div>\\n<\\/div>\",\"active\":[],\"effect\":1,\"delay\":3,\"frame_styles\":{\"1024\":{\"width\":577,\"height\":159,\"bg\":\"http:\\/\\/static.imgsrv.multiplay.hu\\/chat\\/chat.gif\",\"title_height\":51,\"left\":25},\"1280\":{\"width\":487,\"height\":175,\"bg\":\"http:\\/\\/static.myvip.com\\/farm\\/farm_miss0box_1280.gif\",\"title_height\":44,\"left\":25}},\"thumb_styles\":{\"1024\":{\"height\":60,\"width\":82,\"right\":28},\"1280\":{\"height\":96,\"width\":130,\"right\":13}}}".evalJSON());

function drawMultiplayInit() {
	var h=MultiplayHash;
	//$R(0,h.get('col'),true).each(drawMultiplayThumb);
	drawMultiplaystep.delay(h.get('timer'));
}
function drawMultiplaystep() {
	var col=MultiplayHash.get('col');
	var swapcol=parseInt(Math.random()*10+7)%col;
	var obj=$('Multiplay_'+swapcol);

	new Effect.toggle(obj,'Appear', {
		duration:MultiplayHash.get('effect')
		,afterFinish:function() {
			drawMultiplayThumb(swapcol);
			new Effect.toggle(obj,'Appear', {
					duration:MultiplayHash.get('effect')
					,afterFinish:function() {
						drawMultiplaystep.delay(MultiplayHash.get('delay'));
					}
				})
		}
	});
}

function drawMultiplayThumbs() {
	var h=MultiplayHash;
	var col=h.get('col');
	var temp=new Template(h.get('thumb'));

	return $R(0,col,true).collect(function(i) {
		var datas=$H(h.get('datas'));
		var active=h.get('active');
		var ids=datas.keys().reject(function(i) { return active.indexOf(i)!==-1; });
		var id=ids[parseInt(Math.random()*ids.size())];

		var data=$H(datas.get(id));
		var src=data.get('image');
		var name=data.get('name');
		var url=data.get('url');
		active[i]=id;
		MultiplayHash.set('active',active);
		return temp.evaluate({
			domid:'Multiplay_'+i,
			domlinkid: 'Multiplaygamelink_'+i,
			domimagelinkid : 'Multiplayimagelink_'+i,
			thumb: h.get('thumb_styles')[1024],
			src: src,
			name:name,
			url:url});
	}).join('');
}
function drawMultiplayFrame() {
	var h=MultiplayHash;
	var temp=new Template(h.get('frame'));
	document.write(
		temp.evaluate({thumbs: drawMultiplayThumbs(), frame: h.get('frame_styles')[1024]})
	);
}
function drawMultiplayThumb(pos) {
	var h=MultiplayHash;
	var datas=$H(h.get('datas'));
	var active=h.get('active');
	var ids=datas.keys().reject(function(i) { return active.indexOf(i)!==-1; });
	var id=ids[parseInt(Math.random()*ids.size())];

	var data=$H(datas.get(id));
	var img=$('Multiplay_'+pos);
	img.src=data.get('image');
	img.alt=data.get('name');
	img.title=data.get('name');

	$('Multiplaygamelink_'+pos).update(data.get('name')).href=data.get('url');
	$('Multiplayimagelink_'+pos).href=data.get('url');
	
	active[pos]=id;
	MultiplayHash.set('active',active);
}

	drawMultiplayFrame();
	Event.observe(window,'load',drawMultiplayInit);

