
function extend(fn, what)
{
	for(var i in what)
	{
		fn.prototype[i] = what[i];
	}

	return fn;
}


var test = new (extend(function()
{
	jQuery(document).ready(this.ready);
},
{
	index: function()
	{
		jQuery('#type-1-f, #type-2-f, #type-3-f').bind('change', function()
		{
			jQuery('#type-1-opts, #type-2-opts, #type-3-opts').addClass('hidden');
			jQuery('#'+jQuery(this).attr('id').replace(/-f$/, '-opts')).removeClass('hidden');
		});
	},
	generating: function(ready)
	{
		jQuery('#generate-modal').modal().show();

		var fn = function(i)
		{
			if(i == 100)
			{
				ready();
				return;
			}

			jQuery('#progress').css({ width: i+'%' });

			window.setTimeout(fn, 50, i+2);
		};

		fn(0);
	},
	loggedIn: function()
	{
// 		jQuery('#generate').bind('submit', function(e)
// 		{
// 			e.preventDefault();
// 
// 			var obj = this;
// 			test.generating(function()
// 			{
// 				obj.submit();
// 			});
// 		});

		jQuery('#footer > div:not(.right) a').bind('click', function(e)
		{
			e.preventDefault();

			var obj = this;
			test.generating(function()
			{
				window.location.href = jQuery(obj).attr('href');
			});
		});
	},
	notLoggedIn: function()
	{
		jQuery('.register').bind('click', function(e)
		{
			e.preventDefault();
			jQuery('#register-modal').modal().show();
		});

		jQuery('#lostpassword').bind('click', function(e)
		{
			e.preventDefault();
			jQuery('#lostpassword-modal').modal().show();
		});

		jQuery('#footer > div:not(.right) a').bind('click', function(e)
		{
			e.preventDefault();
			jQuery('#generate-anon-modal').modal().show();
			window.location.href = '#';
		});
	},


	ready: function()
	{
		
	}
}));


