//# Login scripts; hold down the CTRL key and click #main_logo to be wisked away to the Log In page
$(document).keydown( function(e){ SetKeyCode(e); } );
$(document).keyup ( function() { SetKeyCode(0); } );
$(document).ready
(
	function()
	{ 
		if(!document.getElementById("main_logo")){ return; }
		document.getElementById("main_logo").onclick = function()
		{
			if(key_code == 17)
			{
				SetKeyCode(0);
				window.location = "/login";						
				return false;
			}
		}
	}
);

var key_code = 0;
var is_alt = false;
var dest = window.location.href;
dest = ( dest.charAt(dest.length-1) == "/" )
	? dest + "login"
	: dest + "/login"
;

function SetKeyCode(arg)
{
	if(isNaN(arg))
	{
		if (!arg) arg = event;
		is_alt = arg.altKey;
		key_code = (window.event) // IE
			? arg.keyCode
			: arg.which
		;
		
		//# ALT+L to go to Login page; TODO: trigger login modal
		if(is_alt && key_code == 76) window.location = dest;
		
	}
	else
	{
		key_code = arg;
		is_alt = false;
	}
	
}


