/*******************************
 *
 *	Page Manager Local Class
 *
 *  Version: 1.0
 *
 *	Authors: 
 *	The Roundhouse
 *  Paul Lewis
 *
 *  Description:
 *
 *	Local page manager extends the global page manager with handlers for its specific section
 *
 *  N.B. All form data should be added AFTER this extension has been applied
 */
 
var LocalPageManager = PageManager.extend({

	// constructor, just calls parent
	initialize: 			function()
	{
		this.parent();
	},
	
	// deals with the AJAX responders local to
	// this page
	loginResponse: 			function(objResponseText, objResponseXML)
	{
		var bValidResponse 		= false;
		var strResponseType		= null;
		if(objResponseXML)
		{
			for(var i = 0; i < objResponseXML.childNodes.length; i++)
			{
				// go through the reponse
				if(objResponseXML.childNodes[i].nodeName == "response")
				{
					bValidResponse	= true;
					// attempt to evaluate the reponse as a JSON object
					var objResponse = Json.evaluate(objResponseXML.childNodes[i].firstChild.nodeValue);
					for(var responseVal in objResponse)
					{
						// since we know that all we get back from this
						// call is a redirect, just action it
						if(responseVal == "redirect")
							window.location = objResponse[responseVal];
					}
				}
			}
		}
		// otherwise whinge
		if(!bValidResponse)
			alert("Malformed XML response from AJAX request:\n"+objResponseText);
	}
	
});

// create and overwrite the global page manager
// as the current manager
var localPageManager = new LocalPageManager();
if(finCore)
	finCore.registerPageManager(localPageManager);

// store the form fields
localPageManager.addFormFields('finloginform', {'username':'req', 'password':'reqmd5'});
