/* 
Class Name: 	
				User
Purpose:		
				To be able to easily control user elements, such as loggin in, verification, etc.
Description:	
				The idea behind this class is to simply add this script to your page. From there 
				you can control user related elements typically needed for a website.
				
				You can store and alter the username
				
				................need to carry on explaining how each part of the class works and how
				to use it.........
*/

var user = new function()
{
	this.username = "username";
	this.password = "password";
	
	this.getUsername = function(id) 
	{
		if( id == null ) id = "username"; // Set location of the username from the login form
		return document.getElementById( id ).value;
	};
	
	this.getPassword = function(id) 
	{
		if( id == null ) id = "password"; // Set location of the password from the login form
		return document.getElementById("password").value;
	};
	
	this.verifyResponse = function( response )
	{
		if( response == "1" ) // login details correct
		{
			div.inject( "Welcome, USER." , "userControl" );
		}
		else // the login details are not correct, inform user.
		{
			alert( "Incorrect username/password combination." );
		}
	}
	
	this.verify = function( uID, pID )
	{
		if( uID == null ) uID = "username"; // Allows the user to control where the username is being taken from.
		if( pID == null ) pID = "password"; // Allows the user to control where the password is being taken from.
		var AjaxGet = new Ajax();
		AjaxGet.addParam('u', user.getUsername( uID ));
		AjaxGet.addParam('p', user.getPassword( pID ));
		AjaxGet.addCallback(user.verifyResponse);
		AjaxGet.getRequest('GET', 'loginchecktest.php', true);
	};
};