try {
	if( !flexmls )
		flexmls = new Object();
}
catch( err )
{
	flexmls = new Object();
}

flexmls.loggingEnabled = true;
flexmls.loggingLevel = 1; /*1 for required, 5 for optional*/

// accepts double array of parameters, i.e.:
// [ ['param1','value1'], ['param2','value2'] ]
flexmls.encodeParams = function( parr )
{
	var s = new Array();
	for( var i = 0; i < parr.length; i++ )
		if( parr[i][1] != undefined )
			s.push('&' + parr[i][0] + '=' + encodeURIComponent( parr[i][1] ) );
	return s.join('');
}

/* logobj may have the following properties:
	u= User name
	d= Activity description
	e= Event initiation mechanism
	t= Actioned item type
	l= Actioned item detail
	i= tech ID of actioned item (for example, a list ID on search results)
	i2= tech ID of previously actioned item (for example, the previously selected list ID on search results)
	s= source ID of the actioned item (for example, link ID for IDX links)
	n= session ID to be able to track an individual session within a single account
	c= context of the click (i.e. which tab was selected at the time of the click in search results)
	a= additional information if needed ... 500 char maximum
*/
flexmls.Log = function( logobj )
{
	if (!logobj.level)
		logobj.level = 5;
	if( flexmls.loggingEnabled && flexmls.loggingLevel >= logobj.level)
	{
		var img = new Image();
		img.src = 'http://gather.flexmls.com/?' + 
			flexmls.encodeParams( [ 
					[ 'u', logobj.u ],
					[ 'd', logobj.d ],
					[ 'e', logobj.e ],
					[ 't', logobj.t ],
					[ 'l', logobj.l ],
					[ 'i', logobj.i ],
					[ 'i2', logobj.i2 ],
					[ 's', logobj.s ],
					[ 'n', logobj.n ],
					[ 'c', logobj.c ],
					[ 'a', logobj.a ],
					[ 'rnd', Math.random() ]
				] );
	}
};

