

var MultiplayHash=new Hash("{\"col\":5,\"datas\":{\"2674\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/71\\/51\\/99\\/small_thumb_2674.jpg\",\"name\":\"Governor of Poker 2\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/sport-jatekok\\/governor-of-poker-2\"},\"2675\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/44\\/36\\/55\\/small_thumb_2675.jpg\",\"name\":\"The Terminal\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/akcio-jatekok\\/the-terminal\"},\"2667\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/55\\/47\\/64\\/small_thumb_2667.jpg\",\"name\":\"Labirintus\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/multiplay-jatekok\\/labyrinth-2\"},\"2668\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/32\\/32\\/96\\/small_thumb_2668.jpg\",\"name\":\"Furfur and Nublo\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/furfur-and-nublo\"},\"2669\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/59\\/22\\/63\\/small_thumb_2669.jpg\",\"name\":\"Catacombs\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/catacombs\"},\"2670\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/88\\/19\\/52\\/small_thumb_2670.jpg\",\"name\":\"Blobble Wars\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/blobble-wars\"},\"2671\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/85\\/89\\/55\\/small_thumb_2671.jpg\",\"name\":\"Royal Envoy\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/strategiai-jatekok\\/royal-envoy\"},\"2672\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/83\\/28\\/59\\/small_thumb_2672.jpg\",\"name\":\"Duality\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/duality\"},\"2676\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/49\\/57\\/37\\/small_thumb_2676.jpg\",\"name\":\"Axis Football League\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/sport-jatekok\\/axis-football-league\"},\"2677\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/87\\/36\\/35\\/small_thumb_2677.jpg\",\"name\":\"Stunt Master\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/stunt-master\"},\"2678\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/17\\/24\\/59\\/small_thumb_2678.jpg\",\"name\":\"Birdys Rainy Day\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/tini-jatekok\\/birdys-rainy-day\"},\"2679\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/47\\/37\\/64\\/small_thumb_2679.jpg\",\"name\":\"Lifeguard Larry\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/kaland-jatekok\\/lifeguard-larry\"},\"2680\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/58\\/39\\/11\\/small_thumb_2680.jpg\",\"name\":\"One Step Back\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/one-step-back\"},\"2682\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/51\\/97\\/44\\/small_thumb_2682.jpg\",\"name\":\"Numz\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/cloud-powered-jetpack-2\"},\"2681\":{\"image\":\"http:\\/\\/gameimages.imgsrv.multiplay.hu\\/22\\/21\\/57\\/small_thumb_2681.jpg\",\"name\":\"Cloud Powered Jetpack\",\"url\":\"http:\\/\\/multiplay.hu\\/jatekok\\/ugyessegi-jatekok\\/cloud-powered-jetpack\"}},\"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);

