YuiAjax =
{
	transaction: null,
	timeout: 3000,
	formTarget: null,
	_formId: null,
	
	get : function ( page )
	{
		this.transaction = YAHOO.util.Connect.asyncRequest( 'GET', page, YuiAjax );
	},
	
	attachForm : function ( form )
	{
		this._formId = form;
		form = document.getElementById( form );
		this.formTarget = form.action;
		YAHOO.util.Event.addListener( form, 'submit', YuiAjax._form );
	},
	
	_form : function ( e )
	{
		YAHOO.util.Connect.setForm( YuiAjax._formId );
		YuiAjax.transaction = YAHOO.util.Connect.asyncRequest( 'POST', YuiAjax.formTarget, YuiAjax );
		
		YAHOO.util.Event.stopEvent( e );
		YAHOO.util.Connect.setForm( YuiAjax._formId );
	},
	
	success : function ( e )
	{
		var resArray;
		
		try 
		{
			resArray = YAHOO.lang.JSON.parse( e.responseText );
		}
		catch ( err )
		{
			alert( 'Server returned a malformed response!' );
		}
		
		if ( resArray )
		{
			var js = resArray['js'];
			var html = resArray['html'];
			var ix = 0;
			
			if ( js )
			{
				for ( ix = 0; ix < js.length; ix++ )
				{
					eval( js[ix] );
				}
			}
			
			if ( html )
			{
				for ( ix = 0; ix < html.length; ix++ )
				{
					var el = document.getElementById( html[ix][0] );
					
					if ( !el )
					{
						alert( 'Invalid element!' );
					}
					else
					{
						el.innerHTML = html[ix][1];
					}
				}
			}
		}
	},
	
	failure : function ( error )
	{
		alert( 'Server did not respond properly.' );
	}
};