jQuery(function(){
	/* For each link on the page that has the pageTracker format, register a click handler to track the event.
	*  Page tracker hashes have the format of "#pageTracker-category-action-optional label-optional-value"
	*  Ex:
		#pageTracker-Product Gallery-CTA clicked
		#pageTracker-10 percent off purchases-CTA clicked-Web99

	   With this code it is currently not possible to track the clicks on actual hash links, 
	   additional work would be required to enable that. 		
	*/
    jQuery("a[href*='#pageTracker']").each(function(){
        // get and parse the pagetracker hash
        var hash = this.hash;
        var pageTrackerVars = hash.split("-"); 
        
        // move to local vars for readability, start at 1 since 0 is "#pageTracker"
        var category = pageTrackerVars[1];
        var action   = pageTrackerVars[2];
        var optLabel = pageTrackerVars[3];
        var optValue = pageTrackerVars[4];
        
        //register each link so a click calls the pageTracker library
        jQuery(this).click(function(){
            pageTracker._trackEvent(category, action, optLabel, optValue);
        });
        
        //clean up the hash
        this.hash = "";
        
    });
});

