/**
 * @author owen@jbanetwork.com
 */
$(document).ready(function(){
	$loginForm = $('form#loginForm');
	$('li#login .button[rel="loginForm"]').click(function(){
		$loginForm.show(0, function(){
			$loginForm.find('input[name="username"]').focus();	
		});
		
	});
	$loginForm.find('.button#loginReset').click(function(){
		$loginForm.hide().find('input').val('');
	});
	$loginForm.find('.button#loginSubmit').click(function(){
		$loginForm.submit();
	});
	$loginForm.submit(function(){
		$(this).fadeOut();
	});
	$('.button').css('cursor', 'pointer').click(function(){
		$(this).blur();
	});
	$loginForm.find('input').keydown(function(e){
			if(e.keyCode == 13) {
				e.preventDefault();
				$(this).is(':password') ? $loginForm.submit() : $loginForm.find(':password').focus();

			}
	});
	// Alerts aka greyspace
	$('.alert').fadeIn(1000).find('button.close').click(function(){
		$('.alert').fadeOut('fast');
	});
	
	/**
	 * Todo: fix our flash so that IE users don't have to "click to activate"
	 */
	
	/*
	$('embed').each(function(){
		attr = {};
		attrStr = new String();
		for( var x = 0; x < this.attributes.length; x++ ) {
			if (this.attributes[x].nodeValue.replace(' ', '') != '') {
				attr[this.attributes[x].nodeName.toLowerCase()] = this.attributes[x].nodeValue;
				attrStr += this.attributes[x].nodeName.toLowerCase() + '=' + this.attributes[x].nodeValue + '\n';	
			}
		}
		alert(attrStr);
	});
	*/
});
