window.addEvent('domready',function()
{
	document.ABox = new BoxSlider('authBoxFolio',3,3,240,160);
	//bs.goDown();
	
	var bsLA = new LinkAction('box');
	bsLA.addEvent('execute',function(id,el)
	{	if (id == 'up')
			document.ABox.goUp();
		else if (id == 'down')
			document.ABox.goDown();
		else if (id == 'left')
			document.ABox.goLeft();
		else if (id == 'right')
			document.ABox.goRight();
	});
	
	InputMask.Init();
	
	var _slForm = new FormCheck('SiteLoginForm',
	{	titlesInsteadNames : 1,
		submitByAjax : true,
		onAjaxSuccess : function(responseText)
		{	eval(responseText);
			if (Result.Status)
				window.location = 'index.php';
			else alert(Result.Message);
		},
		onAjaxFailure : function()
		{ alert('Sorry! Can not proceed with authentication right now. Please try again later.'); }
	});
	
	
	FB.init(
	{ 	appId : '248193365182',
		cookie : true, 
		status : true,
		xfbml : true 
	});
});

function FBLogin()
{	FB.getLoginStatus(function(response)
	{	if (response.session)
		{	var token = response.session.access_token;
			var _Req = new Request(
			{	url : (gContentAddress + 'login.php?a=login&acc=fb'),
				evalResponse : false,
				noCache : true,
				method : 'post'
			}).addEvent('success',function(responseText)
			{	eval(responseText);
				if (Result.Status)
					window.location = 'index.php';
				else alert(Result.Message);
			}).send('token=' + token);
  		} else {
    		alert('Facebook login failed!');
		}
	});
}
