/* 
 * Original scripts by:
 * Jeremy Keith http://www.friendsofed.com/download.html?isbn=1590595335
 * Jake 		http://permanentinkdesign.com/articles/google-analytics-jquery-and-file-downloads/
 * 
 */

window.onload = initialize;
function initialize()
{
  	if (!document.getElementsByTagName) return false;
			
	filetypes = /\.pdf/i; // String contains '.pdf'			
	function linkEnhancer() 
	{			
		var links = document.getElementsByTagName("a");
	  	for (var i=0; i<links.length; i++) 
		{
			if (links[i].className == "popup") 
		 	{
				links[i].onclick = function() 
				{
					
	  				popUp(this.getAttribute("href"));
					return false;
	  			}				
	 		}
			else if (links[i].getAttribute("href").match(filetypes)) 
		 	{
				links[i].onclick = function() 
				{	
					var fileURL = this.getAttribute("href");
					_gaq.push(['_trackPageview', fileURL]); 		
	  			}
	 		}			
	  	}
	}
	linkEnhancer();
	
	function popUp(winURL) 
	{
	  	window.open(winURL,"popup","width=555,height=550,scrollbars=1");
	}		
}
