var lastFocused="" ;
var formSubmitted="0" ;

// if submit HBX (gateway) variable sf="1" , completion = 1; 
function hbFormCompletion(){
	_hbSet("lf","");
	_hbSet("sf","1");
	_hbSend();
}

//if form not submited and focus on the form field , HBX (gateway) variable lf= "field+name";
var previousOnunload = window.onunload;
function hbFormAbandon()
{
	if(previousOnunload!=null) previousOnunload();

	if(formSubmitted == "0" )
	{
		_hbSet("lf",lastFocused);
		_hbSend();
	}
}


String.prototype.replaceSpace = function()
{
	return this.replace(/ /g, '+');
}

// retrieve the field name with the onFocus
function  hbFormFocused()
{
	lastFocused = window.event.srcElement.id.replaceSpace();
}   

function getMeta(name)
{
	var metaElements = document.getElementsByTagName("meta");
	for(var i=0;i<metaElements.length;i++)
		if(metaElements[i].getAttribute("name")==name)
			return metaElements[i].getAttribute("content").replaceSpace();
}

function hbSubmit()
{
	return _hbDownload(window.event.srcElement.id + "+Submit");
}

window.onunload = hbFormAbandon;
