/*
**	This page displays the servers for Dolumar.
**	Feel free to include this javascript in your website.
*/

var Dolumar = new Object ();

Dolumar = 
{
	'PlayNow' : 
	{
		'isPrepared' : false,
		
		'ref' : '',
		'bonus' : '',
		
		'_prepare' : function ()
		{
			if (!Dolumar.PlayNow.isPrepared)
			{
				var headID = document.getElementsByTagName("head")[0];
			
				var css = document.createElement ('link');
				css.type = 'text/css';
				css.rel = 'stylesheet';
				css.href = 'http://master.dolumar.be/css/playnow.css';
				css.media = 'screen';
				
				headID.appendChild (css);
				
				var div = document.createElement ('div');
				div.id = 'master_dolumar_container';
				div.style.display = 'none';
				
				var innerhtml = '';
				innerhtml += ('<div id="master_dolumar_overlay"></div>');
				innerhtml += ('<div class="master_dolumar_chooseserver" id="master_dolumar_chooseserver" style="position: absolute;">');
				innerhtml += ('</div>');
				
				div.innerHTML = innerhtml;
				document.body.appendChild (div);
			}
		},
		
		'_showContent' : function ()
		{
			var innerhtml = ('<div class="master_dolumar_top"></div>');
			innerhtml += ('<h2 id="master_dolumar_title">Select server</h2>');
			innerhtml += ('<ul class="games">');
			innerhtml += ('<li><a href="http://stable.neuroninteractive.com/?ref='+Dolumar.PlayNow.ref+'&bonus='+Dolumar.PlayNow.bonus+'">International stable server</a></li>');
			innerhtml += ('<li><a href="http://speed.neuroninteractive.com/?ref='+Dolumar.PlayNow.ref+'&bonus='+Dolumar.PlayNow.bonus+'">International speed server</a></li>');
			innerhtml += ('</ul>');
			innerhtml += ('<div class="master_dolumar_bottom"></div>');
			
			document.getElementById ('master_dolumar_chooseserver').innerHTML = innerhtml;
		},
		
		'getUrl' : function (sName)
		{		
			return '<a href="#master_dolumar_overlay" onclick="Dolumar.PlayNow.showDialog();" style="font-size: 150%;"><strong>'+sName+'</strong></a>';
		},
	
		'render' : function ()
		{			
			document.write ('<p style="text-align: center;">' + Dolumar.PlayNow.getUrl ('Play Dolumar') + '</p>');
			document.write ('<p style="text-align: center;">(no install, just fun)</p>');		
		},
		
		'showDialog' : function ()
		{
			Dolumar.PlayNow._showContent ();
			
			document.getElementById('master_dolumar_container').style.display = 'block';
			document.getElementById('master_dolumar_container').onclick = Dolumar.PlayNow.hideDialog;
		},
		
		'hideDialog' : function ()
		{
			document.getElementById('master_dolumar_container').style.display = 'none';
			document.body.onclick = '';
		}
	}
}

function addListener(element, type, expression, bubbling)
{
	bubbling = bubbling || false;
 
	if(window.addEventListener)	{ // Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	} else if(window.attachEvent) { // IE
		element.attachEvent('on' + type, expression);
		return true;
	} else return false;
}

addListener(window, 'load', Dolumar.PlayNow._prepare);
