$(document).ready(function()
{

/* Begin JQuery link tracking */
// allows for link tracking to include a defined prefix for any given page
if (typeof(trackingPrefix) != "string") {trackingPrefix = "";}	else {	trackingPrefix = "/" + trackingPrefix;	}	

// find all A and AREA links to external sites, and enable onclick tacking
//var allLinks = $("A[@href^=http://]:not([@href^=http://www.visitphilly.com]),AREA[@href^=http://]:not([@href^=http://www.visitphilly.com])");
var allLinks = $("A[href^='http://']:not([href*='.visitphilly.com']):not([href$='.pdf']):not([href$='.mp3']),AREA[href^='http://']:not([href*='.visitphilly.com']):not([href$='.pdf']):not([href$='.mp3'])");
allLinks.each(function(i){
		var thisHref = $(this).attr("href");
		thisHref = thisHref.replace("http://", "");			// remove http
		if (thisHref.charAt(thisHref.length - 1) == "/")	// trim ending slash
			thisHref = thisHref.substr(0,thisHref.length - 1);
//		console.log(thisHref);
		$(this).click(function() { 
			trackitem('/outbound/' + thisHref)							   
		})
});

var allPdf = $("a[href$='.pdf'],a[href$='.mp3']");
allPdf.each(											 
	function(i){
		var thisHref = $(this).attr("href");
		thisHref = thisHref.replace("http://c0526532.cdn.cloudfiles.rackspacecloud.com/", "");	
		thisHref = thisHref.replace("http://www.visitphilly.com/", "");			
//		console.log(thisHref);
		$(this).click(function() { 			
			trackitem('/downloads/' + thisHref)
		})

});	

function trackitem(wtrack) {
	try {
		if (typeof(pageTracker) == 'object') {
//			console.log("tracking :" + wtrack);
			pageTracker._trackPageview(wtrack);			
		}
	} catch(err) {}
}

});


/* End JQuery link tracking */	

