// copyright 2009 DTLink, LLC. http://www.dtlink.com
//
// generates a hidden field with the response to a login challenge hash.

function fv_loginChallengeResponse( parms )
{

var loginFormName = parms.formName;
var challengeString = parms.challengeString;

// if the challenge field, _fv_CHALLENGE_RESPONSE is not present, add it. 

if ( $("form[name=" + loginFormName + "] input[name=_fv_CHALLENGE_RESPONSE]").length == 0 )
	{
	$("form[name=" + loginFormName + "]").append( "<input type=\"hidden\" name=\"_fv_CHALLENGE_RESPONSE\"/>" );
	}

// get the value of the password field

var password = $( "form[name=" + loginFormName + "] :input[name=_fv_PASSWORD]" ).val();

// clear the password so it does not get sent.

$( "form[name=" + loginFormName + "] :input[name=_fv_PASSWORD]" ).val("");

// using the password and the challengeString from the 

$("form[name=" + loginFormName + "] :input[name=_fv_CHALLENGE_RESPONSE]").val( hex_sha256( hex_sha256( password ) + challengeString ) );

return true;
	   
}
						
						
