﻿function PhAuthenticator( authentication_url )
{
	this.m_oAjax				= null;
	this.m_strAuthenticationUrl	= authentication_url;
	this.m_fpCallback			= null;
	
	this.InitObject();
}


PhAuthenticator.prototype.InitObject = function()
{
	this.m_oAjax = new PhAjaxJson();
}

PhAuthenticator.prototype.SetCallback = function( callback )
{
	this.m_fpCallback = callback;
}

PhAuthenticator.prototype.Authenticate = function( username, password )
{
	var me = this;
	this.m_oAjax.SendRequest( this.m_strAuthenticationUrl, '', 'username='+username+'&password='+password, function( obj ){me.AuthenticateCallback( obj );} );
}

PhAuthenticator.prototype.AuthenticateCallback = function( obj )
{
	if( this.m_fpCallback != null )
		this.m_fpCallback( obj );
}