/******************************************************************

	ajxCrypt.js   -   ajxCrypt.cfm
	Gary D. Gass
	May 29, 2006
	
	Provides a method to use the ColdFusion Encrypt/Decrypt methods
	from javascript.
	
	include this file in your application and call the encode function
	passing one of 2 methods, encrypt or decrypt
	
	var newValue = encode('string', encrypt);

	application must also include prototype.js
*******************************************************************/

var result = "";

function encode(value, opt){

	var url = 'ajxCrypt.cfm';
	if(opt=='encrypt'){
		var params = "value=" + value + "&method=" + opt;
	}else{
		var params = "value=" + value + "&method=" + opt;
	}
	var objRequest = new Ajax.Request(
		url,
		{
			method: 'post',
			parameters: params,
			asynchronous:false,
			onComplete: returnResult
		}
	);
	
	return(result);
}

function returnResult(objResponse){
		result = objResponse.responseText;
}
