// JavaScript Document
ObjectDock.init({
	elements: {
		'home': {
			icon: './_templates/_'+template+'/_images/dockHome.png',
			maxsize: 128,
			onclick: function()
			{
				window.location = './';
			},
			proximity: 300,
			title: DockLang['home']
		},
		'login': {
			icon: './_templates/_'+template+'/_images/dockKey.png',
			maxsize: 128,
			onclick: function()
			{
				var LoginForm = new Element('form', {'id': 'loginForm', 'action': './?ajax=login', 'method': 'post'}).setHTML(
										'<table id="loginTable" cellpadding="0" cellspacing="0">' +
											'<tr>' +
												'<td>'+DockLang['username']+'</td>' +
												'<td><input type="text" id="user" name="user" /></td>'+
											'</tr>' +
											'<tr>' +
												'<td>'+DockLang['password']+'</td>' +
												'<td><input type="password" id="pass" name="pass" /></td>'+
											'</tr>' +
											'<tr>' +
												'<td colspan="2"><input type="submit" name="submit" id="submit"' +
													' value="'+DockLang['submit']+'"/>' +
													'<div id="loginSpinner" style="display: none;"></div></td>' +
											'</tr>' +
										'</table>');
				
				LoginForm.addEvent('submit', function(e) {
					new Event(e).stop();
					
					$('loginSpinner').setStyle('display', 'inline');
	
					this.send({
						onComplete: LoginCheck
					});
				});
				
				HTMLBox.open({
					caption: DockLang['registered'],
					height: 140,
					element: LoginForm,
					title: DockLang['login'],
					width: 334
				});
			},
			proximity: 300,
			title: DockLang['login']
		}
	},
	
	key: 'l',
	hide: true
});

function LoginCheck(xml)
{
	$('loginSpinner').setStyle('display', 'none');
	if(xml == 'success')
	{
		HTMLBox.container.setStyle('background', 'url(_templates/_'+template+'/_images/dockAccepted.png) no-repeat center');
		HTMLBox.container.empty();
		setTimeout('window.location.reload()', 750);
	}
	else
	{
		switch(xml)
		{
			case 'password':
				{
					HTMLBox.container.setStyle('background', 'url(_templates/_'+template+'/_images/dockDenied.png) no-repeat center');
					$('pass').setStyle('border', '1px solid #990000');
					$('user').setStyle('border', '1px solid #cccccc');
				}
				break;
			case 'username':
				{
					HTMLBox.container.setStyle('background', 'url(_templates/_'+template+'/_images/dockDenied.png) no-repeat center');
					$('user').setStyle('border', '1px solid #990000');
					$('pass').setStyle('border', '1px solid #cccccc');
				}
				break;
		}
	}
}

if(window.gecko) {
	if(('' + window.location).indexOf('www') < 0)
	{
		window.location = 'http://www.' + ('' + window.location).substr(7);
	}
}
