/**
 * Admin
 * Created by Jason Pecor
 * May 12, 2009
 *
 * This class allows you to click-and-hold on the site header in
 * order to navigate to the otherwise hidden Admin area of the site
 */

var Admin = Class.create
({
 	timer: null,
	
	initialize: function( element )
	{
		this.element = $( element );
		this.initEvents();
	},
	
	initEvents: function()
	{
		this.element.observe( "mousedown", this.eventMouseDown.bind( this ) );		
		this.element.observe( "mouseup", this.eventMouseUp.bind( this ) );
	},
	
	eventMouseDown: function( e )
	{
		this.element.style.cursor = "wait";
		this.timer = setTimeout( this.jumpToAdmin.bind( this ), 3000 );
	},
	
	eventMouseUp: function( e )
	{
		this.element.style.cursor = "default";
		clearTimeout( this.timer );
	},
	
	jumpToAdmin: function()
	{
		this.element.style.cursor = "default";
		window.location = window.location.toString().substr( 0, 16 ) == 'http://localhost' ? '/3dssports/admin' : '/admin';
	}
});

document.observe( 'dom:loaded', function(){ new Admin( "header" ) } );	