/**
 * MasterQuery Implementor for Instant Activation.
 * @constructor
 * @private
 */
function IaLndbImp()
{
	throw new Error("IaLndbImp is a static class. Do not instantiate.");
}

IaLndbImp.DEFAULT_DOMAIN = "www4.lexisnexis.com";
IaLndbImp.DEFAULT_VERB   = "activate.do";

// Create API Matrix
// The matrix is used to cast object elements into those used by the API.
IaLndbImp.matrix          = new Object();

// Filter out MQ fields that we don't want in the query string
IaLndbImp.matrix.protocol = -1;
IaLndbImp.matrix.verb     = -1;
IaLndbImp.matrix.api      = -1;
IaLndbImp.matrix.target   = -1;
IaLndbImp.matrix.method   = -1;
IaLndbImp.matrix.source   = -1;
IaLndbImp.matrix.search   = -1;
IaLndbImp.matrix.originationcode = -1;
IaLndbImp.matrix.TOCTarget     = -1;	

IaLndbImp.matrix.uid             = "userId";
IaLndbImp.matrix.pwd             = "password";	
IaLndbImp.matrix.mod_id          = "modelId";
IaLndbImp.matrix.mod_psw         = "modelPassword";
IaLndbImp.matrix.fname           = "firstName";
IaLndbImp.matrix.lname           = "lastName";
IaLndbImp.matrix.cookie          = "longLiving";
IaLndbImp.matrix.org_id          = "orgId";
IaLndbImp.matrix._url            = "url";
	
/**
 * Takes a chunnel object and submits it. The last step in the journey
 * of a chunnel object before it becomes a LN search result.
 */
IaLndbImp.submit = function(chunnel)
{
	// Preprocessor needs to convert generic after field 
	// to XLink's relativedate field
	IaLndbImp._preprocessor(chunnel);

	var linker = IaLndbImp.getLink(chunnel);

	// If no target, set the target for the same window.	
	if (!Truth.isTrue(chunnel.target))
	{
		chunnel.target = "_self";
	}
	
	prompt("", linker);
	
	// var w = window.open(linker, chunnel.target, NEW_WINDOW_FEATURES); 

	// chunnel = null;
};

/**
 * Take any actions that need to be made on the MQ object before it gets
 * submitted to its specific API.
 */
IaLndbImp._preprocessor =  function(chunnel)
{
	chunnel.protocol = "https:";

	return chunnel;
};

/**
 * Returns the link that is the target for the API call.
 * This can be used as the action for a form or as the location
 * for a called to window.open.
 *
 * The query string is return based upon the chunnel values filtered 
 * through the implementor's matrix
 */
IaLndbImp.getLink = function(chunnel)
{
	var action;
	
	var verb = chunnel.get("verb");
	
	if (!Truth.isTrue(chunnel.get("verb")))
	{
		var verb = IaLndbImp.DEFAULT_VERB;
	}
	
	if (Truth.isTrue(chunnel.override))
	{
		action = chunnel.override;
	}
	else
	{
		action = chunnel.protocol + "//" + IaLndbImp.DEFAULT_DOMAIN + "/urlapi/" + verb;
	}

	return action + "?" + SearchImplementor.getQueryStringCaseInsensative(chunnel, IaLndbImp.matrix);

};