////////////////////////////////////////////////////////////////////
// Author : Matthew Quinlan  (mquinlan@loopfuse.com)
// Version : 1.0
// File : instrument_downloads.js
// Purpose : Auto-instrument binary download hyperlinks embedded inside HTML document
//
// Functionality : 
//
// Usage : on a new line immediately after the _lf_remora(); call in the beacon add 
//         instrument_downloads(['doc', 'pdf', 'exe', 'zip']);
//
// Requires : jquery 1.3+ (src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js")
//
////////////////////////////////////////////////////////////////////
	
// set debug=1 here if you wish to see console debugging output
debug=0;
if (typeof(window.console) == "undefined") debug=0;
	
	function oc(a)
	{
	  var o = {};
	  for(var i=0;i<a.length;i++)
	  {
	    o[a[i]]='';
	  }
	  return o;
	}

function instrument_downloads(doclist)
	{
	$("a[href|=]").each(function(i) 
		{
		var extension = this.href.substring(this.href.lastIndexOf('.')+1).toLowerCase();
		
		if( extension in oc(doclist) )
			{
			$(this).bind('click', function() 
				{
				_lf_remora_tracker(this.href, '1');
				});
			if (debug) console.log("instrumented : "+this.href);
		}	
			
			}); 
	}

